ruby-nuggets 0.3.5.292 → 0.3.6.294

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ruby-nuggets version 0.3.5
5
+ This documentation refers to ruby-nuggets version 0.3.6
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -27,12 +27,13 @@
27
27
 
28
28
  require 'tempfile'
29
29
 
30
- # use enhanced Tempfile#make_tmpname, as of r13631
31
- if RUBY_RELEASE_DATE < '2007-10-05'
32
- class Tempfile
30
+ class Tempfile
33
31
 
32
+ if RUBY_RELEASE_DATE < '2007-10-05'
34
33
  alias_method :_nuggets_original_make_tmpname, :make_tmpname
35
34
 
35
+ # Enhanced Tempfile#make_tmpname, as of r13631 (Ruby version prior to
36
+ # 2007-10-05)
36
37
  def make_tmpname(basename, name)
37
38
  case basename
38
39
  when Array
@@ -43,6 +44,28 @@ if RUBY_RELEASE_DATE < '2007-10-05'
43
44
 
44
45
  "#{prefix}#{Time.now.strftime('%Y%m%d')}-#{$$}-#{rand(0x100000000).to_s(36)}-#{name}#{suffix}"
45
46
  end
47
+ end
48
+
49
+ alias_method :_nuggets_original_open, :open
46
50
 
51
+ # If no block is given, this is a synonym for new().
52
+ #
53
+ # If a block is given, it will be passed tempfile as an argument,
54
+ # and the tempfile will automatically be closed when the block
55
+ # terminates. In this case, open() returns tempfile -- in contrast
56
+ # to the original implementation, which returns nil.
57
+ def self.open(*args)
58
+ tempfile = new(*args)
59
+
60
+ if block_given?
61
+ begin
62
+ yield tempfile
63
+ ensure
64
+ tempfile.close
65
+ end
66
+ end
67
+
68
+ tempfile
47
69
  end
70
+
48
71
  end
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 3
7
- TINY = 5
7
+ TINY = 6
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nuggets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5.292
4
+ version: 0.3.6.294
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille