summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-22 13:17:33 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-23 17:18:49 +0900
commitbec069b0cae3934bb2caee3aad7fbf587ab95937 (patch)
treebf83ab29cfb9160c92c696b55cd1375e97e3f9de /lib
parent8a364b8512b84530cadfe9f27557fa0306ad9856 (diff)
[rubygems/rubygems] util/rubocop -A --only Style/MultilineMemoization
https://github.com/rubygems/rubygems/commit/c1f6e4a97b
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7582
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/basic_specification.rb18
-rw-r--r--lib/rubygems/specification.rb10
2 files changed, 13 insertions, 15 deletions
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
index 3c69a5a2fe..ca32ffe87a 100644
--- a/lib/rubygems/basic_specification.rb
+++ b/lib/rubygems/basic_specification.rb
@@ -170,18 +170,14 @@ class Gem::BasicSpecification
def to_fullpath(path)
if activated?
@paths_map ||= {}
- @paths_map[path] ||=
- begin
- fullpath = nil
- suffixes = Gem.suffixes
- if suffixes.find do |suf|
- full_require_paths.find do |dir|
- File.file?(fullpath = "#{dir}/#{path}#{suf}")
- end
- end
- fullpath
- end
+ Gem.suffixes.each do |suf|
+ full_require_paths.each do |dir|
+ fullpath = "#{dir}/#{path}#{suf}"
+ next unless File.file?(fullpath)
+ @paths_map[path] ||= fullpath
end
+ end
+ @paths_map[path]
end
end
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index a66d48fc37..f6590cfada 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1031,9 +1031,10 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_by_path(path)
path = path.dup.freeze
- spec = @@spec_with_requirable_file[path] ||= (stubs.find do |s|
+ spec = @@spec_with_requirable_file[path] ||= stubs.find do |s|
s.contains_requirable_file? path
- end || NOT_FOUND)
+ end || NOT_FOUND
+
spec.to_spec
end
@@ -1050,9 +1051,10 @@ class Gem::Specification < Gem::BasicSpecification
end
def self.find_active_stub_by_path(path)
- stub = @@active_stub_with_requirable_file[path] ||= (stubs.find do |s|
+ stub = @@active_stub_with_requirable_file[path] ||= stubs.find do |s|
s.activated? && s.contains_requirable_file?(path)
- end || NOT_FOUND)
+ end || NOT_FOUND
+
stub.this
end