summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-08-12 22:45:45 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-06-06 10:52:57 +0900
commit79e8d91410d85509b554b0885f5bde6899c4b2da (patch)
treea1e1b4bdb7d3dafa7a96c5f74be16de12b3174e1 /lib
parent03246719ccb2a9c042487b59b31bcac8c30bbff1 (diff)
[rubygems/rubygems] Delay cache access in `LockfileParser`
It's the only part that needs "root folder resultion" to figure out the folder for the cache, but it's only needed for some things, so run that logic lazily when needed. https://github.com/rubygems/rubygems/commit/c7b9eae0bc
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/source/rubygems.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index a8d2e26324..af82ca6b6c 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -10,7 +10,7 @@ module Bundler
# Ask for X gems per API request
API_REQUEST_SIZE = 50
- attr_reader :remotes, :caches
+ attr_reader :remotes
def initialize(options = {})
@options = options
@@ -19,11 +19,14 @@ module Bundler
@allow_remote = false
@allow_cached = false
@allow_local = options["allow_local"] || false
- @caches = [cache_path, *Bundler.rubygems.gem_cache]
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
end
+ def caches
+ @caches ||= [cache_path, *Bundler.rubygems.gem_cache]
+ end
+
def local_only!
@specs = nil
@allow_local = true
@@ -324,9 +327,9 @@ module Bundler
def cached_path(spec)
global_cache_path = download_cache_path(spec)
- @caches << global_cache_path if global_cache_path
+ caches << global_cache_path if global_cache_path
- possibilities = @caches.map {|p| package_path(p, spec) }
+ possibilities = caches.map {|p| package_path(p, spec) }
possibilities.find {|p| File.exist?(p) }
end