fspath 2.0.0 → 2.0.1

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/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /pkg/
2
+ /*.gem
2
3
 
3
4
  /doc/
4
5
  /rdoc/
data/fspath.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'fspath'
5
- s.version = '2.0.0'
5
+ s.version = '2.0.1'
6
6
  s.summary = %q{Better than Pathname}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
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
- FSPath.new(super)
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
- describe "temp_file" do
38
- before do
39
- @file = mock(:file)
40
- end
41
-
42
- it "should return instance of FSPath::Tempfile" do
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
- FSPath.temp_file_path.should == @path
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
- it "should yield FSPath with temporary path" do
71
- FSPath::Tempfile.stub!(:open).and_yield(@file)
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
- yielded = nil
74
- FSPath.temp_file_path{ |y| yielded = y }
75
- yielded.should == @path
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 0
10
- version: 2.0.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: 2011-11-20 00:00:00 Z
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.11
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