diff options
author | Andre Arko <andre@arko.net> | 2013-10-05 19:21:06 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2013-10-05 19:21:57 -0700 |
commit | eb1e229f4952049ff7fe5558c8db76543baa8190 (patch) | |
tree | f496f01f0469f23839f1e84f97ce3b31b3aa94a2 | |
parent | 808604be94e8853659372147725f1e27e8681f3c (diff) | |
download | bundler-eb1e229f4952049ff7fe5558c8db76543baa8190.tar.gz |
add MarshalledSpecs fetcher for full index
-rw-r--r-- | lib/bundler.rb | 1 | ||||
-rw-r--r-- | lib/bundler/marshalled_specs.rb | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 983ba542d1..64838ff647 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -31,6 +31,7 @@ module Bundler autoload :Injector, 'bundler/injector' autoload :LazySpecification, 'bundler/lazy_specification' autoload :LockfileParser, 'bundler/lockfile_parser' + autoload :MarshalledSpecs, 'bundler/mashalled_specs' autoload :MatchPlatform, 'bundler/match_platform' autoload :RemoteSpecification, 'bundler/remote_specification' autoload :Resolver, 'bundler/resolver' diff --git a/lib/bundler/marshalled_specs.rb b/lib/bundler/marshalled_specs.rb new file mode 100644 index 0000000000..1c00260bb8 --- /dev/null +++ b/lib/bundler/marshalled_specs.rb @@ -0,0 +1,49 @@ +require 'bundler/rubygems_integration' + +module Bundler + class MarshalledSpecs + + def initialize(source, remote_uri, fetcher) + @source, @remote_uri = source, remote_uri + @fetcher = fetcher + end + + def specs_index + @specs_index ||= generate_index + end + alias_method :specs, :specs_index + + private + + def generate_index + Index.build do |index| + fetch_all_remote_specs.each do |name, version, platform| + next if name == 'bundler' + spec = RemoteSpecification.new(name, version, platform, @fetcher) + spec.source = @source + spec.source_uri = @remote_uri + index << spec + end + end + end + + # fetch from modern index: specs.4.8.gz + def fetch_all_remote_specs + old_sources = Bundler.rubygems.sources + Bundler.rubygems.sources = ["#{@remote_uri}"] + Bundler::Retry.new("source fetch").attempts do + Bundler.rubygems.fetch_all_remote_specs[@remote_uri] + end + rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError => e + if e.message.match("certificate verify failed") + raise Fetcher::CertificateFailureError.new(uri) + else + Bundler.ui.trace e + raise HTTPError, "Could not fetch specs from #{uri}" + end + ensure + Bundler.rubygems.sources = old_sources + end + + end +end
\ No newline at end of file |