summaryrefslogtreecommitdiff
path: root/lib/tempfile.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-11 21:42:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-11 21:42:40 +0000
commit55179696b20fade5a994d711b6fba9901eeb839d (patch)
tree193d912ab0b810b77d235b58f390501341f3c803 /lib/tempfile.rb
parent9a751c21e7151511762c81e78e5e2a39b30ff33e (diff)
* lib/tempfile.rb (Tempfile#initialize): option hash may not be
given. [ruby-core:26681] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tempfile.rb')
-rwxr-xr-xlib/tempfile.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 7024bd9..b327acb 100755
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -133,11 +133,17 @@ class Tempfile < DelegateClass(File)
create(basename, *rest) do |tmpname, n, opts|
lock = tmpname + '.lock'
- mode = opts.delete(:mode) || 0
- mode = File::RDWR|File::CREAT|File::EXCL|mode
+ mode = File::RDWR|File::CREAT|File::EXCL
+ perm = 0600
+ if opts
+ mode |= opts.delete(:mode) || 0
+ opts[:perm] = perm
+ else
+ opts = perm
+ end
self.class.mkdir(lock)
begin
- @data[1] = @tmpfile = File.open(tmpname, mode, 0600, *opts)
+ @data[1] = @tmpfile = File.open(tmpname, mode, opts)
@data[0] = @tmpname = tmpname
ensure
self.class.rmdir(lock)