1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
drbrain 2013-11-21 23:27:30 +00:00
parent b1529a30e0
commit 5307d803f5
30 changed files with 714 additions and 196 deletions

View file

@ -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