torquebox-vfs 1.0.0.CR2-java → 1.0.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
data/lib/torquebox-vfs.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module TorqueboxVfs
2
- VERSION = '1.0.0.CR2'
3
- MAVEN_VERSION = '1.0.0.CR2'
2
+ VERSION = '1.0.0'
3
+ MAVEN_VERSION = '1.0.0'
4
4
  end
5
5
  begin
6
6
  require 'java'
@@ -121,7 +121,6 @@ class Dir
121
121
 
122
122
  #str_pattern = "#{pattern}"
123
123
  str_pattern = pattern.to_str
124
- #puts "glob(#{str_pattern})"
125
124
 
126
125
  segments = str_pattern.split( '/' )
127
126
 
@@ -156,6 +155,7 @@ class Dir
156
155
 
157
156
  matcher_segments = segments - base_segments
158
157
  matcher = matcher_segments.join( '/' )
158
+ dirs_only = (str_pattern[-1,1] == '/')
159
159
  #puts "matcher [#{matcher}]"
160
160
 
161
161
  begin
@@ -173,7 +173,8 @@ class Dir
173
173
  child_path = "" if child_path == "/"
174
174
  #puts "child_path=#{child_path}"
175
175
  #puts "base=#{base}"
176
- filter = TorqueBox::VFS::GlobFilter.new( child_path, matcher )
176
+ # puts "preparing glob filter for path #{child_path} and match #{matcher}"
177
+ filter = TorqueBox::VFS::GlobFilter.new( child_path, matcher, dirs_only )
177
178
  #puts "filter is #{filter}"
178
179
  paths = starting_point.getChildrenRecursively( filter ).collect{|e|
179
180
  #path_name = e.path_name
@@ -23,7 +23,7 @@ module TorqueBox
23
23
  class GlobFilter
24
24
  include Java::org.jboss.vfs.VirtualFileFilter
25
25
 
26
- def initialize(child_path, glob)
26
+ def initialize(child_path, glob, dirs_only)
27
27
  regexp_str = GlobTranslator.translate( glob )
28
28
  if ( child_path && child_path != '' )
29
29
  if ( child_path[-1,1] == '/' )
@@ -34,11 +34,19 @@ module TorqueBox
34
34
  else
35
35
  regexp_str = "^#{regexp_str}$"
36
36
  end
37
- @regexp = Regexp.new( regexp_str )
37
+ @regexp = Regexp.new( regexp_str )
38
+ @dirs_only = dirs_only
39
+ # puts "glob #{glob} ==> #{@regexp}"
38
40
  end
39
41
 
40
42
  def accepts(file)
41
- !!( file.path_name =~ @regexp )
43
+ matched = !!( file.path_name =~ @regexp )
44
+ matched &&= file.directory? if @dirs_only
45
+ matched
46
+ end
47
+
48
+ def to_s
49
+ "#{@regexp}, dirs_only: #{@dirs_only}"
42
50
  end
43
51
  end
44
52
  end
@@ -31,7 +31,7 @@ module TorqueBox
31
31
  def self.translate(glob_str)
32
32
  translator = GlobTranslator.new( glob_str )
33
33
  regexp_str = translator.glob()
34
- #puts "#{glob_str} ==> #{regexp_str}"
34
+ # puts "#{glob_str} ==> #{regexp_str}"
35
35
  regexp_str
36
36
  end
37
37
 
@@ -62,7 +62,7 @@ module TorqueBox
62
62
  end
63
63
  end
64
64
  end
65
- result
65
+ result
66
66
  end
67
67
 
68
68
  def splat()
@@ -71,10 +71,12 @@ module TorqueBox
71
71
  result = double_splat()
72
72
  else
73
73
  if ( cur() == 0 || lb() == '/' )
74
- result = '[^/.][^/]*'
74
+ result = '(?<=/|^)[^.][^/]*'
75
+ # result = '[^/.][^/]*'
75
76
  else
76
77
  result = '[^/]+'
77
78
  end
79
+
78
80
  consume('*')
79
81
  end
80
82
  #puts "exit splat()"
@@ -83,7 +85,12 @@ module TorqueBox
83
85
 
84
86
  def double_splat()
85
87
  #puts "enter double_splat()"
86
- result = '(.*)'
88
+ if la(2) == '/'
89
+ # result = '([^.][^/]+/){0,}'
90
+ result = '([^/.][^/]*/){0,}'
91
+ else
92
+ result = '([^/.][^/]*)'
93
+ end
87
94
  consume('*')
88
95
  consume('*')
89
96
  consume('/') if ( la() == '/' )
data/spec/dir_spec.rb CHANGED
@@ -42,7 +42,25 @@ describe "Dir extensions for VFS" do
42
42
  when :vfs
43
43
  prefix = test_data_base_path( :vfs )
44
44
  end
45
+
46
+ it "should ignore dotdirs by default" do
47
+ items = Dir.glob( "#{prefix}/**/*" )
48
+ items.should_not be_empty
49
+ items.size.should eql(32)
50
+ end
45
51
 
52
+ it "should handle trailing double splats" do
53
+ items = Dir.glob( "#{prefix}/**" )
54
+ items.should_not be_empty
55
+ items.size.should eql(5)
56
+ end
57
+
58
+ it "should handle Rails 2 glob-related arglebargle" do
59
+ items = Dir.glob( "#{prefix}/**/*/**" )
60
+ items.should_not be_empty
61
+ items.size.should eql(27)
62
+ end
63
+
46
64
  it "should ignore dotfiles by default" do
47
65
  glob_pattern = "#{prefix}/dotfiles/*"
48
66
  items = Dir.glob( glob_pattern )
@@ -216,6 +234,15 @@ describe "Dir extensions for VFS" do
216
234
  items.should include( "#{prefix}/home/todd/index.html.haml" )
217
235
  end
218
236
 
237
+ it "should match only directories if trailing slash" do
238
+ items = Dir.glob( "#{prefix}/*/" )
239
+ items.should_not be_empty
240
+ items.size.should eql(3)
241
+ items.should include( "#{prefix}/dotfiles" )
242
+ items.should include( "#{prefix}/home" )
243
+ items.should include( "#{prefix}/sound of music" )
244
+ end
245
+
219
246
  it "should allow globbing of multiple patterns via []" do
220
247
  items = []
221
248
  lambda {
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torquebox-vfs
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 1.0.0.CR2
4
+ prerelease:
5
+ version: 1.0.0
6
6
  platform: java
7
7
  authors: []
8
8
 
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-25 00:00:00 -04:00
13
+ date: 2011-04-29 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -100,9 +100,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  none: false
102
102
  requirements:
103
- - - ">"
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
- version: 1.3.1
105
+ version: "0"
106
106
  requirements: []
107
107
 
108
108
  rubyforge_project: