torquebox-vfs 1.1-java → 1.1.1-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.1'
3
- MAVEN_VERSION = '1.1'
2
+ VERSION = '1.1.1'
3
+ MAVEN_VERSION = '1.1.1'
4
4
  end
5
5
  begin
6
6
  require 'java'
@@ -43,6 +43,10 @@ module FileTest
43
43
  File.writable?(filename)
44
44
  end
45
45
 
46
+ def size(filename)
47
+ File.size(filename)
48
+ end
49
+
46
50
  end
47
51
 
48
52
  end
@@ -21,7 +21,9 @@ class Java::java.sql::DriverManager
21
21
  alias_method :register_driver_without_vfs, :registerDriver
22
22
 
23
23
  # Monkey patch getConnection so we can sort out local filesystem url's for
24
- # SQLite (we need to remove the 'vfs:' from the url)
24
+ # SQLite (we need to remove the 'vfs:' from the url). This works
25
+ # for activerecord-jdbc-adapter v1.1.2 and under. For v1.1.3 and
26
+ # up, see web/web-core/src/main/java/org/torquebox/rails/core/boot.rb
25
27
  def getConnection(url, *params)
26
28
 
27
29
  # Remove any VFS prefix from the url (for SQLite)
@@ -20,6 +20,7 @@ require 'pathname'
20
20
  class Pathname
21
21
 
22
22
  alias_method :realpath_without_vfs, :realpath
23
+ alias_method :relative_without_vfs, :relative?
23
24
 
24
25
  def realpath
25
26
  vfs_path? ? expand_path : realpath_without_vfs
@@ -28,4 +29,8 @@ class Pathname
28
29
  def vfs_path?
29
30
  @path.to_s =~ /^vfs:/
30
31
  end
32
+
33
+ def relative?
34
+ vfs_path? ? false : relative_without_vfs
35
+ end
31
36
  end
@@ -40,7 +40,7 @@ module TorqueBox
40
40
  end
41
41
 
42
42
  def accepts(file)
43
- matched = !!( file.path_name =~ @regexp )
43
+ matched = !!( @regexp =~ file.path_name.to_s )
44
44
  matched &&= file.directory? if @dirs_only
45
45
  matched
46
46
  end
@@ -71,10 +71,10 @@ module TorqueBox
71
71
  result = double_splat()
72
72
  else
73
73
  if ( cur() == 0 || lb() == '/' )
74
- result = '(?<=/|^)[^.][^/]*'
74
+ result = '((?<=/|^)[^.][^/]*)*'
75
75
  # result = '[^/.][^/]*'
76
76
  else
77
- result = '[^/]+'
77
+ result = '[^/]*'
78
78
  end
79
79
 
80
80
  consume('*')
@@ -87,7 +87,7 @@ module TorqueBox
87
87
  #puts "enter double_splat()"
88
88
  if la(2) == '/'
89
89
  # result = '([^.][^/]+/){0,}'
90
- result = '([^/.][^/]*/){0,}'
90
+ result = '([^/.][^/]*/)*'
91
91
  else
92
92
  result = '([^/.][^/]*)'
93
93
  end
data/spec/dir_spec.rb CHANGED
@@ -248,6 +248,13 @@ describe "Dir extensions for VFS" do
248
248
  items.should include( "#{prefix}/sound of music" )
249
249
  end
250
250
 
251
+ it "should allow for multiple single-star globbing" do
252
+ items = Dir.glob( "#{prefix}/home/**/*file*.txt" )
253
+ items.should_not be_empty
254
+ items.should include( "#{prefix}/home/larry/file1.txt" )
255
+ items.should include( "#{prefix}/home/larry/file2.txt" )
256
+ end
257
+
251
258
  it "should allow globbing of multiple patterns via []" do
252
259
  items = []
253
260
  lambda {
@@ -309,7 +316,7 @@ describe "Dir extensions for VFS" do
309
316
  pwd.should == Dir.pwd
310
317
  end
311
318
 
312
- xit "should work for home dirs" do
319
+ it "should work for home dirs" do
313
320
  pwd = Dir.pwd
314
321
  dir = Dir.chdir { Dir.pwd }
315
322
  dir.downcase.should == ENV['HOME'].downcase
@@ -26,6 +26,10 @@ describe "File extensions for VFS" do
26
26
  delegate_to_file(:writable?, 'file')
27
27
  end
28
28
 
29
+ it "should delegate to File.size" do
30
+ delegate_to_file(:size, 'file')
31
+ end
32
+
29
33
  def delegate_to_file(*args)
30
34
  method = args.shift
31
35
  File.should_receive(method).with(*args).and_return('value')
@@ -16,5 +16,20 @@ describe "Pathname extensions for VFS" do
16
16
  pathname.should_receive(:realpath_without_vfs).and_return(Pathname.new("/real/path"))
17
17
  pathname.realpath.to_s.should == "/real/path"
18
18
  end
19
+
20
+ it "should not find vfs paths to be relative" do
21
+ pathname = Pathname.new("vfs:/tmp/test")
22
+ pathname.relative?.should_not be_true
23
+ end
24
+
25
+ it "should find real relative paths to be relative" do
26
+ pathname = Pathname.new("../tmp/test")
27
+ pathname.relative?.should be_true
28
+ end
29
+
30
+ it "should find real absolute paths to not be relative" do
31
+ pathname = Pathname.new("/tmp/test")
32
+ pathname.relative?.should_not be_true
33
+ end
19
34
  end
20
35
  end
metadata CHANGED
@@ -2,15 +2,15 @@
2
2
  name: torquebox-vfs
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "1.1"
5
+ version: 1.1.1
6
6
  platform: java
7
- authors: ["The TorqueBox Team"]
8
-
7
+ authors:
8
+ - The TorqueBox Team
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-13 00:00:00 -04:00
13
+ date: 2011-08-09 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -37,6 +37,7 @@ dependencies:
37
37
  version_requirements: *id002
38
38
  description: ""
39
39
  email:
40
+ - torquebox-dev@torquebox.org
40
41
  executables: []
41
42
 
42
43
  extensions: []