fspath 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/fspath.gemspec +1 -1
- data/lib/fspath.rb +8 -2
- data/spec/fspath_spec.rb +24 -35
- metadata +5 -6
- data/VERSION +0 -1
data/fspath.gemspec
CHANGED
data/lib/fspath.rb
CHANGED
@@ -4,8 +4,14 @@ require 'tmpdir'
|
|
4
4
|
|
5
5
|
class FSPath < Pathname
|
6
6
|
class Tempfile < ::Tempfile
|
7
|
+
def initialize(path_klass, *args)
|
8
|
+
raise ArgumentError.new("#{path_klass.inspect} is not a class") unless path_klass.is_a?(Class)
|
9
|
+
@path_klass = path_klass
|
10
|
+
super(*args)
|
11
|
+
end
|
12
|
+
|
7
13
|
def path
|
8
|
-
|
14
|
+
@path_klass.new(super)
|
9
15
|
end
|
10
16
|
end
|
11
17
|
|
@@ -26,7 +32,7 @@ class FSPath < Pathname
|
|
26
32
|
# Returns or yields temp file created by Tempfile.new with path returning FSPath
|
27
33
|
def temp_file(*args, &block)
|
28
34
|
args = %w[f] if args.empty?
|
29
|
-
Tempfile.open(*args, &block)
|
35
|
+
Tempfile.open(self, *args, &block)
|
30
36
|
end
|
31
37
|
|
32
38
|
# Returns or yields path as FSPath of temp file created by Tempfile.new
|
data/spec/fspath_spec.rb
CHANGED
@@ -2,6 +2,9 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
require 'fspath'
|
3
3
|
|
4
4
|
describe FSPath do
|
5
|
+
class ZPath < FSPath
|
6
|
+
end
|
7
|
+
|
5
8
|
it "should inherit from Pathname" do
|
6
9
|
FSPath.new('.').should be_kind_of(Pathname)
|
7
10
|
end
|
@@ -34,45 +37,31 @@ describe FSPath do
|
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
FSPath::Tempfile.stub!(:open).and_return(@file)
|
44
|
-
|
45
|
-
FSPath.temp_file.should == @file
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should yield instance of FSPath::Tempfile" do
|
49
|
-
FSPath::Tempfile.stub!(:open).and_yield(@file)
|
50
|
-
|
51
|
-
yielded = nil
|
52
|
-
FSPath.temp_file{ |y| yielded = y }
|
53
|
-
yielded.should == @file
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "temp_file_path" do
|
58
|
-
before do
|
59
|
-
@path = mock(:path)
|
60
|
-
@file = mock(:file)
|
61
|
-
@file.stub!(:path).and_return(@path)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should return FSPath with temporary path" do
|
65
|
-
FSPath::Tempfile.stub!(:new).and_return(@file)
|
40
|
+
[FSPath, ZPath].each do |klass|
|
41
|
+
describe "#{klass}.temp_file" do
|
42
|
+
it "should return Tempfile with path returning instance of #{klass}" do
|
43
|
+
klass.temp_file.should be_kind_of(Tempfile)
|
44
|
+
klass.temp_file.path.should be_kind_of(klass)
|
45
|
+
end
|
66
46
|
|
67
|
-
|
47
|
+
it "should yield Tempfile with path returning instance of #{klass}" do
|
48
|
+
yielded = nil
|
49
|
+
klass.temp_file{ |y| yielded = y }
|
50
|
+
yielded.should be_kind_of(Tempfile)
|
51
|
+
yielded.path.should be_kind_of(klass)
|
52
|
+
end
|
68
53
|
end
|
69
54
|
|
70
|
-
|
71
|
-
|
55
|
+
describe "#{klass}.temp_file_path" do
|
56
|
+
it "should return #{klass} with temporary path" do
|
57
|
+
klass.temp_file_path.should be_kind_of(klass)
|
58
|
+
end
|
72
59
|
|
73
|
-
|
74
|
-
|
75
|
-
|
60
|
+
it "should yield #{klass} with temporary path" do
|
61
|
+
yielded = nil
|
62
|
+
klass.temp_file_path{ |y| yielded = y }
|
63
|
+
yielded.should be_kind_of(klass)
|
64
|
+
end
|
76
65
|
end
|
77
66
|
end
|
78
67
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fspath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 1
|
10
|
+
version: 2.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ivan Kuchin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-07 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
@@ -43,7 +43,6 @@ files:
|
|
43
43
|
- .gitignore
|
44
44
|
- LICENSE.txt
|
45
45
|
- README.markdown
|
46
|
-
- VERSION
|
47
46
|
- fspath.gemspec
|
48
47
|
- lib/fspath.rb
|
49
48
|
- spec/fspath_spec.rb
|
@@ -77,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
76
|
requirements: []
|
78
77
|
|
79
78
|
rubyforge_project: fspath
|
80
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.13
|
81
80
|
signing_key:
|
82
81
|
specification_version: 3
|
83
82
|
summary: Better than Pathname
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.2.0
|