diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-09 23:21:36 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-09 23:21:36 +0000 |
commit | 47f0248b0858898dd24d1e654cedf174059ca677 (patch) | |
tree | 493e84160f8609db408d88349f0624a3ff92c3c2 /lib/rubygems/source.rb | |
parent | cd9f9e471977447a991ced4ea38efb2309459ef5 (diff) | |
download | ruby-47f0248b0858898dd24d1e654cedf174059ca677.tar.gz |
* lib/rubygems: Import RubyGems 2.1
* test/rubygems: Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/source.rb')
-rw-r--r-- | lib/rubygems/source.rb | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb index 96d57870e2..8322ac33d4 100644 --- a/lib/rubygems/source.rb +++ b/lib/rubygems/source.rb @@ -25,14 +25,21 @@ class Gem::Source end def <=>(other) - if !@uri - return 0 unless other.uri - return -1 - end + case other + when Gem::Source::Installed, Gem::Source::Local then + -1 + when Gem::Source then + if !@uri + return 0 unless other.uri + return -1 + end - return 1 if !other.uri + return 1 if !other.uri - @uri.to_s <=> other.uri.to_s + @uri.to_s <=> other.uri.to_s + else + nil + end end include Comparable @@ -58,8 +65,7 @@ class Gem::Source def cache_dir(uri) # Correct for windows paths escaped_path = uri.path.sub(/^\/([a-z]):\//i, '/\\1-/') - root = File.join Gem.user_home, '.gem', 'specs' - File.join root, "#{uri.host}%#{uri.port}", File.dirname(escaped_path) + File.join Gem.spec_cache_dir, "#{uri.host}%#{uri.port}", File.dirname(escaped_path) end def update_cache? @@ -141,4 +147,14 @@ class Gem::Source fetcher = Gem::RemoteFetcher.fetcher fetcher.download spec, @uri.to_s, dir end + + def pretty_print q # :nodoc: + q.group 2, '[Remote:', ']' do + q.breakable + q.text @uri.to_s + end + end + end + +require 'rubygems/source/installed' |