[前][次][番号順一覧][スレッド一覧]

ruby-changes:44178

From: sonots <ko1@a...>
Date: Mon, 26 Sep 2016 14:45:34 +0900 (JST)
Subject: [ruby-changes:44178] sonots:r56251 (trunk): * lib/tempfile.rb: provide default basename parameter

sonots	2016-09-26 14:45:29 +0900 (Mon, 26 Sep 2016)

  New Revision: 56251

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56251

  Log:
    * lib/tempfile.rb: provide default basename parameter
      for Tempfile.create. [Feature #11965] Patch by Yuki Kurihara
    * test/test_tempfile.rb: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/tempfile.rb
    trunk/test/test_tempfile.rb
Index: lib/tempfile.rb
===================================================================
--- lib/tempfile.rb	(revision 56250)
+++ lib/tempfile.rb	(revision 56251)
@@ -323,7 +323,7 @@ end https://github.com/ruby/ruby/blob/trunk/lib/tempfile.rb#L323
 #      ... 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
Index: test/test_tempfile.rb
===================================================================
--- test/test_tempfile.rb	(revision 56250)
+++ test/test_tempfile.rb	(revision 56251)
@@ -345,5 +345,14 @@ puts Tempfile.new('foo').path https://github.com/ruby/ruby/blob/trunk/test/test_tempfile.rb#L345
     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
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56250)
+++ ChangeLog	(revision 56251)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Sep 26 14:36:12 2016  Naotoshi Seo  <sonots@g...>
+
+	* 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  <ary@e...>
 
 	* string.c (lstrip_offset): add a fast path in the case of single

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]