Permalink
Browse files

Clarify GemSource#fetch_specs

  • Loading branch information...
1 parent 6fba8ef commit 09c4c681f3151d0d52a28b3751f425f88f89aa1b @jeremy jeremy committed Nov 12, 2009
Showing with 13 additions and 10 deletions.
  1. +13 −10 lib/bundler/source.rb
View
@@ -69,27 +69,30 @@ def download(spec)
def fetch_specs
Bundler.logger.info "Updating source: #{to_s}"
+ build_gem_index(fetch_main_specs + fetch_prerelease_specs)
+ end
- fetcher = Gem::RemoteFetcher.fetcher
- main_index = fetcher.fetch_path("#{uri}/specs.4.8.gz")
- begin
- prerelease_index = fetcher.fetch_path("#{uri}/prerelease_specs.4.8.gz")
- index = Marshal.load(main_index) + Marshal.load(prerelease_index)
- rescue Gem::RemoteFetcher::FetchError
- Bundler.logger.warn "Source '#{uri}' does not support prerelease gems"
- index = Marshal.load(main_index)
- end
-
+ def build_gem_index(index)
gems = Hash.new { |h,k| h[k] = [] }
index.each do |name, version, platform|
spec = RemoteSpecification.new(name, version, platform, @uri)
spec.source = self
gems[spec.name] << spec if Gem::Platform.match(spec.platform)
end
gems
+ end
+
+ def fetch_main_specs
+ Marshal.load(Gem::RemoteFetcher.fetcher.fetch_path("#{uri}/specs.4.8.gz"))
rescue Gem::RemoteFetcher::FetchError => e
raise ArgumentError, "#{to_s} is not a valid source: #{e.message}"
end
+
+ def fetch_prerelease_specs
+ Marshal.load(Gem::RemoteFetcher.fetcher.fetch_path("#{uri}/prerelease_specs.4.8.gz"))
+ rescue Gem::RemoteFetcher::FetchError
+ Bundler.logger.warn "Source '#{uri}' does not support prerelease gems"
+ end
end
class SystemGemSource < Source

0 comments on commit 09c4c68

Please sign in to comment.