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

ruby-changes:70960

From: David <ko1@a...>
Date: Thu, 20 Jan 2022 06:45:51 +0900 (JST)
Subject: [ruby-changes:70960] 2b7025e680 (master): [rubygems/rubygems] Rename `Gem.open_with_flock` to `Gem.open_file`

https://git.ruby-lang.org/ruby.git/commit/?id=2b7025e680

From 2b7025e680eb29f936538c07f057f590003e45bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Tue, 11 Jan 2022 20:11:20 +0100
Subject: [rubygems/rubygems] Rename `Gem.open_with_flock` to `Gem.open_file`

Since it only uses `flock` on Windows.

https://github.com/rubygems/rubygems/commit/b877de4d9c
---
 lib/rubygems.rb                    | 10 +++++-----
 lib/rubygems/specification.rb      |  2 +-
 lib/rubygems/stub_specification.rb |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 22781260206..958d941d70f 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -759,11 +759,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L759
   # Safely read a file in binary mode on all platforms.
 
   def self.read_binary(path)
-    open_with_flock(path, 'rb+') do |io|
+    open_file(path, 'rb+') do |io|
       io.read
     end
   rescue Errno::EACCES, Errno::EROFS
-    open_with_flock(path, 'rb') do |io|
+    open_file(path, 'rb') do |io|
       io.read
     end
   end
@@ -771,15 +771,15 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L771
   ##
   # Safely write a file in binary mode on all platforms.
   def self.write_binary(path, data)
-    open_with_flock(path, 'wb') do |io|
+    open_file(path, 'wb') do |io|
       io.write data
     end
   end
 
   ##
-  # Open a file with given flags, and protect access with flock
+  # Open a file with given flags, and on Windows protect access with flock
 
-  def self.open_with_flock(path, flags, &block)
+  def self.open_file(path, flags, &block)
     File.open(path, flags) do |io|
       if !java_platform? && win_platform?
         begin
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 06e50244a7b..43ab917d191 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1115,7 +1115,7 @@ class Gem::Specification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1115
     file = file.dup.tap(&Gem::UNTAINT)
     return unless File.file?(file)
 
-    code = Gem.open_with_flock(file, 'r:UTF-8:-', &:read)
+    code = Gem.open_file(file, 'r:UTF-8:-', &:read)
 
     code.tap(&Gem::UNTAINT)
 
diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index 1f2dbbc2e2e..b1dd7397ae6 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -110,7 +110,7 @@ class Gem::StubSpecification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/stub_specification.rb#L110
       begin
         saved_lineno = $.
 
-        Gem.open_with_flock loaded_from, OPEN_MODE do |file|
+        Gem.open_file loaded_from, OPEN_MODE do |file|
           begin
             file.readline # discard encoding line
             stubline = file.readline.chomp
-- 
cgit v1.2.1


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

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