torquebox-vfs 1.1.1-java → 2.0.0.beta1-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.
- data/lib/gem_hook.rb +3 -3
- data/lib/torquebox-vfs.jar +0 -0
- data/lib/torquebox-vfs.rb +2 -9
- data/lib/torquebox/vfs.rb +4 -0
- data/lib/torquebox/vfs/ext/dir.rb +11 -4
- data/lib/torquebox/vfs/ext/file.rb +22 -0
- data/lib/torquebox/vfs/ext/io.rb +18 -13
- data/lib/torquebox/vfs/ext/jdbc.rb +17 -4
- data/lib/torquebox/vfs/ext/kernel.rb +8 -0
- data/lib/torquebox/vfs/ext/pathname.rb +8 -1
- data/lib/torquebox/vfs/ext/process.rb +34 -0
- data/lib/torquebox/vfs/glob_filter.rb +0 -1
- data/licenses/lgpl-2.1.txt +7 -9
- data/spec/dir_spec.rb +64 -9
- data/spec/file_spec.rb +36 -2
- data/spec/fileutils_spec.rb +15 -0
- data/spec/io_spec.rb +20 -0
- data/spec/jdbc_spec.rb +23 -0
- data/spec/kernel_spec.rb +32 -0
- data/spec/pathname_spec.rb +21 -0
- data/spec/process_spec.rb +20 -0
- data/spec/relatively_requireable.rb +2 -0
- data/spec/vfs_spec.rb +1 -1
- metadata +20 -18
- data/lib/jboss-common-core-2.2.17.GA.jar +0 -0
- data/lib/jboss-logging-3.0.0.Beta4.jar +0 -0
- data/lib/jboss-logging-spi-2.2.0.CR1.jar +0 -0
- data/lib/jboss-logmanager-1.2.0.CR9.jar +0 -0
- data/lib/jboss-logmanager-log4j-1.0.0.CR3.jar +0 -0
- data/lib/jboss-vfs-3.0.0.GA.jar +0 -0
- data/lib/log4j-1.2.14.jar +0 -0
data/lib/gem_hook.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# This is free software; you can redistribute it and/or modify it
|
4
4
|
# under the terms of the GNU Lesser General Public License as
|
5
5
|
# published by the Free Software Foundation; either version 2.1 of
|
6
6
|
# the License, or (at your option) any later version.
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# This software is distributed in the hope that it will be useful,
|
9
9
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
10
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
11
|
# Lesser General Public License for more details.
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# You should have received a copy of the GNU Lesser General Public
|
14
14
|
# License along with this software; if not, write to the Free
|
15
15
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
data/lib/torquebox-vfs.jar
CHANGED
Binary file
|
data/lib/torquebox-vfs.rb
CHANGED
@@ -1,17 +1,10 @@
|
|
1
1
|
module TorqueboxVfs
|
2
|
-
VERSION = '
|
3
|
-
MAVEN_VERSION = '
|
2
|
+
VERSION = '2.0.0.beta1'
|
3
|
+
MAVEN_VERSION = '2.0.0.beta1'
|
4
4
|
end
|
5
5
|
begin
|
6
6
|
require 'java'
|
7
7
|
require File.dirname(__FILE__) + '/torquebox-vfs.jar'
|
8
|
-
require File.dirname(__FILE__) + '/jboss-vfs-3.0.0.GA.jar'
|
9
|
-
require File.dirname(__FILE__) + '/jboss-logging-spi-2.2.0.CR1.jar'
|
10
|
-
require File.dirname(__FILE__) + '/jboss-logging-3.0.0.Beta4.jar'
|
11
|
-
require File.dirname(__FILE__) + '/jboss-logmanager-1.2.0.CR9.jar'
|
12
|
-
require File.dirname(__FILE__) + '/jboss-logmanager-log4j-1.0.0.CR3.jar'
|
13
|
-
require File.dirname(__FILE__) + '/log4j-1.2.14.jar'
|
14
|
-
require File.dirname(__FILE__) + '/jboss-common-core-2.2.17.GA.jar'
|
15
8
|
rescue LoadError
|
16
9
|
puts 'JAR-based gems require JRuby to load. Please visit www.jruby.org.'
|
17
10
|
raise
|
data/lib/torquebox/vfs.rb
CHANGED
@@ -33,11 +33,15 @@ require 'torquebox/vfs/ext/dir'
|
|
33
33
|
require 'torquebox/vfs/ext/pathname'
|
34
34
|
require 'torquebox/vfs/ext/kernel'
|
35
35
|
require 'torquebox/vfs/ext/jdbc'
|
36
|
+
require 'torquebox/vfs/ext/process'
|
36
37
|
|
37
38
|
|
38
39
|
module TorqueBox
|
39
40
|
module VFS
|
40
41
|
def self.resolve_within_archive(path)
|
42
|
+
if ( path.respond_to?(:vfs_path?) && path.vfs_path? )
|
43
|
+
return "vfs:#{path.to_s}"
|
44
|
+
end
|
41
45
|
path = path.to_s
|
42
46
|
return path if ( path =~ %r(^vfs:) )
|
43
47
|
cur = path
|
@@ -117,7 +117,7 @@ class Dir
|
|
117
117
|
|
118
118
|
def glob_one(pattern, flags=0, &block)
|
119
119
|
#str_pattern = "#{pattern}"
|
120
|
-
str_pattern = pattern
|
120
|
+
str_pattern = File.path_to_str(pattern)
|
121
121
|
|
122
122
|
segments = str_pattern.split( '/' )
|
123
123
|
|
@@ -144,7 +144,7 @@ class Dir
|
|
144
144
|
|
145
145
|
matcher_segments = segments - base_segments
|
146
146
|
matcher = matcher_segments.join( '/' )
|
147
|
-
dirs_only = (str_pattern[-1,1] == '/')
|
147
|
+
dirs_only = ( str_pattern[-1,1] == '/' )
|
148
148
|
#puts "matcher [#{matcher}]"
|
149
149
|
|
150
150
|
begin
|
@@ -164,8 +164,15 @@ class Dir
|
|
164
164
|
#puts "base=#{base}"
|
165
165
|
# puts "preparing glob filter for path #{child_path} and match #{matcher}"
|
166
166
|
filter = TorqueBox::VFS::GlobFilter.new( child_path, matcher, dirs_only )
|
167
|
-
|
168
|
-
|
167
|
+
paths = starting_point.getChildrenRecursively( filter )
|
168
|
+
|
169
|
+
if ( str_pattern[str_pattern.length - 3, str_pattern.length - 1] == '**/' )
|
170
|
+
# if asking for double-splat and a trailing slash, the root counts too.
|
171
|
+
paths << org.jboss.vfs.VFS.child( child_path )
|
172
|
+
end
|
173
|
+
|
174
|
+
# paths = starting_point.getChildrenRecursively( filter ).collect{ |e|
|
175
|
+
paths = paths.collect { |e|
|
169
176
|
#path_name = e.path_name
|
170
177
|
path_name = e.getPathNameRelativeTo( starting_point )
|
171
178
|
#puts "(collect) path_name=#{path_name}"
|
@@ -41,6 +41,26 @@ class File
|
|
41
41
|
alias_method :new_without_vfs, :new
|
42
42
|
alias_method :rename_without_vfs, :rename
|
43
43
|
alias_method :join_without_vfs, :join
|
44
|
+
alias_method :to_s_without_vfs, :to_s
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
s = to_s_without_vfs
|
48
|
+
vfs_path?( s ) ? s[4..-1] : s
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# File.realpath is a 1.9ism
|
53
|
+
#
|
54
|
+
if ( File.respond_to? :realpath )
|
55
|
+
alias_method :realpath_without_vfs, :realpath
|
56
|
+
def realpath(path, dir_string=nil)
|
57
|
+
if vfs_path?( path )
|
58
|
+
virtual_file = TorqueBox::VFS.virtual_file( path )
|
59
|
+
return virtual_file.physical_file.to_s
|
60
|
+
end
|
61
|
+
realpath_without_vfs( path, dir_string )
|
62
|
+
end
|
63
|
+
end
|
44
64
|
|
45
65
|
def open(fname,mode_str='r', flags=nil, &block)
|
46
66
|
if ( Fixnum === fname )
|
@@ -267,6 +287,8 @@ class File
|
|
267
287
|
end
|
268
288
|
|
269
289
|
def vfs_path?(path)
|
290
|
+
return path.vfs_path? if path.respond_to?(:vfs_path?)
|
291
|
+
return path.path =~ /^vfs:/ if path.respond_to?(:path)
|
270
292
|
path.to_s =~ /^vfs:/
|
271
293
|
end
|
272
294
|
|
data/lib/torquebox/vfs/ext/io.rb
CHANGED
@@ -31,31 +31,23 @@ class IO
|
|
31
31
|
write = false
|
32
32
|
read = false
|
33
33
|
create = false
|
34
|
+
binary = false
|
34
35
|
case ( mode_str )
|
35
36
|
when /r/
|
36
37
|
read = true
|
37
|
-
write = false
|
38
|
-
append = false
|
39
|
-
create = false
|
40
38
|
when /r\+/
|
41
39
|
read = true
|
42
40
|
write = true
|
43
|
-
create = false
|
44
|
-
append = false
|
45
41
|
when /w/
|
46
|
-
read = false
|
47
42
|
write = true
|
48
43
|
create = true
|
49
|
-
append = false
|
50
44
|
truncate = true
|
51
45
|
when /w\+/
|
52
|
-
read =
|
46
|
+
read = true
|
53
47
|
write = true
|
54
48
|
create = true
|
55
|
-
append = false
|
56
49
|
truncate = true
|
57
50
|
when /a/
|
58
|
-
read = false
|
59
51
|
write = true
|
60
52
|
create = true
|
61
53
|
append = true
|
@@ -63,6 +55,7 @@ class IO
|
|
63
55
|
read = true
|
64
56
|
write = true
|
65
57
|
create = true
|
58
|
+
append = true
|
66
59
|
when Fixnum
|
67
60
|
if ( mode_str & File::RDONLY != 0 )
|
68
61
|
read = true
|
@@ -88,13 +81,15 @@ class IO
|
|
88
81
|
end
|
89
82
|
end
|
90
83
|
|
84
|
+
binary = mode_str =~ /b/
|
85
|
+
|
91
86
|
# VFS doesn't correctly handle relative paths when
|
92
87
|
# retrieving the physical file so expand it
|
93
88
|
fd = File.expand_path( fd )
|
94
89
|
virtual_file = org.jboss.vfs.VFS.child( fd )
|
95
90
|
|
96
91
|
if ( ! create && ! virtual_file.exists )
|
97
|
-
raise Errno::ENOENT
|
92
|
+
raise Errno::ENOENT, fd
|
98
93
|
end
|
99
94
|
|
100
95
|
if ( read && ! write )
|
@@ -105,16 +100,17 @@ class IO
|
|
105
100
|
java_out = java.io::FileOutputStream.new( physical_file, append )
|
106
101
|
ruby_io = java_out.to_io
|
107
102
|
elsif ( read && write )
|
108
|
-
raise
|
103
|
+
raise ArgumentError.new( "Random-access on VFS not supported" )
|
109
104
|
end
|
110
105
|
|
106
|
+
ruby_io.binmode if binary
|
111
107
|
file_io = TorqueBox::VFS::Ext::VirtualFile.new( ruby_io, fd )
|
112
108
|
|
113
109
|
if ( block )
|
114
110
|
begin
|
115
111
|
block.call( file_io )
|
116
112
|
ensure
|
117
|
-
file_io.close
|
113
|
+
file_io.close unless file_io.closed?
|
118
114
|
end
|
119
115
|
else
|
120
116
|
return file_io
|
@@ -153,6 +149,15 @@ class IO
|
|
153
149
|
vfs_open( name ).readlines( *options )
|
154
150
|
end
|
155
151
|
end
|
152
|
+
|
153
|
+
if RUBY_VERSION =~ /1.9/
|
154
|
+
alias_method :copy_stream_without_vfs, :copy_stream
|
155
|
+
def copy_stream(src, dst, *args)
|
156
|
+
src = src.__getobj__ if src.is_a?( TorqueBox::VFS::Ext::VirtualFile )
|
157
|
+
dst = dst.__getobj__ if dst.is_a?( TorqueBox::VFS::Ext::VirtualFile )
|
158
|
+
copy_stream_without_vfs( src, dst, *args )
|
159
|
+
end
|
160
|
+
end
|
156
161
|
end
|
157
162
|
|
158
163
|
end
|
@@ -23,15 +23,18 @@ class Java::java.sql::DriverManager
|
|
23
23
|
# Monkey patch getConnection so we can sort out local filesystem url's for
|
24
24
|
# SQLite (we need to remove the 'vfs:' from the url). This works
|
25
25
|
# for activerecord-jdbc-adapter v1.1.2 and under. For v1.1.3 and
|
26
|
-
# up, see web/
|
26
|
+
# up, see web/src/main/java/org/torquebox/rails/boot.rb
|
27
27
|
def getConnection(url, *params)
|
28
28
|
|
29
29
|
# Remove any VFS prefix from the url (for SQLite)
|
30
30
|
url = url.sub(':vfs:', ':')
|
31
31
|
|
32
32
|
# Call the correct version based on the number of arguments
|
33
|
-
|
34
|
-
|
33
|
+
case params.count
|
34
|
+
when 0 then get_connection_with_url(url)
|
35
|
+
when 1 then get_connection_with_properties(url, params.first)
|
36
|
+
when 2 then get_connection_with_username_password(url, params[0], params[1])
|
37
|
+
end
|
35
38
|
end
|
36
39
|
|
37
40
|
def registerDriver(driver)
|
@@ -41,12 +44,22 @@ class Java::java.sql::DriverManager
|
|
41
44
|
|
42
45
|
private
|
43
46
|
|
47
|
+
# The 1 param version of getConnection passing in a url
|
48
|
+
def get_connection_with_url(url)
|
49
|
+
get_connection_without_vfs(url)
|
50
|
+
rescue => e
|
51
|
+
raise e unless @driver
|
52
|
+
# If we did register a driver, try to connect using it directly
|
53
|
+
props = java.util.Properties.new
|
54
|
+
@driver.connect(url, props)
|
55
|
+
end
|
56
|
+
|
44
57
|
# The 2 param version of getConnection passing in url and a hash of properties
|
45
58
|
def get_connection_with_properties(url, properties)
|
46
59
|
get_connection_without_vfs(url, properties)
|
47
60
|
rescue => e
|
48
61
|
raise e unless @driver
|
49
|
-
# If we did register a driver, try to
|
62
|
+
# If we did register a driver, try to connect using it directly
|
50
63
|
@driver.connect(url, properties)
|
51
64
|
end
|
52
65
|
|
@@ -19,6 +19,7 @@ module Kernel
|
|
19
19
|
|
20
20
|
private
|
21
21
|
alias_method :open_without_vfs, :open
|
22
|
+
alias_method :backtick_without_vfs, '`'
|
22
23
|
|
23
24
|
def open(name, *rest, &block)
|
24
25
|
if ( name =~ /^vfs:/ )
|
@@ -27,4 +28,11 @@ module Kernel
|
|
27
28
|
open_without_vfs( name, *rest, &block )
|
28
29
|
end
|
29
30
|
|
31
|
+
def `(*args)
|
32
|
+
non_vfs_args = args.map do |arg|
|
33
|
+
arg.is_a?(String) ? arg.gsub("vfs:", "") : arg
|
34
|
+
end
|
35
|
+
backtick_without_vfs(*non_vfs_args)
|
36
|
+
end
|
37
|
+
|
30
38
|
end
|
@@ -21,16 +21,23 @@ class Pathname
|
|
21
21
|
|
22
22
|
alias_method :realpath_without_vfs, :realpath
|
23
23
|
alias_method :relative_without_vfs, :relative?
|
24
|
+
alias_method :to_s_without_vfs, :to_s
|
24
25
|
|
25
26
|
def realpath
|
26
27
|
vfs_path? ? expand_path : realpath_without_vfs
|
27
28
|
end
|
28
29
|
|
29
30
|
def vfs_path?
|
30
|
-
@path
|
31
|
+
@path =~ /^vfs:/
|
31
32
|
end
|
32
33
|
|
33
34
|
def relative?
|
34
35
|
vfs_path? ? false : relative_without_vfs
|
35
36
|
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
s = to_s_without_vfs
|
40
|
+
vfs_path? ? s[4..-1] : s
|
41
|
+
end
|
42
|
+
|
36
43
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
module Process
|
19
|
+
|
20
|
+
class << self
|
21
|
+
|
22
|
+
if self.respond_to?(:spawn)
|
23
|
+
alias_method :spawn_without_vfs, :spawn
|
24
|
+
def spawn(*args)
|
25
|
+
non_vfs_args = args.map do |arg|
|
26
|
+
arg.is_a?(String) ? arg.gsub("vfs:", "") : arg
|
27
|
+
end
|
28
|
+
spawn_without_vfs(*non_vfs_args)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/licenses/lgpl-2.1.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 2.1, February 1999
|
3
3
|
|
4
4
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
5
5
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
@@ -10,7 +10,7 @@
|
|
10
10
|
as the successor of the GNU Library Public License, version 2, hence
|
11
11
|
the version number 2.1.]
|
12
12
|
|
13
|
-
|
13
|
+
Preamble
|
14
14
|
|
15
15
|
The licenses for most software are designed to take away your
|
16
16
|
freedom to share and change it. By contrast, the GNU General Public
|
@@ -112,7 +112,7 @@ modification follow. Pay close attention to the difference between a
|
|
112
112
|
former contains code derived from the library, whereas the latter must
|
113
113
|
be combined with the library in order to run.
|
114
114
|
|
115
|
-
|
115
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
116
116
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
117
117
|
|
118
118
|
0. This License Agreement applies to any software library or other
|
@@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
|
|
146
146
|
on the Library (independent of the use of the Library in a tool for
|
147
147
|
writing it). Whether that is true depends on what the Library does
|
148
148
|
and what the program that uses the Library does.
|
149
|
-
|
149
|
+
|
150
150
|
1. You may copy and distribute verbatim copies of the Library's
|
151
151
|
complete source code as you receive it, in any medium, provided that
|
152
152
|
you conspicuously and appropriately publish on each copy an
|
@@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
|
|
432
432
|
of all derivatives of our free software and of promoting the sharing
|
433
433
|
and reuse of software generally.
|
434
434
|
|
435
|
-
|
435
|
+
NO WARRANTY
|
436
436
|
|
437
437
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
438
438
|
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
@@ -455,7 +455,7 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
|
455
455
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
456
456
|
DAMAGES.
|
457
457
|
|
458
|
-
|
458
|
+
END OF TERMS AND CONDITIONS
|
459
459
|
|
460
460
|
How to Apply These Terms to Your New Libraries
|
461
461
|
|
@@ -500,5 +500,3 @@ necessary. Here is a sample; alter the names:
|
|
500
500
|
Ty Coon, President of Vice
|
501
501
|
|
502
502
|
That's all there is to it!
|
503
|
-
|
504
|
-
|
data/spec/dir_spec.rb
CHANGED
@@ -44,21 +44,21 @@ describe "Dir extensions for VFS" do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should ignore dotdirs by default" do
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
items = Dir.glob( "#{prefix}/**/*" )
|
48
|
+
items.should_not be_empty
|
49
|
+
items.size.should eql(33)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should handle trailing double splats" do
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
items = Dir.glob( "#{prefix}/**" )
|
54
|
+
items.should_not be_empty
|
55
|
+
items.size.should eql(6)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should handle Rails 2 glob-related arglebargle" do
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
items = Dir.glob( "#{prefix}/**/*/**" )
|
60
|
+
items.should_not be_empty
|
61
|
+
items.size.should eql(27)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should ignore dotfiles by default" do
|
@@ -247,6 +247,51 @@ describe "Dir extensions for VFS" do
|
|
247
247
|
items.should include( "#{prefix}/home" )
|
248
248
|
items.should include( "#{prefix}/sound of music" )
|
249
249
|
end
|
250
|
+
|
251
|
+
it "should match the current directory on a double-splat with trailing slash" do
|
252
|
+
items = Dir.glob( "#{prefix}/**/" )
|
253
|
+
|
254
|
+
puts "\nFor 255:"
|
255
|
+
items.each {|i| puts i}
|
256
|
+
|
257
|
+
items.should_not be_empty
|
258
|
+
items.size.should eql(4)
|
259
|
+
items.should include( "#{prefix}/" )
|
260
|
+
items.should include( "#{prefix}/dotfiles" )
|
261
|
+
items.should include( "#{prefix}/home" )
|
262
|
+
items.should include( "#{prefix}/sound of music" )
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should match files on a double splat without a trailing slash" do
|
266
|
+
items = Dir.glob( "#{prefix}/**" )
|
267
|
+
items.should_not be_empty
|
268
|
+
items.size.should eql(6)
|
269
|
+
items.should include( "#{prefix}/dotfiles" )
|
270
|
+
items.should include( "#{prefix}/home" )
|
271
|
+
items.should include( "#{prefix}/sound of music" )
|
272
|
+
items.should include( "#{prefix}/#bad-uri#" )
|
273
|
+
items.should include( "#{prefix}/biscuit.jpg" )
|
274
|
+
items.should include( "#{prefix}/views%2Flocalhost%3A8080%2Fposts" )
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should match using question marks" do
|
278
|
+
items = Dir.glob( "#{prefix}/biscuit.jp?" )
|
279
|
+
items.should_not be_empty
|
280
|
+
items.size.should eql(1)
|
281
|
+
items.should include( "#{prefix}/biscuit.jpg" )
|
282
|
+
end
|
283
|
+
|
284
|
+
it "should match files on a single splat without a trailing slash" do
|
285
|
+
items = Dir.glob( "#{prefix}/*" )
|
286
|
+
items.should_not be_empty
|
287
|
+
items.size.should eql(6)
|
288
|
+
items.should include( "#{prefix}/dotfiles" )
|
289
|
+
items.should include( "#{prefix}/home" )
|
290
|
+
items.should include( "#{prefix}/sound of music" )
|
291
|
+
items.should include( "#{prefix}/#bad-uri#" )
|
292
|
+
items.should include( "#{prefix}/biscuit.jpg" )
|
293
|
+
items.should include( "#{prefix}/views%2Flocalhost%3A8080%2Fposts" )
|
294
|
+
end
|
250
295
|
|
251
296
|
it "should allow for multiple single-star globbing" do
|
252
297
|
items = Dir.glob( "#{prefix}/home/**/*file*.txt" )
|
@@ -274,6 +319,16 @@ describe "Dir extensions for VFS" do
|
|
274
319
|
items.should include( "#{prefix}/home/larry/file1.txt" )
|
275
320
|
end
|
276
321
|
|
322
|
+
it "should allow globbing with pathnames via []" do
|
323
|
+
items = []
|
324
|
+
path = Pathname.new( prefix ).join( "home", "larry", "*" )
|
325
|
+
lambda {
|
326
|
+
items = Dir[path]
|
327
|
+
}.should_not raise_error
|
328
|
+
|
329
|
+
items.should include( "#{prefix}/home/larry/file1.txt" )
|
330
|
+
end
|
331
|
+
|
277
332
|
it "should create new Dirs" do
|
278
333
|
lambda {
|
279
334
|
Dir.new(prefix)
|
data/spec/file_spec.rb
CHANGED
@@ -7,6 +7,20 @@ describe "File extensions for VFS" do
|
|
7
7
|
|
8
8
|
extend TestDataCopyHelper
|
9
9
|
|
10
|
+
it "should set __FILE__ correctly" do
|
11
|
+
__FILE__.should =~ /^#{absolute_prefix}/
|
12
|
+
end
|
13
|
+
|
14
|
+
if ( File.respond_to? :realpath)
|
15
|
+
it "should handle realpath on a normal path" do
|
16
|
+
File.realpath( __FILE__ ).should == __FILE__
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should handle realpath on a VFS path" do
|
20
|
+
File.realpath( vfs_path(__FILE__) ).should =~ /^#{absolute_prefix}/
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
10
24
|
it "should report writable-ness for VFS urls" do
|
11
25
|
prefix = test_copy_base_path( :relative )
|
12
26
|
url = vfs_path( "#{prefix}/home/larry/file1.txt" )
|
@@ -40,12 +54,12 @@ describe "File extensions for VFS" do
|
|
40
54
|
|
41
55
|
it "should expand paths relative to VFS pathnames as VFS" do
|
42
56
|
absolute = File.expand_path("db/development.sqlite3", Pathname.new( vfs_path( "/path/to/app" ) ) )
|
43
|
-
absolute.should eql( vfs_path("#{absolute_prefix}/path/to/app/db/development.sqlite3") )
|
57
|
+
absolute.should eql( vfs_path( "#{absolute_prefix}/path/to/app/db/development.sqlite3" ) )
|
44
58
|
end
|
45
59
|
|
46
60
|
it "should expand absolute Pathname objects correctly" do
|
47
61
|
File.expand_path( vfs_path("/foo") ).should eql( vfs_path("/foo") )
|
48
|
-
File.expand_path(Pathname.new( vfs_path("/foo"))).should eql(
|
62
|
+
File.expand_path(Pathname.new( vfs_path("/foo"))).should eql( "/foo" )
|
49
63
|
end
|
50
64
|
|
51
65
|
it "should return first path when given two vfs paths" do
|
@@ -206,6 +220,26 @@ describe "File extensions for VFS" do
|
|
206
220
|
f.close
|
207
221
|
}.should_not raise_error
|
208
222
|
end
|
223
|
+
|
224
|
+
it "should respect binary mode for vfs files that don't yet exist" do
|
225
|
+
prefix = test_copy_base_path( :absolute )
|
226
|
+
in_path = "#{prefix}/biscuit.jpg"
|
227
|
+
out_path = vfs_path( "#{prefix}/binfile" )
|
228
|
+
data = File.read( in_path )
|
229
|
+
File.open( out_path, 'wb' ) { |f| f.write( data ) }
|
230
|
+
File.size( out_path ).should == File.size( in_path )
|
231
|
+
File.read( out_path ).should == data
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should respect binary mode for vfs files that already exist" do
|
235
|
+
prefix = test_copy_base_path( :absolute )
|
236
|
+
path = "#{prefix}/biscuit.jpg"
|
237
|
+
data = File.read( path )
|
238
|
+
size = File.size( path )
|
239
|
+
File.open( path, 'wb' ) { |f| f.write( data ) }
|
240
|
+
File.size( path ).should == size
|
241
|
+
File.read( path ).should == data
|
242
|
+
end
|
209
243
|
end
|
210
244
|
|
211
245
|
describe "new" do
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
describe "fileutils compatibility with VFS" do
|
5
|
+
|
6
|
+
extend TestDataCopyHelper
|
7
|
+
|
8
|
+
it "should support fileutils.cp for vfs paths" do
|
9
|
+
prefix = test_copy_base_path( :vfs )
|
10
|
+
source = File.join( prefix, "home", "larry", "file1.txt" )
|
11
|
+
destination = File.join( prefix, "home", "larry", "file1_copy.txt" )
|
12
|
+
FileUtils.cp( source, destination )
|
13
|
+
File.exist?( destination ).should be_true
|
14
|
+
end
|
15
|
+
end
|
data/spec/io_spec.rb
CHANGED
@@ -5,6 +5,18 @@ describe "IO extensions for VFS" do
|
|
5
5
|
|
6
6
|
extend TestDataHelper
|
7
7
|
|
8
|
+
describe "vfs_open" do
|
9
|
+
before(:each) do
|
10
|
+
@file = vfs_path( test_data_base_path( :absolute ) + "/home/larry/file1.txt" )
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should raise when given RDWR" do
|
14
|
+
lambda {
|
15
|
+
IO.vfs_open( @file, File::RDWR )
|
16
|
+
}.should raise_error( ArgumentError )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
8
20
|
[ :absolute, :relative ].each do |style|
|
9
21
|
[ :vfs, :normal ].each do |vfs_style|
|
10
22
|
describe "with #{vfs_style} #{style} paths" do
|
@@ -13,6 +25,14 @@ describe "IO extensions for VFS" do
|
|
13
25
|
prefix = vfs_path( prefix ) if vfs_style == :vfs
|
14
26
|
|
15
27
|
describe 'read' do
|
28
|
+
|
29
|
+
it "should raise a proper exception if file not found" do
|
30
|
+
begin
|
31
|
+
content = IO.read( "#{prefix}/joey/jo/jo/junior.shabadoo" )
|
32
|
+
rescue => ex
|
33
|
+
ex.message.should include "joey/jo/jo/junior.shabadoo"
|
34
|
+
end
|
35
|
+
end
|
16
36
|
|
17
37
|
it "should allow reading of regular files" do
|
18
38
|
content = IO.read( "#{prefix}/home/larry/file1.txt" ).chomp
|
data/spec/jdbc_spec.rb
CHANGED
@@ -11,6 +11,12 @@ describe "JDBC Extensions for VFS" do
|
|
11
11
|
|
12
12
|
describe "getConnection" do
|
13
13
|
|
14
|
+
it "should call get_connection_with_url if passed a single argument" do
|
15
|
+
@driver_manager.should_receive(:get_connection_with_url).
|
16
|
+
with("url")
|
17
|
+
@driver_manager.getConnection("url")
|
18
|
+
end
|
19
|
+
|
14
20
|
it "should call get_connection_with_properties if passed two arguments" do
|
15
21
|
properties = Properties.new
|
16
22
|
@driver_manager.should_receive(:get_connection_with_properties).
|
@@ -26,6 +32,23 @@ describe "JDBC Extensions for VFS" do
|
|
26
32
|
|
27
33
|
end
|
28
34
|
|
35
|
+
describe "get_connection_with_url" do
|
36
|
+
|
37
|
+
it "should delegate to original method" do
|
38
|
+
@driver_manager.should_receive(:get_connection_without_vfs).
|
39
|
+
with("url")
|
40
|
+
@driver_manager.send(:get_connection_with_url, "url")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should fall back to connect directly" do
|
44
|
+
driver = mock('driver')
|
45
|
+
driver.should_receive(:connect).with("url", an_instance_of(Properties))
|
46
|
+
@driver_manager.registerDriver(driver)
|
47
|
+
@driver_manager.send(:get_connection_with_url, "url")
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
29
52
|
describe "get_connection_with_properties" do
|
30
53
|
|
31
54
|
it "should delegate to original method" do
|
data/spec/kernel_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
3
|
+
|
4
|
+
describe "Kernel stuff" do
|
5
|
+
|
6
|
+
extend PathHelper
|
7
|
+
extend TestDataCopyHelper
|
8
|
+
|
9
|
+
#
|
10
|
+
# Kernel.require_relative is a 1.9ism
|
11
|
+
#
|
12
|
+
|
13
|
+
if ( Kernel.respond_to? :require_relative )
|
14
|
+
it "should be able to handle require_relative" do
|
15
|
+
require_relative "relatively_requireable"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be able to handle require_relative with VFS __FILE__" do
|
19
|
+
eval( 'require_relative "relatively_requireable"', binding, vfs_path(__FILE__) )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
unless TESTING_ON_WINDOWS
|
24
|
+
it "should remove vfs: prefix from backtick commands" do
|
25
|
+
prefix = test_copy_base_path( :vfs )
|
26
|
+
path = File.join( prefix, "home", "larry", "file1.txt" )
|
27
|
+
result = `ls #{path} 2>&1`
|
28
|
+
result.should_not match( /No such file/i )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/spec/pathname_spec.rb
CHANGED
@@ -4,13 +4,34 @@ require 'pathname'
|
|
4
4
|
|
5
5
|
describe "Pathname extensions for VFS" do
|
6
6
|
|
7
|
+
it "should test VFSness nicely" do
|
8
|
+
pathname = Pathname.new("vfs:/tmp/test")
|
9
|
+
pathname.should be_vfs_path
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should test VFSness nicely for Windows" do
|
13
|
+
pathname = Pathname.new("vfs:/C/tmp/test")
|
14
|
+
pathname.should be_vfs_path
|
15
|
+
end
|
16
|
+
|
7
17
|
describe "realpath" do
|
18
|
+
|
8
19
|
it "should expand VFS paths" do
|
9
20
|
pathname = Pathname.new("vfs:/tmp/test")
|
10
21
|
pathname.should_receive(:expand_path).and_return(Pathname.new("/expanded/path"))
|
11
22
|
pathname.realpath.to_s.should == "/expanded/path"
|
12
23
|
end
|
13
24
|
|
25
|
+
it "should expand VFS paths correctly on Windows" do
|
26
|
+
pathname = Pathname.new("vfs:/C:/tmp/test")
|
27
|
+
pathname.expand_path.to_s.should == "/C:/tmp/test" and pathname.vfs_path?.should be_true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should apply realpath to VFS paths correctly on windows" do
|
31
|
+
pathname = Pathname.new("vfs:/C:/tmp/test")
|
32
|
+
pathname.realpath.to_s.should == "/C:/tmp/test" and pathname.vfs_path?.should be_true
|
33
|
+
end
|
34
|
+
|
14
35
|
it "should find real path for non-VFS paths" do
|
15
36
|
pathname = Pathname.new("/tmp/test")
|
16
37
|
pathname.should_receive(:realpath_without_vfs).and_return(Pathname.new("/real/path"))
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Process compatibility with VFS" do
|
4
|
+
|
5
|
+
extend TestDataCopyHelper
|
6
|
+
|
7
|
+
if Process.respond_to?(:spawn) && !TESTING_ON_WINDOWS
|
8
|
+
it "should remove vfs: prefix from spawned commands" do
|
9
|
+
prefix = test_copy_base_path( :vfs )
|
10
|
+
path = File.join( prefix, "home", "larry", "file1.txt" )
|
11
|
+
r, w = IO.pipe
|
12
|
+
Process.spawn( {}, "ls #{path} 2>&1", STDERR => w, STDOUT => w )
|
13
|
+
w.close
|
14
|
+
result = r.readlines.join("")
|
15
|
+
r.close
|
16
|
+
result.should_not match( /No such file/i )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/vfs_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe "VFS path resolution" do
|
|
11
11
|
it "should return pathnames with vfs: prefix unmodified" do
|
12
12
|
pathname = Pathname.new("vfs:/tmp/foo")
|
13
13
|
path = TorqueBox::VFS.resolve_within_archive(pathname)
|
14
|
-
path.should == pathname
|
14
|
+
pathname.vfs_path?.should be_true and path.should == "vfs:#{pathname}"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
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:
|
5
|
-
version:
|
4
|
+
prerelease: 6
|
5
|
+
version: 2.0.0.beta1
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- The TorqueBox Team
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-12-02 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rspec
|
@@ -21,7 +20,7 @@ dependencies:
|
|
21
20
|
requirements:
|
22
21
|
- - "="
|
23
22
|
- !ruby/object:Gem::Version
|
24
|
-
version: 2.
|
23
|
+
version: 2.7.0
|
25
24
|
type: :development
|
26
25
|
version_requirements: *id001
|
27
26
|
- !ruby/object:Gem::Dependency
|
@@ -30,9 +29,12 @@ dependencies:
|
|
30
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
30
|
none: false
|
32
31
|
requirements:
|
33
|
-
- - "
|
32
|
+
- - ">="
|
34
33
|
- !ruby/object:Gem::Version
|
35
34
|
version: 0.8.7
|
35
|
+
- - <
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.0.0
|
36
38
|
type: :development
|
37
39
|
version_requirements: *id002
|
38
40
|
description: ""
|
@@ -48,13 +50,6 @@ files:
|
|
48
50
|
- licenses/lgpl-2.1.txt
|
49
51
|
- lib/torquebox-vfs.jar
|
50
52
|
- lib/torquebox-vfs.rb
|
51
|
-
- lib/jboss-vfs-3.0.0.GA.jar
|
52
|
-
- lib/jboss-logging-spi-2.2.0.CR1.jar
|
53
|
-
- lib/jboss-logging-3.0.0.Beta4.jar
|
54
|
-
- lib/jboss-logmanager-1.2.0.CR9.jar
|
55
|
-
- lib/jboss-logmanager-log4j-1.0.0.CR3.jar
|
56
|
-
- lib/log4j-1.2.14.jar
|
57
|
-
- lib/jboss-common-core-2.2.17.GA.jar
|
58
53
|
- lib/gem_hook.rb
|
59
54
|
- lib/org.torquebox.vfs.rb
|
60
55
|
- lib/vfs.rb
|
@@ -71,20 +66,24 @@ files:
|
|
71
66
|
- lib/torquebox/vfs/ext/jdbc.rb
|
72
67
|
- lib/torquebox/vfs/ext/kernel.rb
|
73
68
|
- lib/torquebox/vfs/ext/pathname.rb
|
69
|
+
- lib/torquebox/vfs/ext/process.rb
|
74
70
|
- lib/torquebox/vfs/ext/tempfile.rb
|
75
71
|
- lib/torquebox/vfs/ext/vfs.rb
|
76
72
|
- lib/torquebox/vfs/ext/virtual_file.rb
|
77
73
|
- spec/dir_spec.rb
|
78
74
|
- spec/file_spec.rb
|
79
75
|
- spec/file_test_spec.rb
|
76
|
+
- spec/fileutils_spec.rb
|
80
77
|
- spec/io_spec.rb
|
81
78
|
- spec/jdbc_spec.rb
|
79
|
+
- spec/kernel_spec.rb
|
82
80
|
- spec/pathname_spec.rb
|
81
|
+
- spec/process_spec.rb
|
82
|
+
- spec/relatively_requireable.rb
|
83
83
|
- spec/spec_helper.rb
|
84
84
|
- spec/vfs_dir_spec.rb
|
85
85
|
- spec/vfs_spec.rb
|
86
|
-
|
87
|
-
homepage: http://www.torquebox.org/gem-parent/torquebox-vfs/
|
86
|
+
homepage: http://www.torquebox.org/torquebox-gems-parent/torquebox-vfs/
|
88
87
|
licenses:
|
89
88
|
- lgpl
|
90
89
|
post_install_message:
|
@@ -101,13 +100,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
101
|
none: false
|
103
102
|
requirements:
|
104
|
-
- - "
|
103
|
+
- - ">"
|
105
104
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
105
|
+
version: 1.3.1
|
107
106
|
requirements: []
|
108
107
|
|
109
108
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.
|
109
|
+
rubygems_version: 1.8.9
|
111
110
|
signing_key:
|
112
111
|
specification_version: 3
|
113
112
|
summary: TorqueBox VFS
|
@@ -115,8 +114,11 @@ test_files:
|
|
115
114
|
- spec/dir_spec.rb
|
116
115
|
- spec/file_spec.rb
|
117
116
|
- spec/file_test_spec.rb
|
117
|
+
- spec/fileutils_spec.rb
|
118
118
|
- spec/io_spec.rb
|
119
119
|
- spec/jdbc_spec.rb
|
120
|
+
- spec/kernel_spec.rb
|
120
121
|
- spec/pathname_spec.rb
|
122
|
+
- spec/process_spec.rb
|
121
123
|
- spec/vfs_dir_spec.rb
|
122
124
|
- spec/vfs_spec.rb
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/jboss-vfs-3.0.0.GA.jar
DELETED
Binary file
|
data/lib/log4j-1.2.14.jar
DELETED
Binary file
|