lib/bundler/source/rubygems.rb in bundler-2.4.13 vs lib/bundler/source/rubygems.rb in bundler-2.4.14

- old
+ new

@@ -8,24 +8,27 @@ autoload :Remote, File.expand_path("rubygems/remote", __dir__) # Ask for X gems per API request API_REQUEST_SIZE = 50 - attr_reader :remotes, :caches + attr_reader :remotes def initialize(options = {}) @options = options @remotes = [] @dependency_names = [] @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 @allow_cached = false @allow_remote = false @@ -322,12 +325,12 @@ end end 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 def package_path(cache_path, spec) "#{cache_path}/#{spec.file_name}"