org.torquebox.vfs 1.0.0.Beta22
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.
- data/lib/vfs/dir.rb +54 -0
- data/lib/vfs/ext/dir.rb +113 -0
- data/lib/vfs/ext/file.rb +178 -0
- data/lib/vfs/ext/io.rb +123 -0
- data/lib/vfs/ext/kernel.rb +14 -0
- data/lib/vfs/ext/vfs.rb +8 -0
- data/lib/vfs/file.rb +170 -0
- data/lib/vfs/glob_filter.rb +50 -0
- data/lib/vfs.rb +49 -0
- data/licenses/lgpl-2.1.txt +504 -0
- data/spec/dir_spec.rb +159 -0
- data/spec/file_spec.rb +234 -0
- data/spec/io_spec.rb +67 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/vfs_spec.rb +20 -0
- metadata +109 -0
data/spec/dir_spec.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
3
|
+
|
4
|
+
describe "Dir extensions for VFS" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@executor = java.util.concurrent::Executors.newScheduledThreadPool( 1 )
|
8
|
+
@temp_file_provider = org.jboss.vfs::TempFileProvider.create( "vfs-test", @executor )
|
9
|
+
|
10
|
+
@archive1_path = File.expand_path( "#{TEST_DATA_DIR}/home/larry/archive1.jar" )
|
11
|
+
@archive1_file = org.jboss.vfs::VFS.child( @archive1_path )
|
12
|
+
@archive1_mount_point = org.jboss.vfs::VFS.child( @archive1_path )
|
13
|
+
@archive1_handle = org.jboss.vfs::VFS.mountZip( @archive1_file, @archive1_mount_point, @temp_file_provider )
|
14
|
+
|
15
|
+
@archive2_path = "#{@archive1_path}/lib/archive2.jar"
|
16
|
+
@archive2_file = org.jboss.vfs::VFS.child( @archive2_path )
|
17
|
+
@archive2_mount_point = org.jboss.vfs::VFS.child( @archive2_path )
|
18
|
+
@archive2_handle = org.jboss.vfs::VFS.mountZip( @archive2_file, @archive2_mount_point, @temp_file_provider )
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
after(:each) do
|
24
|
+
@archive2_handle.close
|
25
|
+
@archive1_handle.close
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "with vfs urls" do
|
29
|
+
it "should allow globbing within archives with explicit vfs" do
|
30
|
+
pattern = "vfs:#{@archive1_path}/*"
|
31
|
+
items = Dir.glob( pattern )
|
32
|
+
items.should_not be_empty
|
33
|
+
items.should include File.join( "vfs:#{@archive1_path}", 'web.xml' )
|
34
|
+
items.should include File.join( "vfs:#{@archive1_path}", 'lib' )
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should allow globbing within nested archives with explicit vfs" do
|
38
|
+
pattern = "vfs:#{@archive2_path}/*"
|
39
|
+
items = Dir.glob( pattern )
|
40
|
+
items.should_not be_empty
|
41
|
+
items.should include "vfs:#{@archive2_path}/manifest.txt"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
[ :absolute, :relative ].each do |style|
|
46
|
+
describe "with #{style} paths" do
|
47
|
+
|
48
|
+
case ( style )
|
49
|
+
when :relative
|
50
|
+
prefix = "./#{TEST_DATA_BASE}"
|
51
|
+
when :absolute
|
52
|
+
prefix = File.expand_path( File.join( File.dirname( __FILE__ ), '..', TEST_DATA_BASE ) )
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should allow globbing without any special globbing characters on normal files" do
|
56
|
+
items = Dir.glob( "#{prefix}/home/larry" )
|
57
|
+
items.should_not be_empty
|
58
|
+
items.should include( "#{prefix}/home/larry" )
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should allow globbing without any special globbing characters on a single normal file" do
|
62
|
+
items = Dir.glob( "#{prefix}/home/larry/file1.txt" )
|
63
|
+
items.should_not be_empty
|
64
|
+
items.should include( "#{prefix}/home/larry/file1.txt" )
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should allow globbing without any special globbing characters for archives" do
|
68
|
+
items = Dir.glob( "#{prefix}/home/larry/archive1.jar" )
|
69
|
+
items.should_not be_empty
|
70
|
+
items.should include( "#{prefix}/home/larry/archive1.jar" )
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should allow globbing without any special globbing characters within archives" do
|
74
|
+
items = Dir.glob( "#{prefix}/home/larry/archive1.jar/web.xml" )
|
75
|
+
items.should_not be_empty
|
76
|
+
items.should include( "#{prefix}/home/larry/archive1.jar/web.xml" )
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should allow globbing without any special globbing characters for nested archives" do
|
80
|
+
items = Dir.glob( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar" )
|
81
|
+
items.should_not be_empty
|
82
|
+
items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar" )
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should allow globbing without any special globbing characters for within archives" do
|
86
|
+
items = Dir.glob( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar/manifest.txt" )
|
87
|
+
items.should_not be_empty
|
88
|
+
items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar/manifest.txt" )
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should allow appropriate globbing of normal files" do
|
92
|
+
items = Dir.glob( "#{prefix}/home/larry/*" )
|
93
|
+
items.should_not be_empty
|
94
|
+
items.should include( "#{prefix}/home/larry/file1.txt" )
|
95
|
+
items.should include( "#{prefix}/home/larry/file2.txt" )
|
96
|
+
items.should include( "#{prefix}/home/larry/archive1.jar" )
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should determine if VFS is needed for archives" do
|
100
|
+
items = Dir.glob( "#{@archive1_path}/*" )
|
101
|
+
items.should_not be_empty
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should determine if VFS is needed for nested archives" do
|
105
|
+
base = "#{prefix}/home/larry/archive1.jar/lib/archive2.jar"
|
106
|
+
items = Dir.glob( "#{base}/*" )
|
107
|
+
items.should_not be_empty
|
108
|
+
items.should include( "#{base}/manifest.txt" )
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should determine if VFS is needed with relative paths" do
|
112
|
+
base = "#{prefix}/home/larry/archive1.jar/lib/archive2.jar"
|
113
|
+
items = Dir.glob( "#{base}/*" )
|
114
|
+
items.should_not be_empty
|
115
|
+
items.should include( "#{base}/manifest.txt" )
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should allow alternation globbing on normal files" do
|
119
|
+
items = Dir.glob( "#{prefix}/home/{larry}/file{,1,2}.{txt}" )
|
120
|
+
items.should_not be_empty
|
121
|
+
items.size.should eql 2
|
122
|
+
items.should include( "#{prefix}/home/larry/file1.txt" )
|
123
|
+
items.should include( "#{prefix}/home/larry/file2.txt" )
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should allow alternation globbing within archives" do
|
127
|
+
items = Dir.glob( "#{prefix}/home/larry/archive1.jar/lib/archive*{.zip,.jar,.ear}" )
|
128
|
+
items.should_not be_empty
|
129
|
+
items.size.should eql 3
|
130
|
+
items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar" )
|
131
|
+
items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive3.ear" )
|
132
|
+
items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive4.zip" )
|
133
|
+
items.should_not include( "#{prefix}/home/larry/archive1.jar/lib/archive4.txt" )
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should allow alternation globbing wiht trailing comma" do
|
137
|
+
items = Dir.glob( "#{prefix}/home/todd/index{.en,}{.html,}{.erb,.haml,}" )
|
138
|
+
items.should_not be_empty
|
139
|
+
items.size.should eql 4
|
140
|
+
items.should include( "#{prefix}/home/todd/index.html.erb" )
|
141
|
+
items.should include( "#{prefix}/home/todd/index.en.html.erb" )
|
142
|
+
items.should include( "#{prefix}/home/todd/index.html.haml" )
|
143
|
+
items.should include( "#{prefix}/home/todd/index.en.html.haml" )
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should allow for double-star globbing within archives" do
|
147
|
+
#items = Dir.glob( "#{prefix}#{TEST_DATA_DIR}/home/larry/**/*{.zip,.jar,.ear}" )
|
148
|
+
items = Dir.glob( "#{prefix}/home/larry/archive1.jar/**/*.jar" )
|
149
|
+
items.should_not be_empty
|
150
|
+
#items.size.should eql 1
|
151
|
+
items.should include( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar" )
|
152
|
+
items.should include( "#{prefix}/home/larry/archive1.jar/other_lib/subdir/archive6.jar" )
|
153
|
+
items.should_not include( "#{prefix}/home/larry/archive1.jar/lib/archive4.txt" )
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
data/spec/file_spec.rb
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
describe "File extensions for VFS" do
|
7
|
+
|
8
|
+
TEST_COPY_BASE = File.join( File.dirname( TEST_DATA_BASE ), 'test-copy' )
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
test_copy_dir = File.join( File.dirname( TEST_DATA_DIR ), 'test-copy' )
|
12
|
+
FileUtils.rm_rf( test_copy_dir )
|
13
|
+
FileUtils.cp_r( TEST_DATA_DIR, test_copy_dir )
|
14
|
+
@executor = java.util.concurrent::Executors.newScheduledThreadPool( 1 )
|
15
|
+
@temp_file_provider = org.jboss.vfs::TempFileProvider.create( "vfs-test", @executor )
|
16
|
+
|
17
|
+
#@archive1_path = File.join( TEST_DATA_DIR, "/home/larry/archive1.jar" )
|
18
|
+
@archive1_path = File.join( test_copy_dir, "/home/larry/archive1.jar" )
|
19
|
+
@archive1_file = org.jboss.vfs::VFS.child( @archive1_path )
|
20
|
+
@archive1_mount_point = org.jboss.vfs::VFS.child( @archive1_path )
|
21
|
+
@archive1_handle = org.jboss.vfs::VFS.mountZip( @archive1_file, @archive1_mount_point, @temp_file_provider )
|
22
|
+
|
23
|
+
@archive2_path = "#{@archive1_path}/lib/archive2.jar"
|
24
|
+
@archive2_file = org.jboss.vfs::VFS.child( @archive2_path )
|
25
|
+
@archive2_mount_point = org.jboss.vfs::VFS.child( @archive2_path )
|
26
|
+
@archive2_handle = org.jboss.vfs::VFS.mountZip( @archive2_file, @archive2_mount_point, @temp_file_provider )
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:each) do
|
30
|
+
@archive2_handle.close
|
31
|
+
@archive1_handle.close
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
it "should report writable-ness for VFS urls" do
|
36
|
+
prefix = File.expand_path( File.join( File.dirname( __FILE__ ), '..', TEST_COPY_BASE ) )
|
37
|
+
url = "vfs:#{prefix}/home/larry/file1.txt"
|
38
|
+
File.exists?( url ).should be_true
|
39
|
+
File.exist?( url ).should be_true
|
40
|
+
File.writable?( url ).should be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should expand paths relative to VFS urls as absolute" do
|
44
|
+
absolute = File.expand_path("db/development.sqlite3", "vfs:/path/to/app")
|
45
|
+
absolute.should eql("/path/to/app/db/development.sqlite3")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should expand paths relative to VFS pathnames as absolute" do
|
49
|
+
absolute = File.expand_path("db/development.sqlite3", Pathname.new("vfs:/path/to/app"))
|
50
|
+
absolute.should eql("/path/to/app/db/development.sqlite3")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should expand absolute Pathname objects correctly" do
|
54
|
+
File.expand_path("vfs:/foo").should eql("vfs:/foo")
|
55
|
+
File.expand_path(Pathname.new("vfs:/foo")).should eql("vfs:/foo")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should handle vfs urls as readable" do
|
59
|
+
File.readable?( __FILE__ ).should be_true
|
60
|
+
File.readable?( "vfs:#{__FILE__}" ).should be_true
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should handle #'s in filenames properly" do
|
64
|
+
prefix = File.expand_path( File.join( File.dirname( __FILE__ ), '..', TEST_COPY_BASE ) )
|
65
|
+
File.file?( "#{prefix}/#bad-uri#" ).should be_true
|
66
|
+
File.file?( "vfs:#{prefix}/#bad-uri#" ).should be_true
|
67
|
+
File.file?( "vfs:#{prefix}/#missing#" ).should be_false
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be able to chmod real files with vfs urls" do
|
71
|
+
path = File.expand_path("foo")
|
72
|
+
begin
|
73
|
+
f = File.new(path, "w")
|
74
|
+
FileUtils.chmod( 666, "vfs:#{path}")
|
75
|
+
m1 = f.stat.mode
|
76
|
+
FileUtils.chmod( 644, "vfs:#{path}")
|
77
|
+
m2 = f.stat.mode
|
78
|
+
m1.should_not eql(m2)
|
79
|
+
ensure
|
80
|
+
File.delete(path) rescue nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should be able to create new files with vfs urls" do
|
85
|
+
lambda {
|
86
|
+
File.new("vfs:#{__FILE__}", 'r')
|
87
|
+
}.should_not raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should be able to create new tempfiles" do
|
91
|
+
lambda {
|
92
|
+
Tempfile.new("temp_file_test")
|
93
|
+
}.should_not raise_error
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "open" do
|
97
|
+
it "should return File when called on File with VFS url" do
|
98
|
+
puts @archive1_path
|
99
|
+
File.open("vfs:#{@archive1_path}", 'r').should be_an_instance_of(File)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should return File when called on File without VFS url" do
|
103
|
+
File.open(@archive1_path, 'r').should be_an_instance_of(File)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "new" do
|
108
|
+
it "should return File when called on File with VFS url" do
|
109
|
+
File.new("vfs:#{@archive1_path}", 'r').should be_an_instance_of(File)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should return File when called on File without VFS url" do
|
113
|
+
File.new(@archive1_path, 'r').should be_an_instance_of(File)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
[ :absolute, :relative, :vfs ].each do |style|
|
118
|
+
describe "with #{style} paths" do
|
119
|
+
case ( style )
|
120
|
+
when :relative
|
121
|
+
prefix = "./#{TEST_COPY_BASE}"
|
122
|
+
when :absolute
|
123
|
+
prefix = File.expand_path( File.join( File.dirname( __FILE__ ), '..', TEST_COPY_BASE ) )
|
124
|
+
when :vfs
|
125
|
+
prefix = "vfs:#{File.expand_path( File.join( File.dirname( __FILE__ ), '..', TEST_COPY_BASE ) )}"
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should provide mtime for normal files" do
|
129
|
+
mtime = File.mtime( "#{prefix}/home/larry/file1.txt" )
|
130
|
+
mtime.should_not be_nil
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should report writeable-ness for normal files" do
|
134
|
+
File.writable?( "#{prefix}/home/larry/file1.txt" ).should be_true
|
135
|
+
end
|
136
|
+
|
137
|
+
# move to kernel_spec
|
138
|
+
it "should allow writing with truncation via open()" do
|
139
|
+
open( "#{prefix}/home/larry/file1.txt", (File::WRONLY | File::TRUNC | File::CREAT) ) do |file|
|
140
|
+
file.puts "howdy"
|
141
|
+
end
|
142
|
+
contents = File.read( "#{prefix}/home/larry/file1.txt" )
|
143
|
+
contents.should eql( "howdy\n" )
|
144
|
+
end
|
145
|
+
|
146
|
+
# move to kernel_spec
|
147
|
+
it "should allow writing with appending via open()" do
|
148
|
+
open( "#{prefix}/home/larry/file1.txt", (File::WRONLY | File::APPEND | File::CREAT) ) do |file|
|
149
|
+
file.puts "howdy"
|
150
|
+
end
|
151
|
+
contents = File.read( "#{prefix}/home/larry/file1.txt" )
|
152
|
+
contents.should eql( "This is file 1\nhowdy\n" )
|
153
|
+
|
154
|
+
fs_file = File.join( File.dirname(__FILE__), '..', TEST_COPY_BASE, 'home/larry/file1.txt' )
|
155
|
+
puts "confirm from #{fs_file}"
|
156
|
+
fs_contents = File.read( fs_file )
|
157
|
+
fs_contents.should eql( "This is file 1\nhowdy\n" )
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should allow stat for normal files" do
|
161
|
+
file = "#{prefix}/home/larry/file1.txt"
|
162
|
+
stat = File.stat( file )
|
163
|
+
stat.should_not be_nil
|
164
|
+
stat.mtime.should eql( File.mtime( file ) )
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should provide mtime for files in an archive" do
|
168
|
+
mtime = File.mtime( "#{prefix}/home/larry/archive1.jar/web.xml" )
|
169
|
+
mtime.should_not be_nil
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should allow stat for files in an archive" do
|
173
|
+
file = "#{prefix}/home/larry/archive1.jar/web.xml"
|
174
|
+
stat = File.stat( file )
|
175
|
+
stat.should_not be_nil
|
176
|
+
stat.mtime.should eql( File.mtime( file ) )
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should provide mtime for files in a nested archive" do
|
180
|
+
mtime = File.mtime( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar/manifest.txt" )
|
181
|
+
mtime.should_not be_nil
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should test existance of normal files" do
|
185
|
+
File.exist?( "#{prefix}/home/larry/file1.txt" ).should be_true
|
186
|
+
File.exist?( "#{prefix}/home/larry/file42.txt" ).should be_false
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should test existance of files in an archive" do
|
190
|
+
File.exist?( "#{prefix}/home/larry/archive1.jar/web.xml" ).should be_true
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should test directoryness for normal files" do
|
194
|
+
File.directory?( "#{prefix}/home/larry" ).should be_true
|
195
|
+
File.directory?( "#{prefix}/home/larry/file1.txt" ).should be_false
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should test directoryness for files within an archive" do
|
199
|
+
File.directory?( "#{prefix}/home/larry/archive1.jar/lib" ).should be_true
|
200
|
+
File.directory?( "#{prefix}/home/larry/archive1.jar/web.xml" ).should be_false
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should test directoryness for non-existant files" do
|
204
|
+
File.directory?( "#{prefix}/home/larry/archive1.jar/fib" ).should be_false
|
205
|
+
File.directory?( "#{prefix}/home/larry/archive1.jar/tacos" ).should be_false
|
206
|
+
File.directory?( "#{prefix}/tacos" ).should be_false
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should test fileness for normal files" do
|
210
|
+
File.file?( "#{prefix}/home/larry" ).should be_false
|
211
|
+
File.file?( "#{prefix}/home/larry/file1.txt" ).should be_true
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should test fileness for files within an archive" do
|
215
|
+
File.file?( "#{prefix}/home/larry/archive1.jar/lib" ).should be_false
|
216
|
+
File.file?( "#{prefix}/home/larry/archive1.jar/web.xml" ).should be_true
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe 'dirname' do
|
222
|
+
it "should properly handle non-vfs paths" do
|
223
|
+
File.dirname('/').should == '/'
|
224
|
+
File.dirname('/a').should == '/'
|
225
|
+
File.dirname('/a/b').should == '/a'
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should return vfs paths when given a vfs path" do
|
229
|
+
File.dirname('vfs:/').should == 'vfs:/'
|
230
|
+
File.dirname('vfs:/a').should == 'vfs:/'
|
231
|
+
File.dirname('vfs:/a/b').should == 'vfs:/a'
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
data/spec/io_spec.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
3
|
+
|
4
|
+
describe "IO extensions for VFS" do
|
5
|
+
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@executor = java.util.concurrent::Executors.newScheduledThreadPool( 1 )
|
9
|
+
@temp_file_provider = org.jboss.vfs::TempFileProvider.create( "vfs-test", @executor )
|
10
|
+
|
11
|
+
@archive1_path = File.join( TEST_DATA_DIR, "/home/larry/archive1.jar" )
|
12
|
+
@archive1_file = org.jboss.vfs::VFS.child( @archive1_path )
|
13
|
+
@archive1_mount_point = org.jboss.vfs::VFS.child( @archive1_path )
|
14
|
+
@archive1_handle = org.jboss.vfs::VFS.mountZip( @archive1_file, @archive1_mount_point, @temp_file_provider )
|
15
|
+
|
16
|
+
@archive2_path = "#{@archive1_path}/lib/archive2.jar"
|
17
|
+
@archive2_file = org.jboss.vfs::VFS.child( @archive2_path )
|
18
|
+
@archive2_mount_point = org.jboss.vfs::VFS.child( @archive2_path )
|
19
|
+
@archive2_handle = org.jboss.vfs::VFS.mountZip( @archive2_file, @archive2_mount_point, @temp_file_provider )
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:each) do
|
23
|
+
@archive2_handle.close
|
24
|
+
@archive1_handle.close
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should allow reading of full VFS URLs" do
|
28
|
+
content = IO.read( "vfs:#{TEST_DATA_DIR}/home/larry/archive1.jar/lib/archive2.jar/manifest.txt" ).chomp
|
29
|
+
content.should_not be_nil
|
30
|
+
content.should_not be_empty
|
31
|
+
content.should eql( "This is manifest.txt" )
|
32
|
+
end
|
33
|
+
|
34
|
+
[ :absolute, :relative ].each do |style|
|
35
|
+
describe "with #{style} paths" do
|
36
|
+
|
37
|
+
case ( style )
|
38
|
+
when :relative
|
39
|
+
prefix = "./#{TEST_DATA_BASE}"
|
40
|
+
when :absolute
|
41
|
+
prefix = File.expand_path( File.join( File.dirname( __FILE__ ), '..', TEST_DATA_BASE ) )
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should allow reading of regular files" do
|
45
|
+
content = IO.read( "#{prefix}/home/larry/file1.txt" ).chomp
|
46
|
+
content.should_not be_nil
|
47
|
+
content.should_not be_empty
|
48
|
+
content.should eql( "This is file 1" )
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should allow reading of files within an archive" do
|
52
|
+
content = IO.read( "#{prefix}/home/larry/archive1.jar/web.xml" ).chomp
|
53
|
+
content.should_not be_nil
|
54
|
+
content.should_not be_empty
|
55
|
+
content.should eql( "This is web.xml" )
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should allow reading of files within a nested archive" do
|
59
|
+
content = IO.read( "#{prefix}/home/larry/archive1.jar/lib/archive2.jar/manifest.txt" ).chomp
|
60
|
+
content.should_not be_nil
|
61
|
+
content.should_not be_empty
|
62
|
+
content.should eql( "This is manifest.txt" )
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/vfs_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
describe "VFS path resolution" do
|
3
|
+
|
4
|
+
it "should prefix relative paths with the current dir" do
|
5
|
+
cwd = Dir.pwd
|
6
|
+
path = VFS.resolve_path_url( "foo/bar" )
|
7
|
+
path.should match /^vfs:#{cwd}\/foo\/bar$/
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should not prefix absolute paths with the current dir" do
|
11
|
+
path = VFS.resolve_path_url( "/foo/bar" )
|
12
|
+
path.should match /^vfs:\/foo\/bar$/
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should treat paths with windows drive letters as absolute" do
|
16
|
+
path = VFS.resolve_path_url( "C:/foo/bar" )
|
17
|
+
path.should match /^vfs:\/C:\/foo\/bar$/
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: org.torquebox.vfs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- Beta22
|
10
|
+
version: 1.0.0.Beta22
|
11
|
+
platform: ruby
|
12
|
+
authors: []
|
13
|
+
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-30 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 3
|
31
|
+
- 0
|
32
|
+
version: 1.3.0
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
- 8
|
45
|
+
- 7
|
46
|
+
version: 0.8.7
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
description: ""
|
50
|
+
email:
|
51
|
+
executables: []
|
52
|
+
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files:
|
58
|
+
- licenses/lgpl-2.1.txt
|
59
|
+
- lib/vfs.rb
|
60
|
+
- lib/vfs/dir.rb
|
61
|
+
- lib/vfs/file.rb
|
62
|
+
- lib/vfs/glob_filter.rb
|
63
|
+
- lib/vfs/ext/dir.rb
|
64
|
+
- lib/vfs/ext/file.rb
|
65
|
+
- lib/vfs/ext/io.rb
|
66
|
+
- lib/vfs/ext/kernel.rb
|
67
|
+
- lib/vfs/ext/vfs.rb
|
68
|
+
- spec/dir_spec.rb
|
69
|
+
- spec/file_spec.rb
|
70
|
+
- spec/io_spec.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
- spec/vfs_spec.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://www.torquebox.org/vfs/
|
75
|
+
licenses:
|
76
|
+
- lgpl
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
segments:
|
94
|
+
- 1
|
95
|
+
- 3
|
96
|
+
- 1
|
97
|
+
version: 1.3.1
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.3.6
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: TorqueBox VFS
|
105
|
+
test_files:
|
106
|
+
- spec/dir_spec.rb
|
107
|
+
- spec/file_spec.rb
|
108
|
+
- spec/io_spec.rb
|
109
|
+
- spec/vfs_spec.rb
|