lib/bundler/source/rubygems.rb in bundler-1.6.1 vs lib/bundler/source/rubygems.rb in bundler-1.6.2
- old
+ new
@@ -15,13 +15,11 @@
@remotes = (options["remotes"] || []).map { |r| normalize_uri(r) }
@fetchers = {}
@dependency_names = []
@allow_remote = false
@allow_cached = false
-
- @caches = [ Bundler.app_cache ] +
- Bundler.rubygems.gem_path.map{|p| File.expand_path("#{p}/cache") }
+ @caches = [Bundler.app_cache, *Bundler.rubygems.gem_cache]
end
def remote!
@allow_remote = true
end
@@ -70,12 +68,11 @@
return ["Using #{version_message(spec)}", nil] if installed_specs[spec].any?
# Download the gem to get the spec, because some specs that are returned
# by rubygems.org are broken and wrong.
if spec.source_uri
- path = Fetcher.download_gem_from_uri(spec, spec.source_uri)
- s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
+ s = Bundler.rubygems.spec_from_gem(fetch_gem(spec), Bundler.settings["trust-policy"])
spec.__swap__(s)
end
path = cached_gem(spec)
if Bundler.requires_sudo?
@@ -126,15 +123,16 @@
FileUtils.remove_entry_secure(install_path)
end
end
def cache(spec, custom_path = nil)
- # Gems bundled with Ruby don't have .gem files cached locally, but it doesn't matter
- # since they're always going to be installed on this Ruby version.
- return if builtin_gem?(spec)
-
- cached_path = cached_gem(spec)
+ if builtin_gem?(spec)
+ remote_spec = remote_specs.search(spec).first
+ cached_path = fetch_gem(remote_spec)
+ else
+ cached_path = cached_gem(spec)
+ end
raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
return if File.dirname(cached_path) == Bundler.app_cache.to_s
Bundler.ui.info " * #{File.basename(cached_path)}"
FileUtils.cp(cached_path, Bundler.app_cache(custom_path))
end
@@ -289,15 +287,20 @@
ensure
Bundler.rubygems.sources = old
end
end
+ def fetch_gem(spec)
+ return false unless spec.source_uri
+ Fetcher.download_gem_from_uri(spec, spec.source_uri)
+ end
+
def builtin_gem?(spec)
- # Ruby 2.1-style
+ # Ruby 2.1, where all included gems have this summary
return true if spec.summary =~ /is bundled with Ruby/
- # Ruby 2.0 style
- spec.loaded_from.include?("specifications/default/")
+ # Ruby 2.0, where gemspecs are stored in specifications/default/
+ spec.loaded_from && spec.loaded_from.include?("specifications/default/")
end
end
end
end