fspath 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
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.1'
5
+ s.version = '2.0.2'
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
@@ -36,13 +36,17 @@ class FSPath < Pathname
36
36
  end
37
37
 
38
38
  # Returns or yields path as FSPath of temp file created by Tempfile.new
39
+ # WARNING: loosing reference to returned object will remove file on nearest GC run
39
40
  def temp_file_path(*args)
40
41
  if block_given?
41
42
  temp_file(*args) do |file|
42
43
  yield file.path
43
44
  end
44
45
  else
45
- temp_file(*args).path
46
+ file = temp_file(*args)
47
+ path = file.path
48
+ path.instance_variable_set(:@__temp_file, file)
49
+ path
46
50
  end
47
51
  end
48
52
 
data/spec/fspath_spec.rb CHANGED
@@ -57,6 +57,13 @@ describe FSPath do
57
57
  klass.temp_file_path.should be_kind_of(klass)
58
58
  end
59
59
 
60
+ it "should not allow GC to finalize TempFile" do
61
+ paths = Array.new(100){ FSPath.temp_file_path }
62
+ paths.should be_all(&:exist?)
63
+ GC.start
64
+ paths.should be_all(&:exist?)
65
+ end
66
+
60
67
  it "should yield #{klass} with temporary path" do
61
68
  yielded = nil
62
69
  klass.temp_file_path{ |y| yielded = y }
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: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 1
10
- version: 2.0.1
9
+ - 2
10
+ version: 2.0.2
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: 2012-01-07 00:00:00 Z
18
+ date: 2012-01-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec