ruby-changes:30615
From: drbrain <ko1@a...>
Date: Tue, 27 Aug 2013 05:25:10 +0900 (JST)
Subject: [ruby-changes:30615] drbrain:r42693 (trunk): * lib/rubygems: Import RubyGems 2.1.0 Release Candidate
drbrain 2013-08-27 05:24:51 +0900 (Tue, 27 Aug 2013) New Revision: 42693 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42693 Log: * lib/rubygems: Import RubyGems 2.1.0 Release Candidate * test/rubygems: ditto. Added files: trunk/test/rubygems/test_gem_source_installed.rb Modified files: trunk/ChangeLog trunk/lib/rubygems/basic_specification.rb trunk/lib/rubygems/commands/build_command.rb trunk/lib/rubygems/commands/check_command.rb trunk/lib/rubygems/commands/cleanup_command.rb trunk/lib/rubygems/commands/contents_command.rb trunk/lib/rubygems/commands/dependency_command.rb trunk/lib/rubygems/commands/environment_command.rb trunk/lib/rubygems/commands/fetch_command.rb trunk/lib/rubygems/commands/list_command.rb trunk/lib/rubygems/commands/mirror_command.rb trunk/lib/rubygems/commands/outdated_command.rb trunk/lib/rubygems/commands/owner_command.rb trunk/lib/rubygems/commands/pristine_command.rb trunk/lib/rubygems/commands/push_command.rb trunk/lib/rubygems/commands/query_command.rb trunk/lib/rubygems/commands/rdoc_command.rb trunk/lib/rubygems/commands/search_command.rb trunk/lib/rubygems/commands/sources_command.rb trunk/lib/rubygems/commands/specification_command.rb trunk/lib/rubygems/commands/stale_command.rb trunk/lib/rubygems/commands/uninstall_command.rb trunk/lib/rubygems/commands/unpack_command.rb trunk/lib/rubygems/commands/update_command.rb trunk/lib/rubygems/commands/which_command.rb trunk/lib/rubygems/commands/yank_command.rb trunk/lib/rubygems/core_ext/kernel_require.rb trunk/lib/rubygems/defaults.rb trunk/lib/rubygems/dependency_installer.rb trunk/lib/rubygems/package_task.rb trunk/lib/rubygems/security/policy.rb trunk/lib/rubygems/security/signer.rb trunk/lib/rubygems/source/local.rb trunk/lib/rubygems/source/specific_file.rb trunk/lib/rubygems/source.rb trunk/lib/rubygems/specification.rb trunk/lib/rubygems/stub_specification.rb trunk/lib/rubygems/test_case.rb trunk/lib/rubygems.rb trunk/test/rubygems/test_gem.rb trunk/test/rubygems/test_gem_commands_uninstall_command.rb trunk/test/rubygems/test_gem_package_task.rb trunk/test/rubygems/test_gem_security_policy.rb trunk/test/rubygems/test_gem_security_signer.rb trunk/test/rubygems/test_gem_source.rb trunk/test/rubygems/test_gem_source_local.rb trunk/test/rubygems/test_gem_source_specific_file.rb trunk/test/rubygems/test_gem_specification.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42692) +++ ChangeLog (revision 42693) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Aug 27 05:24:34 2013 Eric Hodel <drbrain@s...> + + * lib/rubygems: Import RubyGems 2.1.0 Release Candidate + * test/rubygems: ditto. + Mon Aug 26 16:24:58 2013 Nobuyoshi Nakada <nobu@r...> * parse.y (parser_nextc): warn carriage return in middle of line. Index: lib/rubygems/basic_specification.rb =================================================================== --- lib/rubygems/basic_specification.rb (revision 42692) +++ lib/rubygems/basic_specification.rb (revision 42693) @@ -1,139 +1,143 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L1 -module Gem - # BasicSpecification is an abstract class which implements some common code used by - # both Specification and StubSpecification. - class BasicSpecification - def self.default_specifications_dir - File.join(Gem.default_dir, "specifications", "default") - end +## +# BasicSpecification is an abstract class which implements some common code +# used by both Specification and StubSpecification. - ## - # Name of the gem +class Gem::BasicSpecification - def name - raise NotImplementedError - end + ## + # The path this gemspec was loaded from. This attribute is not persisted. - ## - # Version of the gem + attr_reader :loaded_from - def version - raise NotImplementedError - end + def self.default_specifications_dir + File.join(Gem.default_dir, "specifications", "default") + end - ## - # Platform of the gem + ## + # True when the gem has been activated - def platform - raise NotImplementedError - end + def activated? + raise NotImplementedError + end + + ## + # Returns the full path to the base gem directory. + # + # eg: /usr/local/lib/ruby/gems/1.8 + + def base_dir + return Gem.dir unless loaded_from + @base_dir ||= if default_gem? then + File.dirname File.dirname File.dirname loaded_from + else + File.dirname File.dirname loaded_from + end + end - ## - # Require paths of the gem + ## + # Return true if this spec can require +file+. - def require_paths - raise NotImplementedError + def contains_requirable_file? file + root = full_gem_path + suffixes = Gem.suffixes + + require_paths.any? do |lib| + base = "#{root}/#{lib}/#{file}" + suffixes.any? { |suf| File.file? "#{base}#{suf}" } end + end - ## - # True when the gem has been activated + def default_gem? + loaded_from && + File.dirname(loaded_from) == self.class.default_specifications_dir + end - def activated? - raise NotImplementedError - end + def find_full_gem_path # :nodoc: + # TODO: also, shouldn't it default to full_name if it hasn't been written? + path = File.expand_path File.join(gems_dir, full_name) + path.untaint + path if File.directory? path + end - ## - # Return a Gem::Specification from this gem + private :find_full_gem_path - def to_spec - raise NotImplementedError - end + ## + # The full path to the gem (install path + full name). - ## - # The filename of the gem specification - attr_reader :filename - - ## - # Set the filename of the Specification was loaded from. +path+ is converted - # to a String. - - def filename= path - @filename = path && path.to_s - - @full_gem_path = nil - @gems_dir = nil - @base_dir = nil + def full_gem_path + # TODO: This is a heavily used method by gems, so we'll need + # to aleast just alias it to #gem_dir rather than remove it. + @full_gem_path ||= find_full_gem_path + end + + ## + # Returns the full name (name-version) of this Gem. Platform information + # is included (name-version-platform) if it is specified and not the + # default Ruby platform. + + def full_name + if platform == Gem::Platform::RUBY or platform.nil? then + "#{name}-#{version}".untaint + else + "#{name}-#{version}-#{platform}".untaint end + end + + ## + # Returns the full path to the gems directory containing this spec's + # gem directory. eg: /usr/local/lib/ruby/1.8/gems + + def gems_dir + # TODO: this logic seems terribly broken, but tests fail if just base_dir + @gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems") + end - ## - # Return true if this spec can require +file+. + ## + # Set the path the Specification was loaded from. +path+ is converted to a + # String. + + def loaded_from= path + @loaded_from = path && path.to_s + + @full_gem_path = nil + @gems_dir = nil + @base_dir = nil + end - def contains_requirable_file? file - root = full_gem_path - suffixes = Gem.suffixes - - require_paths.any? do |lib| - base = "#{root}/#{lib}/#{file}" - suffixes.any? { |suf| File.file? "#{base}#{suf}" } - end - end + ## + # Name of the gem - ## - # The full path to the gem (install path + full name). + def name + raise NotImplementedError + end - def full_gem_path - # TODO: This is a heavily used method by gems, so we'll need - # to aleast just alias it to #gem_dir rather than remove it. - @full_gem_path ||= find_full_gem_path - end + ## + # Platform of the gem - # :nodoc: - def find_full_gem_path - # TODO: also, shouldn't it default to full_name if it hasn't been written? - path = File.expand_path File.join(gems_dir, full_name) - path.untaint - path if File.directory? path - end - private :find_full_gem_path + def platform + raise NotImplementedError + end - ## - # Returns the full path to the gems directory containing this spec's - # gem directory. eg: /usr/local/lib/ruby/1.8/gems - - def gems_dir - # TODO: this logic seems terribly broken, but tests fail if just base_dir - @gems_dir ||= File.join(filename && base_dir || Gem.dir, "gems") - end + ## + # Require paths of the gem - ## - # Returns the full path to the base gem directory. - # - # eg: /usr/local/lib/ruby/gems/1.8 - - def base_dir - return Gem.dir unless filename - @base_dir ||= if default_gem? then - File.dirname File.dirname File.dirname filename - else - File.dirname File.dirname filename - end - end + def require_paths + raise NotImplementedError + end - def default_gem? - filename && - File.dirname(filename) == self.class.default_specifications_dir - end + ## + # Return a Gem::Specification from this gem - ## - # Returns the full name (name-version) of this Gem. Platform information - # is included (name-version-platform) if it is specified and not the - # default Ruby platform. - - def full_name - if platform == Gem::Platform::RUBY or platform.nil? then - "#{name}-#{version}".untaint - else - "#{name}-#{version}-#{platform}".untaint - end - end + def to_spec + raise NotImplementedError + end + + ## + # Version of the gem + + def version + raise NotImplementedError end + end + Index: lib/rubygems/dependency_installer.rb =================================================================== --- lib/rubygems/dependency_installer.rb (revision 42692) +++ lib/rubygems/dependency_installer.rb (revision 42693) @@ -5,8 +5,7 @@ require 'rubygems/package' https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L5 require 'rubygems/installer' require 'rubygems/spec_fetcher' require 'rubygems/user_interaction' -require 'rubygems/source/local' -require 'rubygems/source/specific_file' +require 'rubygems/source' require 'rubygems/available_set' ## @@ -251,7 +250,6 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L250 def find_spec_by_name_and_version gem_name, version = Gem::Requirement.default, prerelease = false - set = Gem::AvailableSet.new if consider_local? @@ -269,7 +267,6 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L267 if set.empty? dep = Gem::Dependency.new gem_name, version - # HACK Dependency objects should be immutable dep.prerelease = true if prerelease set = find_gems_with_sources(dep) Index: lib/rubygems/specification.rb =================================================================== --- lib/rubygems/specification.rb (revision 42692) +++ lib/rubygems/specification.rb (revision 42693) @@ -206,15 +206,19 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L206 attr_reader :version ## - # Paths in the gem to add to <tt>$LOAD_PATH</tt> when this gem is activated. + # Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is + # activated. + # + # If you have an extension you do not need to add <code>"ext"</code> to the + # require path, the extension build process will copy the extension files + # into "lib" for you. + # + # The default value is <code>"lib"</code> # # Usage: # # # If all library files are in the root directory... # spec.require_path = '.' - # - # # If you have 'lib' and 'ext' directories... - # spec.require_paths << 'ext' attr_accessor :require_paths @@ -228,7 +232,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L232 ## # A short summary of this gem's description. Displayed in `gem list -d`. # - # The description should be more detailed than the summary. + # The #description should be more detailed than the summary. # # Usage: # @@ -241,21 +245,23 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L245 # # This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT. # - # Most gems contain pure Ruby code; they should simply leave the default value - # in place. Some gems contain C (or other) code to be compiled into a Ruby - # xtension The should leave the default value in place unless their code - # will only compile on a certain type of system. Some gems consist of - # pre-compiled code (inary gems. It especially important that they set - # the platform attribute appropriately. A shortcut is to set the platform to - # Gem::Platform::CURRENT, which will cause the gem builder to set the platform - # to the appropriate value for the system on which the build is being performed. - # - # If this attribute is set to a non-default value, it will be included in the - # filename of the gem when it is built, e.g. fxruby-1.2.0-win32.gem. + # Most gems contain pure Ruby code; they should simply leave the default + # value in place. Some gems contain C (or other) code to be compiled into a + # Ruby "extension". The should leave the default value in place unless + # their code will only compile on a certain type of system. Some gems + # consist of pre-compiled code ("binary gems"). It's especially important + # that they set the platform attribute appropriately. A shortcut is to set + # the platform to Gem::Platform::CURRENT, which will cause the gem builder + # to set the platform to the appropriate value for the system on which the + # build is being performed. + # + # If this attribute is set to a non-default value, it will be included in + # the filename of the gem when it is built such as: + # nokogiri-1.6.0-x86-mingw32.gem # # Usage: # - # spec.platform = Gem::Platform::Win32 + # spec.platform = Gem::Platform.local def platform= platform if @original_platform.nil? or @@ -357,7 +363,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L363 attr_reader :description ## - # A contact email for this gem + # A contact email address (or addresses) for this gem # # Usage: # @@ -473,6 +479,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L479 # Usage: # # spec.extensions << 'ext/rmagic/extconf.rb' + # + # See Gem::Ext::Builder for information about writing extensions for gems. def extensions @extensions ||= [] @@ -502,6 +510,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L510 # This should just be the name of your license. The full # text of the license should be inside of the gem when you build it. # + # You can set multiple licenses with #licenses= + # # Usage: # spec.license = 'MIT' @@ -538,15 +548,20 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L548 end ## - # The version of Ruby required by this gem + # The version of Ruby required by this gem. The ruby version can be + # specified to the patch-level: + # + # $ ruby -v -e 'p Gem.ruby_version' + # ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] + # #<Gem::Version "2.0.0.247"> # # Usage: # - # # If it will work with 1.8.6 or greater... + # # This gem will work with 1.8.6 or greater... # spec.required_ruby_version = '>= 1.8.6' # - # # Hopefully by now: - # spec.required_ruby_version = '>= 1.9.2' + # # Only with ruby 2.0.x + # spec.required_ruby_version = '~> 2.0' def required_ruby_version= req @required_ruby_version = Gem::Requirement.create req @@ -554,7 +569,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L569 ## # Lists the external (to RubyGems) requirements that must be met for this gem - # to work. It simply information for the user. + # to work. It's simply information for the user. # # Usage: # @@ -566,7 +581,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L581 end ## - # A collection of unit test files. They will be loaded as unit tests when + # A collection of unit test files. They will be loaded as unit tests when # the user requests a gem to be unit tested. # # Usage: @@ -592,7 +607,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L607 # # Deprecated: It is neither supported nor functional. - attr_accessor :autorequire + attr_accessor :autorequire # :nodoc: ## # Sets the default executable for this gem. @@ -615,9 +630,12 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L630 # The RubyGems version required by this gem attr_reader :required_rubygems_version + ## # The rubyforge project this gem lives under. i.e. RubyGems' # rubyforge_project is "rubygems". + # + # This option is deprecated. attr_accessor :rubyforge_project @@ -768,7 +786,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L786 # -- wilsonb def self.all= specs - @@all = specs + @@all = @@stubs = specs end ## @@ -1320,7 +1338,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1338 end ## - # Singular reader for #authors + # Singular reader for #authors. Returns the first author in the list def author val = authors and val.first @@ -1328,6 +1346,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1346 ## # The list of author names who wrote this gem. + # + # spec.authors = ['Chad Fowler', 'Jim Weirich', 'Rich Kilmer'] def authors @authors ||= [] @@ -1407,7 +1427,9 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1427 end ## - # The date this gem was created. Lazily defaults to TODAY. + # The date this gem was created. Lazily defaults to the current UTC date. + # + # There is no need to set this in your gem specification. def date @date ||= TODAY @@ -1454,7 +1476,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1476 # Deprecated: The name of the gem is assumed to be the name of the # executable now. See Gem.bin_path. - def default_executable + def default_executable # :nodoc: if defined?(@default_executable) and @default_executable result = @default_executable elsif @executables and @executables.size == 1 @@ -1513,7 +1535,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1535 end ## - # A long description of this gem + # A detailed description of this gem. See also #summary def description= str @description = str.to_s @@ -1672,7 +1694,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1694 # # Formerly used to indicate this gem was RDoc-capable. - def has_rdoc + def has_rdoc # :nodoc: true end @@ -1681,11 +1703,11 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1703 # # Formerly used to indicate this gem was RDoc-capable. - def has_rdoc= ignored + def has_rdoc= ignored # :nodoc: @has_rdoc = true end - alias :has_rdoc? :has_rdoc + alias :has_rdoc? :has_rdoc # :nodoc: ## # True if this gem has files in test_files @@ -1818,7 +1840,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1840 @licenses ||= [] end - def filename= path + def loaded_from= path # :nodoc: super @bin_dir = nil @@ -1832,17 +1854,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1854 end ## - # Path this gemspec was loaded from. This attribute is not persisted. - - alias loaded_from filename - - ## - # Set the location a Specification was loaded from. +obj+ is converted - # to a String. - - alias loaded_from= filename= - - ## # Sets the rubygems_version to the current RubyGems version. def mark_version Index: lib/rubygems/source/specific_file.rb =================================================================== --- lib/rubygems/source/specific_file.rb (revision 42692) +++ lib/rubygems/source/specific_file.rb (revision 42693) @@ -25,4 +25,32 @@ class Gem::Source::SpecificFile < Gem::S https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/specific_file.rb#L25 raise Gem::Exception, "Unable to download '#{spec.full_name}'" end + def pretty_print q # :nodoc: + q.group 2, '[Local:', ']' do + q.breakable + q.text @path + end + end + + ## + # Orders this source against +other+. + # + # If +other+ is a SpecificFile from a different gem name +nil+ is returned. + # + # If +other+ is a SpecificFile from the same gem name the versions are + # compared using Gem::Version#<=> + # + # Otherwise Gem::Source#<=> is used. + + def <=> other + case other + when Gem::Source::SpecificFile then + return nil if @spec.name != other.spec.name + + @spec.version <=> other.spec.version + el (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/