diff options
author | Andre Arko <andre@arko.net> | 2016-10-07 22:40:25 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2016-10-07 22:40:25 -0700 |
commit | dbec80b26132da62d8cecd9712e34c8e2d3d75ac (patch) | |
tree | 6f57e9f6017495c002e431ed3ba0a9b4c4b6e018 /lib/bundler | |
parent | f16ce5717c9739c4a543d311471dc2e74f4ad5a7 (diff) | |
download | bundler-dbec80b26132da62d8cecd9712e34c8e2d3d75ac.tar.gz |
make lambda an object with explicit attributes
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/fetcher/compact_index.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb index 7d4da7d4a8..b010cebe89 100644 --- a/lib/bundler/fetcher/compact_index.rb +++ b/lib/bundler/fetcher/compact_index.rb @@ -80,6 +80,7 @@ module Bundler def compact_index_client @compact_index_client ||= begin SharedHelpers.filesystem_access(cache_path) do + compact_fetcher = Fetcher.new(downloader, fetch_url, Bundler.ui) CompactIndexClient.new(cache_path, compact_fetcher) end.tap do |client| client.in_parallel = lambda do |inputs, &blk| @@ -106,15 +107,13 @@ module Bundler Bundler.user_cache.join("compact_index", remote.cache_slug) end - def compact_fetcher - lambda do |path, headers| - begin - downloader.fetch(fetch_uri + path, headers) - rescue NetworkDownError => e - raise unless Bundler.feature_flag.allow_offline_install? && headers["If-None-Match"] - Bundler.ui.warn "Using the cached data for the new index because of a network error: #{e}" - Net::HTTPNotModified.new(nil, nil, nil) - end + Fetcher = Struct.new(:downloader, :fetch_uri, :ui) do + def call(path, headers) + downloader.fetch(fetch_uri + path, headers) + rescue NetworkDownError => e + raise unless Bundler.feature_flag.allow_offline_install? && headers["If-None-Match"] + ui.warn "Using the cached data for the new index because of a network error: #{e}" + Net::HTTPNotModified.new(nil, nil, nil) end end end |