Граф коммитов

116 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 3d40f11564 [ruby/tempfile] [DOC] Missing documents
https://github.com/ruby/tempfile/commit/6932d6bc6f
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA f19de1289b [ruby/tempfile] Bump up 0.2.1
https://github.com/ruby/tempfile/commit/1450bb4f1c
2023-12-05 07:02:17 +00:00
Akshay Birajdar 494e2e4bfb [ruby/tempfile] Alias #to_s to #inspect
https://github.com/ruby/tempfile/commit/e515889412
2023-12-05 06:43:42 +00:00
Jeremy Evans ddd99a5290 [ruby/tempfile] Make Tempfile#open return the underlying File
Add test for this behavior.

https://github.com/ruby/tempfile/commit/0ca31a6b8d
2023-11-08 16:47:29 +00:00
git 32e89b7f9c * remove trailing spaces. [ci skip] 2023-11-08 15:20:01 +00:00
Jeremy Evans ddcfc9feab [ruby/tempfile] Fix Tempfile#{dup,clone}
Instead of storing the delegate in @tmpfile, use __getobj__, since
delegate library already handles dup/clone for that.  Copy the
unlinked, mode, and opts instance variables to the returned object
when using dup/clone.

Split the close/unlink finalizer into two finalizers. The close
finalizer always closes when any Tempfile instance is GCed, since
each Tempfile instance uses a separate file descriptor. The unlink
finalizer unlinks only when the original and all duped/cloned
Tempfiles are GCed, since all share the same path.

For Tempfile#open, undefine the close finalizer after closing the
current file, the redefine the close finalizer with the new file.

