diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-21 23:27:30 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-21 23:27:30 +0000 |
commit | 5307d803f5cce7b14a6afd1d51f6d53ec85ca87d (patch) | |
tree | aac2997a9ff000fbf2f1f9f27077bb7b2403f2c9 /lib/rubygems/source.rb | |
parent | b1529a30e08040b717adef8ac1fa8be1c060e7e1 (diff) | |
download | ruby-5307d803f5cce7b14a6afd1d51f6d53ec85ca87d.tar.gz |
* lib/rubygems: Update to RubyGems master 50a8210. Important changes
in this commit:
RubyGems now automatically checks for gem.deps.rb or Gemfile when
running ruby executables. This behavior is similar to `bundle exec
rake`. This change may be reverted before Ruby 2.1.0 if too many bugs
are found.
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/source.rb')
-rw-r--r-- | lib/rubygems/source.rb | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb index a40a27594b..b6e2d97523 100644 --- a/lib/rubygems/source.rb +++ b/lib/rubygems/source.rb @@ -1,13 +1,30 @@ require 'uri' require 'fileutils' +## +# A Source knows how to list and fetch gems from a RubyGems marshal index. +# +# There are other Source subclasses for installed gems, local gems, the +# bundler dependency API and so-forth. + class Gem::Source - FILES = { + + include Comparable + + FILES = { # :nodoc: :released => 'specs', :latest => 'latest_specs', :prerelease => 'prerelease_specs', } + ## + # The URI this source will fetch gems from. + + attr_reader :uri + + ## + # Creates a new Source which will use the index located at +uri+. + 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 + ## + # Use an SRV record on the host to look up the true endpoint for the index. - def api_uri + def api_uri # :nodoc: require 'rubygems/remote_fetcher' @api_uri ||= Gem::RemoteFetcher.fetcher.api_endpoint uri end + ## + # Sources are ordered by installation preference. + def <=>(other) case other when Gem::Source::Installed, @@ -46,13 +67,11 @@ class Gem::Source end end - include Comparable - - def ==(other) + def == other # :nodoc: self.class === other and @uri == other.uri end - alias_method :eql?, :== + alias_method :eql?, :== # :nodoc: ## # Returns a Set that can fetch specifications from this source. @@ -70,7 +89,7 @@ class Gem::Source end end - def hash + def hash # :nodoc: @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 + ## + # Returns true when it is possible and safe to update the cache directory. + def update_cache? @update_cache ||= begin @@ -166,6 +188,10 @@ class Gem::Source end end + ## + # Downloads +spec+ and writes it to +dir+. See also + # Gem::RemoteFetcher#download. + 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 + q.text api.to_s end end end |