ruby-nuggets 0.3.5.292 → 0.3.6.294
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/README +1 -1
- data/lib/nuggets/tempfile.rb +26 -3
- data/lib/nuggets/version.rb +1 -1
- metadata +1 -1
data/README
CHANGED
data/lib/nuggets/tempfile.rb
CHANGED
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
|
|
28
28
|
require 'tempfile'
|
|
29
29
|
|
|
30
|
-
|
|
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
|
data/lib/nuggets/version.rb
CHANGED