diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/tempfile.rb | 2 | ||||
-rw-r--r-- | test/test_tempfile.rb | 9 |
3 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Mon Sep 26 14:36:12 2016 Naotoshi Seo <[email protected]> + + * lib/tempfile.rb: provide default basename parameter for + Tempfile.create. [Feature #11965] Patch by Yuki Kurihara + * test/test_tempfile.rb: ditto. + Mon Sep 26 14:10:54 2016 Ary Borenszweig <[email protected]> * string.c (lstrip_offset): add a fast path in the case of single diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 223637f84a..b0ebd0be0e 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -323,7 +323,7 @@ end # ... do something with f ... # end # -def Tempfile.create(basename, tmpdir=nil, mode: 0, **options) +def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options) tmpfile = nil Dir::Tmpname.create(basename, tmpdir, options) do |tmpname, n, opts| mode |= File::RDWR|File::CREAT|File::EXCL diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 8147d93f85..cd2828df37 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -345,5 +345,14 @@ puts Tempfile.new('foo').path f.close if f && !f.closed? File.unlink path if path end + + def test_create_default_basename + path = nil + Tempfile.create {|f| + path = f.path + assert_file.exist?(path) + } + assert_file.not_exist?(path) + end end |