summaryrefslogtreecommitdiff
path: root/lib/bundler/fetcher/index.rb
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2015-03-28 05:42:23 -0700
committerAndre Arko <andre@arko.net>2015-03-28 06:10:38 -0700
commitaf9ddf848e6eb8ea817abfda949271a7a0b0c3de (patch)
treeace41b8ebf9e72e3bde9430bc8b50e2c1b111d85 /lib/bundler/fetcher/index.rb
parent1f25cbc0613f3bef4f03932075c45e7f1b9f40a0 (diff)
downloadbundler-af9ddf848e6eb8ea817abfda949271a7a0b0c3de.tar.gz
less FetcherFetcher
Diffstat (limited to 'lib/bundler/fetcher/index.rb')
-rw-r--r--lib/bundler/fetcher/index.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb
new file mode 100644
index 0000000000..f9bd279d0d
--- /dev/null
+++ b/lib/bundler/fetcher/index.rb
@@ -0,0 +1,31 @@
+require 'bundler/fetcher/base'
+
+module Bundler
+ class Fetcher
+ class Index < Base
+ def specs(_gem_names)
+ old_sources = Bundler.rubygems.sources
+ Bundler.rubygems.sources = [remote_uri.to_s]
+ Bundler.rubygems.fetch_all_remote_specs
+ rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError => e
+ case e.message
+ when /certificate verify failed/
+ raise CertificateFailureError.new(display_uri)
+ when /401/
+ raise AuthenticationRequiredError, remote_uri
+ when /403/
+ if remote_uri.userinfo
+ raise BadAuthenticationError, remote_uri
+ else
+ raise AuthenticationRequiredError, remote_uri
+ end
+ else
+ Bundler.ui.trace e
+ raise HTTPError, "Could not fetch specs from #{display_uri}"
+ end
+ ensure
+ Bundler.rubygems.sources = old_sources
+ end
+ end
+ end
+end