Fixes [Bug #19441]

https://github.com/ruby/tempfile/commit/dafabf9c7b
2023-11-08 15:19:52 +00:00
Hiroshi SHIBATA 0c55886fc2 [ruby/tempfile] Bump up 0.2.0
https://github.com/ruby/tempfile/commit/d6ddf7881e
2023-11-07 12:54:09 +09:00
Hiroshi SHIBATA 8b924ebdf2 [ruby/tempfile] Expose Tempfile::VERSION
https://github.com/ruby/tempfile/commit/6aa1f37dc4
2023-04-13 09:49:14 +00:00
Sven Schwyn cc8329e8bc [ruby/tempfile] Fix inconsistency in doc of Tempfile.create
https://github.com/ruby/tempfile/commit/3f96b2ed29
2023-02-27 02:29:06 +00:00
Nobuyoshi Nakada 3539da64fc
[DOC] Replace the external URIs to docs with rdoc-ref 2022-10-12 12:27:40 +09:00
Burdette Lamar 589f1c1d55
[ruby/tempfile] Enhanced RDoc for ::new and ::create (https://github.com/ruby/tempfile/pull/10)
https://github.com/ruby/tempfile/commit/a5e53aa82a
2022-05-20 17:49:14 +09:00
Stan Lo fe7aaa94b4 Small grammar fixes 2021-09-01 09:15:57 +09:00
Benoit Daloze 7d8b43d2ed [ruby/tempfile] Improve the documentation for Tempfile.create and recommend Tempfile.open instead
https://github.com/ruby/tempfile/commit/8bac025065
2020-10-05 19:17:25 +02:00
Jeremy Evans 6997109fca [ruby/tempfile] Revert Tempfile.open unlinking the file
Document difference in behavior between Tempfile.open and
Tempfile.create.

https://github.com/ruby/tempfile/commit/426d6f887f
2020-09-09 20:15:41 +09:00
Benoit Daloze fa21985a7a Sync with ruby/tempfile@aa9ea12d94 2020-08-29 12:05:48 +02:00
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
Jeremy Evans 80b5a0ff2a
Make rb_scan_args handle keywords more similar to Ruby methods (#2460)
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.

This makes the following changes to : handling.

* Treats as **kw, prompting keyword argument separation warnings
  if called with a positional hash.

* Do not look for an option hash if empty keywords are provided.
  For backwards compatibility, treat an empty keyword splat as a empty
  mandatory positional hash argument, but emit a a warning, as this
  behavior will be removed in Ruby 3.  The argument number check
  needs to be moved lower so it can correctly handle an empty
  positional argument being added.

* If the last argument is nil and it is necessary to treat it as an option
  hash in order to make sure all arguments are processed, continue to
  treat the last argument as the option hash. Emit a warning in this case,
  as this behavior will be removed in Ruby 3.

* If splitting the keyword hash into two hashes, issue a warning, as we
  will not be splitting hashes in Ruby 3.

* If the keyword argument is required to fill a mandatory positional
  argument, continue to do so, but emit a warning as this behavior will
  be going away in Ruby 3.

* If keyword arguments are provided and the last argument is not a hash,
  that indicates something wrong. This can happen if a cfunc is calling
  rb_scan_args multiple times, and providing arguments that were not
  passed to it from Ruby.  Callers need to switch to the new
  rb_scan_args_kw function, which allows passing of whether keywords
  were provided.

This commit fixes all warnings caused by the changes above.

It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used.  If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.

In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby.  The last argument may or may not be a hash,
so we can't set keyword argument mode.  However, if it is a
hash, we don't want to warn when treating it as keywords.

In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args.  Also, make
sure not to pass nil in place of an option hash.

Work around Kernel#warn warnings due to problems in the Rubygems
override of the method.  There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.

Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.
2019-09-25 11:18:49 -07:00
Jeremy Evans 434582d888 Fix Tempfile.open to correctly pass keywords to Tempfile.new 2019-09-06 19:41:23 -07:00
Jeremy Evans d08e1004e0 Fix keyword argument separation issues in lib
Mostly requires adding ** in either calls or method definitions.
2019-08-30 12:39:31 -07:00
Kazuhiro NISHIYAMA e44c9b1147
Try to avoid `not delagated` error
```
.../ruby/lib/delegate.rb:405:in `__getobj__': not delegated (ArgumentError)
```
https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian9/ruby-master/log/20190703T063006Z.fail.html.gz
2019-07-03 19:29:12 +09:00
nobu 13fd78c2e1 Enhance Tempfile docs [ci skip]
[ruby-core:90525] [Bug #15411]

From: zverok (Victor Shepelev) <zverok.offline@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-16 12:09:08 +00:00
nobu d11525728f No document of Tempfile::Remover [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-14 03:36:13 +00:00
shyouhei f2a91397fd Add uplevel keyword to Kernel#warn and use it
If uplevel keyword is given, the warning message is prepended
with caller file and line information and the string "warning: ".
The use of the uplevel keyword makes Kernel#warn format output
similar to how rb_warn formats output.

This patch modifies net/ftp and net/imap to use Kernel#warn
instead of $stderr.puts or $stderr.printf, since they are used
for printing warnings.

This makes lib/cgi/core and tempfile use $stderr.puts instead of
warn for debug logging, since they are used for debug printing
and not for warning.

This does not modify bundler, rubygems, or rdoc, as those are
maintained outside of ruby and probably wish to remain backwards
compatible with older ruby versions.

rb_warn_m code is originally from nobu, but I've changed it
so that it only includes the path and lineno from uplevel
(not the method), and also prepends the string "warning: ",
to make it more similar to rb_warn.

From: Jeremy Evans code@jeremyevans.net
Signed-off-by: Urabe Shyouhei shyouhei@ruby-lang.org


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:56:25 +00:00
nobu 593d978646 tempfile.rb: [DOC] all arguments [ci skip]
* lib/tempfile.rb (Tempfile.create): mention the other arguments
  too.  [ruby-core:83321] [Misc #14019]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-17 12:40:00 +00:00
nobu 6b4cd8a996 Layout fixes in rdoc of lib/tempfile.rb [ci skip]
RDoc doesn't understand an asterisk inside the plus markers. Moving them
out of the markers looks better.
[Fix GH-1716]

From:    Herwin Weststrate <herwinw@herwinw.nl>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-16 23:11:40 +00:00
nobu a6df192ded tempfile.rb: do not call File.identical? on closed stream
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19 09:36:34 +00:00
nobu 3c5344bf30 tempfile.rb: remove in Tempfile.create
* lib/tempfile.rb (Tempfile.create): should not fail even if the
  temporary file has been removed in the block, just ignore.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19 09:20:14 +00:00
glass 279d31f11d Fix bug of Tempfile#size if nothing is written [Bug #13198]
* lib/tempfile.rb (Tempfile#size): Fix its behavior when nothing
  is written. Tempfile#size should return 0 in this case.
  The patch is from nobu <nobu@ruby-lang.org>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14 12:53:32 +00:00
kazu 562bbdf995 lib/tempfile.rb: Specify frozen_string_literal: true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-21 12:21:05 +00:00
normal f845a9ef76 lib/*: remove closed checks
Follow r56795.  Since Ruby 2.2, calling #close on a closed
socket no longer raises exceptions.

* lib/cgi/session.rb (update): remove closed? check
* lib/net/http.rb (finish, transport_request): ditto
* lib/net/imap.rb (disconnect): ditto
* lib/net/pop.rb (do_start, do_finish): ditto
* lib/net/smtp.rb (do_start, do_finish): ditto
* lib/open3.rb (popen_run, pipeline_run): ditto
* lib/pstore.rb (transaction): ditto
* lib/shell/process-controller.rb (sfork):
* lib/tempfile (_close, call, Tempfile.create): ditto
* lib/webrick/httpauth/htdigest.rb (flush): ditto
* lib/webrick/httpauth/htpasswd.rb (flush): ditto
* lib/webrick/server.rb (start_thread, cleanup_shutdown_pipe): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-21 23:05:41 +00:00
sonots 64f53f0dbf * lib/tempfile.rb: provide default basename parameter
for Tempfile.create. [Feature #11965] Patch by Yuki Kurihara
* test/test_tempfile.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-26 05:45:29 +00:00
nobu 75687e0aff Fix doc with default value with GH-523
* lib/tempfile.rb (Tempfile#initialize): [DOC] the first parameter
  `basename` is optional and defaulted to an empty string since
  [GH-523].  [Fix GH-1225]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-27 07:35:34 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
hsbt 654b90d31a * lib/tempfile.rb: Fix typo. [fix GH-933] Patch by @Zorbash
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-13 02:40:38 +00:00
usa cc09968d71 * lib/tempfile.rb (Remover#call): fixed wrong condition introduced at
r50682.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 09:05:50 +00:00
usa c1f355d91f * lib/tempfile.rb (Tempfile#initialize): initialize @unlinked to fix
test failures introduced at r50682.  I hope that check the results of
  tests before committing, at least the tests about the changed feature.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 07:01:29 +00:00
glass 354c9747e4 * lib/tempfile.rb: refactoring.
* use warn instead of STDERR.print
  * remove @tmpname and use @tmpfile.path
  * introduce @unlinked flag
  * Remover takes only @tmpfile
  * mode will be modified just before file reopen

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 01:29:48 +00:00
hsbt 05c108cdba * lib/tempfile.rb: provide default basename parameter.
[fix GH-523] Patch by @dissolved
* test/test_tempfile.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-04 00:18:38 +00:00
nobu a718be06fa tempfile.rb: fix r47655
* lib/tempfile.rb (Tempfile#initialize, Tempfile.create): get rid of
  shadowing local variables.

* lib/tmpdir.rb (Dir::Tmpname#make_tmpname): simlify argument
  splitting.

* test/test_tempfile.rb: need thread library for ConditionVariable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 01:40:21 +00:00
glass 09e91be9ab * lib/tempfile.rb: define parameters appropriately and some
refactoring.

* lib/tmpdir.rb:   ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20 17:35:06 +00:00
glass c4ad649e07 * lib/tempfile.rb: remove "require 'thread'". its features are no
longer used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-27 14:36:25 +00:00
nobu 84ae5332e5 lib/tempfile.rb: include doc of Tempfile.open
* lib/tempfile.rb: start rdoc parsing inside singleton class
  definition to include the document there.
  [ruby-core:64157] [Bug #10105]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-11 02:26:36 +00:00
hsbt a7f672a17e * lib/tempfile.rb: split executable code into sample directory.
* sample/tempfile.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-23 19:44:23 +00:00
akr 592c6ba3b3 * lib/tempfile.rb (Tempfile#inspect): Show "(closed)" if the tempfile
is closed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 16:03:35 +00:00
nobu 2958ecae67 tempfile.rb: get rid of warnings
* lib/tempfile.rb (Tempfile#initialize): use class method to get rid
  of warnings when $VERBOSE.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 09:28:43 +00:00
nobu ec2db8decf tempfile.rb: undefine finalizer on unlink
* lib/tempfile.rb (Tempfile#unlink): finalizer is no longer needed
  after unlinking.  patched by by normalperson (Eric Wong) at
  [ruby-core:56521] [Bug #8768]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-01 13:03:58 +00:00
zzak caca17a898 * lib/tempfile.rb: nodoc Tempfile#inspect
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 23:03:25 +00:00
akr 65261bda4d * lib/tempfile.rb (Tempfile.create): Close when the block exits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-20 15:16:24 +00:00
akr 5388fb64d9 * lib/tempfile.rb (Tempfile.create): New method.
The method name is proposed by Shugo Maeda.  [ruby-dev:47220]
  [ruby-core:41478] [Feature #5707]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-20 13:50:47 +00:00
glass 31f72cf518 * lib/tempfile.rb: fix confusing inspect.
previous Tempfile#inspect says it is a File, but actually
  it is not a File.

    t = Tempfile.new("foo") #=> #<File:/tmp/foo20121106-31970-1ffbum0>
    t.is_a? File #=> false

  now Tempfile#inspect returns like:

    t = Tempfile.new("foo")
    #=> #<Tempfile:/tmp/foo20121106-31970-1ffbum0>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 08:06:21 +00:00