diff options
author | Carl Lerche <carllerche@mac.com> | 2010-01-26 11:23:36 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-01-26 11:23:51 -0800 |
commit | 152a50a4aff32cc1c10bedd14d9ea822da4f3eef (patch) | |
tree | 196c7b97eaf6f3189084969b89e3ad7b2ddaeb22 /lib/bundler/remote_specification.rb | |
parent | 63e4af6bd86041ef6c7eebebd7670b2b39b20043 (diff) | |
download | bundler-152a50a4aff32cc1c10bedd14d9ea822da4f3eef.tar.gz |
Rename gemfile back to bundler
Diffstat (limited to 'lib/bundler/remote_specification.rb')
-rw-r--r-- | lib/bundler/remote_specification.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb new file mode 100644 index 0000000000..b483f83a06 --- /dev/null +++ b/lib/bundler/remote_specification.rb @@ -0,0 +1,53 @@ +module Bundler + # Represents a lazily loaded gem specification, where the full specification + # is on the source server in rubygems' "quick" index. The proxy object is to + # be seeded with what we're given from the source's abbreviated index - the + # full specification will only be fetched when necesary. + class RemoteSpecification + attr_reader :name, :version, :platform + attr_accessor :source + + def initialize(name, version, platform, source_uri) + @name = name + @version = version + @platform = platform + @source_uri = source_uri + end + + def full_name + if platform == Gem::Platform::RUBY or platform.nil? then + "#{@name}-#{@version}" + else + "#{@name}-#{@version}-#{platform}" + end + end + + # Because Rubyforge cannot be trusted to provide valid specifications + # once the remote gem is donwloaded, the backend specification will + # be swapped out. + def __swap__(spec) + @specification = spec + end + + private + + def _remote_uri + # "#{@source_uri}/quick/Marshal.4.8/#{@name}-#{@version}.gemspec.rz" + tuple = [@name, @version, @platform] + tuple = tuple - [nil, 'ruby', ''] + "#{@source_uri}/quick/Marshal.4.8/#{tuple.join("-")}.gemspec.rz" + end + + def _remote_specification + @specification ||= begin + deflated = Gem::RemoteFetcher.fetcher.fetch_path(_remote_uri) + inflated = Gem.inflate(deflated) + Marshal.load(inflated) + end + end + + def method_missing(method, *args, &blk) + _remote_specification.send(method, *args, &blk) + end + end +end
\ No newline at end of file |