1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/tempfile.rb (Tempfile#initialize): now Tempfile.new takes

keyword arguments to open().  [ruby-dev:36756]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-10-18 10:32:26 +00:00
parent fcce99c52d
commit 88aa863274
2 changed files with 17 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Sat Oct 18 04:08:18 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/tempfile.rb (Tempfile#initialize): now Tempfile.new takes
keyword arguments to open(). [ruby-dev:36756]
Tue Oct 14 17:10:10 2008 Martin Duerst <duerst@it.aoyama.ac.jp>
* tool/transcode-tblgen.rb: added set_valid_byte_pattern

View file

@ -29,7 +29,12 @@ class Tempfile < DelegateClass(File)
# Dir::tmpdir provided by 'tmpdir.rb'.
# When $SAFE > 0 and the given tmpdir is tainted, it uses
# /tmp. (Note that ENV values are tainted by default)
def initialize(basename, tmpdir=Dir::tmpdir)
def initialize(basename, *rest)
# I wish keyword argument settled soon.
if opts = Hash.try_convert(rest[-1])
rest.pop
end
tmpdir = rest[0] || Dir::tmpdir
if $SAFE > 0 and tmpdir.tainted?
tmpdir = '/tmp'
end
@ -56,7 +61,12 @@ class Tempfile < DelegateClass(File)
@clean_proc = Tempfile.callback(@data)
ObjectSpace.define_finalizer(self, @clean_proc)
@tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
if opts.nil?
opts = []
else
opts = [opts]
end
@tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600, *opts)
@tmpname = tmpname
@@cleanlist << @tmpname
@data[1] = @tmpfile