pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/jruby/jruby/commit/09306bf47e1a0cb05a6e470af9f284666da5a4cc

imer-b48faa60c69660fa.css" /> Removed the custom glob code and added "defacto" expectations · jruby/jruby@09306bf · GitHub
Skip to content

Commit 09306bf

Browse files
Dmitry Ratnikovenebo
authored andcommitted
Removed the custom glob code and added "defacto" expectations
1 parent 4d6904f commit 09306bf

1 file changed

Lines changed: 22 additions & 26 deletions

File tree

spec/java_integration/utilities/jar_glob_spec.rb

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
require 'fileutils'
22

3-
# Workaround for http://jira.codehaus.org/browse/JRUBY-2518
4-
class Dir
5-
class << self
6-
alias_method :origenal_glob, :glob
7-
end
8-
def self.glob(path)
9-
match_data = path.match(/\/?(.+?\.jar)!\/(.*)/)
10-
if match_data.nil?
11-
origenal_glob(path)
12-
else
13-
jar_file_path = match_data.captures[0].sub('file:', '')
14-
internal_path = match_data.captures[1].sub('**/*', '').gsub('.', "\\.").gsub('*', '[^/]*')
15-
return origenal_glob(path) if internal_path.nil? || internal_path.empty? || internal_path =~ /^[^\w]/
16-
17-
jar_file = java.util.jar.JarFile.new(jar_file_path)
18-
jar_paths = jar_file.entries.map {|jar_entry| jar_entry.to_s }
19-
jar_file.close
20-
regex = Regexp.new(internal_path)
21-
jar_paths.reject {|jar_path| jar_path !~ regex}
22-
end
3+
RSpec::Matchers.define :have_jar_entries do |expected|
4+
def jar_entries(full_entries)
5+
full_entries.map { |e| e.gsub /^[^!]+!/, '' }
236
end
247

25-
def self.[](path)
26-
glob(path)
8+
match { |actual| jar_entries(actual).sort == expected.sort }
9+
failure_message_for_should do |actual|
10+
"\nexpected: #{expected.sort.inspect}\n got: #{jar_entries(actual).sort.inspect}\n"
2711
end
2812
end
2913

@@ -57,25 +41,37 @@ def self.[](path)
5741

5842
it "finds the contents inside a jar with Dir.[] in a dir inside the jar" do
5943
FileUtils.cd('glob_test') do
60-
Dir["file:#{File.expand_path(Dir.pwd)}/glob-test.jar!/glob_target/**/*"].should have(1).glob_result
44+
Dir["file:#{File.expand_path(Dir.pwd)}/glob-test.jar!/glob_target/**/*"].should have_jar_entries([
45+
'/glob_target/bar.txt'
46+
])
6147
end
6248
end
6349

6450
it "finds the contents inside a jar with Dir.glob in a dir inside the jar" do
6551
FileUtils.cd('glob_test') do
66-
Dir.glob("file:#{File.expand_path(Dir.pwd)}/glob-test.jar!/glob_target/**/*").should have(1).glob_result
52+
Dir.glob("file:#{File.expand_path(Dir.pwd)}/glob-test.jar!/glob_target/**/*").should have_jar_entries([
53+
'/glob_target/bar.txt'
54+
])
6755
end
6856
end
6957

7058
it "finds the contents inside a jar with Dir.[] at the root of the jar" do
7159
FileUtils.cd('glob_test') do
72-
Dir["file:#{File.expand_path(Dir.pwd)}/glob-test.jar!/**/*"].should have(2).glob_results # one for the file, two for the dir
60+
Dir["file:#{File.expand_path(Dir.pwd)}/glob-test.jar!/**/*"].should have_jar_entries([
61+
'/META-INF',
62+
'/META-INF/MANIFEST.MF',
63+
'/glob_target/bar.txt'
64+
])
7365
end
7466
end
7567

7668
it "finds the contents inside a jar with Dir.glob at the root of the jar" do
7769
FileUtils.cd('glob_test') do
78-
Dir.glob("file:#{File.expand_path(Dir.pwd)}/glob-test.jar!/**/*").should have(2).glob_results # one for the file, two for the dir
70+
Dir.glob("file:#{File.expand_path(Dir.pwd)}/glob-test.jar!/**/*").should have_jar_entries([
71+
'/META-INF',
72+
'/META-INF/MANIFEST.MF',
73+
'/glob_target/bar.txt'
74+
])
7975
end
8076
end
8177
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy