summaryrefslogtreecommitdiff
path: root/lib/rubygems/source.rb
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/source.rb44
1 files changed, 35 insertions, 9 deletions
@@ -1,13 +1,30 @@
require 'uri'
require 'fileutils'
class Gem::Source
- FILES = {
:released => 'specs',
:latest => 'latest_specs',
:prerelease => 'prerelease_specs',
}
def initialize(uri)
unless uri.kind_of? URI
uri = URI.parse(uri.to_s)
@@ -17,13 +34,17 @@ class Gem::Source
@api_uri = nil
end
- attr_reader :uri
- def api_uri
require 'rubygems/remote_fetcher'
@api_uri ||= Gem::RemoteFetcher.fetcher.api_endpoint uri
end
def <=>(other)
case other
when Gem::Source::Installed,
@@ -46,13 +67,11 @@ class Gem::Source
end
end
- include Comparable
-
- def ==(other)
self.class === other and @uri == other.uri
end
- alias_method :eql?, :==
##
# Returns a Set that can fetch specifications from this source.
@@ -70,7 +89,7 @@ class Gem::Source
end
end
- def hash
@uri.hash
end
@@ -83,6 +102,9 @@ class Gem::Source
File.join Gem.spec_cache_dir, "#{uri.host}%#{uri.port}", File.dirname(escaped_path)
end
def update_cache?
@update_cache ||=
begin
@@ -166,6 +188,10 @@ class Gem::Source
end
end
def download(spec, dir=Dir.pwd)
fetcher = Gem::RemoteFetcher.fetcher
fetcher.download spec, api_uri.to_s, dir
@@ -176,7 +202,7 @@ class Gem::Source
q.breakable
q.text @uri.to_s
if api = api_uri
- g.text api
end
end
end