# File lib/bundler/source/rubygems.rb, line 207defcached_built_in_gem(spec)
cached_path = cached_path(spec)
ifcached_path.nil?remote_spec = remote_specs.search(spec).firstifremote_speccached_path = fetch_gem(remote_spec)
elseBundler.ui.warn"#{spec.full_name} is built in to Ruby, and can't be cached because your Gemfile doesn't have any sources that contain it."endendcached_pathend

# File lib/bundler/source/rubygems.rb, line 257defdouble_check_for(unmet_dependency_names)
returnunless@allow_remotereturnunlessapi_fetchers.any?unmet_dependency_names = unmet_dependency_names.callunlessunmet_dependency_names.nil?ifapi_fetchers.size<=1# can't do this when there are multiple fetchers because then we might not fetch from _all_# of themunmet_dependency_names-=remote_specs.spec_names# avoid re-fetching things we've already gottenendreturnifunmet_dependency_names.empty?endBundler.ui.debug"Double checking for #{unmet_dependency_names || "all specs (due to the size of the request)"} in #{self}"fetch_names(api_fetchers, unmet_dependency_names, specs, false)
end

# File lib/bundler/source/rubygems.rb, line 441defbuiltin_gem?(spec)
# Ruby 2.1, where all included gems have this summaryreturntrueifspec.summary=~/is bundled with Ruby/# Ruby 2.0, where gemspecs are stored in specifications/default/spec.loaded_from&&spec.loaded_from.include?("specifications/default/")
end

# File lib/bundler/source/rubygems.rb, line 385defremote_specs@remote_specs||=Index.builddo|idx|index_fetchers = fetchers-api_fetchers# gather lists from non-api sitesfetch_names(index_fetchers, nil, idx, false)
# because ensuring we have all the gems we need involves downloading# the gemspecs of those gems, if the non-api sites contain more than# about 500 gems, we treat all sites as non-api for speed.allow_api = idx.size<API_REQUEST_LIMIT&&dependency_names.size<API_REQUEST_LIMITBundler.ui.debug"Need to query more than #{API_REQUEST_LIMIT} gems." \
" Downloading full index instead..."unlessallow_apifetch_names(api_fetchers, allow_api&&dependency_names, idx, false)
endend

Private Instance Methods

cache_globally(spec, local_cache_path)click to toggle source

Checks if the requested spec exists in the global cache. If it does not, we create the relevant global cache subdirectory if it does not exist and copy the spec from the local cache to the global cache.

Note that the Source determines the path's subdirectory. We use this subdirectory in the global cache path so that gems with the same name – and possibly different versions – from different sources are saved to their respective subdirectories and do not override one another.