forked from rubygems/bundler
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting to refactor the Bundler to get it ready for multiple kinds o…
…f sources
- Loading branch information
Carl Lerche
committed
Jul 30, 2009
1 parent
d14390b
commit 0785b65
Showing
14 changed files
with
138 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
module Bundler | |||
# Represents a source of rubygems. Initially, this is only gem repositories, but | |||
# eventually, this will be git, svn, HTTP | |||
class Source | |||
attr_reader :uri | |||
|
|||
def initialize(uri) | |||
@uri = uri.is_a?(URI) ? uri : URI.parse(uri) | |||
raise ArgumentError, "The source must be an absolute URI" unless @uri.absolute? | |||
end | |||
|
|||
def specs | |||
@specs ||= fetch_specs | |||
end | |||
|
|||
def ==(other) | |||
uri == other.uri | |||
end | |||
|
|||
def to_s | |||
@uri.to_s | |||
end | |||
|
|||
def download(spec, destination) | |||
Bundler.logger.info "Downloading #{spec.full_name}.gem" | |||
Gem::RemoteFetcher.fetcher.download(spec, uri, destination) | |||
end | |||
|
|||
private | |||
|
|||
def fetch_specs | |||
Bundler.logger.info "Updating source: #{to_s}" | |||
|
|||
deflated = Gem::RemoteFetcher.fetcher.fetch_path("#{uri}/Marshal.4.8.Z") | |||
inflated = Gem.inflate deflated | |||
|
|||
index = Marshal.load(inflated) | |||
specs = Hash.new { |h,k| h[k] = {} } | |||
|
|||
index.gems.values.each do |spec| | |||
next unless Gem::Platform.match(spec.platform) | |||
spec.source = self | |||
specs[spec.name][spec.version] = spec | |||
end | |||
|
|||
specs | |||
rescue Gem::RemoteFetcher::FetchError => e | |||
raise ArgumentError, "#{to_s} is not a valid source: #{e.message}" | |||
end | |||
end | |||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.