aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--NEWS4
-rw-r--r--lib/rbconfig/datadir.rb19
-rw-r--r--lib/rubygems.rb366
-rw-r--r--lib/rubygems/builder.rb23
-rw-r--r--lib/rubygems/command.rb18
-rw-r--r--lib/rubygems/command_manager.rb9
-rw-r--r--lib/rubygems/commands/build_command.rb6
-rw-r--r--lib/rubygems/commands/cert_command.rb14
-rw-r--r--lib/rubygems/commands/check_command.rb25
-rw-r--r--lib/rubygems/commands/cleanup_command.rb8
-rw-r--r--lib/rubygems/commands/contents_command.rb6
-rw-r--r--lib/rubygems/commands/dependency_command.rb28
-rw-r--r--lib/rubygems/commands/environment_command.rb11
-rw-r--r--lib/rubygems/commands/fetch_command.rb8
-rw-r--r--lib/rubygems/commands/generate_index_command.rb17
-rw-r--r--lib/rubygems/commands/help_command.rb11
-rw-r--r--lib/rubygems/commands/install_command.rb26
-rw-r--r--lib/rubygems/commands/list_command.rb6
-rw-r--r--lib/rubygems/commands/lock_command.rb8
-rw-r--r--lib/rubygems/commands/mirror_command.rb111
-rw-r--r--lib/rubygems/commands/outdated_command.rb6
-rw-r--r--lib/rubygems/commands/owner_command.rb6
-rw-r--r--lib/rubygems/commands/pristine_command.rb7
-rw-r--r--lib/rubygems/commands/push_command.rb21
-rw-r--r--lib/rubygems/commands/query_command.rb34
-rw-r--r--lib/rubygems/commands/rdoc_command.rb6
-rw-r--r--lib/rubygems/commands/search_command.rb6
-rw-r--r--lib/rubygems/commands/server_command.rb14
-rw-r--r--lib/rubygems/commands/setup_command.rb12
-rw-r--r--lib/rubygems/commands/sources_command.rb40
-rw-r--r--lib/rubygems/commands/specification_command.rb9
-rw-r--r--lib/rubygems/commands/stale_command.rb6
-rw-r--r--lib/rubygems/commands/uninstall_command.rb6
-rw-r--r--lib/rubygems/commands/unpack_command.rb9
-rw-r--r--lib/rubygems/commands/update_command.rb79
-rw-r--r--lib/rubygems/commands/which_command.rb7
-rw-r--r--lib/rubygems/config_file.rb37
-rw-r--r--lib/rubygems/custom_require.rb14
-rw-r--r--lib/rubygems/defaults.rb6
-rw-r--r--lib/rubygems/dependency.rb83
-rw-r--r--lib/rubygems/dependency_installer.rb61
-rw-r--r--lib/rubygems/dependency_list.rb15
-rw-r--r--lib/rubygems/doc_manager.rb8
-rw-r--r--lib/rubygems/errors.rb6
-rw-r--r--lib/rubygems/exceptions.rb6
-rw-r--r--lib/rubygems/ext.rb6
-rw-r--r--lib/rubygems/ext/builder.rb10
-rw-r--r--lib/rubygems/ext/configure_builder.rb6
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb6
-rw-r--r--lib/rubygems/ext/rake_builder.rb8
-rw-r--r--lib/rubygems/format.rb8
-rw-r--r--lib/rubygems/gem_openssl.rb10
-rw-r--r--lib/rubygems/gem_path_searcher.rb20
-rw-r--r--lib/rubygems/gem_runner.rb12
-rw-r--r--lib/rubygems/gemcutter_utilities.rb12
-rw-r--r--lib/rubygems/indexer.rb83
-rw-r--r--lib/rubygems/install_update_options.rb16
-rw-r--r--lib/rubygems/installer.rb46
-rw-r--r--lib/rubygems/local_remote_options.rb29
-rw-r--r--lib/rubygems/old_format.rb13
-rw-r--r--lib/rubygems/package.rb13
-rw-r--r--lib/rubygems/package/f_sync_dir.rb6
-rw-r--r--lib/rubygems/package/tar_header.rb6
-rw-r--r--lib/rubygems/package/tar_input.rb9
-rw-r--r--lib/rubygems/package/tar_output.rb6
-rw-r--r--lib/rubygems/package/tar_reader.rb6
-rw-r--r--lib/rubygems/package/tar_reader/entry.rb6
-rw-r--r--lib/rubygems/package/tar_writer.rb6
-rw-r--r--lib/rubygems/package_task.rb18
-rw-r--r--lib/rubygems/platform.rb8
-rw-r--r--lib/rubygems/remote_fetcher.rb63
-rw-r--r--lib/rubygems/require_paths_builder.rb23
-rw-r--r--lib/rubygems/requirement.rb8
-rw-r--r--lib/rubygems/security.rb257
-rw-r--r--lib/rubygems/server.rb59
-rw-r--r--lib/rubygems/source_index.rb278
-rw-r--r--lib/rubygems/source_info_cache.rb395
-rw-r--r--lib/rubygems/source_info_cache_entry.rb56
-rw-r--r--lib/rubygems/spec_fetcher.rb107
-rw-r--r--lib/rubygems/specification.rb52
-rw-r--r--lib/rubygems/test_utilities.rb6
-rw-r--r--lib/rubygems/text.rb41
-rw-r--r--lib/rubygems/uninstaller.rb6
-rw-r--r--lib/rubygems/user_interaction.rb142
-rw-r--r--lib/rubygems/validator.rb93
-rw-r--r--lib/rubygems/version.rb69
-rw-r--r--lib/rubygems/version_option.rb6
-rw-r--r--test/rubygems/bogussources.rb6
-rw-r--r--test/rubygems/fake_certlib/openssl.rb6
-rw-r--r--test/rubygems/foo/discover.rb6
-rw-r--r--test/rubygems/functional.rb6
-rw-r--r--test/rubygems/gem_installer_test_case.rb8
-rw-r--r--test/rubygems/gem_package_tar_test_case.rb12
-rw-r--r--test/rubygems/gemutilities.rb92
-rw-r--r--test/rubygems/insure_session.rb6
-rw-r--r--test/rubygems/mockgemui.rb6
-rw-r--r--test/rubygems/plugin/exception/rubygems_plugin.rb6
-rw-r--r--test/rubygems/plugin/load/rubygems_plugin.rb6
-rw-r--r--test/rubygems/plugin/standarderror/rubygems_plugin.rb6
-rw-r--r--test/rubygems/rubygems/commands/crash_command.rb6
-rw-r--r--test/rubygems/rubygems_plugin.rb6
-rw-r--r--test/rubygems/sff/discover.rb6
-rw-r--r--test/rubygems/simple_gem.rb6
-rw-r--r--test/rubygems/test_config.rb16
-rw-r--r--test/rubygems/test_gem.rb136
-rw-r--r--test/rubygems/test_gem_activation.rb20
-rw-r--r--test/rubygems/test_gem_builder.rb8
-rw-r--r--test/rubygems/test_gem_command.rb8
-rw-r--r--test/rubygems/test_gem_command_manager.rb24
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb11
-rw-r--r--test/rubygems/test_gem_commands_check_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_dependency_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb19
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_generate_index_command.rb20
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb63
-rw-r--r--test/rubygems/test_gem_commands_list_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_lock_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_mirror_command.rb60
-rw-r--r--test/rubygems/test_gem_commands_outdated_command.rb12
-rw-r--r--test/rubygems/test_gem_commands_owner_command.rb20
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb42
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb14
-rw-r--r--test/rubygems/test_gem_commands_server_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_specification_command.rb16
-rw-r--r--test/rubygems/test_gem_commands_stale_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_uninstall_command.rb10
-rw-r--r--test/rubygems/test_gem_commands_unpack_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb8
-rw-r--r--test/rubygems/test_gem_commands_which_command.rb8
-rw-r--r--test/rubygems/test_gem_config_file.rb10
-rw-r--r--test/rubygems/test_gem_dependency.rb32
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb52
-rw-r--r--test/rubygems/test_gem_dependency_list.rb8
-rw-r--r--test/rubygems/test_gem_doc_manager.rb8
-rw-r--r--test/rubygems/test_gem_ext_configure_builder.rb8
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb69
-rw-r--r--test/rubygems/test_gem_ext_rake_builder.rb23
-rw-r--r--test/rubygems/test_gem_format.rb10
-rw-r--r--test/rubygems/test_gem_gem_path_searcher.rb8
-rw-r--r--test/rubygems/test_gem_gem_runner.rb8
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb11
-rw-r--r--test/rubygems/test_gem_indexer.rb125
-rw-r--r--test/rubygems/test_gem_install_update_options.rb10
-rw-r--r--test/rubygems/test_gem_installer.rb13
-rw-r--r--test/rubygems/test_gem_local_remote_options.rb27
-rw-r--r--test/rubygems/test_gem_package_tar_header.rb8
-rw-r--r--test/rubygems/test_gem_package_tar_input.rb8
-rw-r--r--test/rubygems/test_gem_package_tar_output.rb8
-rw-r--r--test/rubygems/test_gem_package_tar_reader.rb8
-rw-r--r--test/rubygems/test_gem_package_tar_reader_entry.rb8
-rw-r--r--test/rubygems/test_gem_package_tar_writer.rb8
-rw-r--r--test/rubygems/test_gem_package_task.rb10
-rw-r--r--test/rubygems/test_gem_platform.rb9
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb24
-rw-r--r--test/rubygems/test_gem_requirement.rb12
-rw-r--r--test/rubygems/test_gem_security.rb96
-rw-r--r--test/rubygems/test_gem_server.rb146
-rw-r--r--test/rubygems/test_gem_source_index.rb87
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb8
-rw-r--r--test/rubygems/test_gem_specification.rb29
-rw-r--r--test/rubygems/test_gem_stream_ui.rb82
-rw-r--r--test/rubygems/test_gem_text.rb49
-rw-r--r--test/rubygems/test_gem_uninstaller.rb8
-rw-r--r--test/rubygems/test_gem_validator.rb10
-rw-r--r--test/rubygems/test_gem_version.rb45
-rw-r--r--test/rubygems/test_gem_version_option.rb8
-rw-r--r--test/rubygems/test_kernel.rb21
173 files changed, 2722 insertions, 2456 deletions
diff --git a/ChangeLog b/ChangeLog
index 13124bee36..5eec3c1bd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jan 19 08:13:59 2011 Ryan Davis <ryand-ruby@zenspider.com>
+
+ * lib/rubygems*: Import rubygems 1.5.0 (release candidate)
+ * test/rubygems: Ditto
+
Tue Jan 18 23:31:01 2011 Yusuke Endoh <mame@tsg.ne.jp>
* parse.y: avoid NULL reference. [ruby-dev:43067]
diff --git a/NEWS b/NEWS
index df7c8a8b82..7a749daca2 100644
--- a/NEWS
+++ b/NEWS
@@ -102,6 +102,10 @@ with all sufficient information, see the ChangeLog file.
Output#encoding and Source#encoding) return an Encoding
object instead of an encoding name.
+* Rubygems
+ * Rubygems has been upgraded to rubygems 1.5.0. For full release notes see
+ http://rubygems.rubyforge.org/rubygems-update/History_txt.html
+
* stringio
* extended method:
* StringIO#set_encoding can get 2nd argument and optional hash.
diff --git a/lib/rbconfig/datadir.rb b/lib/rbconfig/datadir.rb
index 554b7fead7..9b7eabb473 100644
--- a/lib/rbconfig/datadir.rb
+++ b/lib/rbconfig/datadir.rb
@@ -4,17 +4,10 @@
# See LICENSE.txt for permissions.
#++
-module RbConfig
-
- ##
- # Return the path to the data directory associated with the given package
- # name. Normally this is just
- # "#{RbConfig::CONFIG['datadir']}/#{package_name}", but may be modified by
- # packages like RubyGems to handle versioned data directories.
-
- def self.datadir(package_name)
- File.join(CONFIG['datadir'], package_name)
- end unless RbConfig.respond_to?(:datadir)
-
-end
+# N.B. This file is used by Config.datadir in rubygems.rb, and must not be
+# removed before that require is removed. I require to avoid warning more than
+# once.
+warn 'rbconfig/datadir.rb and {Rb}Config.datadir is being deprecated from '\
+ 'RubyGems. It will be removed completely on or after June 2011. If you '\
+ 'wish to rely on a datadir, please use Gem.datadir.'
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 9f72b8aa45..28fe95889e 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -5,9 +5,24 @@
# See LICENSE.txt for permissions.
#++
+# TODO: remove when 1.9.1 no longer supported
+QUICKLOADER_SUCKAGE = RUBY_VERSION >= "1.9.1" and RUBY_VERSION < "1.9.2"
+# TODO: remove when 1.9.2 no longer supported
+GEM_PRELUDE_SUCKAGE = RUBY_VERSION >= "1.9.2" and RUBY_VERSION < "1.9.3"
+
+gem_preluded = GEM_PRELUDE_SUCKAGE and defined? Gem
+
+if GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
+ Gem::QuickLoader.load_full_rubygems_library
+
+ class << Gem
+ remove_method :try_activate if Gem.respond_to?(:try_activate, true)
+ end
+end
+
require 'rubygems/defaults'
-require 'thread'
-require 'etc'
+require 'rbconfig'
+require 'thread' # HACK: remove me for 1.5 - this is here just for rails
##
# RubyGems is the Ruby standard for publishing and managing third party
@@ -98,7 +113,7 @@ require 'etc'
# -The RubyGems Team
module Gem
- RubyGemsVersion = VERSION = '1.3.7'
+ RubyGemsVersion = VERSION = '1.5.0'
##
# Raised when RubyGems is unable to load or activate a gem. Contains the
@@ -110,40 +125,49 @@ module Gem
attr_accessor :name
# Version requirement of gem
- attr_accessor :version_requirement
- end
+ attr_accessor :requirement
- ##
- # Configuration settings from ::RbConfig
+ def version_requirement
+ warn "#{Gem.location_of_caller.join ':'}:Warning: " \
+ "Gem::LoadError#version_requirement is deprecated " \
+ "and will be removed on or after January 2011. " \
+ "Use #requirement."
+
+ requirement
+ end
+
+ def version_requirement= requirement
+ warn "#{Gem.location_of_caller.join ':'}:Warning: " \
+ "Gem::LoadError#version_requirement= is deprecated " \
+ "and will be removed on or after January 2011. " \
+ "Use #requirement."
- ConfigMap = {} unless defined?(ConfigMap)
+ self.requirement = requirement
+ end
+ end
- require 'rbconfig'
+ RbConfigPriorities = %w[
+ EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
+ ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
+ ]
- ConfigMap.merge!(
- :EXEEXT => RbConfig::CONFIG["EXEEXT"],
- :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
- :arch => RbConfig::CONFIG["arch"],
- :bindir => RbConfig::CONFIG["bindir"],
- :datadir => RbConfig::CONFIG["datadir"],
- :libdir => RbConfig::CONFIG["libdir"],
- :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
- :ruby_version => RbConfig::CONFIG["ruby_version"],
- :rubylibprefix => RbConfig::CONFIG["rubylibprefix"],
- :sitedir => RbConfig::CONFIG["sitedir"],
- :sitelibdir => RbConfig::CONFIG["sitelibdir"],
- :vendordir => RbConfig::CONFIG["vendordir"] ,
- :vendorlibdir => RbConfig::CONFIG["vendorlibdir"]
- )
+ unless defined?(ConfigMap)
+ ##
+ # Configuration settings from ::RbConfig
+ ConfigMap = Hash.new do |cm, key|
+ cm[key] = RbConfig::CONFIG[key.to_s]
+ end
+ else
+ RbConfigPriorities.each do |key|
+ ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
+ end
+ end
##
# Default directories in a gem repository
DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
- # :stopdoc:
- MUTEX = Mutex.new
-
RubyGemsPackageVersion = VERSION
# :startdoc:
@@ -175,8 +199,21 @@ module Gem
@pre_install_hooks ||= []
##
+ # Try to activate a gem containing +path+. Returns true if
+ # activation succeeded or wasn't needed because it was already
+ # activated. Returns false if it can't find the path in a gem.
+
+ def self.try_activate path
+ spec = Gem.searcher.find path
+ return false unless spec
+
+ Gem.activate spec.name, "= #{spec.version}"
+ return true
+ end
+
+ ##
# Activates an installed gem matching +gem+. The gem must satisfy
- # +version_requirements+.
+ # +requirements+.
#
# Returns true if the gem is activated, false if it is already
# loaded, or an exception otherwise.
@@ -190,22 +227,22 @@ module Gem
# More information on version requirements can be found in the
# Gem::Requirement and Gem::Version documentation.
- def self.activate(gem, *version_requirements)
- if version_requirements.last.is_a?(Hash)
- options = version_requirements.pop
+ def self.activate(gem, *requirements)
+ if requirements.last.is_a?(Hash)
+ options = requirements.pop
else
options = {}
end
sources = options[:sources] || []
- if version_requirements.empty? then
- version_requirements = Gem::Requirement.default
+ if requirements.empty? then
+ requirements = Gem::Requirement.default
end
unless gem.respond_to?(:name) and
gem.respond_to?(:requirement) then
- gem = Gem::Dependency.new(gem, version_requirements)
+ gem = Gem::Dependency.new(gem, requirements)
end
matches = Gem.source_index.find_name(gem.name, gem.requirement)
@@ -226,7 +263,7 @@ module Gem
e = Gem::LoadError.new msg
e.name = gem.name
- e.version_requirement = gem.requirement
+ e.requirement = gem.requirement
raise e
end
@@ -247,9 +284,6 @@ module Gem
activate dep_gem, :sources => [spec, *sources]
end
- # bin directory must come before library directories
- spec.require_paths.unshift spec.bindir if spec.bindir
-
require_paths = spec.require_paths.map do |path|
File.join spec.full_gem_path, path
end
@@ -310,26 +344,30 @@ module Gem
##
# Find the full path to the executable for gem +name+. If the +exec_name+
# is not given, the gem's default_executable is chosen, otherwise the
- # specified executable's path is returned. +version_requirements+ allows
+ # specified executable's path is returned. +requirements+ allows
# you to specify specific gem versions.
- def self.bin_path(name, exec_name = nil, *version_requirements)
- version_requirements = Gem::Requirement.default if
- version_requirements.empty?
- spec = Gem.source_index.find_name(name, version_requirements).last
+ def self.bin_path(name, exec_name = nil, *requirements)
+ requirements = Gem::Requirement.default if
+ requirements.empty?
+ specs = Gem.source_index.find_name(name, requirements)
raise Gem::GemNotFoundException,
- "can't find gem #{name} (#{version_requirements})" unless spec
+ "can't find gem #{name} (#{requirements})" if specs.empty?
- exec_name ||= spec.default_executable
+ specs = specs.find_all do |spec|
+ spec.executables.include?(exec_name)
+ end if exec_name
- unless exec_name
- msg = "no default executable for #{spec.full_name}"
- raise Gem::Exception, msg
+ unless spec = specs.last
+ msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}"
+ raise Gem::GemNotFoundException, msg
end
- unless spec.executables.include? exec_name
- msg = "can't find executable #{exec_name} for #{spec.full_name}"
+ exec_name ||= spec.default_executable
+
+ unless exec_name
+ msg = "no default executable for #{spec.full_name} and none given"
raise Gem::Exception, msg
end
@@ -364,9 +402,7 @@ module Gem
@@source_index = nil
- MUTEX.synchronize do
- @searcher = nil
- end
+ @searcher = nil
end
##
@@ -414,7 +450,7 @@ module Gem
def self.dir
@gem_home ||= nil
- set_home(ENV['GEM_HOME'] || Gem.configuration.home || default_dir) unless @gem_home
+ set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
@gem_home
end
@@ -455,41 +491,66 @@ module Gem
end
##
- # Returns a list of paths matching +file+ that can be used by a gem to pick
+ # Returns a list of paths matching +glob+ that can be used by a gem to pick
# up features from other gems. For example:
#
# Gem.find_files('rdoc/discover').each do |path| load path end
#
- # find_files search $LOAD_PATH for files as well as gems.
+ # if +check_load_path+ is true (the default), then find_files also searches
+ # $LOAD_PATH for files as well as gems.
#
# Note that find_files will return all files even if they are from different
# versions of the same gem.
- def self.find_files(path)
- load_path_files = suffixes.map do |sfx|
- base = path + sfx
- $LOAD_PATH.map {|load_path|
- Dir[File.expand_path(base, load_path)]
- }
- end.flatten.select {|f| File.file?(f.untaint)}
+ def self.find_files(glob, check_load_path=true)
+ files = []
- specs = searcher.find_all path
+ if check_load_path
+ files = $LOAD_PATH.map { |load_path|
+ Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"]
+ }.flatten.select { |file| File.file? file.untaint }
+ end
- specs_files = specs.map do |spec|
- searcher.matching_files spec, path
- end.flatten
+ specs = searcher.find_all glob
- (load_path_files + specs_files).flatten.uniq
+ specs.each do |spec|
+ files.concat searcher.matching_files(spec, glob)
+ end
+
+ # $LOAD_PATH might contain duplicate entries or reference
+ # the spec dirs directly, so we prune.
+ files.uniq! if check_load_path
+
+ return files
end
##
# Finds the user's home directory.
+ #--
+ # Some comments from the ruby-talk list regarding finding the home
+ # directory:
+ #
+ # I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems
+ # to be depending on HOME in those code samples. I propose that
+ # it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at
+ # least on Win32).
def self.find_home
+ unless RUBY_VERSION > '1.9' then
+ ['HOME', 'USERPROFILE'].each do |homekey|
+ return File.expand_path(ENV[homekey]) if ENV[homekey]
+ end
+
+ if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
+ return File.expand_path("#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}")
+ end
+ end
+
File.expand_path "~"
rescue
if File::ALT_SEPARATOR then
- "C:/"
+ drive = ENV['HOMEDRIVE'] || ENV['SystemDrive']
+ File.join(drive.to_s, '/')
else
"/"
end
@@ -530,6 +591,20 @@ module Gem
end
##
+ # Get the default RubyGems API host. This is normally
+ # <tt>https://rubygems.org</tt>.
+
+ def self.host
+ @host ||= "https://rubygems.org"
+ end
+
+ ## Set the default RubyGems API host.
+
+ def self.host= host
+ @host = host
+ end
+
+ ##
# Return a list of all possible load paths for the latest version for all
# gems in the Gem installation.
@@ -573,13 +648,29 @@ module Gem
# so you can override the gem_prelude.rb default $LOAD_PATH paths.
def self.load_path_insert_index
- $LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index }
+ index = $LOAD_PATH.index ConfigMap[:sitelibdir]
+
+ if QUICKLOADER_SUCKAGE then
+ $LOAD_PATH.each_with_index do |path, i|
+ if path.instance_variables.include?(:@gem_prelude_index) or
+ path.instance_variables.include?('@gem_prelude_index') then
+ index = i
+ break
+ end
+ end
+ end
+
+ index
end
- def self.remove_prelude_paths
- # Gem::QuickLoader::GemLoadPaths.each do |path|
- # $LOAD_PATH.delete(path)
- # end
+ ##
+ # Loads YAML, preferring Psych
+
+ def self.load_yaml
+ require 'psych'
+ rescue ::LoadError
+ ensure
+ require 'yaml'
end
##
@@ -607,7 +698,7 @@ module Gem
@gem_path ||= nil
unless @gem_path then
- paths = [ENV['GEM_PATH'] || Gem.configuration.path || default_path]
+ paths = [ENV['GEM_PATH'] || default_path]
if defined?(APPLE_GEM_HOME) and not ENV['GEM_PATH'] then
paths << APPLE_GEM_HOME
@@ -720,9 +811,7 @@ module Gem
def self.refresh
source_index.refresh!
- MUTEX.synchronize do
- @searcher = nil
- end
+ @searcher = nil
end
##
@@ -750,7 +839,7 @@ module Gem
end
error.name = gem.name
- error.version_requirement = gem.requirement
+ error.requirement = gem.requirement
raise error
end
@@ -812,9 +901,7 @@ module Gem
# The GemPathSearcher object used to search for matching installed gems.
def self.searcher
- MUTEX.synchronize do
- @searcher ||= Gem::GemPathSearcher.new
- end
+ @searcher ||= Gem::GemPathSearcher.new
end
##
@@ -895,8 +982,14 @@ module Gem
# Suffixes for require-able paths.
def self.suffixes
- ['', '.rb', ".#{RbConfig::CONFIG["DLEXT"]}"]
- end unless defined?(suffixes)
+ @suffixes ||= ['',
+ '.rb',
+ *%w(DLEXT DLEXT2).map { |key|
+ val = RbConfig::CONFIG[key]
+ ".#{val}" unless val.empty?
+ }
+ ].compact.uniq
+ end
##
# Prints the amount of time the supplied block takes to run using the debug
@@ -952,11 +1045,9 @@ module Gem
end
##
- # Find all 'rubygems_plugin' files and load them
-
- def self.load_plugins
- plugins = Gem.find_files 'rubygems_plugin'
+ # Load +plugins+ as ruby files
+ def self.load_plugin_files(plugins)
plugins.each do |plugin|
# Skip older versions of the GemCutter plugin: Its commands are in
@@ -973,6 +1064,31 @@ module Gem
end
end
+ ##
+ # Find all 'rubygems_plugin' files in installed gems and load them
+
+ def self.load_plugins
+ load_plugin_files find_files('rubygems_plugin', false)
+ end
+
+ ##
+ # Find all 'rubygems_plugin' files in $LOAD_PATH and load them
+
+ def self.load_env_plugins
+ path = "rubygems_plugin"
+
+ files = []
+ $LOAD_PATH.each do |load_path|
+ globbed = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
+
+ globbed.each do |load_path_file|
+ files << load_path_file if File.file?(load_path_file.untaint)
+ end
+ end
+
+ load_plugin_files files
+ end
+
class << self
##
@@ -1014,21 +1130,27 @@ module Gem
MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"
- ##
- # Location of legacy YAML quick gemspecs on remote repositories
-
- YAML_SPEC_DIR = 'quick/'
-
+ autoload :Version, 'rubygems/version'
+ autoload :Requirement, 'rubygems/requirement'
+ autoload :Dependency, 'rubygems/dependency'
+ autoload :GemPathSearcher, 'rubygems/gem_path_searcher'
+ autoload :SpecFetcher, 'rubygems/spec_fetcher'
+ autoload :Specification, 'rubygems/specification'
+ autoload :Cache, 'rubygems/source_index'
+ autoload :SourceIndex, 'rubygems/source_index'
+ autoload :Platform, 'rubygems/platform'
+ autoload :Builder, 'rubygems/builder'
+ autoload :ConfigFile, 'rubygems/config_file'
end
module Kernel
- remove_method :gem if respond_to?(:gem, true) # defined in gem_prelude.rb on 1.9
+ remove_method :gem if respond_to? :gem # defined in gem_prelude.rb on 1.9
##
# Use Kernel#gem to activate a specific version of +gem_name+.
#
- # +version_requirements+ is a list of version requirements that the
+ # +requirements+ is a list of version requirements that the
# specified gem must match, most commonly "= example.version.number". See
# Gem::Requirement for how to specify a version requirement.
#
@@ -1051,10 +1173,10 @@ module Kernel
#
# GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
- def gem(gem_name, *version_requirements) # :doc:
+ def gem(gem_name, *requirements) # :doc:
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
- Gem.activate(gem_name, *version_requirements)
+ Gem.activate(gem_name, *requirements)
end
private :gem
@@ -1068,54 +1190,40 @@ end
# "#{ConfigMap[:datadir]}/#{package_name}".
def RbConfig.datadir(package_name)
+ require 'rbconfig/datadir' # TODO Deprecate after June 2010.
Gem.datadir(package_name) ||
File.join(Gem::ConfigMap[:datadir], package_name)
end
require 'rubygems/exceptions'
-require 'rubygems/version'
-require 'rubygems/requirement'
-require 'rubygems/dependency'
-require 'rubygems/gem_path_searcher' # Needed for Kernel#gem
-require 'rubygems/source_index' # Needed for Kernel#gem
-require 'rubygems/platform'
-require 'rubygems/builder' # HACK: Needed for rake's package task.
-begin
- ##
- # Defaults the operating system (or packager) wants to provide for RubyGems.
-
- require 'rubygems/defaults/operating_system'
-rescue LoadError
-end
-
-if defined?(RUBY_ENGINE) then
+unless gem_preluded then # TODO: remove guard after 1.9.2 dropped
begin
##
- # Defaults the ruby implementation wants to provide for RubyGems
+ # Defaults the operating system (or packager) wants to provide for RubyGems.
- require "rubygems/defaults/#{RUBY_ENGINE}"
+ require 'rubygems/defaults/operating_system'
rescue LoadError
end
-end
-
-require 'rubygems/config_file'
-class << Gem
- remove_method :try_activate if Gem.respond_to?(:try_activate, true)
+ if defined?(RUBY_ENGINE) then
+ begin
+ ##
+ # Defaults the ruby implementation wants to provide for RubyGems
- def try_activate(path)
- spec = Gem.searcher.find(path)
- return false unless spec
-
- Gem.activate(spec.name, "= #{spec.version}")
- return true
+ require "rubygems/defaults/#{RUBY_ENGINE}"
+ rescue LoadError
+ end
end
end
-require 'rubygems/custom_require'
+##
+# Enables the require hook for RubyGems.
+#
+# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem
+# constant at rubygems.rb load time.
-Gem.clear_paths
+require 'rubygems/custom_require' unless RUBY_VERSION > '1.9'
-Gem.load_plugins
+Gem.clear_paths
diff --git a/lib/rubygems/builder.rb b/lib/rubygems/builder.rb
index 2bcd4b0bb3..a5f8fec352 100644
--- a/lib/rubygems/builder.rb
+++ b/lib/rubygems/builder.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -6,6 +12,16 @@
require 'rubygems/user_interaction'
+begin
+ require 'psych'
+rescue LoadError
+end
+
+Gem.load_yaml
+
+require 'rubygems/package'
+require 'rubygems/security'
+
##
# The Builder class processes RubyGem specification files
# to produce a .gem file.
@@ -20,10 +36,6 @@ class Gem::Builder
# spec:: [Gem::Specification] The specification instance
def initialize(spec)
- require "yaml"
- require "rubygems/package"
- require "rubygems/security"
-
@spec = spec
end
@@ -72,7 +84,8 @@ EOM
def write_package
open @spec.file_name, 'wb' do |gem_io|
Gem::Package.open gem_io, 'w', @signer do |pkg|
- pkg.metadata = @spec.to_yaml
+ yaml = @spec.to_yaml
+ pkg.metadata = yaml
@spec.files.each do |file|
next if File.directory? file
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index f3961f1821..98503cb40f 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -146,15 +152,23 @@ class Gem::Command
end
##
- #
# Display to the user that a gem couldn't be found and reasons why
- def show_lookup_failure(gem_name, version, errors=nil)
+
+ def show_lookup_failure(gem_name, version, errors, domain)
if errors and !errors.empty?
alert_error "Could not find a valid gem '#{gem_name}' (#{version}), here is why:"
errors.each { |x| say " #{x.wordy}" }
else
alert_error "Could not find a valid gem '#{gem_name}' (#{version}) in any repository"
end
+
+ unless domain == :local then # HACK
+ suggestions = Gem::SpecFetcher.fetcher.suggest_gems_from_name gem_name
+
+ unless suggestions.empty?
+ alert_error "Possible alternatives: #{suggestions.join(", ")}"
+ end
+ end
end
##
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
index 176e6a0bb4..60d82c865e 100644
--- a/lib/rubygems/command_manager.rb
+++ b/lib/rubygems/command_manager.rb
@@ -1,10 +1,15 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require 'timeout'
require 'rubygems/command'
require 'rubygems/user_interaction'
@@ -42,6 +47,7 @@ class Gem::CommandManager
# Register all the subcommands supported by the gem command.
def initialize
+ require 'timeout'
@commands = {}
register_command :build
register_command :cert
@@ -56,7 +62,6 @@ class Gem::CommandManager
register_command :install
register_command :list
register_command :lock
- register_command :mirror
register_command :outdated
register_command :owner
register_command :pristine
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index c1ba9d2a63..5aac489459 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/builder'
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index f5b698855b..17eaaa113f 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/security'
@@ -59,21 +65,21 @@ class Gem::Commands::CertCommand < Gem::Command
add_option('-C', '--certificate CERT',
'Certificate for --sign command.') do |value, options|
cert = OpenSSL::X509::Certificate.new(File.read(value))
- Gem::Security::OPT[:issuer_cert] = cert
+ options[:issuer_cert] = cert
end
add_option('-K', '--private-key KEY',
'Private key for --sign command.') do |value, options|
key = OpenSSL::PKey::RSA.new(File.read(value))
- Gem::Security::OPT[:issuer_key] = key
+ options[:issuer_key] = key
end
add_option('-s', '--sign NEWCERT',
'Sign a certificate with my key and',
'certificate.') do |value, options|
cert = OpenSSL::X509::Certificate.new(File.read(value))
- my_cert = Gem::Security::OPT[:issuer_cert]
- my_key = Gem::Security::OPT[:issuer_key]
+ my_cert = options[:issuer_cert]
+ my_key = options[:issuer_key]
cert = Gem::Security.sign_cert(cert, my_key, my_cert)
File.open(value, 'wb') { |file| file.write(cert.to_pem) }
end
diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb
index 0bfad9b97c..d739244bed 100644
--- a/lib/rubygems/commands/check_command.rb
+++ b/lib/rubygems/commands/check_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/version_option'
require 'rubygems/validator'
@@ -21,25 +27,10 @@ class Gem::Commands::CheckCommand < Gem::Command
options[:alien] = true
end
- add_option('-v', '--verbose', "Spew more words") do |value, options|
- options[:verbose] = true
- end
-
- add_option('-t', '--test', "Run unit tests for gem") do |value, options|
- options[:test] = true
- end
-
- add_version_option 'run tests for'
+ add_version_option 'check'
end
def execute
- if options[:test]
- version = options[:version] || Gem::Requirement.default
- dep = Gem::Dependency.new get_one_gem_name, version
- gem_spec = Gem::SourceIndex.from_installed_gems.search(dep).first
- Gem::Validator.new.unit_test(gem_spec)
- end
-
if options[:alien]
say "Performing the 'alien' operation"
say
@@ -52,7 +43,7 @@ class Gem::Commands::CheckCommand < Gem::Command
say " #{error_entry.problem}"
end
else
- say "#{key} is error-free" if options[:verbose]
+ say "#{key} is error-free" if Gem.configuration.verbose
end
say
end
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index 1b6e405782..0cdf50433e 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/source_index'
require 'rubygems/dependency_list'
@@ -8,7 +14,7 @@ class Gem::Commands::CleanupCommand < Gem::Command
def initialize
super 'cleanup',
'Clean up old versions of installed gems in the local repository',
- :force => false, :test => false, :install_dir => Gem.dir
+ :force => false, :install_dir => Gem.dir
add_option('-d', '--dryrun', "") do |value, options|
options[:dryrun] = true
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index a49918689c..42ae913b01 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/version_option'
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index 649e3c2d2d..98d6b42893 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
@@ -76,25 +82,13 @@ class Gem::Commands::DependencyCommand < Gem::Command
if remote? and not options[:reverse_dependencies] then
fetcher = Gem::SpecFetcher.fetcher
- begin
- specs_and_sources = fetcher.find_matching(dependency, false, true,
- dependency.prerelease?)
-
- specs_and_sources.each do |spec_tuple, source_uri|
- spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
-
- source_indexes[source_uri].add_spec spec
- end
- rescue Gem::RemoteFetcher::FetchError => e
- raise unless fetcher.warn_legacy e do
- require 'rubygems/source_info_cache'
+ specs_and_sources = fetcher.find_matching(dependency, false, true,
+ dependency.prerelease?)
- specs = Gem::SourceInfoCache.search_with_source dependency, false
+ specs_and_sources.each do |spec_tuple, source_uri|
+ spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
- specs.each do |spec, source_uri|
- source_indexes[source_uri].add_spec spec
- end
- end
+ source_indexes[source_uri].add_spec spec
end
end
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
index a8284b4bf6..f8de984547 100644
--- a/lib/rubygems/commands/environment_command.rb
+++ b/lib/rubygems/commands/environment_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
class Gem::Commands::EnvironmentCommand < Gem::Command
@@ -13,6 +19,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
gempath display path used to search for gems
version display the gem format version
remotesources display the remote gem servers
+ platform display the supporte gem platforms
<omitted> display everything
EOF
return args.gsub(/^\s+/, '')
@@ -32,8 +39,6 @@ is a YAML file with the following YAML keys:
levels
:update_sources: Enable/disable automatic updating of repository metadata
:backtrace: Print backtrace when RubyGems encounters an error
- :bulk_threshold: Switch to a bulk update when this many sources are out of
- date (legacy setting)
:gempath: The paths in which to look for gems
gem_command: A string containing arguments for the specified gem command
@@ -76,6 +81,8 @@ lib/rubygems/defaults/operating_system.rb
out << Gem.path.join(File::PATH_SEPARATOR)
when /^remotesources/ then
out << Gem.sources.join("\n")
+ when /^platform/ then
+ out << Gem.platforms.join(File::PATH_SEPARATOR)
when nil then
out = "RubyGems Environment:\n"
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 43229c0512..a95f1e4fb6 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
@@ -52,7 +58,7 @@ class Gem::Commands::FetchCommand < Gem::Command
spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
if spec.nil? then
- show_lookup_failure gem_name, version, errors
+ show_lookup_failure gem_name, version, errors, options[:domain]
next
end
diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb
index 945d32383c..bd074fd5ec 100644
--- a/lib/rubygems/commands/generate_index_command.rb
+++ b/lib/rubygems/commands/generate_index_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/indexer'
@@ -19,8 +25,7 @@ class Gem::Commands::GenerateIndexCommand < Gem::Command
end
add_option '--[no-]legacy',
- 'Generate indexes for RubyGems older than',
- '1.2.0' do |value, options|
+ 'Generate Marshal.4.8' do |value, options|
unless options[:build_modern] or value then
raise OptionParser::InvalidOption, 'no indicies will be built'
end
@@ -87,20 +92,12 @@ When done, it will generate a set of files like this:
quick/Marshal.<version>/<gemname>.gemspec.rz # Marshal quick index file
# these files support legacy RubyGems
- quick/index
- quick/index.rz # quick index manifest
- quick/<gemname>.gemspec.rz # legacy YAML quick index
- # file
Marshal.<version>
Marshal.<version>.Z # Marshal full index
- yaml
- yaml.Z # legacy YAML full index
The .Z and .rz extension files are compressed with the inflate algorithm.
The Marshal version number comes from ruby's Marshal::MAJOR_VERSION and
Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
-The yaml indexes exist for legacy RubyGems clients and fallback in case of
-Marshal version changes.
If --rss-host and --rss-gem-host are given an RSS feed will be generated at
index.rss containing gems released in the last two days.
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 0c4a4ec16f..16921ead37 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
class Gem::Commands::HelpCommand < Gem::Command
@@ -14,11 +20,6 @@ Some examples of 'gem' usage.
gem install rake --remote
-* Install 'rake' from remote server, and run unit tests,
- and generate RDocs:
-
- gem install --remote rake --test --rdoc --ri
-
* Install 'rake', but only version 0.3.1, even if dependencies
are not met, and into a user-specific directory:
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 06a89eeb0a..530f746e89 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/doc_manager'
require 'rubygems/install_update_options'
@@ -22,7 +28,6 @@ class Gem::Commands::InstallCommand < Gem::Command
:generate_rdoc => true,
:generate_ri => true,
:format_executable => false,
- :test => false,
:version => Gem::Requirement.default,
})
@@ -41,7 +46,7 @@ class Gem::Commands::InstallCommand < Gem::Command
def defaults_str # :nodoc:
"--both --version '#{Gem::Requirement.default}' --rdoc --ri --no-force\n" \
- "--no-test --install-dir #{Gem.dir}"
+ "--install-dir #{Gem.dir}"
end
def description # :nodoc:
@@ -115,6 +120,8 @@ to write the specification by hand. For example:
get_all_gem_names.each do |gem_name|
begin
+ next if options[:conservative] && Gem.available?(gem_name, options[:version])
+
inst = Gem::DependencyInstaller.new options
inst.install gem_name, options[:version]
@@ -127,7 +134,7 @@ to write the specification by hand. For example:
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
rescue Gem::GemNotFoundException => e
- show_lookup_failure e.name, e.version, e.errors
+ show_lookup_failure e.name, e.version, e.errors, options[:domain]
exit_code |= 2
end
@@ -154,19 +161,6 @@ to write the specification by hand. For example:
Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
end
end
-
- if options[:test] then
- installed_gems.each do |spec|
- gem_spec = Gem::SourceIndex.from_installed_gems.find_name(spec.name, spec.version.version).first
- result = Gem::Validator.new.unit_test(gem_spec)
- if result and not result.passed?
- unless ask_yes_no("...keep Gem?", true)
- require 'rubygems/uninstaller'
- Gem::Uninstaller.new(spec.name, :version => spec.version.version).uninstall
- end
- end
- end
- end
end
raise Gem::SystemExitException, exit_code
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index f3e5da9551..267c20f432 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/commands/query_command'
diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb
index 5a43978dd9..a17dd36d7a 100644
--- a/lib/rubygems/commands/lock_command.rb
+++ b/lib/rubygems/commands/lock_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
class Gem::Commands::LockCommand < Gem::Command
@@ -75,7 +81,7 @@ lock it down to the exact version.
until pending.empty? do
full_name = pending.shift
- spec = Gem::SourceIndex.load_specification spec_path(full_name)
+ spec = Gem::Specification.load spec_path(full_name)
if spec.nil? then
complain "Could not find gem #{full_name}, try using the full name"
diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb
deleted file mode 100644
index 7cb8583326..0000000000
--- a/lib/rubygems/commands/mirror_command.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-require 'yaml'
-require 'zlib'
-
-require 'rubygems/command'
-require 'open-uri'
-
-class Gem::Commands::MirrorCommand < Gem::Command
-
- def initialize
- super 'mirror', 'Mirror a gem repository'
- end
-
- def description # :nodoc:
- <<-EOF
-The mirror command uses the ~/.gemmirrorrc config file to mirror remote gem
-repositories to a local path. The config file is a YAML document that looks
-like this:
-
- ---
- - from: http://gems.example.com # source repository URI
- to: /path/to/mirror # destination directory
-
-Multiple sources and destinations may be specified.
- EOF
- end
-
- def execute
- config_file = File.join Gem.user_home, '.gemmirrorrc'
-
- raise "Config file #{config_file} not found" unless File.exist? config_file
-
- mirrors = YAML.load_file config_file
-
- raise "Invalid config file #{config_file}" unless mirrors.respond_to? :each
-
- mirrors.each do |mir|
- raise "mirror missing 'from' field" unless mir.has_key? 'from'
- raise "mirror missing 'to' field" unless mir.has_key? 'to'
-
- get_from = mir['from']
- save_to = File.expand_path mir['to']
-
- raise "Directory not found: #{save_to}" unless File.exist? save_to
- raise "Not a directory: #{save_to}" unless File.directory? save_to
-
- gems_dir = File.join save_to, "gems"
-
- if File.exist? gems_dir then
- raise "Not a directory: #{gems_dir}" unless File.directory? gems_dir
- else
- Dir.mkdir gems_dir
- end
-
- source_index_data = ''
-
- say "fetching: #{get_from}/Marshal.#{Gem.marshal_version}.Z"
-
- get_from = URI.parse get_from
-
- if get_from.scheme.nil? then
- get_from = get_from.to_s
- elsif get_from.scheme == 'file' then
- # check if specified URI contains a drive letter (file:/D:/Temp)
- get_from = get_from.to_s
- get_from = if get_from =~ /^file:.*[a-z]:/i then
- get_from[6..-1]
- else
- get_from[5..-1]
- end
- end
-
- open File.join(get_from.to_s, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y|
- source_index_data = Zlib::Inflate.inflate y.read
- open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out|
- out.write source_index_data
- end
- end
-
- source_index = Marshal.load source_index_data
-
- progress = ui.progress_reporter source_index.size,
- "Fetching #{source_index.size} gems"
- source_index.each do |fullname, gem|
- gem_file = gem.file_name
- gem_dest = File.join gems_dir, gem_file
-
- unless File.exist? gem_dest then
- begin
- open "#{get_from}/gems/#{gem_file}", "rb" do |g|
- contents = g.read
- open gem_dest, "wb" do |out|
- out.write contents
- end
- end
- rescue
- old_gf = gem_file
- gem_file = gem_file.downcase
- retry if old_gf != gem_file
- alert_error $!
- end
- end
-
- progress.updated gem_file
- end
-
- progress.done
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb
index 9e054f988c..0a9a87060e 100644
--- a/lib/rubygems/commands/outdated_command.rb
+++ b/lib/rubygems/commands/outdated_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/spec_fetcher'
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index e88734e8fb..8b770e6f54 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/gemcutter_utilities'
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index ef11129d2c..64ea8ce91c 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -1,4 +1,9 @@
-require 'fileutils'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/format'
require 'rubygems/installer'
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index cabcd3d94d..e72b74ebbf 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/gemcutter_utilities'
@@ -21,6 +27,13 @@ class Gem::Commands::PushCommand < Gem::Command
def initialize
super 'push', description
add_proxy_option
+
+ add_option(
+ '--host HOST',
+ 'Push to another gemcutter-compatible host'
+ ) do |value, options|
+ options[:host] = value
+ end
end
def execute
@@ -29,9 +42,13 @@ class Gem::Commands::PushCommand < Gem::Command
end
def send_gem name
- say "Pushing gem to RubyGems.org..."
+ say "Pushing gem to #{options[:host] || Gem.host}..."
+
+ args = [:post, "api/v1/gems"]
+
+ args << options[:host] if options[:host]
- response = rubygems_api_request :post, "api/v1/gems" do |request|
+ response = rubygems_api_request(*args) do |request|
request.body = Gem.read_binary name
request.add_field "Content-Length", request.body.size
request.add_field "Content-Type", "application/octet-stream"
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index 65258fd1ac..29e53065e7 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/spec_fetcher'
@@ -108,31 +114,11 @@ class Gem::Commands::QueryCommand < Gem::Command
all = options[:all]
- begin
- fetcher = Gem::SpecFetcher.fetcher
- spec_tuples = fetcher.find_matching dep, all, false, prerelease
-
- spec_tuples += fetcher.find_matching dep, false, false, true if
- prerelease and all
- rescue Gem::RemoteFetcher::FetchError => e
- if prerelease then
- raise Gem::OperationNotSupportedError,
- "Prereleases not supported on legacy repositories"
- end
-
- raise unless fetcher.warn_legacy e do
- require 'rubygems/source_info_cache'
-
- dep.name = '' if dep.name == //
+ fetcher = Gem::SpecFetcher.fetcher
+ spec_tuples = fetcher.find_matching dep, all, false, prerelease
- specs = Gem::SourceInfoCache.search_with_source dep, false, all
-
- spec_tuples = specs.map do |spec, source_uri|
- [[spec.name, spec.version, spec.original_platform, spec],
- source_uri]
- end
- end
- end
+ spec_tuples += fetcher.find_matching dep, false, false, true if
+ prerelease and all
output_query_results spec_tuples
end
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index ea0f3ad592..d7912fd279 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/version_option'
require 'rubygems/doc_manager'
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index 52e96fd1ef..1d1c194dac 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/commands/query_command'
diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb
index 1760700e27..0d18a82201 100644
--- a/lib/rubygems/commands/server_command.rb
+++ b/lib/rubygems/commands/server_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/server'
@@ -43,6 +49,14 @@ class Gem::Commands::ServerCommand < Gem::Command
options[:addresses] ||= []
options[:addresses].push(*address)
end
+
+ add_option '-l', '--launch[=COMMAND]',
+ 'launches a browser window',
+ "COMMAND defaults to 'start' on Windows",
+ "and 'open' on all other platforms" do |launch, options|
+ launch ||= Gem.win_platform? ? 'start' : 'open'
+ options[:launch] = launch
+ end
end
def defaults_str # :nodoc:
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 4bc115eaf8..288be22f31 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -1,7 +1,10 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
-require 'fileutils'
-require 'rbconfig'
-require 'tmpdir'
##
# Installs RubyGems itself. This command is ordinarily only available from a
@@ -10,6 +13,8 @@ require 'tmpdir'
class Gem::Commands::SetupCommand < Gem::Command
def initialize
+ require 'tmpdir'
+
super 'setup', 'Install RubyGems',
:format_executable => true, :rdoc => true, :ri => true,
:site_or_vendor => :sitelibdir,
@@ -98,6 +103,7 @@ By default, this RubyGems will install gem as:
check_ruby_version
+ require 'fileutils'
if Gem.configuration.really_verbose then
extend FileUtils::Verbose
else
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index 245ab91c9f..571e664272 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -1,4 +1,9 @@
-require 'fileutils'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/remote_fetcher'
require 'rubygems/source_info_cache'
@@ -10,6 +15,8 @@ class Gem::Commands::SourcesCommand < Gem::Command
include Gem::LocalRemoteOptions
def initialize
+ require 'fileutils'
+
super 'sources',
'Manage the sources and cache file RubyGems uses to search for gems'
@@ -79,23 +86,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
rescue URI::Error, ArgumentError
say "#{source_uri} is not a URI"
rescue Gem::RemoteFetcher::FetchError => e
- yaml_uri = uri + 'yaml'
- gem_repo = Gem::RemoteFetcher.fetcher.fetch_size yaml_uri rescue false
-
- if e.uri =~ /specs\.#{Regexp.escape Gem.marshal_version}\.gz$/ and
- gem_repo then
-
- alert_warning <<-EOF
-RubyGems 1.2+ index not found for:
-\t#{source_uri}
-
-Will cause RubyGems to revert to legacy indexes, degrading performance.
- EOF
-
- say "#{source_uri} added to sources"
- else
- say "Error fetching #{source_uri}:\n\t#{e.message}"
- end
+ say "Error fetching #{source_uri}:\n\t#{e.message}"
end
end
@@ -115,15 +106,10 @@ Will cause RubyGems to revert to legacy indexes, degrading performance.
if options[:update] then
fetcher = Gem::SpecFetcher.fetcher
- if fetcher.legacy_repos.empty? then
- Gem.sources.each do |update_uri|
- update_uri = URI.parse update_uri
- fetcher.load_specs update_uri, 'specs'
- fetcher.load_specs update_uri, 'latest_specs'
- end
- else
- Gem::SourceInfoCache.cache true
- Gem::SourceInfoCache.cache.flush
+ Gem.sources.each do |update_uri|
+ update_uri = URI.parse update_uri
+ fetcher.load_specs update_uri, 'specs'
+ fetcher.load_specs update_uri, 'latest_specs'
end
say "source cache successfully updated"
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 07d2c2cf0d..dd2f6bd4da 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -1,4 +1,9 @@
-require 'yaml'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
@@ -11,6 +16,8 @@ class Gem::Commands::SpecificationCommand < Gem::Command
include Gem::VersionOption
def initialize
+ Gem.load_yaml
+
super 'specification', 'Display gem specification (in yaml)',
:domain => :local, :version => Gem::Requirement.default,
:format => :yaml
diff --git a/lib/rubygems/commands/stale_command.rb b/lib/rubygems/commands/stale_command.rb
index 78cbdcc00a..9a024faa6d 100644
--- a/lib/rubygems/commands/stale_command.rb
+++ b/lib/rubygems/commands/stale_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
class Gem::Commands::StaleCommand < Gem::Command
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index db6aeed022..52d5b03edb 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/version_option'
require 'rubygems/uninstaller'
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index 8ed99babbe..5e0bc830f2 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -1,4 +1,9 @@
-require 'fileutils'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/installer'
require 'rubygems/version_option'
@@ -8,6 +13,8 @@ class Gem::Commands::UnpackCommand < Gem::Command
include Gem::VersionOption
def initialize
+ require 'fileutils'
+
super 'unpack', 'Unpack an installed gem to the current directory',
:version => Gem::Requirement.default,
:target => Dir.pwd
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 2e6f11949a..b2f69a5b52 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/command_manager'
require 'rubygems/install_update_options'
@@ -17,8 +23,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
'Update the named gems (or all installed gems) in the local repository',
:generate_rdoc => true,
:generate_ri => true,
- :force => false,
- :test => false
+ :force => false
add_install_update_options
@@ -37,7 +42,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
def defaults_str # :nodoc:
- "--rdoc --ri --no-force --no-test --install-dir #{Gem.dir}"
+ "--rdoc --ri --no-force --install-dir #{Gem.dir}"
end
def usage # :nodoc:
@@ -60,6 +65,19 @@ class Gem::Commands::UpdateCommand < Gem::Command
hig['rubygems-update'] = rubygems_update
options[:user_install] = false
+
+ Gem.source_index.refresh!
+
+ update_gems = Gem.source_index.find_name 'rubygems-update'
+
+ latest_update_gem = update_gems.sort_by { |s| s.version }.last
+
+ say "Updating RubyGems to #{latest_update_gem.version}"
+ installed = do_rubygems_update latest_update_gem.version
+
+ say "RubyGems system software updated" if installed
+
+ return
else
say "Updating installed gems"
@@ -97,35 +115,22 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
end
- if gems_to_update.include? "rubygems-update" then
- Gem.source_index.refresh!
-
- update_gems = Gem.source_index.find_name 'rubygems-update'
-
- latest_update_gem = update_gems.sort_by { |s| s.version }.last
-
- say "Updating RubyGems to #{latest_update_gem.version}"
- installed = do_rubygems_update latest_update_gem.version
-
- say "RubyGems system software updated" if installed
+ if updated.empty? then
+ say "Nothing to update"
else
- if updated.empty? then
- say "Nothing to update"
- else
- say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}"
-
- if options[:generate_ri] then
- updated.each do |gem|
- Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
- end
+ say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}"
- Gem::DocManager.update_ri_cache
+ if options[:generate_ri] then
+ updated.each do |gem|
+ Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
end
- if options[:generate_rdoc] then
- updated.each do |gem|
- Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
- end
+ Gem::DocManager.update_ri_cache
+ end
+
+ if options[:generate_rdoc] then
+ updated.each do |gem|
+ Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
end
end
end
@@ -164,22 +169,8 @@ class Gem::Commands::UpdateCommand < Gem::Command
dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}"
- begin
- fetcher = Gem::SpecFetcher.fetcher
- spec_tuples = fetcher.find_matching dependency
- rescue Gem::RemoteFetcher::FetchError => e
- raise unless fetcher.warn_legacy e do
- require 'rubygems/source_info_cache'
-
- dependency.name = '' if dependency.name == //
-
- specs = Gem::SourceInfoCache.search_with_source dependency
-
- spec_tuples = specs.map do |spec, source_uri|
- [[spec.name, spec.version, spec.original_platform], source_uri]
- end
- end
- end
+ fetcher = Gem::SpecFetcher.fetcher
+ spec_tuples = fetcher.find_matching dependency
matching_gems = spec_tuples.select do |(name, _, platform),|
name == l_name and Gem::Platform.match platform
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index b785f15660..aeb91f203c 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command'
require 'rubygems/gem_path_searcher'
@@ -33,6 +39,7 @@ class Gem::Commands::WhichCommand < Gem::Command
found = false
options[:args].each do |arg|
+ arg = arg.sub(/#{Regexp.union(*EXT)}$/, '')
dirs = $LOAD_PATH
spec = searcher.find arg
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 1a96356fa8..f3593999d3 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -47,10 +53,29 @@ class Gem::ConfigFile
system_config_path =
begin
- require 'etc.so'
+ require "etc"
Etc.sysconfdir
- rescue LoadError
- '/etc'
+ rescue LoadError, NoMethodError
+ begin
+ # TODO: remove after we drop 1.8.7 and 1.9.1
+ require 'Win32API'
+
+ CSIDL_COMMON_APPDATA = 0x0023
+ path = 0.chr * 260
+ if RUBY_VERSION > '1.9' then
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP',
+ 'L', :stdcall
+ SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
+ else
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP',
+ 'L'
+ SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
+ end
+
+ path.strip
+ rescue LoadError
+ "/etc"
+ end
end
SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
@@ -192,7 +217,7 @@ class Gem::ConfigFile
dirname = File.dirname(credentials_path)
Dir.mkdir(dirname) unless File.exists?(dirname)
- require 'yaml'
+ Gem.load_yaml
File.open(credentials_path, 'w') do |f|
f.write config.to_yaml
@@ -202,9 +227,10 @@ class Gem::ConfigFile
end
def load_file(filename)
+ Gem.load_yaml
+
return {} unless filename and File.exists?(filename)
begin
- require 'yaml'
YAML.load(File.read(filename))
rescue ArgumentError
warn "Failed to load #{config_file_name}"
@@ -299,7 +325,6 @@ class Gem::ConfigFile
# Writes out this config file, replacing its source.
def write
- require 'yaml'
open config_file_name, 'w' do |io|
io.write to_yaml
end
diff --git a/lib/rubygems/custom_require.rb b/lib/rubygems/custom_require.rb
index 480cb7e315..88e7aa4c4c 100644
--- a/lib/rubygems/custom_require.rb
+++ b/lib/rubygems/custom_require.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -28,10 +34,8 @@ module Kernel
def require(path) # :doc:
gem_original_require path
rescue LoadError => load_error
- if load_error.message.end_with?(path)
- if Gem.try_activate(path)
- return gem_original_require(path)
- end
+ if load_error.message.end_with?(path) and Gem.try_activate(path) then
+ return gem_original_require(path)
end
raise load_error
@@ -40,5 +44,5 @@ module Kernel
private :require
private :gem_original_require
-end unless Kernel.private_method_defined?(:gem_original_require)
+end
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index 8950d0f73d..63ccd85e2a 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
module Gem
@post_install_hooks ||= []
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index ec5d88b607..d19663e4bd 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require "rubygems/requirement"
##
@@ -5,18 +11,6 @@ require "rubygems/requirement"
class Gem::Dependency
- # :stopdoc:
- @warned_version_requirement = false
-
- def self.warned_version_requirement
- @warned_version_requirement
- end
-
- def self.warned_version_requirement= value
- @warned_version_requirement = value
- end
- # :startdoc:
-
##
# Valid dependency types.
#--
@@ -54,7 +48,7 @@ class Gem::Dependency
unless TYPES.include? type
raise ArgumentError, "Valid types are #{TYPES.inspect}, "
- + "not #{@type.inspect}"
+ + "not #{type.inspect}"
end
@name = name
@@ -88,7 +82,7 @@ class Gem::Dependency
@prerelease || requirement.prerelease?
end
- def pretty_print(q) # :nodoc:
+ def pretty_print q # :nodoc:
q.group 1, 'Gem::Dependency.new(', ')' do
q.pp name
q.text ','
@@ -133,12 +127,6 @@ class Gem::Dependency
@requirement = @version_requirements if defined?(@version_requirements)
end
- ##
- # Rails subclasses Gem::Dependency and uses this method, so we'll hack
- # around it.
-
- alias __requirement requirement # :nodoc:
-
def requirements_list
requirement.as_list
end
@@ -147,30 +135,6 @@ class Gem::Dependency
"#{name} (#{requirement}, #{type})"
end
- def version_requirements # :nodoc:
- unless Gem::Dependency.warned_version_requirement then
- warn "#{Gem.location_of_caller.join ':'}:Warning: " \
- "Gem::Dependency#version_requirements is deprecated " \
- "and will be removed on or after August 2010. " \
- "Use #requirement"
-
- Gem::Dependency.warned_version_requirement = true
- end
-
- __requirement
- end
-
- alias version_requirement version_requirements # :nodoc:
-
- def version_requirements= requirements # :nodoc:
- warn "#{Gem.location_of_caller.join ':'}:Warning: " \
- "Gem::Dependency#version_requirements= is deprecated " \
- "and will be removed on or after August 2010. " \
- "Use Gem::Dependency.new."
-
- @requirement = Gem::Requirement.create requirements
- end
-
def == other # :nodoc:
Gem::Dependency === other &&
self.name == other.name &&
@@ -182,7 +146,7 @@ class Gem::Dependency
# Dependencies are ordered by name.
def <=> other
- [@name] <=> [other.name]
+ @name <=> other.name
end
##
@@ -193,16 +157,11 @@ class Gem::Dependency
def =~ other
unless Gem::Dependency === other
- other = Gem::Dependency.new other.name, other.version rescue return false
+ return unless other.respond_to?(:name) && other.respond_to?(:version)
+ other = Gem::Dependency.new other.name, other.version
end
- pattern = name
-
- if Regexp === pattern then
- return false unless pattern =~ other.name
- else
- return false unless pattern == other.name
- end
+ return false unless name === other.name
reqs = other.requirement.requirements
@@ -214,18 +173,18 @@ class Gem::Dependency
requirement.satisfied_by? version
end
- def match?(spec_name, spec_version)
- pattern = name
+ def match? name, version
+ return false unless self.name === name
+ return true if requirement.none?
- if Regexp === pattern
- return false unless pattern =~ spec_name
- else
- return false unless pattern == spec_name
- end
+ requirement.satisfied_by? Gem::Version.new(version)
+ end
- return true if requirement.none?
+ def matches_spec? spec
+ return false unless name === spec.name
+ return true if requirement.none?
- requirement.satisfied_by? Gem::Version.new(spec_version)
+ requirement.satisfied_by?(spec.version)
end
end
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index 099d223295..3913f36bc2 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems'
require 'rubygems/dependency_list'
require 'rubygems/installer'
@@ -132,41 +138,48 @@ class Gem::DependencyInstaller
dependency_list = Gem::DependencyList.new @development
dependency_list.add(*specs)
+ to_do = specs.dup
- unless @ignore_dependencies then
- to_do = specs.dup
- seen = {}
+ add_found_dependencies to_do, dependency_list unless @ignore_dependencies
- until to_do.empty? do
- spec = to_do.shift
- next if spec.nil? or seen[spec.name]
- seen[spec.name] = true
+ @gems_to_install = dependency_list.dependency_order.reverse
+ end
- deps = spec.runtime_dependencies
- deps |= spec.development_dependencies if @development
+ def add_found_dependencies to_do, dependency_list
+ seen = {}
- deps.each do |dep|
- results = find_gems_with_sources(dep).reverse
+ until to_do.empty? do
+ spec = to_do.shift
+ next if spec.nil? or seen[spec.name]
+ seen[spec.name] = true
- results.reject! do |dep_spec,|
- to_do.push dep_spec
+ deps = spec.runtime_dependencies
+ deps |= spec.development_dependencies if @development
- @source_index.any? do |_, installed_spec|
- dep.name == installed_spec.name and
- dep.requirement.satisfied_by? installed_spec.version
- end
- end
+ deps.each do |dep|
+ results = find_gems_with_sources(dep).reverse
+
+ # FIX: throw in everything that satisfies, and let
+ # FIX: dependencylist reduce to the chosen few
+ results.reject! do |dep_spec,|
+ to_do.push dep_spec
- results.each do |dep_spec, source_uri|
- next if seen[dep_spec.name]
- @specs_and_sources << [dep_spec, source_uri]
- dependency_list.add dep_spec
+ # already locally installed
+ @source_index.any? do |_, installed_spec|
+ dep.name == installed_spec.name and
+ dep.requirement.satisfied_by? installed_spec.version
end
end
+
+ results.each do |dep_spec, source_uri|
+ next if seen[dep_spec.name]
+ @specs_and_sources << [dep_spec, source_uri]
+
+ # FIX: this is the bug
+ dependency_list.add dep_spec
+ end
end
end
-
- @gems_to_install = dependency_list.dependency_order.reverse
end
##
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
index 25d469d68c..647bb91ae2 100644
--- a/lib/rubygems/dependency_list.rb
+++ b/lib/rubygems/dependency_list.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -187,6 +193,7 @@ class Gem::DependencyList
begin
yield spec
rescue TSort::Cyclic
+ # do nothing
end
break
end
@@ -201,13 +208,7 @@ class Gem::DependencyList
# +ignored+.
def active_count(specs, ignored)
- result = 0
-
- specs.each do |spec|
- result += 1 unless ignored[spec.full_name]
- end
-
- result
+ specs.count { |spec| ignored[spec.full_name].nil? }
end
end
diff --git a/lib/rubygems/doc_manager.rb b/lib/rubygems/doc_manager.rb
index b38fce1aba..055aa22f13 100644
--- a/lib/rubygems/doc_manager.rb
+++ b/lib/rubygems/doc_manager.rb
@@ -1,10 +1,15 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require 'fileutils'
require 'rubygems'
##
@@ -85,6 +90,7 @@ class Gem::DocManager
# RDoc (template etc.) as a String.
def initialize(spec, rdoc_args="")
+ require 'fileutils'
@spec = spec
@doc_dir = File.join(spec.installation_path, "doc", spec.full_name)
@rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index 950b34d744..878a8a41b0 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
class Gem::ErrorReason; end
# Generated when trying to lookup a gem to indicate that the gem
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 55d67f9125..7668d4ee0b 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
##
# Base exception class for RubyGems. All exception raised by RubyGems are a
# subclass of this one.
diff --git a/lib/rubygems/ext.rb b/lib/rubygems/ext.rb
index 97ee762a4a..8cce7a06ba 100644
--- a/lib/rubygems/ext.rb
+++ b/lib/rubygems/ext.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index c029bbe1e9..89242aff08 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -22,7 +28,9 @@ class Gem::Ext::Builder
File.open('Makefile', 'wb') {|f| f.print mf}
- make_program = ENV['make']
+ # try to find make program from Ruby configue arguments first
+ RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
+ make_program = $1 || ENV['make']
unless make_program then
make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
end
diff --git a/lib/rubygems/ext/configure_builder.rb b/lib/rubygems/ext/configure_builder.rb
index c2087eb5ad..660505702a 100644
--- a/lib/rubygems/ext/configure_builder.rb
+++ b/lib/rubygems/ext/configure_builder.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
index b3d588dc9c..ec3275d43a 100644
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ b/lib/rubygems/ext/ext_conf_builder.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
index 3b45ef4369..d3b5cba75c 100644
--- a/lib/rubygems/ext/rake_builder.rb
+++ b/lib/rubygems/ext/rake_builder.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -19,7 +25,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
# Deal with possible spaces in the path, e.g. C:/Program Files
dest_path = '"' + dest_path + '"' if dest_path.include?(' ')
- cmd = ENV['rake'] || "#{Gem.ruby} -rubygems #{Gem.bin_path('rake')}" rescue Gem.default_exec_format % 'rake'
+ cmd = ENV['rake'] || "\"#{Gem.ruby}\" -rubygems #{Gem.bin_path('rake')}" rescue Gem.default_exec_format % 'rake'
cmd += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
run cmd, results
diff --git a/lib/rubygems/format.rb b/lib/rubygems/format.rb
index d4c66d9f85..9f8e7b8fb9 100644
--- a/lib/rubygems/format.rb
+++ b/lib/rubygems/format.rb
@@ -1,11 +1,15 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require 'fileutils'
-
require 'rubygems/package'
##
diff --git a/lib/rubygems/gem_openssl.rb b/lib/rubygems/gem_openssl.rb
index ade95641bf..5c33cac8c6 100644
--- a/lib/rubygems/gem_openssl.rb
+++ b/lib/rubygems/gem_openssl.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -42,9 +48,7 @@ begin
# Reference a constant defined in the .rb portion of ssl (just to
# make sure that part is loaded too).
- OpenSSL::Digest::SHA1
-
- Gem.ssl_available = true
+ Gem.ssl_available = !!OpenSSL::Digest::SHA1
class OpenSSL::X509::Certificate # :nodoc:
# Check the validity of this certificate.
diff --git a/lib/rubygems/gem_path_searcher.rb b/lib/rubygems/gem_path_searcher.rb
index 6ee3c078d5..9dae006222 100644
--- a/lib/rubygems/gem_path_searcher.rb
+++ b/lib/rubygems/gem_path_searcher.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
##
# GemPathSearcher has the capability to find loadable files inside
# gems. It generates data up front to speed up searches later.
@@ -22,7 +28,7 @@ class Gem::GemPathSearcher
end
##
- # Look in all the installed gems until a matching _path_ is found.
+ # Look in all the installed gems until a matching +glob+ is found.
# Return the _gemspec_ of the gem where it was found. If no match
# is found, return nil.
#
@@ -41,16 +47,18 @@ class Gem::GemPathSearcher
# This method doesn't care about the full filename that matches;
# only that there is a match.
- def find(path)
- @gemspecs.find do |spec| matching_file? spec, path end
+ def find(glob)
+ @gemspecs.find do |spec|
+ matching_file? spec, glob
+ end
end
##
- # Works like #find, but finds all gemspecs matching +path+.
+ # Works like #find, but finds all gemspecs matching +glob+.
- def find_all(path)
+ def find_all(glob)
@gemspecs.select do |spec|
- matching_file? spec, path
+ matching_file? spec, glob
end
end
diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb
index 07a792dd9b..1c432ba494 100644
--- a/lib/rubygems/gem_runner.rb
+++ b/lib/rubygems/gem_runner.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -9,6 +15,11 @@ require 'rubygems/config_file'
require 'rubygems/doc_manager'
##
+# Load additional plugins from $LOAD_PATH
+
+Gem.load_env_plugins rescue nil
+
+##
# Run an instance of the gem program.
#
# Gem::GemRunner is only intended for internal use by RubyGems itself. It
@@ -76,3 +87,4 @@ class Gem::GemRunner
end
+Gem.load_plugins
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 225bd704f9..1681356805 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -1,4 +1,9 @@
-require 'net/http'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/remote_fetcher'
module Gem::GemcutterUtilities
@@ -23,8 +28,9 @@ module Gem::GemcutterUtilities
end
end
- def rubygems_api_request(method, path, &block)
- host = ENV['RUBYGEMS_HOST'] || 'https://rubygems.org'
+ def rubygems_api_request(method, path, host = Gem.host, &block)
+ require 'net/http'
+ host = ENV['RUBYGEMS_HOST'] if ENV['RUBYGEMS_HOST']
uri = URI.parse "#{host}/#{path}"
request_method = Net::HTTP.const_get method.to_s.capitalize
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index f85fe8467d..e1265c2d34 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -1,6 +1,8 @@
-require 'fileutils'
-require 'tmpdir'
-require 'zlib'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
require 'rubygems'
require 'rubygems/format'
@@ -57,6 +59,10 @@ class Gem::Indexer
# Create an indexer that will index the gems in +directory+.
def initialize(directory, options = {})
+ require 'fileutils'
+ require 'tmpdir'
+ require 'zlib'
+
unless ''.respond_to? :to_xs then
raise "Gem::Indexer requires that the XML Builder library be installed:" \
"\n\tgem install builder"
@@ -136,42 +142,6 @@ class Gem::Indexer
# Builds indicies for RubyGems older than 1.2.x
def build_legacy_indicies(index)
- progress = ui.progress_reporter index.size,
- "Generating YAML quick index gemspecs for #{index.size} gems",
- "Complete"
-
- Gem.time 'Generated YAML quick index gemspecs' do
- index.released_gems.each do |original_name, spec|
- spec_file_name = "#{original_name}.gemspec.rz"
- yaml_name = File.join @quick_dir, spec_file_name
-
- yaml_zipped = Gem.deflate spec.to_yaml
- open yaml_name, 'wb' do |io| io.write yaml_zipped end
-
- progress.updated original_name
- end
-
- progress.done
- end
-
- say "Generating quick index"
-
- Gem.time 'Generated quick index' do
- open @quick_index, 'wb' do |io|
- io.puts index.sort.map { |_, spec| spec.original_name }
- end
- end
-
- say "Generating latest index"
-
- Gem.time 'Generated latest index' do
- open @latest_index, 'wb' do |io|
- io.puts index.latest_specs.sort.map { |spec| spec.original_name }
- end
- end
-
- # Don't need prerelease legacy index
-
say "Generating Marshal master index"
Gem.time 'Generated Marshal master index' do
@@ -180,32 +150,6 @@ class Gem::Indexer
end
end
- progress = ui.progress_reporter index.size,
- "Generating YAML master index for #{index.size} gems (this may take a while)",
- "Complete"
-
- Gem.time 'Generated YAML master index' do
- open @master_index, 'wb' do |io|
- io.puts "--- !ruby/object:#{index.class}"
- io.puts "gems:"
-
- gems = index.sort_by { |name, gemspec| gemspec.sort_obj }
- gems.each do |original_name, gemspec|
- yaml = gemspec.to_yaml.gsub(/^/, ' ')
- yaml = yaml.sub(/\A ---/, '') # there's a needed extra ' ' here
- io.print " #{original_name}:"
- io.puts yaml
-
- progress.updated original_name
- end
- end
-
- progress.done
- end
-
- @files << @quick_dir
- @files << @master_index
- @files << "#{@master_index}.Z"
@files << @marshal_index
@files << "#{@marshal_index}.Z"
end
@@ -462,17 +406,8 @@ class Gem::Indexer
Gem.time 'Compressed indicies' do
if @build_legacy then
- compress @quick_index, 'rz'
- paranoid @quick_index, 'rz'
-
- compress @latest_index, 'rz'
- paranoid @latest_index, 'rz'
-
compress @marshal_index, 'Z'
paranoid @marshal_index, 'Z'
-
- compress @master_index, 'Z'
- paranoid @master_index, 'Z'
end
if @build_modern then
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index 4e7f9e7952..f3ec1aa12a 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -58,10 +64,6 @@ module Gem::InstallUpdateOptions
options[:force] = value
end
- add_option(:"Install/Update", '-t', '--[no-]test',
- 'Ignored; just for compatiblity') do |value, options|
- end
-
add_option(:"Install/Update", '-w', '--[no-]wrappers',
'Use bin wrappers for executables',
'Not available on dosish platforms') do |value, options|
@@ -103,6 +105,12 @@ module Gem::InstallUpdateOptions
"dependencies") do |value, options|
options[:development] = true
end
+
+ add_option(:"Install/Update", "--conservative",
+ "Don't attempt to upgrade gems already",
+ "meeting version requirement") do |value, options|
+ options[:conservative] = true
+ end
end
##
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index d942960b2f..3665aa3e0b 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -1,13 +1,17 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require 'fileutils'
-require 'rbconfig'
-
require 'rubygems/format'
+require 'rubygems/exceptions'
require 'rubygems/ext'
require 'rubygems/require_paths_builder'
@@ -40,7 +44,7 @@ class Gem::Installer
include Gem::UserInteraction
- include Gem::RequirePathsBuilder
+ include Gem::RequirePathsBuilder if QUICKLOADER_SUCKAGE
##
# The directory a gem's executables will be installed into
@@ -91,6 +95,8 @@ class Gem::Installer
# :wrappers:: Install wrappers if true, symlinks if false.
def initialize(gem, options={})
+ require 'fileutils'
+
@gem = gem
options = {
@@ -198,7 +204,7 @@ class Gem::Installer
build_extensions
write_spec
- write_require_paths_file_if_needed
+ write_require_paths_file_if_needed if QUICKLOADER_SUCKAGE
# HACK remove? Isn't this done in multiple places?
cached_gem = File.join @gem_home, "cache", @gem.split(/\//).pop
@@ -318,24 +324,15 @@ class Gem::Installer
def generate_bin_script(filename, bindir)
bin_script_path = File.join bindir, formatted_program_filename(filename)
- File.join @gem_dir, @spec.bindir, filename
+ FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
- # HACK some gems don't have #! in their executables, restore 2008/06
- #if File.read(exec_path, 2) == '#!' then
- FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
-
- File.open bin_script_path, 'w', 0755 do |file|
- file.print app_script_text(filename)
- end
+ File.open bin_script_path, 'w', 0755 do |file|
+ file.print app_script_text(filename)
+ end
- say bin_script_path if Gem.configuration.really_verbose
+ say bin_script_path if Gem.configuration.really_verbose
- generate_windows_script filename, bindir
- #else
- # FileUtils.rm_f bin_script_path
- # FileUtils.cp exec_path, bin_script_path,
- # :verbose => Gem.configuration.really_verbose
- #end
+ generate_windows_script filename, bindir
end
##
@@ -497,6 +494,8 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
raise ArgumentError, "format required to extract from" if @format.nil?
+ dirs = []
+
@format.file_entries.each do |entry, file_data|
path = entry['path'].untaint
@@ -514,7 +513,12 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
end
FileUtils.rm_rf(path) if File.exists?(path)
- FileUtils.mkdir_p File.dirname(path)
+
+ dir = File.dirname(path)
+ if !dirs.include?(dir)
+ dirs << dir
+ FileUtils.mkdir_p dir
+ end
File.open(path, "wb") do |out|
out.write file_data
diff --git a/lib/rubygems/local_remote_options.rb b/lib/rubygems/local_remote_options.rb
index e238c7292c..b752423845 100644
--- a/lib/rubygems/local_remote_options.rb
+++ b/lib/rubygems/local_remote_options.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -51,6 +57,7 @@ module Gem::LocalRemoteOptions
end
add_bulk_threshold_option
+ add_clear_sources_option
add_source_option
add_proxy_option
add_update_sources_option
@@ -69,6 +76,18 @@ module Gem::LocalRemoteOptions
end
##
+ # Add the --clear-sources option
+
+ def add_clear_sources_option
+ add_option(:"Local/Remote", '--clear-sources',
+ 'Clear the gem sources') do |value, options|
+
+ Gem.sources.clear
+ options[:sources_cleared] = true
+ end
+ end
+
+ ##
# Add the --http-proxy option
def add_proxy_option
@@ -88,14 +107,14 @@ module Gem::LocalRemoteOptions
accept_uri_http
add_option(:"Local/Remote", '--source URL', URI::HTTP,
- 'Use URL as the remote source for gems') do |source, options|
+ 'Add URL as a remote source for gems') do |source, options|
+
source << '/' if source !~ /\/\z/
- if options[:added_source] then
- Gem.sources << source unless Gem.sources.include?(source)
+ if options.delete :sources_cleared then
+ Gem.sources = [source]
else
- options[:added_source] = true
- Gem.sources.replace [source]
+ Gem.sources << source unless Gem.sources.include?(source)
end
end
end
diff --git a/lib/rubygems/old_format.rb b/lib/rubygems/old_format.rb
index 4cbff51c68..73d36155f4 100644
--- a/lib/rubygems/old_format.rb
+++ b/lib/rubygems/old_format.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -5,9 +11,6 @@
#++
require 'rubygems'
-require 'fileutils'
-require 'yaml'
-require 'zlib'
##
# The format class knows the guts of the RubyGem .gem file format and provides
@@ -24,6 +27,10 @@ class Gem::OldFormat
# gem:: [String] The file name of the gem
def initialize(gem_path)
+ require 'fileutils'
+ require 'zlib'
+ Gem.load_yaml
+
@gem_path = gem_path
end
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 937da584cb..a03263ed1a 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -1,15 +1,15 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
# -*- coding: utf-8 -*-
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
#++
-require 'fileutils'
-require 'find'
-require 'stringio'
-require 'yaml'
-require 'zlib'
-
require 'rubygems/security'
require 'rubygems/specification'
@@ -20,6 +20,7 @@ require 'rubygems/specification'
class Gem::FileOperations
def initialize(logger = nil)
+ require 'fileutils'
@logger = logger
end
diff --git a/lib/rubygems/package/f_sync_dir.rb b/lib/rubygems/package/f_sync_dir.rb
index f7eb7f3ce3..a819939502 100644
--- a/lib/rubygems/package/f_sync_dir.rb
+++ b/lib/rubygems/package/f_sync_dir.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
# -*- coding: utf-8 -*-
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
index 4f923b9b5e..431f8f339b 100644
--- a/lib/rubygems/package/tar_header.rb
+++ b/lib/rubygems/package/tar_header.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
# -*- coding: utf-8 -*-
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
diff --git a/lib/rubygems/package/tar_input.rb b/lib/rubygems/package/tar_input.rb
index 6c286585e9..587d79c493 100644
--- a/lib/rubygems/package/tar_input.rb
+++ b/lib/rubygems/package/tar_input.rb
@@ -1,9 +1,18 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
# -*- coding: iso-8859-1 -*-
#++
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
#--
+require 'zlib'
+Gem.load_yaml
+
class Gem::Package::TarInput
include Gem::Package::FSyncDir
diff --git a/lib/rubygems/package/tar_output.rb b/lib/rubygems/package/tar_output.rb
index 7d99a51127..f3be675e9f 100644
--- a/lib/rubygems/package/tar_output.rb
+++ b/lib/rubygems/package/tar_output.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
# -*- coding: utf-8 -*-
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
diff --git a/lib/rubygems/package/tar_reader.rb b/lib/rubygems/package/tar_reader.rb
index e6a71d386c..0e92221a62 100644
--- a/lib/rubygems/package/tar_reader.rb
+++ b/lib/rubygems/package/tar_reader.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
# -*- coding: utf-8 -*-
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
diff --git a/lib/rubygems/package/tar_reader/entry.rb b/lib/rubygems/package/tar_reader/entry.rb
index eeb70bf000..d5c624f3d5 100644
--- a/lib/rubygems/package/tar_reader/entry.rb
+++ b/lib/rubygems/package/tar_reader/entry.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#++
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb
index d115162a76..aeb11ad6ce 100644
--- a/lib/rubygems/package/tar_writer.rb
+++ b/lib/rubygems/package/tar_writer.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
# -*- coding: utf-8 -*-
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
diff --git a/lib/rubygems/package_task.rb b/lib/rubygems/package_task.rb
index d43dfc8323..2e9c89d834 100644
--- a/lib/rubygems/package_task.rb
+++ b/lib/rubygems/package_task.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
# Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -111,14 +117,14 @@ class Gem::PackageTask < Rake::PackageTask
Gem.configuration.verbose = trace
file gem_path => [package_dir, gem_dir] + @gem_spec.files do
- when_writing "Creating #{gem_spec.file_name}" do
- Gem::Builder.new(gem_spec).build
- verbose trace do
- mv gem_file, gem_path
+ chdir(gem_dir) do
+ when_writing "Creating #{gem_spec.file_name}" do
+ Gem::Builder.new(gem_spec).build
+ verbose(true) {
+ mv gem_file, ".."
+ }
end
end
end
end
-
end
-
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index c9a084707a..b6608c7814 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
##
# Available list of platforms for targeting Gem installations.
@@ -70,7 +76,7 @@ class Gem::Platform
when /hpux(\d+)/ then [ 'hpux', $1 ]
when /^java$/, /^jruby$/ then [ 'java', nil ]
when /^java([\d.]*)/ then [ 'java', $1 ]
- when /^dotnet$/ then [ 'dotnet', nil ]
+ when /^dotnet$/ then [ 'dotnet', nil ]
when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
when /linux/ then [ 'linux', $1 ]
when /mingw32/ then [ 'mingw32', nil ]
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 07cd55b161..aa63392848 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -1,9 +1,12 @@
-require 'net/http'
-require 'stringio'
-require 'time'
-require 'uri'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
require 'rubygems'
+require 'rubygems/user_interaction'
+require 'uri'
##
# RemoteFetcher handles the details of fetching gems and gem information from
@@ -56,6 +59,11 @@ class Gem::RemoteFetcher
# * <tt>:no_proxy</tt>: ignore environment variables and _don't_ use a proxy
def initialize(proxy = nil)
+ require 'net/http'
+ require 'stringio'
+ require 'time'
+ require 'uri'
+
Socket.do_not_reverse_lookup = true
@connections = {}
@@ -75,6 +83,8 @@ class Gem::RemoteFetcher
# always replaced.
def download(spec, source_uri, install_dir = Gem.dir)
+ Gem.ensure_gem_subdirectories(install_dir) rescue nil
+
if File.writable?(install_dir)
cache_dir = File.join install_dir, 'cache'
else
@@ -147,7 +157,7 @@ class Gem::RemoteFetcher
source_uri.path
end
- source_path = URI.unescape source_path
+ source_path = unescape source_path
begin
FileUtils.cp source_path, local_gem_path unless
@@ -191,12 +201,20 @@ class Gem::RemoteFetcher
def escape(str)
return unless str
- URI.escape(str)
+ @uri_parser ||= uri_escaper
+ @uri_parser.escape str
end
def unescape(str)
return unless str
- URI.unescape(str)
+ @uri_parser ||= uri_escaper
+ @uri_parser.unescape str
+ end
+
+ def uri_escaper
+ URI::Parser.new
+ rescue NameError
+ URI
end
##
@@ -241,7 +259,7 @@ class Gem::RemoteFetcher
]
end
- connection_id = net_http_args.join ':'
+ connection_id = [Thread.current.object_id, *net_http_args].join ':'
@connections[connection_id] ||= Net::HTTP.new(*net_http_args)
connection = @connections[connection_id]
@@ -339,7 +357,34 @@ class Gem::RemoteFetcher
say "#{request.method} #{uri}" if
Gem.configuration.really_verbose
- response = connection.request request
+
+ file_name = File.basename(uri.path)
+ # perform download progress reporter only for gems
+ if request.response_body_permitted? && file_name =~ /\.gem$/
+ reporter = ui.download_reporter
+ response = connection.request(request) do |incomplete_response|
+ if Net::HTTPOK === incomplete_response
+ reporter.fetch(file_name, incomplete_response.content_length)
+ downloaded = 0
+ data = ''
+
+ incomplete_response.read_body do |segment|
+ data << segment
+ downloaded += segment.length
+ reporter.update(downloaded)
+ end
+ reporter.done
+ if incomplete_response.respond_to? :body=
+ incomplete_response.body = data
+ else
+ incomplete_response.instance_variable_set(:@body, data)
+ end
+ end
+ end
+ else
+ response = connection.request request
+ end
+
say "#{response.code} #{response.message}" if
Gem.configuration.really_verbose
diff --git a/lib/rubygems/require_paths_builder.rb b/lib/rubygems/require_paths_builder.rb
index 5cf41b9da8..61bc1af920 100644
--- a/lib/rubygems/require_paths_builder.rb
+++ b/lib/rubygems/require_paths_builder.rb
@@ -1,13 +1,24 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems'
+# TODO: remove after 1.9.1 dropped
module Gem::RequirePathsBuilder
def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home)
- require_paths = spec.require_paths
- return if require_paths.size == 1 and require_paths.first == "lib"
- file_name = "#{gem_home}/gems/#{@spec.full_name}/.require_paths".untaint
- File.open(file_name, "wb") do |file|
- file.puts require_paths
+ return if spec.require_paths == ["lib"] &&
+ (spec.bindir.nil? || spec.bindir == "bin")
+ file_name = File.join(gem_home, 'gems', "#{@spec.full_name}", ".require_paths")
+ file_name.untaint
+ File.open(file_name, "w") do |file|
+ spec.require_paths.each do |path|
+ file.puts path
+ end
+ file.puts spec.bindir if spec.bindir
end
end
-end
+end if QUICKLOADER_SUCKAGE
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index d51bf8ffa3..8af5fbd6b4 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require "rubygems/version"
##
@@ -14,7 +20,7 @@ class Gem::Requirement
"<" => lambda { |v, r| v < r },
">=" => lambda { |v, r| v >= r },
"<=" => lambda { |v, r| v <= r },
- "~>" => lambda { |v, r| v = v.release; v >= r && v < r.bump }
+ "~>" => lambda { |v, r| v >= r && v.release < r.bump }
}
quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
index 5cd3fb756f..9f3daa9453 100644
--- a/lib/rubygems/security.rb
+++ b/lib/rubygems/security.rb
@@ -1,12 +1,19 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require 'rubygems'
+require 'rubygems/exceptions'
require 'rubygems/gem_openssl'
+#
# = Signed Gems README
#
# == Table of Contents
@@ -265,6 +272,34 @@ require 'rubygems/gem_openssl'
# A more detailed description of each options is available in the walkthrough
# above.
#
+# == Manually verifying signatures
+#
+# In case you don't trust RubyGems you can verify gem signatures manually:
+#
+# 1. Fetch and unpack the gem
+#
+# gem fetch some_signed_gem
+# tar -xf some_signed_gem-1.0.gem
+#
+# 2. Grab the public key from the gemspec
+#
+# gem spec some_signed_gem-1.0.gem cert_chain | \
+# ruby -pe 'sub(/^ +/, "")' > public_key.crt
+#
+# 3. Generate a SHA1 hash of the data.tar.gz
+#
+# openssl dgst -sha1 < data.tar.gz > my.hash
+#
+# 4. Verify the signature
+#
+# openssl rsautl -verify -inkey public_key.crt -certin \
+# -in data.tar.gz.sig > verified.hash
+#
+# 5. Compare your hash to the verified hash
+#
+# diff -s verified.hash my.hash
+#
+# 6. Repeat 5 and 6 with metadata.gz
#
# == OpenSSL Reference
#
@@ -319,11 +354,14 @@ require 'rubygems/gem_openssl'
module Gem::Security
+ ##
+ # Gem::Security default exception type
+
class Exception < Gem::Exception; end
- #
- # default options for most of the methods below
- #
+ ##
+ # Default options for most of the methods below
+
OPT = {
# private key options
:key_algo => Gem::SSL::PKEY_RSA,
@@ -338,38 +376,38 @@ module Gem::Security
'basicConstraints' => 'CA:FALSE',
'subjectKeyIdentifier' => 'hash',
'keyUsage' => 'keyEncipherment,dataEncipherment,digitalSignature',
- },
-
- # save the key and cert to a file in build_self_signed_cert()?
- :save_key => true,
- :save_cert => true,
-
- # if you define either of these, then they'll be used instead of
- # the output_fmt macro below
- :save_key_path => nil,
- :save_cert_path => nil,
-
- # output name format for self-signed certs
- :output_fmt => 'gem-%s.pem',
- :munge_re => Regexp.new(/[^a-z0-9_.-]+/),
-
- # output directory for trusted certificate checksums
- :trust_dir => File::join(Gem.user_home, '.gem', 'trust'),
-
- # default permissions for trust directory and certs
- :perms => {
- :trust_dir => 0700,
- :trusted_cert => 0600,
- :signing_cert => 0600,
- :signing_key => 0600,
- },
+ },
+
+ # save the key and cert to a file in build_self_signed_cert()?
+ :save_key => true,
+ :save_cert => true,
+
+ # if you define either of these, then they'll be used instead of
+ # the output_fmt macro below
+ :save_key_path => nil,
+ :save_cert_path => nil,
+
+ # output name format for self-signed certs
+ :output_fmt => 'gem-%s.pem',
+ :munge_re => Regexp.new(/[^a-z0-9_.-]+/),
+
+ # output directory for trusted certificate checksums
+ :trust_dir => File::join(Gem.user_home, '.gem', 'trust'),
+
+ # default permissions for trust directory and certs
+ :perms => {
+ :trust_dir => 0700,
+ :trusted_cert => 0600,
+ :signing_cert => 0600,
+ :signing_key => 0600,
+ },
}
- #
+ ##
# A Gem::Security::Policy object encapsulates the settings for verifying
# signed gem files. This is the base class. You can either declare an
# instance of this or use one of the preset security policies below.
- #
+
class Policy
attr_accessor :verify_data, :verify_signer, :verify_chain,
:verify_root, :only_trusted, :only_signed
@@ -509,9 +547,9 @@ module Gem::Security
end
end
- #
+ ##
# No security policy: all package signature checks are disabled.
- #
+
NoSecurity = Policy.new(
:verify_data => false,
:verify_signer => false,
@@ -521,14 +559,14 @@ module Gem::Security
:only_signed => false
)
- #
+ ##
# AlmostNo security policy: only verify that the signing certificate is the
# one that actually signed the data. Make no attempt to verify the signing
# certificate chain.
#
# This policy is basically useless. better than nothing, but can still be
# easily spoofed, and is not recommended.
- #
+
AlmostNoSecurity = Policy.new(
:verify_data => true,
:verify_signer => false,
@@ -538,13 +576,13 @@ module Gem::Security
:only_signed => false
)
- #
+ ##
# Low security policy: only verify that the signing certificate is actually
# the gem signer, and that the signing certificate is valid.
#
# This policy is better than nothing, but can still be easily spoofed, and
# is not recommended.
- #
+
LowSecurity = Policy.new(
:verify_data => true,
:verify_signer => true,
@@ -554,7 +592,7 @@ module Gem::Security
:only_signed => false
)
- #
+ ##
# Medium security policy: verify the signing certificate, verify the signing
# certificate chain all the way to the root certificate, and only trust root
# certificates that we have explicitly allowed trust for.
@@ -562,7 +600,7 @@ module Gem::Security
# This security policy is reasonable, but it allows unsigned packages, so a
# malicious person could simply delete the package signature and pass the
# gem off as unsigned.
- #
+
MediumSecurity = Policy.new(
:verify_data => true,
:verify_signer => true,
@@ -572,7 +610,7 @@ module Gem::Security
:only_signed => false
)
- #
+ ##
# High security policy: only allow signed gems to be installed, verify the
# signing certificate, verify the signing certificate chain all the way to
# the root certificate, and only trust root certificates that we have
@@ -580,7 +618,7 @@ module Gem::Security
#
# This security policy is significantly more difficult to bypass, and offers
# a reasonable guarantee that the contents of the gem have not been altered.
- #
+
HighSecurity = Policy.new(
:verify_data => true,
:verify_signer => true,
@@ -590,9 +628,9 @@ module Gem::Security
:only_signed => true
)
- #
+ ##
# Hash of configured security policies
- #
+
Policies = {
'NoSecurity' => NoSecurity,
'AlmostNoSecurity' => AlmostNoSecurity,
@@ -601,25 +639,24 @@ module Gem::Security
'HighSecurity' => HighSecurity,
}
- #
+ ##
# Sign the cert cert with @signing_key and @signing_cert, using the digest
# algorithm opt[:dgst_algo]. Returns the newly signed certificate.
- #
+
def self.sign_cert(cert, signing_key, signing_cert, opt = {})
opt = OPT.merge(opt)
- # set up issuer information
cert.issuer = signing_cert.subject
- cert.sign(signing_key, opt[:dgst_algo].new)
+ cert.sign signing_key, opt[:dgst_algo].new
cert
end
- #
+ ##
# Make sure the trust directory exists. If it does exist, make sure it's
# actually a directory. If not, then create it with the appropriate
# permissions.
- #
+
def self.verify_trust_dir(path, perms)
# if the directory exists, then make sure it is in fact a directory. if
# it doesn't exist, then create it with the appropriate permissions
@@ -636,94 +673,99 @@ module Gem::Security
end
end
- #
+ ##
# Build a certificate from the given DN and private key.
- #
+
def self.build_cert(name, key, opt = {})
Gem.ensure_ssl_available
- opt = OPT.merge(opt)
+ opt = OPT.merge opt
+
+ cert = OpenSSL::X509::Certificate.new
- # create new cert
- ret = OpenSSL::X509::Certificate.new
+ cert.not_after = Time.now + opt[:cert_age]
+ cert.not_before = Time.now
+ cert.public_key = key.public_key
+ cert.serial = 0
+ cert.subject = name
+ cert.version = 2
- # populate cert attributes
- ret.version = 2
- ret.serial = 0
- ret.public_key = key.public_key
- ret.not_before = Time.now
- ret.not_after = Time.now + opt[:cert_age]
- ret.subject = name
+ ef = OpenSSL::X509::ExtensionFactory.new nil, cert
- # add certificate extensions
- ef = OpenSSL::X509::ExtensionFactory.new(nil, ret)
- ret.extensions = opt[:cert_exts].map { |k, v| ef.create_extension(k, v) }
+ cert.extensions = opt[:cert_exts].map do |ext_name, value|
+ ef.create_extension ext_name, value
+ end
- # sign cert
- i_key, i_cert = opt[:issuer_key] || key, opt[:issuer_cert] || ret
- ret = sign_cert(ret, i_key, i_cert, opt)
+ i_key = opt[:issuer_key] || key
+ i_cert = opt[:issuer_cert] || cert
- # return cert
- ret
+ cert = sign_cert cert, i_key, i_cert, opt
+
+ cert
end
- #
+ ##
# Build a self-signed certificate for the given email address.
- #
+
def self.build_self_signed_cert(email_addr, opt = {})
Gem.ensure_ssl_available
opt = OPT.merge(opt)
path = { :key => nil, :cert => nil }
- # split email address up
- cn, dcs = email_addr.split('@')
- dcs = dcs.split('.')
-
- # munge email CN and DCs
- cn = cn.gsub(opt[:munge_re], '_')
- dcs = dcs.map { |dc| dc.gsub(opt[:munge_re], '_') }
-
- # create DN
- name = "CN=#{cn}/" << dcs.map { |dc| "DC=#{dc}" }.join('/')
- name = OpenSSL::X509::Name::parse(name)
+ name = email_to_name email_addr, opt[:munge_re]
- # build private key
- key = opt[:key_algo].new(opt[:key_size])
+ key = opt[:key_algo].new opt[:key_size]
- # method name pretty much says it all :)
- verify_trust_dir(opt[:trust_dir], opt[:perms][:trust_dir])
+ verify_trust_dir opt[:trust_dir], opt[:perms][:trust_dir]
- # if we're saving the key, then write it out
- if opt[:save_key]
+ if opt[:save_key] then
path[:key] = opt[:save_key_path] || (opt[:output_fmt] % 'private_key')
- File.open(path[:key], 'wb') do |file|
- file.chmod(opt[:perms][:signing_key])
- file.write(key.to_pem)
+
+ open path[:key], 'wb' do |io|
+ io.chmod opt[:perms][:signing_key]
+ io.write key.to_pem
end
end
- # build self-signed public cert from key
- cert = build_cert(name, key, opt)
+ cert = build_cert name, key, opt
- # if we're saving the cert, then write it out
- if opt[:save_cert]
+ if opt[:save_cert] then
path[:cert] = opt[:save_cert_path] || (opt[:output_fmt] % 'public_cert')
- File.open(path[:cert], 'wb') do |file|
- file.chmod(opt[:perms][:signing_cert])
- file.write(cert.to_pem)
+
+ open path[:cert], 'wb' do |file|
+ file.chmod opt[:perms][:signing_cert]
+ file.write cert.to_pem
end
end
- # return key, cert, and paths (if applicable)
{ :key => key, :cert => cert,
:key_path => path[:key], :cert_path => path[:cert] }
end
- #
+ ##
+ # Turns +email_address+ into an OpenSSL::X509::Name
+
+ def self.email_to_name email_address, munge_re
+ cn, dcs = email_address.split '@'
+
+ dcs = dcs.split '.'
+
+ cn = cn.gsub munge_re, '_'
+
+ dcs = dcs.map do |dc|
+ dc.gsub munge_re, '_'
+ end
+
+ name = "CN=#{cn}/" << dcs.map { |dc| "DC=#{dc}" }.join('/')
+
+ OpenSSL::X509::Name.parse name
+ end
+
+ ##
# Add certificate to trusted cert list.
#
# Note: At the moment these are stored in OPT[:trust_dir], although that
# directory may change in the future.
- #
+
def self.add_trusted_cert(cert, opt = {})
opt = OPT.merge(opt)
@@ -743,11 +785,13 @@ module Gem::Security
nil
end
- #
+ ##
# Basic OpenSSL-based package signing class.
- #
+
class Signer
- attr_accessor :key, :cert_chain
+
+ attr_accessor :cert_chain
+ attr_accessor :key
def initialize(key, cert_chain)
Gem.ensure_ssl_available
@@ -774,13 +818,14 @@ module Gem::Security
end
end
- #
+ ##
# Sign data with given digest algorithm
- #
+
def sign(data)
@key.sign(@algo.new, data)
end
end
+
end
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
index 3b966f269b..76cb22f252 100644
--- a/lib/rubygems/server.rb
+++ b/lib/rubygems/server.rb
@@ -1,5 +1,10 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'webrick'
-require 'yaml'
require 'zlib'
require 'erb'
@@ -21,7 +26,6 @@ require 'rubygems/doc_manager'
# * legacy indexes:
# * "/Marshal.#{Gem.marshal_version}" - Full SourceIndex dump of metadata
# for installed gems
-# * "/yaml" - YAML dump of metadata for installed gems - deprecated
#
# == Usage
#
@@ -429,18 +433,19 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
def self.run(options)
new(options[:gemdir], options[:port], options[:daemon],
- options[:addresses]).run
+ options[:launch], options[:addresses]).run
end
##
# Only the first directory in gem_dirs is used for serving gems
- def initialize(gem_dirs, port, daemon, addresses = nil)
+ def initialize(gem_dirs, port, daemon, launch = nil, addresses = nil)
Socket.do_not_reverse_lookup = true
@gem_dirs = Array gem_dirs
@port = port
@daemon = daemon
+ @launch = launch
@addresses = addresses
logger = WEBrick::Log.new nil, WEBrick::BasicLog::FATAL
@server = WEBrick::HTTPServer.new :DoNotListen => true, :Logger => logger
@@ -553,19 +558,6 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
add_date res
case req.request_uri.path
- when '/quick/index' then
- res.body << @source_index.map { |name,| name }.sort.join("\n")
- when '/quick/index.rz' then
- index = @source_index.map { |name,| name }.sort.join("\n")
- res['content-type'] = 'application/x-deflate'
- res.body << Gem.deflate(index)
- when '/quick/latest_index' then
- index = @source_index.latest_specs.map { |spec| spec.full_name }
- res.body << index.sort.join("\n")
- when '/quick/latest_index.rz' then
- index = @source_index.latest_specs.map { |spec| spec.full_name }
- res['content-type'] = 'application/x-deflate'
- res.body << Gem.deflate(index.sort.join("\n"))
when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then
dep = Gem::Dependency.new $2, $3
specs = @source_index.search dep
@@ -590,9 +582,6 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
elsif marshal_format then
res['content-type'] = 'application/x-deflate'
res.body << Gem.deflate(Marshal.dump(specs.first))
- else # deprecated YAML format
- res['content-type'] = 'application/x-deflate'
- res.body << Gem.deflate(specs.first.to_yaml)
end
else
raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found."
@@ -675,6 +664,9 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
values = { "gem_count" => specs.size.to_s, "specs" => specs,
"total_file_count" => total_file_count.to_s }
+ # suppress 1.9.3dev warning about unused variable
+ values = values
+
result = template.result binding
res.body = result
end
@@ -768,9 +760,6 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
WEBrick::Daemon.start if @daemon
- @server.mount_proc "/yaml", method(:yaml)
- @server.mount_proc "/yaml.Z", method(:yaml)
-
@server.mount_proc "/Marshal.#{Gem.marshal_version}", method(:Marshal)
@server.mount_proc "/Marshal.#{Gem.marshal_version}.Z", method(:Marshal)
@@ -803,6 +792,8 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
trap("INT") { @server.shutdown; exit! }
trap("TERM") { @server.shutdown; exit! }
+ launch if @launch
+
@server.start
end
@@ -833,26 +824,14 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end
end
- def yaml(req, res)
- @source_index.refresh!
+ def launch
+ listeners = @server.listeners.map{|l| l.addr[2] }
- add_date res
+ host = listeners.any?{|l| l == '0.0.0.0'} ? 'localhost' : listeners.first
- index = @source_index.to_yaml
+ say "Launching browser to http://#{host}:#{@port}"
- if req.path =~ /Z$/ then
- res['content-type'] = 'application/x-deflate'
- index = Gem.deflate index
- else
- res['content-type'] = 'text/plain'
- end
-
- if req.request_method == 'HEAD' then
- res['content-length'] = index.length
- return
- end
-
- res.body << index
+ system("#{@launch} http://#{host}:#{@port}")
end
end
diff --git a/lib/rubygems/source_index.rb b/lib/rubygems/source_index.rb
index 4700fbbb89..7c571fff55 100644
--- a/lib/rubygems/source_index.rb
+++ b/lib/rubygems/source_index.rb
@@ -1,18 +1,17 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require 'rubygems/user_interaction'
require 'rubygems/specification'
-# :stopdoc:
-module Gem
- autoload :SpecFetcher, 'rubygems/spec_fetcher'
-end
-# :startdoc:
-
##
# The SourceIndex object indexes all the gems available from a
# particular source (e.g. a list of gem directories, or a remote
@@ -28,8 +27,6 @@ class Gem::SourceIndex
include Enumerable
- include Gem::UserInteraction
-
attr_reader :gems # :nodoc:
##
@@ -38,8 +35,6 @@ class Gem::SourceIndex
attr_accessor :spec_dirs
class << self
- include Gem::UserInteraction
-
##
# Factory method to construct a source index instance for a given
# path.
@@ -83,33 +78,7 @@ class Gem::SourceIndex
# loaded spec.
def load_specification(file_name)
- return nil unless file_name and File.exist? file_name
-
- spec_code = if defined? Encoding then
- File.read file_name, :encoding => 'UTF-8'
- else
- File.read file_name
- end.untaint
-
- begin
- gemspec = eval spec_code, binding, file_name
-
- if gemspec.is_a?(Gem::Specification)
- gemspec.loaded_from = file_name
- return gemspec
- end
- alert_warning "File '#{file_name}' does not evaluate to a gem specification"
- rescue SignalException, SystemExit
- raise
- rescue SyntaxError => e
- alert_warning e
- alert_warning spec_code
- rescue Exception => e
- alert_warning "#{e.inspect}\n#{spec_code}"
- alert_warning "Invalid .gemspec format in '#{file_name}'"
- end
-
- return nil
+ Gem::Specification.load file_name
end
end
@@ -150,7 +119,7 @@ class Gem::SourceIndex
spec_files = Dir.glob File.join(spec_dir, '*.gemspec')
spec_files.each do |spec_file|
- gemspec = self.class.load_specification spec_file.untaint
+ gemspec = Gem::Specification.load spec_file
add_spec gemspec if gemspec
end
end
@@ -275,8 +244,8 @@ class Gem::SourceIndex
##
# Find a gem by an exact match on the short name.
- def find_name(gem_name, version_requirement = Gem::Requirement.default)
- dep = Gem::Dependency.new gem_name, version_requirement
+ def find_name(gem_name, requirement = Gem::Requirement.default)
+ dep = Gem::Dependency.new gem_name, requirement
search dep
end
@@ -290,7 +259,7 @@ class Gem::SourceIndex
# behavior is deprecated and will be removed.
def search(gem_pattern, platform_only = false)
- version_requirement = nil
+ requirement = nil
only_platform = false
# TODO - Remove support and warning for legacy arguments after 2008/11
@@ -300,10 +269,10 @@ class Gem::SourceIndex
case gem_pattern
when Regexp then
- version_requirement = platform_only || Gem::Requirement.default
+ requirement = platform_only || Gem::Requirement.default
when Gem::Dependency then
only_platform = platform_only
- version_requirement = gem_pattern.requirement
+ requirement = gem_pattern.requirement
gem_pattern = if Regexp === gem_pattern.name then
gem_pattern.name
elsif gem_pattern.name.empty? then
@@ -312,17 +281,17 @@ class Gem::SourceIndex
/^#{Regexp.escape gem_pattern.name}$/
end
else
- version_requirement = platform_only || Gem::Requirement.default
+ requirement = platform_only || Gem::Requirement.default
gem_pattern = /#{gem_pattern}/i
end
- unless Gem::Requirement === version_requirement then
- version_requirement = Gem::Requirement.create version_requirement
+ unless Gem::Requirement === requirement then
+ requirement = Gem::Requirement.create requirement
end
specs = all_gems.values.select do |spec|
spec.name =~ gem_pattern and
- version_requirement.satisfied_by? spec.version
+ requirement.satisfied_by? spec.version
end
if only_platform then
@@ -354,19 +323,9 @@ class Gem::SourceIndex
latest_specs.each do |local|
dependency = Gem::Dependency.new local.name, ">= #{local.version}"
- begin
- fetcher = Gem::SpecFetcher.fetcher
- remotes = fetcher.find_matching dependency
- remotes = remotes.map { |(_,version,_),_| version }
- rescue Gem::RemoteFetcher::FetchError => e
- raise unless fetcher.warn_legacy e do
- require 'rubygems/source_info_cache'
-
- specs = Gem::SourceInfoCache.search_with_source dependency, true
-
- remotes = specs.map { |spec,| spec.version }
- end
- end
+ fetcher = Gem::SpecFetcher.fetcher
+ remotes = fetcher.find_matching dependency
+ remotes = remotes.map { |(_, version, _), _| version }
latest = remotes.sort.last
@@ -376,43 +335,6 @@ class Gem::SourceIndex
outdateds
end
- ##
- # Updates this SourceIndex from +source_uri+. If +all+ is false, only the
- # latest gems are fetched.
-
- def update(source_uri, all)
- source_uri = URI.parse source_uri unless URI::Generic === source_uri
- source_uri.path += '/' unless source_uri.path =~ /\/$/
-
- use_incremental = false
-
- begin
- gem_names = fetch_quick_index source_uri, all
- remove_extra gem_names
- missing_gems = find_missing gem_names
-
- return false if missing_gems.size.zero?
-
- say "Missing metadata for #{missing_gems.size} gems" if
- missing_gems.size > 0 and Gem.configuration.really_verbose
-
- use_incremental = missing_gems.size <= Gem.configuration.bulk_threshold
- rescue Gem::OperationNotSupportedError => ex
- alert_error "Falling back to bulk fetch: #{ex.message}" if
- Gem.configuration.really_verbose
- use_incremental = false
- end
-
- if use_incremental then
- update_with_missing(source_uri, missing_gems)
- else
- new_index = fetch_bulk_index(source_uri)
- @gems.replace(new_index.gems)
- end
-
- true
- end
-
def ==(other) # :nodoc:
self.class === other and @gems == other.gems
end
@@ -421,166 +343,6 @@ class Gem::SourceIndex
Marshal.dump(self)
end
- private
-
- def fetcher
- require 'rubygems/remote_fetcher'
-
- Gem::RemoteFetcher.fetcher
- end
-
- def fetch_index_from(source_uri)
- @fetch_error = nil
-
- indexes = %W[
- Marshal.#{Gem.marshal_version}.Z
- Marshal.#{Gem.marshal_version}
- yaml.Z
- yaml
- ]
-
- indexes.each do |name|
- spec_data = nil
- index = source_uri + name
- begin
- spec_data = fetcher.fetch_path index
- spec_data = unzip(spec_data) if name =~ /\.Z$/
-
- if name =~ /Marshal/ then
- return Marshal.load(spec_data)
- else
- return YAML.load(spec_data)
- end
- rescue => e
- if Gem.configuration.really_verbose then
- alert_error "Unable to fetch #{name}: #{e.message}"
- end
-
- @fetch_error = e
- end
- end
-
- nil
- end
-
- def fetch_bulk_index(source_uri)
- say "Bulk updating Gem source index for: #{source_uri}" if
- Gem.configuration.verbose
-
- index = fetch_index_from(source_uri)
- if index.nil? then
- raise Gem::RemoteSourceException,
- "Error fetching remote gem cache: #{@fetch_error}"
- end
- @fetch_error = nil
- index
- end
-
- ##
- # Get the quick index needed for incremental updates.
-
- def fetch_quick_index(source_uri, all)
- index = all ? 'index' : 'latest_index'
-
- zipped_index = fetcher.fetch_path source_uri + "quick/#{index}.rz"
-
- unzip(zipped_index).split("\n")
- rescue ::Exception => e
- unless all then
- say "Latest index not found, using quick index" if
- Gem.configuration.really_verbose
-
- fetch_quick_index source_uri, true
- else
- raise Gem::OperationNotSupportedError,
- "No quick index found: #{e.message}"
- end
- end
-
- ##
- # Make a list of full names for all the missing gemspecs.
-
- def find_missing(spec_names)
- unless defined? @originals then
- @originals = {}
- each do |full_name, spec|
- @originals[spec.original_name] = spec
- end
- end
-
- spec_names.find_all { |full_name|
- @originals[full_name].nil?
- }
- end
-
- def remove_extra(spec_names)
- dictionary = spec_names.inject({}) { |h, k| h[k] = true; h }
- each do |name, spec|
- remove_spec name unless dictionary.include? spec.original_name
- end
- end
-
- ##
- # Unzip the given string.
-
- def unzip(string)
- require 'zlib'
- Gem.inflate string
- end
-
- ##
- # Tries to fetch Marshal representation first, then YAML
-
- def fetch_single_spec(source_uri, spec_name)
- @fetch_error = nil
-
- begin
- marshal_uri = source_uri + "quick/Marshal.#{Gem.marshal_version}/#{spec_name}.gemspec.rz"
- zipped = fetcher.fetch_path marshal_uri
- return Marshal.load(unzip(zipped))
- rescue => ex
- @fetch_error = ex
-
- if Gem.configuration.really_verbose then
- say "unable to fetch marshal gemspec #{marshal_uri}: #{ex.class} - #{ex}"
- end
- end
-
- begin
- yaml_uri = source_uri + "quick/#{spec_name}.gemspec.rz"
- zipped = fetcher.fetch_path yaml_uri
- return YAML.load(unzip(zipped))
- rescue => ex
- @fetch_error = ex
- if Gem.configuration.really_verbose then
- say "unable to fetch YAML gemspec #{yaml_uri}: #{ex.class} - #{ex}"
- end
- end
-
- nil
- end
-
- ##
- # Update the cached source index with the missing names.
-
- def update_with_missing(source_uri, missing_names)
- progress = ui.progress_reporter(missing_names.size,
- "Updating metadata for #{missing_names.size} gems from #{source_uri}")
- missing_names.each do |spec_name|
- gemspec = fetch_single_spec(source_uri, spec_name)
- if gemspec.nil? then
- ui.say "Failed to download spec #{spec_name} from #{source_uri}:\n" \
- "\t#{@fetch_error.message}"
- else
- add_spec gemspec
- progress.updated spec_name
- end
- @fetch_error = nil
- end
- progress.done
- progress.count
- end
-
end
# :stopdoc:
diff --git a/lib/rubygems/source_info_cache.rb b/lib/rubygems/source_info_cache.rb
deleted file mode 100644
index 36615d82a1..0000000000
--- a/lib/rubygems/source_info_cache.rb
+++ /dev/null
@@ -1,395 +0,0 @@
-require 'fileutils'
-
-require 'rubygems'
-require 'rubygems/source_info_cache_entry'
-require 'rubygems/user_interaction'
-
-##
-# SourceInfoCache stores a copy of the gem index for each gem source.
-#
-# There are two possible cache locations, the system cache and the user cache:
-# * The system cache is preferred if it is writable or can be created.
-# * The user cache is used otherwise
-#
-# Once a cache is selected, it will be used for all operations.
-# SourceInfoCache will not switch between cache files dynamically.
-#
-# Cache data is a Hash mapping a source URI to a SourceInfoCacheEntry.
-#
-#--
-# To keep things straight, this is how the cache objects all fit together:
-#
-# Gem::SourceInfoCache
-# @cache_data = {
-# source_uri => Gem::SourceInfoCacheEntry
-# @size = source index size
-# @source_index = Gem::SourceIndex
-# ...
-# }
-
-class Gem::SourceInfoCache
-
- include Gem::UserInteraction
-
- ##
- # The singleton Gem::SourceInfoCache. If +all+ is true, a full refresh will
- # be performed if the singleton instance is being initialized.
-
- def self.cache(all = false)
- return @cache if @cache
- @cache = new
- @cache.refresh all if Gem.configuration.update_sources
- @cache
- end
-
- def self.cache_data
- cache.cache_data
- end
-
- ##
- # The name of the system cache file.
-
- def self.latest_system_cache_file
- File.join File.dirname(system_cache_file),
- "latest_#{File.basename system_cache_file}"
- end
-
- ##
- # The name of the latest user cache file.
-
- def self.latest_user_cache_file
- File.join File.dirname(user_cache_file),
- "latest_#{File.basename user_cache_file}"
- end
-
- ##
- # Reset all singletons, discarding any changes.
-
- def self.reset
- @cache = nil
- @system_cache_file = nil
- @user_cache_file = nil
- end
-
- ##
- # Search all source indexes. See Gem::SourceInfoCache#search.
-
- def self.search(*args)
- cache.search(*args)
- end
-
- ##
- # Search all source indexes returning the source_uri. See
- # Gem::SourceInfoCache#search_with_source.
-
- def self.search_with_source(*args)
- cache.search_with_source(*args)
- end
-
- ##
- # The name of the system cache file. (class method)
-
- def self.system_cache_file
- @system_cache_file ||= Gem.default_system_source_cache_dir
- end
-
- ##
- # The name of the user cache file.
-
- def self.user_cache_file
- @user_cache_file ||=
- ENV['GEMCACHE'] || Gem.default_user_source_cache_dir
- end
-
- def initialize # :nodoc:
- @cache_data = nil
- @cache_file = nil
- @dirty = false
- @only_latest = true
- end
-
- ##
- # The most recent cache data.
-
- def cache_data
- return @cache_data if @cache_data
- cache_file # HACK writable check
-
- @only_latest = true
-
- @cache_data = read_cache_data latest_cache_file
-
- @cache_data
- end
-
- ##
- # The name of the cache file.
-
- def cache_file
- return @cache_file if @cache_file
- @cache_file = (try_file(system_cache_file) or
- try_file(user_cache_file) or
- raise "unable to locate a writable cache file")
- end
-
- ##
- # Write the cache to a local file (if it is dirty).
-
- def flush
- write_cache if @dirty
- @dirty = false
- end
-
- def latest_cache_data
- latest_cache_data = {}
-
- cache_data.each do |repo, sice|
- latest = sice.source_index.latest_specs
-
- new_si = Gem::SourceIndex.new
- new_si.add_specs(*latest)
-
- latest_sice = Gem::SourceInfoCacheEntry.new new_si, sice.size
- latest_cache_data[repo] = latest_sice
- end
-
- latest_cache_data
- end
-
- ##
- # The name of the latest cache file.
-
- def latest_cache_file
- File.join File.dirname(cache_file), "latest_#{File.basename cache_file}"
- end
-
- ##
- # The name of the latest system cache file.
-
- def latest_system_cache_file
- self.class.latest_system_cache_file
- end
-
- ##
- # The name of the latest user cache file.
-
- def latest_user_cache_file
- self.class.latest_user_cache_file
- end
-
- ##
- # Merges the complete cache file into this Gem::SourceInfoCache.
-
- def read_all_cache_data
- if @only_latest then
- @only_latest = false
- all_data = read_cache_data cache_file
-
- cache_data.update all_data do |source_uri, latest_sice, all_sice|
- all_sice.source_index.gems.update latest_sice.source_index.gems
-
- Gem::SourceInfoCacheEntry.new all_sice.source_index, latest_sice.size
- end
-
- begin
- refresh true
- rescue Gem::RemoteFetcher::FetchError
- end
- end
- end
-
- ##
- # Reads cached data from +file+.
-
- def read_cache_data(file)
- # Marshal loads 30-40% faster from a String, and 2MB on 20061116 is small
- data = open file, 'rb' do |fp| fp.read end
- cache_data = Marshal.load data
-
- cache_data.each do |url, sice|
- next unless sice.is_a?(Hash)
- update
-
- cache = sice['cache']
- size = sice['size']
-
- if cache.is_a?(Gem::SourceIndex) and size.is_a?(Numeric) then
- new_sice = Gem::SourceInfoCacheEntry.new cache, size
- cache_data[url] = new_sice
- else # irreperable, force refetch.
- reset_cache_for url, cache_data
- end
- end
-
- cache_data
- rescue Errno::ENOENT
- {}
- rescue => e
- if Gem.configuration.really_verbose then
- say "Exception during cache_data handling: #{e.class} - #{e}"
- say "Cache file was: #{file}"
- say "\t#{e.backtrace.join "\n\t"}"
- end
-
- {}
- end
-
- ##
- # Refreshes each source in the cache from its repository. If +all+ is
- # false, only latest gems are updated.
-
- def refresh(all)
- Gem.sources.each do |source_uri|
- cache_entry = cache_data[source_uri]
- if cache_entry.nil? then
- cache_entry = Gem::SourceInfoCacheEntry.new nil, 0
- cache_data[source_uri] = cache_entry
- end
-
- update if cache_entry.refresh source_uri, all
- end
-
- flush
- end
-
- def reset_cache_for(url, cache_data)
- say "Reseting cache for #{url}" if Gem.configuration.really_verbose
-
- sice = Gem::SourceInfoCacheEntry.new Gem::SourceIndex.new, 0
- sice.refresh url, false # HACK may be unnecessary, see ::cache and #refresh
-
- cache_data[url] = sice
- cache_data
- end
-
- def reset_cache_data
- @cache_data = nil
- @only_latest = true
- end
-
- ##
- # Force cache file to be reset, useful for integration testing of rubygems
-
- def reset_cache_file
- @cache_file = nil
- end
-
- ##
- # Searches all source indexes. See Gem::SourceIndex#search for details on
- # +pattern+ and +platform_only+. If +all+ is set to true, the full index
- # will be loaded before searching.
-
- def search(pattern, platform_only = false, all = false)
- read_all_cache_data if all
-
- cache_data.map do |source_uri, sic_entry|
- next unless Gem.sources.include? source_uri
- # TODO - Remove this gunk after 2008/11
- unless pattern.kind_of? Gem::Dependency then
- pattern = Gem::Dependency.new pattern, Gem::Requirement.default
- end
- sic_entry.source_index.search pattern, platform_only
- end.flatten.compact
- end
-
- ##
- # Searches all source indexes for +pattern+. If +only_platform+ is true,
- # only gems matching Gem.platforms will be selected. Returns an Array of
- # pairs containing the Gem::Specification found and the source_uri it was
- # found at.
-
- def search_with_source(pattern, only_platform = false, all = false)
- read_all_cache_data if all
-
- results = []
-
- cache_data.map do |source_uri, sic_entry|
- next unless Gem.sources.include? source_uri
-
- # TODO - Remove this gunk after 2008/11
- unless pattern.kind_of?(Gem::Dependency)
- pattern = Gem::Dependency.new(pattern, Gem::Requirement.default)
- end
-
- sic_entry.source_index.search(pattern, only_platform).each do |spec|
- results << [spec, source_uri]
- end
- end
-
- results
- end
-
- ##
- # Set the source info cache data directly. This is mainly used for unit
- # testing when we don't want to read a file system to grab the cached source
- # index information. The +hash+ should map a source URL into a
- # SourceInfoCacheEntry.
-
- def set_cache_data(hash)
- @cache_data = hash
- update
- end
-
- ##
- # The name of the system cache file.
-
- def system_cache_file
- self.class.system_cache_file
- end
-
- ##
- # Determine if +path+ is a candidate for a cache file. Returns +path+ if
- # it is, nil if not.
-
- def try_file(path)
- return path if File.writable? path
- return nil if File.exist? path
-
- dir = File.dirname path
-
- unless File.exist? dir then
- begin
- FileUtils.mkdir_p dir
- rescue RuntimeError, SystemCallError
- return nil
- end
- end
-
- return path if File.writable? dir
-
- nil
- end
-
- ##
- # Mark the cache as updated (i.e. dirty).
-
- def update
- @dirty = true
- end
-
- ##
- # The name of the user cache file.
-
- def user_cache_file
- self.class.user_cache_file
- end
-
- ##
- # Write data to the proper cache files.
-
- def write_cache
- if not File.exist?(cache_file) or not @only_latest then
- open cache_file, 'wb' do |io|
- io.write Marshal.dump(cache_data)
- end
- end
-
- open latest_cache_file, 'wb' do |io|
- io.write Marshal.dump(latest_cache_data)
- end
- end
-
- reset
-
-end
-
diff --git a/lib/rubygems/source_info_cache_entry.rb b/lib/rubygems/source_info_cache_entry.rb
deleted file mode 100644
index d8106b2806..0000000000
--- a/lib/rubygems/source_info_cache_entry.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'rubygems'
-require 'rubygems/source_index'
-require 'rubygems/remote_fetcher'
-
-##
-# Entries held by a SourceInfoCache.
-
-class Gem::SourceInfoCacheEntry
-
- ##
- # The source index for this cache entry.
-
- attr_reader :source_index
-
- ##
- # The size of the source entry. Used to determine if the source index has
- # changed.
-
- attr_reader :size
-
- ##
- # Create a cache entry.
-
- def initialize(si, size)
- @source_index = si || Gem::SourceIndex.new({})
- @size = size
- @all = false
- end
-
- def refresh(source_uri, all)
- begin
- marshal_uri = URI.join source_uri.to_s, "Marshal.#{Gem.marshal_version}"
- remote_size = Gem::RemoteFetcher.fetcher.fetch_size marshal_uri
- rescue Gem::RemoteSourceException
- yaml_uri = URI.join source_uri.to_s, 'yaml'
- remote_size = Gem::RemoteFetcher.fetcher.fetch_size yaml_uri
- end
-
- # TODO Use index_signature instead of size?
- return false if @size == remote_size and @all
-
- updated = @source_index.update source_uri, all
- @size = remote_size
- @all = all
-
- updated
- end
-
- def ==(other) # :nodoc:
- self.class === other and
- @size == other.size and
- @source_index == other.source_index
- end
-
-end
-
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index dac35d85d0..c999a65cd9 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -1,9 +1,13 @@
-require 'zlib'
-require 'fileutils'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
require 'rubygems/remote_fetcher'
require 'rubygems/user_interaction'
require 'rubygems/errors'
+require 'rubygems/text'
##
# SpecFetcher handles metadata updates from remote gem repositories.
@@ -11,6 +15,13 @@ require 'rubygems/errors'
class Gem::SpecFetcher
include Gem::UserInteraction
+ include Gem::Text
+
+ FILES = {
+ :all => 'specs',
+ :latest => 'latest_specs',
+ :prerelease => 'prerelease_specs',
+ }
##
# The SpecFetcher cache dir.
@@ -43,6 +54,8 @@ class Gem::SpecFetcher
end
def initialize
+ require 'fileutils'
+
@dir = File.join Gem.user_home, '.gem', 'specs'
@update_cache = File.stat(Gem.user_home).uid == Process.uid
@@ -50,6 +63,12 @@ class Gem::SpecFetcher
@latest_specs = {}
@prerelease_specs = {}
+ @caches = {
+ :latest => @latest_specs,
+ :prerelease => @prerelease_specs,
+ :all => @specs
+ }
+
@fetcher = Gem::RemoteFetcher.fetcher
end
@@ -74,14 +93,6 @@ class Gem::SpecFetcher
end
return [ss, errors]
-
- rescue Gem::RemoteFetcher::FetchError => e
- raise unless warn_legacy e do
- require 'rubygems/source_info_cache'
-
- return [Gem::SourceInfoCache.search_with_source(dependency,
- matching_platform, all), nil]
- end
end
def fetch(*args)
@@ -160,26 +171,31 @@ class Gem::SpecFetcher
end
##
- # Returns Array of gem repositories that were generated with RubyGems less
- # than 1.2.
+ # Suggests a gem based on the supplied +gem_name+. Returns a string
+ # of the gem name if an approximate match can be found or nil
+ # otherwise. NOTE: for performance reasons only gems which exactly
+ # match the first character of +gem_name+ are considered.
- def legacy_repos
- Gem.sources.reject do |source_uri|
- source_uri = URI.parse source_uri
- spec_path = source_uri + "specs.#{Gem.marshal_version}.gz"
+ def suggest_gems_from_name gem_name
+ gem_name = gem_name.downcase
+ max = gem_name.size / 2
+ specs = list.values.flatten(1) # flatten(1) is 1.8.7 and up
- begin
- @fetcher.fetch_size spec_path
- rescue Gem::RemoteFetcher::FetchError
- begin
- @fetcher.fetch_size(source_uri + 'yaml') # re-raise if non-repo
- rescue Gem::RemoteFetcher::FetchError
- alert_error "#{source_uri} does not appear to be a repository"
- raise
- end
- false
- end
- end
+ matches = specs.map { |name, version, platform|
+ next unless Gem::Platform.match platform
+
+ distance = levenshtein_distance gem_name, name.downcase
+
+ next if distance >= max
+
+ return [name] if distance == 0
+
+ [name, distance]
+ }.compact
+
+ matches = matches.uniq.sort_by { |name, dist| dist }
+
+ matches.first(5).map { |name, dist| name }
end
##
@@ -197,15 +213,9 @@ class Gem::SpecFetcher
:latest
end
- list = {}
-
- file = { :latest => 'latest_specs',
- :prerelease => 'prerelease_specs',
- :all => 'specs' }[type]
-
- cache = { :latest => @latest_specs,
- :prerelease => @prerelease_specs,
- :all => @specs }[type]
+ list = {}
+ file = FILES[type]
+ cache = @caches[type]
Gem.sources.each do |source_uri|
source_uri = URI.parse source_uri
@@ -273,28 +283,5 @@ class Gem::SpecFetcher
specs
end
- ##
- # Warn about legacy repositories if +exception+ indicates only legacy
- # repositories are available, and yield to the block. Returns false if the
- # exception indicates some other FetchError.
-
- def warn_legacy(exception)
- uri = exception.uri.to_s
- if uri =~ /specs\.#{Regexp.escape Gem.marshal_version}\.gz$/ then
- alert_warning <<-EOF
-RubyGems 1.2+ index not found for:
-\t#{legacy_repos.join "\n\t"}
-
-RubyGems will revert to legacy indexes degrading performance.
- EOF
-
- yield
-
- return true
- end
-
- false
- end
-
end
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index c9a4a0c640..56584adc07 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -498,17 +504,37 @@ class Gem::Specification
end
##
- # Loads ruby format gemspec from +filename+
+ # Loads Ruby format gemspec from +file+.
+
+ def self.load file
+ return unless file && File.file?(file)
+
+ file = file.dup.untaint
+
+ code = if defined? Encoding
+ File.read file, :encoding => "UTF-8"
+ else
+ File.read file
+ end
+
+ code.untaint
+
+ begin
+ spec = eval code, binding, file
+
+ if Gem::Specification === spec
+ spec.loaded_from = file
+ return spec
+ end
+
+ warn "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
+ rescue SignalException, SystemExit
+ raise
+ rescue SyntaxError, Exception => e
+ warn "Invalid gemspec in [#{file}]: #{e}"
+ end
- def self.load(filename)
- gemspec = nil
- raise "NESTED Specification.load calls not allowed!" if @@gather
- @@gather = proc { |gs| gemspec = gs }
- data = File.read filename
- eval data, nil, filename
- gemspec
- ensure
- @@gather = nil
+ nil
end
##
@@ -672,8 +698,7 @@ class Gem::Specification
def hash # :nodoc:
@@attributes.inject(0) { |hash_code, (name, _)|
- n = self.send(name).hash
- hash_code + n
+ hash_code ^ self.send(name).hash
}
end
@@ -765,7 +790,6 @@ class Gem::Specification
result << nil
result << " if s.respond_to? :specification_version then"
- result << " current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION"
result << " s.specification_version = #{specification_version}"
result << nil
@@ -909,7 +933,7 @@ class Gem::Specification
# Warnings
- %w[author description email homepage rubyforge_project summary].each do |attribute|
+ %w[author description email homepage summary].each do |attribute|
value = self.send attribute
alert_warning "no #{attribute} specified" if value.nil? or value.empty?
end
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 9a4759cb99..892e4dd9e5 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'tempfile'
require 'rubygems'
require 'rubygems/remote_fetcher'
diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb
index c694e8a9c0..ddf1e820a7 100644
--- a/lib/rubygems/text.rb
+++ b/lib/rubygems/text.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems'
##
@@ -26,5 +32,40 @@ module Gem::Text
result.join("\n").gsub(/^/, " " * indent)
end
+ # This code is based directly on the Text gem implementation
+ # Returns a value representing the "cost" of transforming str1 into str2
+ def levenshtein_distance str1, str2
+ s = str1
+ t = str2
+ n = s.length
+ m = t.length
+ max = n/2
+
+ return m if (0 == n)
+ return n if (0 == m)
+ return n if (n - m).abs > max
+
+ d = (0..m).to_a
+ x = nil
+
+ n.times do |i|
+ e = i+1
+
+ m.times do |j|
+ cost = (s[i] == t[j]) ? 0 : 1
+ x = [
+ d[j+1] + 1, # insertion
+ e + 1, # deletion
+ d[j] + cost # substitution
+ ].min
+ d[j] = e
+ e = x
+ end
+
+ d[m] = x
+ end
+
+ return x
+ end
end
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index b8feb483f8..185926e949 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 5db2dfd21c..06b847cf41 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -218,20 +224,66 @@ class Gem::StreamUI
result
end
- ##
- # Ask for a password. Does not echo response to terminal.
+ if RUBY_VERSION >= "1.9" then
+ ##
+ # Ask for a password. Does not echo response to terminal.
- def ask_for_password(question)
- return nil if not @ins.tty?
+ def ask_for_password(question)
+ return nil if not @ins.tty?
- require 'io/console'
+ require 'io/console'
- @outs.print(question + " ")
- @outs.flush
+ @outs.print(question + " ")
+ @outs.flush
+
+ password = @ins.noecho {@ins.gets}
+ password.chomp! if password
+ password
+ end
+ else
+ ##
+ # Ask for a password. Does not echo response to terminal.
+
+ def ask_for_password(question)
+ return nil if not @ins.tty?
+
+ @outs.print(question + " ")
+ @outs.flush
+
+ Gem.win_platform? ? ask_for_password_on_windows : ask_for_password_on_unix
+ end
+
+ ##
+ # Asks for a password that works on windows. Ripped from the Heroku gem.
+
+ def ask_for_password_on_windows
+ require "Win32API"
+ char = nil
+ password = ''
+
+ while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
+ break if char == 10 || char == 13 # received carriage return or newline
+ if char == 127 || char == 8 # backspace and delete
+ password.slice!(-1, 1)
+ else
+ password << char.chr
+ end
+ end
+
+ puts
+ password
+ end
- password = @ins.noecho {@ins.gets}
- password.chomp! if password
- password
+ ##
+ # Asks for a password that works on unix
+
+ def ask_for_password_on_unix
+ system "stty -echo"
+ password = @ins.gets
+ password.chomp! if password
+ system "stty echo"
+ password
+ end
end
##
@@ -384,6 +436,76 @@ class Gem::StreamUI
end
end
+ ##
+ # Return a download reporter object chosen from the current verbosity
+
+ def download_reporter(*args)
+ case Gem.configuration.verbose
+ when nil, false
+ SilentDownloadReporter.new(@outs, *args)
+ else
+ VerboseDownloadReporter.new(@outs, *args)
+ end
+ end
+
+ ##
+ # An absolutely silent download reporter.
+
+ class SilentDownloadReporter
+ def initialize(out_stream, *args)
+ end
+
+ def fetch(filename, filesize)
+ end
+
+ def update(current)
+ end
+
+ def done
+ end
+ end
+
+ ##
+ # A progress reporter that prints out messages about the current progress.
+
+ class VerboseDownloadReporter
+ attr_reader :file_name, :total_bytes, :progress
+
+ def initialize(out_stream, *args)
+ @out = out_stream
+ @progress = 0
+ end
+
+ def fetch(file_name, total_bytes)
+ @file_name, @total_bytes = file_name, total_bytes
+ update_display(false)
+ end
+
+ def update(bytes)
+ new_progress = ((bytes.to_f * 100) / total_bytes.to_f).ceil
+ return if new_progress == @progress
+
+ @progress = new_progress
+ update_display
+ end
+
+ def done
+ @progress = 100
+ update_display(true, true)
+ end
+
+ private
+
+ def update_display(show_progress = true, new_line = false)
+ return unless @out.tty?
+ if show_progress
+ @out.print "\rFetching: %s (%3d%%)" % [@file_name, @progress]
+ else
+ @out.print "Fetching: %s" % @file_name
+ end
+ @out.puts if new_line
+ end
+ end
end
##
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
index 16e12ef02e..d2750f14ea 100644
--- a/lib/rubygems/validator.rb
+++ b/lib/rubygems/validator.rb
@@ -1,21 +1,18 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++
-require 'find'
-
-require 'digest'
require 'rubygems/format'
require 'rubygems/installer'
-begin
- gem 'test-unit'
-rescue Gem::LoadError
- # Ignore - use the test-unit library that's part of the standard library
-end
-
##
# Validator performs various gem file and gem database validation
@@ -23,6 +20,11 @@ class Gem::Validator
include Gem::UserInteraction
+ def initialize
+ require 'find'
+ require 'digest'
+ end
+
##
# Given a gem file's contents, validates against its own MD5 checksum
# gem_data:: [String] Contents of the gem file
@@ -165,79 +167,6 @@ class Gem::Validator
errors
end
-=begin
- if RUBY_VERSION < '1.9' then
- class TestRunner
- def initialize(suite, ui)
- @suite = suite
- @ui = ui
- end
-
- def self.run(suite, ui)
- require 'test/unit/ui/testrunnermediator'
- return new(suite, ui).start
- end
-
- def start
- @mediator = Test::Unit::UI::TestRunnerMediator.new(@suite)
- @mediator.add_listener(Test::Unit::TestResult::FAULT, &method(:add_fault))
- return @mediator.run_suite
- end
-
- def add_fault(fault)
- if Gem.configuration.verbose then
- @ui.say fault.long_display
- end
- end
- end
-
- autoload :TestRunner, 'test/unit/ui/testrunnerutilities'
- end
-=end
-
- ##
- # Runs unit tests for a given gem specification
-
- def unit_test(gem_spec)
- start_dir = Dir.pwd
- Dir.chdir(gem_spec.full_gem_path)
- $: << gem_spec.full_gem_path
- # XXX: why do we need this gem_spec when we've already got 'spec'?
- test_files = gem_spec.test_files
-
- if test_files.empty? then
- say "There are no unit tests to run for #{gem_spec.full_name}"
- return nil
- end
-
- gem gem_spec.name, "= #{gem_spec.version.version}"
-
- test_files.each do |f| require f end
-
-=begin
- if RUBY_VERSION < '1.9' then
- suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}")
-
- ObjectSpace.each_object(Class) do |klass|
- suite << klass.suite if (klass < Test::Unit::TestCase)
- end
-
- result = TestRunner.run suite, ui
-
- alert_error result.to_s unless result.passed?
- else
- result = MiniTest::Unit.new
- result.run
- end
-=end
- result = MiniTest::Unit.new
- result.run
-
- result
- ensure
- Dir.chdir(start_dir)
- end
-
def remove_leading_dot_dir(path)
path.sub(/^\.\//, "")
end
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 50d8204a5d..03eaf3bbb3 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
##
# The Version class processes string versions into comparable
# values. A version string should normally be a series of numbers
@@ -8,15 +14,18 @@
#
# If any part contains letters (currently only a-z are supported) then
# that version is considered prerelease. Versions with a prerelease
-# part in the Nth part sort less than versions with N-1 parts. Prerelease
-# parts are sorted alphabetically using the normal Ruby string sorting
-# rules.
+# part in the Nth part sort less than versions with N-1
+# parts. Prerelease parts are sorted alphabetically using the normal
+# Ruby string sorting rules. If a prerelease part contains both
+# letters and numbers, it will be broken into multiple parts to
+# provide expected sort behavior (1.0.a10 becomes 1.0.a.10, and is
+# greater than 1.0.a9).
#
# Prereleases sort between real releases (newest to oldest):
#
# 1. 1.0
-# 2. 1.0.b
-# 3. 1.0.a
+# 2. 1.0.b1
+# 3. 1.0.a.2
# 4. 0.9
#
# == How Software Changes
@@ -138,6 +147,8 @@
# "~> 3.5.0" 3.5.0 ... 3.6
class Gem::Version
+ autoload :Requirement, 'rubygems/requirement'
+
include Comparable
VERSION_PATTERN = '[0-9]+(\.[0-9a-zA-Z]+)*' # :nodoc:
@@ -184,15 +195,13 @@ class Gem::Version
@version = version.to_s
@version.strip!
-
- segments # prime @segments
end
##
# Return a new version object where the next to the last revision
# number is one greater (e.g., 5.3.1 => 5.4).
#
- # Pre-release (alpha) parts, e.g, 5.3.1.b2 => 5.4, are ignored.
+ # Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
def bump
segments = self.segments.dup
@@ -208,7 +217,7 @@ class Gem::Version
# same precision. Version "1.0" is not the same as version "1".
def eql? other
- self.class === other and segments == other.segments
+ self.class === other and @version == other.version
end
def hash # :nodoc:
@@ -239,7 +248,7 @@ class Gem::Version
# A version is considered a prerelease if it contains a letter.
def prerelease?
- @prerelease ||= segments.any? { |s| String === s }
+ @prerelease ||= @version =~ /[a-zA-Z]/
end
def pretty_print q # :nodoc:
@@ -260,12 +269,10 @@ class Gem::Version
def segments # :nodoc:
- # @segments is lazy so it can pick up @version values that come
- # from old marshaled versions, which don't go through
- # marshal_load. +segments+ is called in +initialize+ to "prime
- # the pump" in normal cases.
+ # segments is lazy so it can pick up version values that come from
+ # old marshaled versions, which don't go through marshal_load.
- @segments ||= @version.scan(/[0-9a-z]+/i).map do |s|
+ @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
/^\d+$/ =~ s ? s.to_i : s
end
end
@@ -284,23 +291,33 @@ class Gem::Version
end
##
- # Compares this version with +other+ returning -1, 0, or 1 if the other
- # version is larger, the same, or smaller than this one.
+ # Compares this version with +other+ returning -1, 0, or 1 if the
+ # other version is larger, the same, or smaller than this
+ # one. Attempts to compare to something that's not a
+ # <tt>Gem::Version</tt> return +nil+.
def <=> other
- return 1 unless other # HACK: comparable with nil? why?
- return nil unless self.class === other
+ return unless Gem::Version === other
+ return 0 if @version == other.version
- lhsize = segments.size
- rhsize = other.segments.size
+ lhsegments = segments
+ rhsegments = other.segments
+
+ lhsize = lhsegments.size
+ rhsize = rhsegments.size
limit = (lhsize > rhsize ? lhsize : rhsize) - 1
- 0.upto(limit) do |i|
- lhs, rhs = segments[i] || 0, other.segments[i] || 0
+ i = 0
+
+ while i <= limit
+ lhs, rhs = lhsegments[i] || 0, rhsegments[i] || 0
+ i += 1
+
+ next if lhs == rhs
+ return -1 if String === lhs && Numeric === rhs
+ return 1 if Numeric === lhs && String === rhs
- return -1 if String === lhs && Numeric === rhs
- return 1 if Numeric === lhs && String === rhs
- return lhs <=> rhs if lhs != rhs
+ return lhs <=> rhs
end
return 0
diff --git a/lib/rubygems/version_option.rb b/lib/rubygems/version_option.rb
index a3de4dc9e7..79da8f4e54 100644
--- a/lib/rubygems/version_option.rb
+++ b/lib/rubygems/version_option.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/test/rubygems/bogussources.rb b/test/rubygems/bogussources.rb
index 008e3a1de5..fe12541c3d 100644
--- a/test/rubygems/bogussources.rb
+++ b/test/rubygems/bogussources.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/test/rubygems/fake_certlib/openssl.rb b/test/rubygems/fake_certlib/openssl.rb
index 9de90c0a10..aaf48735c0 100644
--- a/test/rubygems/fake_certlib/openssl.rb
+++ b/test/rubygems/fake_certlib/openssl.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/test/rubygems/foo/discover.rb b/test/rubygems/foo/discover.rb
index e69de29bb2..284a221bf9 100644
--- a/test/rubygems/foo/discover.rb
+++ b/test/rubygems/foo/discover.rb
@@ -0,0 +1,6 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
diff --git a/test/rubygems/functional.rb b/test/rubygems/functional.rb
index 62f8c64d2d..6b7131f9d6 100644
--- a/test/rubygems/functional.rb
+++ b/test/rubygems/functional.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems'
require 'minitest/unit'
require 'test/insure_session'
diff --git a/test/rubygems/gem_installer_test_case.rb b/test/rubygems/gem_installer_test_case.rb
index ac353fbc43..6bf9687e86 100644
--- a/test/rubygems/gem_installer_test_case.rb
+++ b/test/rubygems/gem_installer_test_case.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/installer'
class Gem::Installer
diff --git a/test/rubygems/gem_package_tar_test_case.rb b/test/rubygems/gem_package_tar_test_case.rb
index f671693cc0..572c6b8a02 100644
--- a/test/rubygems/gem_package_tar_test_case.rb
+++ b/test/rubygems/gem_package_tar_test_case.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/package'
class TarTestCase < RubyGemTestCase
@@ -120,8 +126,10 @@ class TarTestCase < RubyGemTestCase
def util_entry(tar)
io = TempIO.new tar
+
header = Gem::Package::TarHeader.from io
- entry = Gem::Package::TarReader::Entry.new header, io
+
+ Gem::Package::TarReader::Entry.new header, io
end
def util_dir_entry
diff --git a/test/rubygems/gemutilities.rb b/test/rubygems/gemutilities.rb
index 66914d0c0e..fc27d6077c 100644
--- a/test/rubygems/gemutilities.rb
+++ b/test/rubygems/gemutilities.rb
@@ -1,8 +1,18 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
at_exit { $SAFE = 1 }
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'rubygems'
+if defined? Gem::QuickLoader
+ Gem::QuickLoader.load_full_rubygems_library
+else
+ require 'rubygems'
+end
require 'fileutils'
require 'minitest/autorun'
require 'tmpdir'
@@ -11,6 +21,8 @@ require 'rubygems/package'
require 'rubygems/test_utilities'
require 'pp'
require 'yaml'
+require 'zlib'
+
begin
YAML::ENGINE.yamler = 'psych'
rescue LoadError
@@ -23,11 +35,11 @@ end
require 'rdoc/rdoc'
-require_relative 'mockgemui'
+require "test/rubygems/mockgemui"
module Gem
def self.searcher=(searcher)
- MUTEX.synchronize do @searcher = searcher end
+ @searcher = searcher
end
def self.source_index=(si)
@@ -38,6 +50,10 @@ module Gem
@@win_platform = val
end
+ def self.ruby= ruby
+ @ruby = ruby
+ end
+
module DefaultUserInteraction
@ui = MockGemUi.new
end
@@ -53,15 +69,19 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
def setup
super
+ @orig_gem_home = ENV['GEM_HOME']
+ @orig_gem_path = ENV['GEM_PATH']
+
@ui = MockGemUi.new
tmpdir = nil
Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
- @tempdir = File.join tmpdir, "test_rubygems_#{$$}"
+ if ENV['KEEP_FILES'] then
+ @tempdir = File.join tmpdir, "test_rubygems_#{$$}.#{Time.now.to_i}"
+ else
+ @tempdir = File.join tmpdir, "test_rubygems_#{$$}"
+ end
@tempdir.untaint
- @gemhome = File.join @tempdir, "gemhome"
- @gemcache = File.join(@gemhome, "source_cache")
- @usrcache = File.join(@gemhome, ".gem", "user_cache")
- @latest_usrcache = File.join(@gemhome, ".gem", "latest_user_cache")
+ @gemhome = File.join @tempdir, 'gemhome'
@userhome = File.join @tempdir, 'userhome'
Gem.ensure_gem_subdirectories @gemhome
@@ -80,7 +100,6 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
FileUtils.mkdir_p @gemhome
FileUtils.mkdir_p @userhome
- ENV['GEMCACHE'] = @usrcache
Gem.use_paths(@gemhome)
Gem.loaded_specs.clear
@@ -131,9 +150,13 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem.pre_uninstall do |uninstaller|
@pre_uninstall_hook_arg = uninstaller
end
+
+ @orig_LOAD_PATH = $LOAD_PATH.dup
end
def teardown
+ $LOAD_PATH.replace @orig_LOAD_PATH
+
Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY
Gem::ConfigMap[:arch] = @orig_arch
@@ -141,15 +164,15 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem::RemoteFetcher.fetcher = nil
end
- FileUtils.rm_rf @tempdir
+ FileUtils.rm_rf @tempdir unless ENV['KEEP_FILES']
- ENV.delete 'GEMCACHE'
- ENV.delete 'GEM_HOME'
- ENV.delete 'GEM_PATH'
+ ENV['GEM_HOME'] = @orig_gem_home
+ ENV['GEM_PATH'] = @orig_gem_path
Gem.clear_paths
- Gem.class_eval { @ruby = ruby } if ruby = @orig_ruby
+ _ = @orig_ruby
+ Gem.class_eval { @ruby = _ } if _
if @orig_ENV_HOME then
ENV['HOME'] = @orig_ENV_HOME
@@ -171,6 +194,14 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem::Installer.new(gem, :wrappers => true).install
end
+ def uninstall_gem gem
+ require 'rubygems/uninstaller'
+
+ uninstaller = Gem::Uninstaller.new gem.name, :executables => true,
+ :user_install => true
+ uninstaller.uninstall
+ end
+
def mu_pp(obj)
s = ''
s = PP.pp obj, s
@@ -283,7 +314,15 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem.source_index.refresh!
end
- def util_gem(name, version, &block)
+ def util_gem(name, version, deps = nil, &block)
+ if deps then # fuck you eric
+ block = proc do |s|
+ deps.each do |n, req|
+ s.add_dependency n, (req || '>= 0')
+ end
+ end
+ end
+
spec = quick_gem(name, version, &block)
util_build_gem spec
@@ -500,13 +539,12 @@ Also, a list:
def build_rake_in
gem_ruby = Gem.ruby
- ruby = @@ruby
- Gem.module_eval {@ruby = ruby}
+ Gem.ruby = @@ruby
env_rake = ENV["rake"]
ENV["rake"] = @@rake
yield @@rake
ensure
- Gem.module_eval {@ruby = gem_ruby}
+ Gem.ruby = gem_ruby
if env_rake
ENV["rake"] = env_rake
else
@@ -515,11 +553,11 @@ Also, a list:
end
def self.rubybin
- if ruby = ENV["RUBY"]
- return ruby
- end
+ ruby = ENV["RUBY"]
+ return ruby if ruby
ruby = "ruby"
- rubyexe = ruby+".exe"
+ rubyexe = "#{ruby}.exe"
+
3.times do
if File.exist? ruby and File.executable? ruby and !File.directory? ruby
return File.expand_path(ruby)
@@ -529,12 +567,12 @@ Also, a list:
end
ruby = File.join("..", ruby)
end
+
begin
require "rbconfig"
- File.join(
- RbConfig::CONFIG["bindir"],
- RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]
- )
+ File.join(RbConfig::CONFIG["bindir"],
+ RbConfig::CONFIG["ruby_install_name"] +
+ RbConfig::CONFIG["EXEEXT"])
rescue LoadError
"ruby"
end
diff --git a/test/rubygems/insure_session.rb b/test/rubygems/insure_session.rb
index 8a6df89246..508450b23b 100644
--- a/test/rubygems/insure_session.rb
+++ b/test/rubygems/insure_session.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems'
def install_session
diff --git a/test/rubygems/mockgemui.rb b/test/rubygems/mockgemui.rb
index 18ca70b821..52b0e7ffdc 100644
--- a/test/rubygems/mockgemui.rb
+++ b/test/rubygems/mockgemui.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'stringio'
require 'rubygems/user_interaction'
diff --git a/test/rubygems/plugin/exception/rubygems_plugin.rb b/test/rubygems/plugin/exception/rubygems_plugin.rb
index affa72f09c..ef019a7193 100644
--- a/test/rubygems/plugin/exception/rubygems_plugin.rb
+++ b/test/rubygems/plugin/exception/rubygems_plugin.rb
@@ -1,2 +1,8 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
TestGem::TEST_PLUGIN_EXCEPTION = :loaded
raise Exception.new('boom') \ No newline at end of file
diff --git a/test/rubygems/plugin/load/rubygems_plugin.rb b/test/rubygems/plugin/load/rubygems_plugin.rb
index bf020b0f6a..32faee7e2b 100644
--- a/test/rubygems/plugin/load/rubygems_plugin.rb
+++ b/test/rubygems/plugin/load/rubygems_plugin.rb
@@ -1 +1,7 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
TestGem::TEST_PLUGIN_LOAD = :loaded \ No newline at end of file
diff --git a/test/rubygems/plugin/standarderror/rubygems_plugin.rb b/test/rubygems/plugin/standarderror/rubygems_plugin.rb
index d36849f144..44efaef48a 100644
--- a/test/rubygems/plugin/standarderror/rubygems_plugin.rb
+++ b/test/rubygems/plugin/standarderror/rubygems_plugin.rb
@@ -1,2 +1,8 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
TestGem::TEST_PLUGIN_STANDARDERROR = :loaded
raise StandardError.new('boom') \ No newline at end of file
diff --git a/test/rubygems/rubygems/commands/crash_command.rb b/test/rubygems/rubygems/commands/crash_command.rb
index e77b3fcd72..b34ac8e2f3 100644
--- a/test/rubygems/rubygems/commands/crash_command.rb
+++ b/test/rubygems/rubygems/commands/crash_command.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
class Gem::Commands::CrashCommand < Gem::Command
raise "crash"
diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb
index 6c08f97c6d..e8c36a4a3f 100644
--- a/test/rubygems/rubygems_plugin.rb
+++ b/test/rubygems/rubygems_plugin.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
require 'rubygems/command_manager'
##
diff --git a/test/rubygems/sff/discover.rb b/test/rubygems/sff/discover.rb
new file mode 100644
index 0000000000..284a221bf9
--- /dev/null
+++ b/test/rubygems/sff/discover.rb
@@ -0,0 +1,6 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
diff --git a/test/rubygems/simple_gem.rb b/test/rubygems/simple_gem.rb
index e9207f95cc..d2145e6e47 100644
--- a/test/rubygems/simple_gem.rb
+++ b/test/rubygems/simple_gem.rb
@@ -1,3 +1,9 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
SIMPLE_GEM = <<-GEMDATA
MD5SUM = "b12a4d48febeb2289c539c2574c4b6f8"
if $0 == __FILE__
diff --git a/test/rubygems/test_config.rb b/test/rubygems/test_config.rb
index 3458a1a682..da1998390b 100644
--- a/test/rubygems/test_config.rb
+++ b/test/rubygems/test_config.rb
@@ -1,11 +1,21 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems'
class TestConfig < RubyGemTestCase
def test_datadir
- datadir = RbConfig::CONFIG['datadir']
- assert_equal "#{datadir}/xyz", RbConfig.datadir('xyz')
+ _, err = capture_io do
+ datadir = RbConfig::CONFIG['datadir']
+ assert_equal "#{datadir}/xyz", RbConfig.datadir('xyz')
+ end
+
+ assert_match(/deprecate/, err)
end
end
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 91dbe226b5..6d17d65789 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems'
require 'rubygems/gem_openssl'
require 'rubygems/installer'
@@ -64,19 +70,19 @@ class TestGem < RubyGemTestCase
assert_equal @exec_path, Gem.bin_path('a', nil, '4')
end
- def test_self_bin_path_no_default_bin
+ def test_self_bin_path_nonexistent_binfile
quick_gem 'a', '2' do |s|
s.executables = ['exec']
end
- assert_raises(Gem::Exception) do
- Gem.bin_path('a', '2')
+ assert_raises(Gem::GemNotFoundException) do
+ Gem.bin_path('a', 'other', '2')
end
end
def test_self_bin_path_no_bin_file
quick_gem 'a', '1'
assert_raises(Gem::Exception) do
- Gem.bin_path('a', '1')
+ Gem.bin_path('a', nil, '1')
end
end
@@ -86,6 +92,16 @@ class TestGem < RubyGemTestCase
end
end
+ def test_self_bin_path_bin_file_gone_in_latest
+ util_exec_gem
+ quick_gem 'a', '10' do |s|
+ s.executables = []
+ s.default_executable = nil
+ end
+ # Should not find a-10's non-abin (bug)
+ assert_equal @abin_path, Gem.bin_path('a', 'abin')
+ end
+
def test_self_bindir
assert_equal File.join(@gemhome, 'bin'), Gem.bindir
assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Gem.dir)
@@ -259,15 +275,15 @@ class TestGem < RubyGemTestCase
end
def test_self_find_files
- discover_path = File.join 'lib', 'foo', 'discover.rb'
+ discover_path = File.join 'lib', 'sff', 'discover.rb'
cwd = File.expand_path '..', __FILE__
$LOAD_PATH.unshift cwd.dup
- foo1 = quick_gem 'foo', '1' do |s|
+ foo1 = quick_gem 'sff', '1' do |s|
s.files << discover_path
end
- foo2 = quick_gem 'foo', '2' do |s|
+ foo2 = quick_gem 'sff', '2' do |s|
s.files << discover_path
end
@@ -285,14 +301,13 @@ class TestGem < RubyGemTestCase
Gem.searcher = nil
expected = [
- File.expand_path('../foo/discover.rb', __FILE__),
+ File.expand_path('../sff/discover.rb', __FILE__),
File.join(foo2.full_gem_path, discover_path),
File.join(foo1.full_gem_path, discover_path),
]
- assert_equal expected, Gem.find_files('foo/discover')
- bug3701 = '[ruby-core:31730]'
- assert_equal expected, Gem.find_files('foo/**.rb'), bug3701
+ assert_equal expected, Gem.find_files('sff/discover')
+ assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]'
ensure
assert_equal cwd, $LOAD_PATH.shift
end
@@ -321,11 +336,18 @@ class TestGem < RubyGemTestCase
assert_equal true, Gem.loaded_specs.keys.include?('foo')
end
+ def util_path
+ ENV.delete "GEM_HOME"
+ ENV.delete "GEM_PATH"
+ end
+
def test_self_path
assert_equal [Gem.dir], Gem.path
end
def test_self_path_default
+ util_path
+
if defined? APPLE_GEM_HOME
orig_APPLE_GEM_HOME = APPLE_GEM_HOME
Object.send :remove_const, :APPLE_GEM_HOME
@@ -339,6 +361,8 @@ class TestGem < RubyGemTestCase
unless win_platform?
def test_self_path_APPLE_GEM_HOME
+ util_path
+
Gem.clear_paths
apple_gem_home = File.join @tempdir, 'apple_gem_home'
Gem.const_set :APPLE_GEM_HOME, apple_gem_home
@@ -599,42 +623,90 @@ class TestGem < RubyGemTestCase
end
end
- def test_self_user_home_user_drive_and_path
- Gem.clear_paths
+ if Gem.win_platform? then
+ def test_self_user_home_userprofile
+ skip 'Ruby 1.9 properly handles ~ path expansion' unless '1.9' > RUBY_VERSION
+
+ Gem.clear_paths
- # safe-keep env variables
- orig_home, orig_user_profile = ENV['HOME'], ENV['USERPROFILE']
- orig_user_drive, orig_user_path = ENV['HOMEDRIVE'], ENV['HOMEPATH']
+ # safe-keep env variables
+ orig_home, orig_user_profile = ENV['HOME'], ENV['USERPROFILE']
- # prepare the environment
- ENV.delete('HOME')
- ENV.delete('USERPROFILE')
- ENV['HOMEDRIVE'] = 'Z:'
- ENV['HOMEPATH'] = '\\Users\\RubyUser'
+ # prepare for the test
+ ENV.delete('HOME')
+ ENV['USERPROFILE'] = "W:\\Users\\RubyUser"
- assert_equal "Z:\\Users\\RubyUser", Gem.user_home
+ assert_equal 'W:/Users/RubyUser', Gem.user_home
- ensure
- ENV['HOME'] = orig_home
- ENV['USERPROFILE'] = orig_user_profile
- ENV['USERDRIVE'] = orig_user_drive
- ENV['USERPATH'] = orig_user_path
- end if '1.9' > RUBY_VERSION
+ ensure
+ ENV['HOME'] = orig_home
+ ENV['USERPROFILE'] = orig_user_profile
+ end
+
+ def test_self_user_home_user_drive_and_path
+ skip 'Ruby 1.9 properly handles ~ path expansion' unless '1.9' > RUBY_VERSION
+
+ Gem.clear_paths
+
+ # safe-keep env variables
+ orig_home, orig_user_profile = ENV['HOME'], ENV['USERPROFILE']
+ orig_home_drive, orig_home_path = ENV['HOMEDRIVE'], ENV['HOMEPATH']
+
+ # prepare the environment
+ ENV.delete('HOME')
+ ENV.delete('USERPROFILE')
+ ENV['HOMEDRIVE'] = 'Z:'
+ ENV['HOMEPATH'] = "\\Users\\RubyUser"
+
+ assert_equal 'Z:/Users/RubyUser', Gem.user_home
+
+ ensure
+ ENV['HOME'] = orig_home
+ ENV['USERPROFILE'] = orig_user_profile
+ ENV['HOMEDRIVE'] = orig_home_drive
+ ENV['HOMEPATH'] = orig_home_path
+ end
+ end
def test_load_plugins
- with_plugin('load') { Gem.load_plugins }
+ plugin_path = File.join "lib", "rubygems_plugin.rb"
+
+ Dir.chdir @tempdir do
+ FileUtils.mkdir_p 'lib'
+ File.open plugin_path, "w" do |fp|
+ fp.puts "TestGem::TEST_SPEC_PLUGIN_LOAD = :loaded"
+ end
+
+ foo = quick_gem 'foo', '1' do |s|
+ s.files << plugin_path
+ end
+
+ install_gem foo
+ end
+
+ Gem.source_index = nil
+
+ gem 'foo'
+
+ Gem.load_plugins
+
+ assert_equal :loaded, TEST_SPEC_PLUGIN_LOAD
+ end
+
+ def test_load_env_plugins
+ with_plugin('load') { Gem.load_env_plugins }
assert_equal :loaded, TEST_PLUGIN_LOAD
util_remove_interrupt_command
# Should attempt to cause a StandardError
- with_plugin('standarderror') { Gem.load_plugins }
+ with_plugin('standarderror') { Gem.load_env_plugins }
assert_equal :loaded, TEST_PLUGIN_STANDARDERROR
util_remove_interrupt_command
# Should attempt to cause an Exception
- with_plugin('exception') { Gem.load_plugins }
+ with_plugin('exception') { Gem.load_env_plugins }
assert_equal :loaded, TEST_PLUGIN_EXCEPTION
end
diff --git a/test/rubygems/test_gem_activation.rb b/test/rubygems/test_gem_activation.rb
deleted file mode 100644
index 2d1cd4832d..0000000000
--- a/test/rubygems/test_gem_activation.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../ruby/envutil'
-require 'test/unit'
-
-class TestGemActivation < Test::Unit::TestCase
- def test_activation
- bug3140 = '[ruby-core:29486]'
- src = %{begin
- require 'rubygems-bug-parent'
-rescue Gem::LoadError
- puts $!
-else
- puts $bug_3140
-end}
- basedir = File.expand_path("../gems/current", __FILE__)
- env = {"HOME"=>basedir, "GEM_HOME"=>basedir, "GEM_PATH"=>basedir}
- assert_in_out_err([env, "-rrubygems-bug-child", "-e", src], "",
- /can't activate rubygems-bug-child.*already activated rubygems-bug-child-1\.1/, [],
- bug3140)
- end
-end if defined?(::Gem) and RUBY_VERSION < "1.9"
diff --git a/test/rubygems/test_gem_builder.rb b/test/rubygems/test_gem_builder.rb
index e5493ffc13..c007548ae5 100644
--- a/test/rubygems/test_gem_builder.rb
+++ b/test/rubygems/test_gem_builder.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/builder'
class TestGemBuilder < RubyGemTestCase
diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb
index 7897979d8f..e1db011d44 100644
--- a/test/rubygems/test_gem_command.rb
+++ b/test/rubygems/test_gem_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/command'
class Gem::Command
diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb
index 815798ae06..66168f0fd5 100644
--- a/test/rubygems/test_gem_command_manager.rb
+++ b/test/rubygems/test_gem_command_manager.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/command_manager'
class TestGemCommandManager < RubyGemTestCase
@@ -10,7 +16,9 @@ class TestGemCommandManager < RubyGemTestCase
end
def test_run_interrupt
- Gem.load_plugins
+ old_load_path = $:.dup
+ $: << "test/rubygems"
+ Gem.load_env_plugins
use_ui @ui do
assert_raises MockGemUi::TermError do
@@ -19,9 +27,14 @@ class TestGemCommandManager < RubyGemTestCase
assert_equal '', ui.output
assert_equal "ERROR: Interrupted\n", ui.error
end
+ ensure
+ $:.replace old_load_path
end
def test_run_crash_command
+ old_load_path = $:.dup
+ $: << "test/rubygems"
+
@command_manager.register_command :crash
use_ui @ui do
assert_raises MockGemUi::TermError do
@@ -31,6 +44,8 @@ class TestGemCommandManager < RubyGemTestCase
err = ui.error.split("\n").first
assert_equal "ERROR: Loading command: crash (RuntimeError)", err
end
+ ensure
+ $:.replace old_load_path
end
def test_process_args_bad_arg
@@ -54,7 +69,6 @@ class TestGemCommandManager < RubyGemTestCase
#check defaults
@command_manager.process_args("install")
- assert_equal false, check_options[:test]
assert_equal true, check_options[:generate_rdoc]
assert_equal false, check_options[:force]
assert_equal :both, check_options[:domain]
@@ -66,7 +80,7 @@ class TestGemCommandManager < RubyGemTestCase
#check settings
check_options = nil
@command_manager.process_args(
- "install --force --test --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
+ "install --force --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
assert_equal true, check_options[:generate_rdoc]
assert_equal true, check_options[:force]
assert_equal :local, check_options[:domain]
@@ -195,7 +209,7 @@ class TestGemCommandManager < RubyGemTestCase
#check settings
check_options = nil
- @command_manager.process_args("update --force --test --rdoc --install-dir .")
+ @command_manager.process_args("update --force --rdoc --install-dir .")
assert_equal true, check_options[:generate_rdoc]
assert_equal true, check_options[:force]
assert_equal Dir.pwd, check_options[:install_dir]
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index db29226b71..9064974551 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/build_command'
require 'rubygems/format'
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb
index 23c48439fc..6afd938861 100644
--- a/test/rubygems/test_gem_commands_cert_command.rb
+++ b/test/rubygems/test_gem_commands_cert_command.rb
@@ -1,5 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+require "test/rubygems/gemutilities"
require 'rubygems/commands/cert_command'
unless defined? OpenSSL then
@@ -73,7 +78,7 @@ class TestGemCommandsCertCommand < RubyGemTestCase
assert_equal '', @ui.error
assert_equal File.read(@cert_file_name),
- Gem::Security::OPT[:issuer_cert].to_s
+ @cmd.options[:issuer_cert].to_s
end
def test_execute_list
@@ -94,7 +99,7 @@ class TestGemCommandsCertCommand < RubyGemTestCase
assert_equal '', @ui.error
assert_equal File.read(@pkey_file_name),
- Gem::Security::OPT[:issuer_key].to_s
+ @cmd.options[:issuer_key].to_s
end
def test_execute_remove
diff --git a/test/rubygems/test_gem_commands_check_command.rb b/test/rubygems/test_gem_commands_check_command.rb
index 83065cf218..14418148f0 100644
--- a/test/rubygems/test_gem_commands_check_command.rb
+++ b/test/rubygems/test_gem_commands_check_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/check_command'
class TestGemCommandsCheckCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb
index 2085947afa..e865e29af0 100644
--- a/test/rubygems/test_gem_commands_contents_command.rb
+++ b/test/rubygems/test_gem_commands_contents_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/contents_command'
class TestGemCommandsContentsCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_dependency_command.rb b/test/rubygems/test_gem_commands_dependency_command.rb
index 8463017d50..2f044dce16 100644
--- a/test/rubygems/test_gem_commands_dependency_command.rb
+++ b/test/rubygems/test_gem_commands_dependency_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/dependency_command'
class TestGemCommandsDependencyCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb
index 6d694c3372..809e05327b 100644
--- a/test/rubygems/test_gem_commands_environment_command.rb
+++ b/test/rubygems/test_gem_commands_environment_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/environment_command'
class TestGemCommandsEnvironmentCommand < RubyGemTestCase
@@ -131,5 +137,14 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
assert_equal '', @ui.error
end
-end
+ def test_execute_platform
+ @cmd.send :handle_options, %w[platform]
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ assert_equal "#{Gem.platforms.join File::PATH_SEPARATOR}\n", @ui.output
+ assert_equal '', @ui.error
+ end
+end
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb
index 909bcf89de..9a995a0e8e 100644
--- a/test/rubygems/test_gem_commands_fetch_command.rb
+++ b/test/rubygems/test_gem_commands_fetch_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/package'
require 'rubygems/security'
require 'rubygems/commands/fetch_command'
diff --git a/test/rubygems/test_gem_commands_generate_index_command.rb b/test/rubygems/test_gem_commands_generate_index_command.rb
index 0952530e7f..21320bd721 100644
--- a/test/rubygems/test_gem_commands_generate_index_command.rb
+++ b/test/rubygems/test_gem_commands_generate_index_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/indexer'
require 'rubygems/commands/generate_index_command'
@@ -16,15 +22,11 @@ class TestGemCommandsGenerateIndexCommand < RubyGemTestCase
@cmd.execute
end
- yaml = File.join @gemhome, 'yaml'
- yaml_z = File.join @gemhome, 'yaml.Z'
- quick_index = File.join @gemhome, 'quick', 'index'
- quick_index_rz = File.join @gemhome, 'quick', 'index.rz'
+ marshal = File.join @gemhome, 'Marshal.4.8'
+ marshal_z = File.join @gemhome, 'Marshal.4.8.Z'
- assert File.exist?(yaml), yaml
- assert File.exist?(yaml_z), yaml_z
- assert File.exist?(quick_index), quick_index
- assert File.exist?(quick_index_rz), quick_index_rz
+ assert File.exist?(marshal), marshal
+ assert File.exist?(marshal_z), marshal_z
end
def test_execute_rss_update
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index ccdce787af..91e5a9ea0e 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/install_command'
class TestGemCommandsInstallCommand < RubyGemTestCase
@@ -172,6 +178,30 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error)
end
+ def test_execute_nonexistent_with_hint
+ misspelled = "nonexistent_with_hint"
+ correctly_spelled = "non_existent_with_hint"
+
+ util_setup_fake_fetcher
+ util_setup_spec_fetcher quick_gem(correctly_spelled, '2')
+
+ @cmd.options[:args] = [misspelled]
+
+ use_ui @ui do
+ e = assert_raises Gem::SystemExitException do
+ @cmd.execute
+ end
+
+ assert_equal 2, e.exit_code
+ end
+
+ expected = "ERROR: Could not find a valid gem 'nonexistent_with_hint' (>= 0) in any repository
+ERROR: Possible alternatives: non_existent_with_hint
+"
+
+ assert_equal expected, @ui.error
+ end
+
def test_execute_prerelease
util_setup_fake_fetcher(:prerelease)
util_setup_spec_fetcher @a2, @a2_pre
@@ -258,5 +288,36 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
assert out.empty?, out.inspect
end
+ def test_execute_conservative
+ util_setup_fake_fetcher
+ util_setup_spec_fetcher @b2
+
+ @fetcher.data["#{@gem_repo}gems/#{@b2.file_name}"] =
+ read_binary(File.join(@gemhome, 'cache', @b2.file_name))
+
+ uninstall_gem(@b2)
+
+ @cmd.options[:conservative] = true
+
+ @cmd.options[:args] = [@a2.name, @b2.name]
+
+ use_ui @ui do
+ orig_dir = Dir.pwd
+ begin
+ Dir.chdir @tempdir
+ e = assert_raises Gem::SystemExitException do
+ @cmd.execute
+ end
+ assert_equal 0, e.exit_code
+ ensure
+ Dir.chdir orig_dir
+ end
+ end
+
+ out = @ui.output.split "\n"
+ assert_equal "Successfully installed #{@b2.full_name}", out.shift
+ assert_equal "1 gem installed", out.shift
+ assert out.empty?, out.inspect
+ end
end
diff --git a/test/rubygems/test_gem_commands_list_command.rb b/test/rubygems/test_gem_commands_list_command.rb
index e9de62f3d0..d4cfadda49 100644
--- a/test/rubygems/test_gem_commands_list_command.rb
+++ b/test/rubygems/test_gem_commands_list_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/list_command'
class TestGemCommandsListCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_lock_command.rb b/test/rubygems/test_gem_commands_lock_command.rb
index 11d1c4fe8a..7696bd8b0f 100644
--- a/test/rubygems/test_gem_commands_lock_command.rb
+++ b/test/rubygems/test_gem_commands_lock_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/lock_command'
class TestGemCommandsLockCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_mirror_command.rb b/test/rubygems/test_gem_commands_mirror_command.rb
deleted file mode 100644
index 0c790ac24e..0000000000
--- a/test/rubygems/test_gem_commands_mirror_command.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-require_relative 'gemutilities'
-require 'rubygems/indexer'
-require 'rubygems/commands/mirror_command'
-
-class TestGemCommandsMirrorCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::MirrorCommand.new
- end
-
- def test_execute
- util_make_gems
-
- gems_dir = File.join @tempdir, 'gems'
- mirror = File.join @tempdir, 'mirror'
-
- FileUtils.mkdir_p gems_dir
- FileUtils.mkdir_p mirror
-
- Dir[File.join(@gemhome, 'cache', '*.gem')].each do |gem|
- FileUtils.mv gem, gems_dir
- end
-
- use_ui @ui do
- Gem::Indexer.new(@tempdir).generate_index
- end
-
- orig_HOME = ENV['HOME']
- ENV['HOME'] = @tempdir
- Gem.instance_variable_set :@user_home, nil
-
- File.open File.join(Gem.user_home, '.gemmirrorrc'), 'w' do |fp|
- fp.puts "---"
- # tempdir could be a drive+path (under windows)
- if @tempdir.match(/[a-z]:/i)
- fp.puts "- from: file:///#{@tempdir}"
- else
- fp.puts "- from: file://#{@tempdir}"
- end
- fp.puts " to: #{mirror}"
- end
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert File.exist?(File.join(mirror, 'gems', @a1.file_name))
- assert File.exist?(File.join(mirror, 'gems', @a2.file_name))
- assert File.exist?(File.join(mirror, 'gems', @b2.file_name))
- assert File.exist?(File.join(mirror, 'gems', @c1_2.file_name))
- assert File.exist?(File.join(mirror, "Marshal.#{@marshal_version}"))
- ensure
- orig_HOME.nil? ? ENV.delete('HOME') : ENV['HOME'] = orig_HOME
- Gem.instance_variable_set :@user_home, nil
- end
-
-end if ''.respond_to? :to_xs
-
diff --git a/test/rubygems/test_gem_commands_outdated_command.rb b/test/rubygems/test_gem_commands_outdated_command.rb
index 1abfe0f984..10862dedf7 100644
--- a/test/rubygems/test_gem_commands_outdated_command.rb
+++ b/test/rubygems/test_gem_commands_outdated_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/outdated_command'
class TestGemCommandsOutdatedCommand < RubyGemTestCase
@@ -14,8 +20,8 @@ class TestGemCommandsOutdatedCommand < RubyGemTestCase
end
def test_execute
- local_01 = quick_gem 'foo', '0.1'
- local_02 = quick_gem 'foo', '0.2'
+ quick_gem 'foo', '0.1'
+ quick_gem 'foo', '0.2'
remote_10 = quick_gem 'foo', '1.0'
remote_20 = quick_gem 'foo', '2.0'
diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb
index fa4281c6a7..f95061f0eb 100644
--- a/test/rubygems/test_gem_commands_owner_command.rb
+++ b/test/rubygems/test_gem_commands_owner_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/owner_command'
class TestGemCommandsOwnerCommand < RubyGemTestCase
@@ -20,7 +26,7 @@ class TestGemCommandsOwnerCommand < RubyGemTestCase
- email: user2@example.com
EOF
- @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 200, 'OK']
use_ui @ui do
@cmd.show_owners("freewill")
@@ -36,7 +42,7 @@ EOF
def test_show_owners_denied
response = "You don't have permission to push to this gem"
- @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners.yaml"] = [response, 403, 'Forbidden']
assert_raises MockGemUi::TermError do
use_ui @ui do
@@ -49,7 +55,7 @@ EOF
def test_add_owners
response = "Owner added successfully."
- @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
use_ui @ui do
@cmd.add_owners("freewill", ["user-new1@example.com"])
@@ -64,7 +70,7 @@ EOF
def test_add_owners_denied
response = "You don't have permission to push to this gem"
- @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
assert_raises MockGemUi::TermError do
use_ui @ui do
@@ -77,7 +83,7 @@ EOF
def test_remove_owners
response = "Owner removed successfully."
- @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 200, 'OK']
use_ui @ui do
@cmd.remove_owners("freewill", ["user-remove1@example.com"])
@@ -92,7 +98,7 @@ EOF
def test_remove_owners_denied
response = "You don't have permission to push to this gem"
- @fetcher.data["https://rubygems.org/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
+ @fetcher.data["#{Gem.host}/api/v1/gems/freewill/owners"] = [response, 403, 'Forbidden']
assert_raises MockGemUi::TermError do
use_ui @ui do
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb
index 06f43aa2b6..47df2e4a44 100644
--- a/test/rubygems/test_gem_commands_pristine_command.rb
+++ b/test/rubygems/test_gem_commands_pristine_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/pristine_command'
class TestGemCommandsPristineCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index d461bd8af6..7d7d89166f 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/push_command'
class TestGemCommandsPushCommand < RubyGemTestCase
@@ -18,15 +24,12 @@ class TestGemCommandsPushCommand < RubyGemTestCase
@cmd = Gem::Commands::PushCommand.new
end
- def test_sending_gem
- response = "Successfully registered gem: freewill (1.0.0)"
- @fetcher.data["https://rubygems.org/api/v1/gems"] = [response, 200, 'OK']
-
+ def send_battery
use_ui @ui do
@cmd.send_gem(@path)
end
- assert_match %r{Pushing gem to RubyGems.org...}, @ui.output
+ assert_match %r{Pushing gem to #{Gem.host}...}, @ui.output
assert_equal Net::HTTP::Post, @fetcher.last_request.class
assert_equal Gem.read_binary(@path), @fetcher.last_request.body
@@ -34,7 +37,30 @@ class TestGemCommandsPushCommand < RubyGemTestCase
assert_equal "application/octet-stream", @fetcher.last_request["Content-Type"]
assert_equal Gem.configuration.rubygems_api_key, @fetcher.last_request["Authorization"]
- assert_match response, @ui.output
+ assert_match @response, @ui.output
+ end
+
+ def test_sending_gem_default
+ @response = "Successfully registered gem: freewill (1.0.0)"
+ @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, 'OK']
+
+ send_battery
+ end
+
+ def test_sending_gem_host
+ @response = "Successfully registered gem: freewill (1.0.0)"
+ @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, 'OK']
+ @cmd.options[:host] = "#{Gem.host}"
+
+ send_battery
+ end
+
+ def test_sending_gem_ENV
+ @response = "Successfully registered gem: freewill (1.0.0)"
+ @fetcher.data["#{Gem.host}/api/v1/gems"] = [@response, 200, 'OK']
+ ENV["RUBYGEMS_HOST"] = "#{Gem.host}"
+
+ send_battery
end
def test_raises_error_with_no_arguments
@@ -46,7 +72,7 @@ class TestGemCommandsPushCommand < RubyGemTestCase
def test_sending_gem_denied
response = "You don't have permission to push to this gem"
- @fetcher.data["https://rubygems.org/api/v1/gems"] = [response, 403, 'Forbidden']
+ @fetcher.data["#{Gem.host}/api/v1/gems"] = [response, 403, 'Forbidden']
assert_raises MockGemUi::TermError do
use_ui @ui do
diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb
index aa54e9f545..1a4a3e0b75 100644
--- a/test/rubygems/test_gem_commands_query_command.rb
+++ b/test/rubygems/test_gem_commands_query_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/query_command'
class TestGemCommandsQueryCommand < RubyGemTestCase
@@ -64,9 +70,6 @@ pl (1 i386-linux)
end
def test_execute_all
- a1_name = @a1.full_name
- a2_name = @a2.full_name
-
@cmd.handle_options %w[-r --all]
use_ui @ui do
@@ -86,9 +89,6 @@ pl (1 i386-linux)
end
def test_execute_all_prerelease
- a1_name = @a1.full_name
- a2_name = @a2.full_name
-
@cmd.handle_options %w[-r --all --prerelease]
use_ui @ui do
diff --git a/test/rubygems/test_gem_commands_server_command.rb b/test/rubygems/test_gem_commands_server_command.rb
index 780e542036..8cdcb8b24b 100644
--- a/test/rubygems/test_gem_commands_server_command.rb
+++ b/test/rubygems/test_gem_commands_server_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/server_command'
class TestGemCommandsServerCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index 34632ea5f1..5930e2a9b7 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/sources_command'
class TestGemCommandsSourcesCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb
index 6a43439969..abdbd733a3 100644
--- a/test/rubygems/test_gem_commands_specification_command.rb
+++ b/test/rubygems/test_gem_commands_specification_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/specification_command'
class TestGemCommandsSpecificationCommand < RubyGemTestCase
@@ -25,8 +31,8 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
end
def test_execute_all
- foo1 = quick_gem 'foo', '0.0.1'
- foo2 = quick_gem 'foo', '0.0.2'
+ quick_gem 'foo', '0.0.1'
+ quick_gem 'foo', '0.0.2'
@cmd.options[:args] = %w[foo]
@cmd.options[:all] = true
@@ -56,8 +62,8 @@ class TestGemCommandsSpecificationCommand < RubyGemTestCase
end
def test_execute_exact_match
- foo = quick_gem 'foo'
- foo_bar = quick_gem 'foo_bar'
+ quick_gem 'foo'
+ quick_gem 'foo_bar'
@cmd.options[:args] = %w[foo]
diff --git a/test/rubygems/test_gem_commands_stale_command.rb b/test/rubygems/test_gem_commands_stale_command.rb
index 0bc7fc2734..4f72d13e81 100644
--- a/test/rubygems/test_gem_commands_stale_command.rb
+++ b/test/rubygems/test_gem_commands_stale_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/stale_command'
class TestGemCommandsStaleCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb
index 6113ed61b2..cb995cd941 100644
--- a/test/rubygems/test_gem_commands_uninstall_command.rb
+++ b/test/rubygems/test_gem_commands_uninstall_command.rb
@@ -1,5 +1,11 @@
-require_relative 'gemutilities'
-require_relative 'gem_installer_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
+require "test/rubygems/gem_installer_test_case"
require 'rubygems/commands/uninstall_command'
class TestGemCommandsUninstallCommand < GemInstallerTestCase
diff --git a/test/rubygems/test_gem_commands_unpack_command.rb b/test/rubygems/test_gem_commands_unpack_command.rb
index f81a84e3ac..f8585d1265 100644
--- a/test/rubygems/test_gem_commands_unpack_command.rb
+++ b/test/rubygems/test_gem_commands_unpack_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/unpack_command'
class TestGemCommandsUnpackCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
index 5264cd3955..7da4607151 100644
--- a/test/rubygems/test_gem_commands_update_command.rb
+++ b/test/rubygems/test_gem_commands_update_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/update_command'
class TestGemCommandsUpdateCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_commands_which_command.rb b/test/rubygems/test_gem_commands_which_command.rb
index 137f598378..4a86067079 100644
--- a/test/rubygems/test_gem_commands_which_command.rb
+++ b/test/rubygems/test_gem_commands_which_command.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/commands/which_command'
class TestGemCommandsWhichCommand < RubyGemTestCase
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index b76ff7b180..ad0d65038f 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/config_file'
class TestGemConfigFile < RubyGemTestCase
@@ -46,7 +52,6 @@ class TestGemConfigFile < RubyGemTestCase
fp.puts ":benchmark: true"
fp.puts ":bulk_threshold: 10"
fp.puts ":verbose: false"
- fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
fp.puts ":sources:"
fp.puts " - http://more-gems.example.com"
fp.puts "install: --wrappers"
@@ -62,7 +67,6 @@ class TestGemConfigFile < RubyGemTestCase
assert_equal 10, @cfg.bulk_threshold
assert_equal false, @cfg.verbose
assert_equal false, @cfg.update_sources
- assert_equal "701229f217cdf23b1344c7b4b54ca97", @cfg.rubygems_api_key
assert_equal %w[http://more-gems.example.com], Gem.sources
assert_equal '--wrappers', @cfg[:install]
assert_equal(['/usr/ruby/1.8/lib/ruby/gems/1.8', '/var/ruby/1.8/gem_home'],
diff --git a/test/rubygems/test_gem_dependency.rb b/test/rubygems/test_gem_dependency.rb
index fb88735a03..723364be41 100644
--- a/test/rubygems/test_gem_dependency.rb
+++ b/test/rubygems/test_gem_dependency.rb
@@ -1,19 +1,13 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/dependency'
class TestGemDependency < RubyGemTestCase
-
- def test_subclass
- sc = Class.new Gem::Dependency
- def sc.requirement() bogus; end
-
- out, err = capture_io do
- assert_equal Gem::Requirement.default, sc.new('a').version_requirement
- end
-
- assert_match %r%deprecated%, err
- end
-
def test_initialize
d = dep "pkg", "> 1.0"
@@ -133,17 +127,5 @@ class TestGemDependency < RubyGemTestCase
assert d.prerelease?
end
-
- def test_version_requirements_equals_deprecated
- d = dep "pkg", "1.0"
-
- out, err = capture_io do
- d.version_requirements = '2.0'
- assert_equal Gem::Requirement.new(%w[2.0]), d.requirement
- end
-
- assert_match %r%deprecated%, err
- end
-
end
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index 237c0a02a4..80f6cd21fd 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/dependency_installer'
class TestGemDependencyInstaller < RubyGemTestCase
@@ -44,20 +50,20 @@ class TestGemDependencyInstaller < RubyGemTestCase
s.platform = Gem::Platform.new %w[cpu other_platform 1]
end
- @w1, @w1_gem = util_gem 'w', '1' do |s| s.add_dependency 'x' end
+ @w1, @w1_gem = util_gem 'w', '1', 'x' => nil
@y1, @y1_gem = util_gem 'y', '1'
@y1_1_p, @y1_1_p_gem = util_gem 'y', '1.1' do |s|
s.platform = Gem::Platform.new %w[cpu my_platform 1]
end
- @z1, @z1_gem = util_gem 'z', '1' do |s| s.add_dependency 'y' end
+ @z1, @z1_gem = util_gem 'z', '1', 'y' => nil
@fetcher = Gem::FakeFetcher.new
Gem::RemoteFetcher.fetcher = @fetcher
- si = util_setup_spec_fetcher(@a1, @a1_pre, @b1, @b1_pre, @c1_pre, @d1, @d2,
- @x1_m, @x1_o, @w1, @y1, @y1_1_p, @z1)
+ util_setup_spec_fetcher(@a1, @a1_pre, @b1, @b1_pre, @c1_pre, @d1, @d2,
+ @x1_m, @x1_o, @w1, @y1, @y1_1_p, @z1)
util_clear_gems
end
@@ -78,7 +84,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
end
def test_install_all_dependencies
- e1, e1_gem = util_gem 'e', '1' do |s|
+ _, e1_gem = util_gem 'e', '1' do |s|
s.add_dependency 'b'
end
@@ -190,9 +196,9 @@ class TestGemDependencyInstaller < RubyGemTestCase
end
def test_install_dependency_old
- e1, e1_gem = util_gem 'e', '1'
- f1, f1_gem = util_gem 'f', '1' do |s| s.add_dependency 'e' end
- f2, f2_gem = util_gem 'f', '2'
+ _, e1_gem = util_gem 'e', '1'
+ _, f1_gem = util_gem 'f', '1', 'e' => nil
+ _, f2_gem = util_gem 'f', '2'
FileUtils.mv e1_gem, @tempdir
FileUtils.mv f1_gem, @tempdir
@@ -607,27 +613,25 @@ class TestGemDependencyInstaller < RubyGemTestCase
assert_equal [@a1_pre], prereleases
end
- def test_gather_dependencies
+ def assert_resolve expected, *specs
+ util_clear_gems
+
+ util_setup_spec_fetcher(*specs)
+
inst = Gem::DependencyInstaller.new
- inst.find_spec_by_name_and_version 'b'
+ inst.find_spec_by_name_and_version 'a'
inst.gather_dependencies
- assert_equal %w[a-1 b-1], inst.gems_to_install.map { |s| s.full_name }
+ actual = inst.gems_to_install.map { |s| s.full_name }
+ assert_equal expected, actual
end
- def test_gather_dependencies_dropped
- b2, = util_gem 'b', '2'
- c1, = util_gem 'c', '1' do |s| s.add_dependency 'b' end
-
- util_clear_gems
-
- si = util_setup_spec_fetcher @a1, @b1, b2, c1
-
+ def test_gather_dependencies
inst = Gem::DependencyInstaller.new
- inst.find_spec_by_name_and_version 'c'
+ inst.find_spec_by_name_and_version 'b'
inst.gather_dependencies
- assert_equal %w[b-2 c-1], inst.gems_to_install.map { |s| s.full_name }
+ assert_equal %w[a-1 b-1], inst.gems_to_install.map { |s| s.full_name }
end
def test_gather_dependencies_platform_alternate
@@ -659,11 +663,11 @@ class TestGemDependencyInstaller < RubyGemTestCase
end
def test_gather_dependencies_old_required
- e1, = util_gem 'e', '1' do |s| s.add_dependency 'd', '= 1' end
+ e1, = util_gem 'e', '1', 'd' => '= 1'
util_clear_gems
- si = util_setup_spec_fetcher @d1, @d2, e1
+ util_setup_spec_fetcher @d1, @d2, e1
inst = Gem::DependencyInstaller.new
inst.find_spec_by_name_and_version 'e'
diff --git a/test/rubygems/test_gem_dependency_list.rb b/test/rubygems/test_gem_dependency_list.rb
index eacd912f7a..394676b6ab 100644
--- a/test/rubygems/test_gem_dependency_list.rb
+++ b/test/rubygems/test_gem_dependency_list.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/dependency_list'
class TestGemDependencyList < RubyGemTestCase
diff --git a/test/rubygems/test_gem_doc_manager.rb b/test/rubygems/test_gem_doc_manager.rb
index 46f425b9ba..7732df2608 100644
--- a/test/rubygems/test_gem_doc_manager.rb
+++ b/test/rubygems/test_gem_doc_manager.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/doc_manager'
class TestGemDocManager < RubyGemTestCase
diff --git a/test/rubygems/test_gem_ext_configure_builder.rb b/test/rubygems/test_gem_ext_configure_builder.rb
index c4842034e9..2f2bac351d 100644
--- a/test/rubygems/test_gem_ext_configure_builder.rb
+++ b/test/rubygems/test_gem_ext_configure_builder.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/ext'
class TestGemExtConfigureBuilder < RubyGemTestCase
diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb
index d9483df2de..4b03858a2a 100644
--- a/test/rubygems/test_gem_ext_ext_conf_builder.rb
+++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/ext'
class TestGemExtExtConfBuilder < RubyGemTestCase
@@ -28,19 +34,60 @@ class TestGemExtExtConfBuilder < RubyGemTestCase
Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end
- expected = [
- "ruby extconf.rb",
- "creating Makefile\n",
- "make",
- "make: Nothing to be done for `all'.\n",
- "make install",
- "make: Nothing to be done for `install'.\n"
- ]
-
assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
assert_equal "creating Makefile\n", output[1]
+ case RUBY_PLATFORM
+ when /mswin/ then
+ assert_equal "nmake", output[2]
+ assert_equal "nmake install", output[4]
+ else
+ assert_equal "make", output[2]
+ assert_equal "make install", output[4]
+ end
+ end
+
+ def test_class_build_rbconfig_make_prog
+ configure_args = RbConfig::CONFIG['configure_args']
+
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
+ extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
+ end
+
+ output = []
+
+ Dir.chdir @ext do
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
+ end
+
+ assert_equal "creating Makefile\n", output[1]
assert_equal make_command, output[2]
- assert_equal make_command + " install", output[4]
+ assert_equal "#{make_command} install", output[4]
+ ensure
+ RbConfig::CONFIG['configure_args'] = configure_args
+ end
+
+ def test_class_build_env_make
+ configure_args, env_make = RbConfig::CONFIG['configure_args'], ENV.delete('make')
+ RbConfig::CONFIG['configure_args'] = ''
+ ENV['make'] = 'anothermake'
+
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
+ extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
+ end
+
+ output = []
+
+ assert_raises Gem::InstallError do
+ Dir.chdir @ext do
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
+ end
+ end
+
+ assert_equal "creating Makefile\n", output[1]
+ assert_equal "anothermake", output[2]
+ ensure
+ RbConfig::CONFIG['configure_args'] = configure_args
+ ENV['make'] = env_make
end
def test_class_build_extconf_fail
diff --git a/test/rubygems/test_gem_ext_rake_builder.rb b/test/rubygems/test_gem_ext_rake_builder.rb
index 243852b86f..d2e7de4cda 100644
--- a/test/rubygems/test_gem_ext_rake_builder.rb
+++ b/test/rubygems/test_gem_ext_rake_builder.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/ext'
class TestGemExtRakeBuilder < RubyGemTestCase
@@ -33,13 +39,6 @@ class TestGemExtRakeBuilder < RubyGemTestCase
output = output.join "\n"
- expected = [
- "#{@@ruby} mkrf_conf.rb",
- "",
- "#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
- "(in #{realdir})\n"
- ]
-
refute_match %r%^rake failed:%, output
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
assert_match %r%^#{Regexp.escape @@rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
@@ -64,14 +63,6 @@ class TestGemExtRakeBuilder < RubyGemTestCase
end
end
- expected = <<-EOF.strip
-rake failed:
-
-#{@@ruby} mkrf_conf.rb
-
-#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
- EOF
-
assert_match %r%^rake failed:%, error.message
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, error.message
assert_match %r%^#{Regexp.escape @@rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, error.message
diff --git a/test/rubygems/test_gem_format.rb b/test/rubygems/test_gem_format.rb
index 555f98d77c..0fa0bba4bf 100644
--- a/test/rubygems/test_gem_format.rb
+++ b/test/rubygems/test_gem_format.rb
@@ -1,5 +1,11 @@
-require_relative 'gemutilities'
-require_relative 'simple_gem'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
+require "test/rubygems/simple_gem"
require 'rubygems/format'
class TestGemFormat < RubyGemTestCase
diff --git a/test/rubygems/test_gem_gem_path_searcher.rb b/test/rubygems/test_gem_gem_path_searcher.rb
index 3fb54d08f2..c9f49681c7 100644
--- a/test/rubygems/test_gem_gem_path_searcher.rb
+++ b/test/rubygems/test_gem_gem_path_searcher.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/gem_path_searcher'
class Gem::GemPathSearcher
diff --git a/test/rubygems/test_gem_gem_runner.rb b/test/rubygems/test_gem_gem_runner.rb
index 5c3b03d473..78af8d9a4d 100644
--- a/test/rubygems/test_gem_gem_runner.rb
+++ b/test/rubygems/test_gem_gem_runner.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/gem_runner'
class TestGemGemRunner < RubyGemTestCase
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index f6495cbc74..c4d804bd43 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -1,6 +1,11 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems'
-require 'rubygems/command'
require 'rubygems/gemcutter_utilities'
class TestGemGemcutterUtilities < RubyGemTestCase
@@ -86,7 +91,7 @@ class TestGemGemcutterUtilities < RubyGemTestCase
if host
ENV['RUBYGEMS_HOST'] = host
else
- host = "https://rubygems.org"
+ host = Gem.host
end
@fetcher = Gem::FakeFetcher.new
diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb
index 9474f3fd36..ebfe9c8105 100644
--- a/test/rubygems/test_gem_indexer.rb
+++ b/test/rubygems/test_gem_indexer.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/indexer'
unless ''.respond_to? :to_xs then
@@ -93,8 +99,6 @@ class TestGemIndexer < RubyGemTestCase
@indexer.generate_index
end
- assert_indexed @tempdir, 'yaml'
- assert_indexed @tempdir, 'yaml.Z'
assert_indexed @tempdir, "Marshal.#{@marshal_version}"
assert_indexed @tempdir, "Marshal.#{@marshal_version}.Z"
@@ -104,52 +108,9 @@ class TestGemIndexer < RubyGemTestCase
assert File.directory?(quickdir)
assert File.directory?(marshal_quickdir)
- assert_indexed quickdir, "index"
- assert_indexed quickdir, "index.rz"
-
- quick_index = File.read File.join(quickdir, 'index')
- expected = <<-EOF
-a-1
-a-2
-a-3.a
-a_evil-9
-b-2
-c-1.2
-d-2.0
-d-2.0.a
-d-2.0.b
-pl-1-i386-linux
- EOF
-
- assert_equal expected, quick_index
-
- assert_indexed quickdir, "latest_index"
- assert_indexed quickdir, "latest_index.rz"
-
- latest_quick_index = File.read File.join(quickdir, 'latest_index')
- expected = <<-EOF
-a-2
-a_evil-9
-b-2
-c-1.2
-d-2.0
-pl-1-i386-linux
- EOF
-
- assert_equal expected, latest_quick_index
-
- assert_indexed quickdir, "#{@a1.spec_name}.rz"
- assert_indexed quickdir, "#{@a2.spec_name}.rz"
- assert_indexed quickdir, "#{@b2.spec_name}.rz"
- assert_indexed quickdir, "#{@c1_2.spec_name}.rz"
-
- assert_indexed quickdir, "#{@pl1.original_name}.gemspec.rz"
- refute_indexed quickdir, "#{@pl1.spec_name}.rz"
-
assert_indexed marshal_quickdir, "#{@a1.spec_name}.rz"
assert_indexed marshal_quickdir, "#{@a2.spec_name}.rz"
- refute_indexed quickdir, @c1_2.spec_name
refute_indexed marshal_quickdir, @c1_2.spec_name
assert_indexed @tempdir, "specs.#{@marshal_version}"
@@ -301,8 +262,6 @@ eighty characters.&lt;/pre&gt;
@indexer.generate_index
end
- assert_indexed @tempdir, 'yaml'
- assert_indexed @tempdir, 'yaml.Z'
assert_indexed @tempdir, "Marshal.#{@marshal_version}"
assert_indexed @tempdir, "Marshal.#{@marshal_version}.Z"
@@ -312,24 +271,9 @@ eighty characters.&lt;/pre&gt;
assert File.directory?(quickdir)
assert File.directory?(marshal_quickdir)
- assert_indexed quickdir, "index"
- assert_indexed quickdir, "index.rz"
-
- assert_indexed quickdir, "latest_index"
- assert_indexed quickdir, "latest_index.rz"
-
- assert_indexed quickdir, "#{@a1.spec_name}.rz"
- assert_indexed quickdir, "#{@a2.spec_name}.rz"
- assert_indexed quickdir, "#{@b2.spec_name}.rz"
- assert_indexed quickdir, "#{@c1_2.spec_name}.rz"
-
- assert_indexed quickdir, "#{@pl1.original_name}.gemspec.rz"
- refute_indexed quickdir, "#{@pl1.spec_name}.rz"
-
assert_indexed marshal_quickdir, "#{@a1.spec_name}.rz"
assert_indexed marshal_quickdir, "#{@a2.spec_name}.rz"
- refute_indexed quickdir, "#{@c1_2.spec_name}"
refute_indexed marshal_quickdir, "#{@c1_2.spec_name}"
refute_indexed @tempdir, "specs.#{@marshal_version}"
@@ -355,30 +299,14 @@ eighty characters.&lt;/pre&gt;
@indexer.generate_index
end
- assert_indexed @tempdir, 'yaml'
- assert_indexed @tempdir, 'yaml.Z'
assert_indexed @tempdir, "Marshal.#{@marshal_version}"
assert_indexed @tempdir, "Marshal.#{@marshal_version}.Z"
quickdir = File.join @tempdir, 'quick'
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
- assert File.directory?(quickdir)
assert File.directory?(marshal_quickdir)
- assert_indexed quickdir, "index"
- assert_indexed quickdir, "index.rz"
-
- assert_indexed quickdir, "latest_index"
- assert_indexed quickdir, "latest_index.rz"
-
- assert_indexed quickdir, "#{@a1.spec_name}.rz"
- assert_indexed quickdir, "#{@a2.spec_name}.rz"
- assert_indexed quickdir, "#{@b2.spec_name}.rz"
- assert_indexed quickdir, "#{@c1_2.spec_name}.rz"
-
- assert_indexed quickdir, "#{@pl1.original_name}.gemspec.rz"
-
assert_indexed marshal_quickdir, "#{@a1.spec_name}.rz"
assert_indexed marshal_quickdir, "#{@a2.spec_name}.rz"
@@ -451,8 +379,6 @@ eighty characters.&lt;/pre&gt;
@indexer.generate_index
end
- assert_indexed @tempdir, 'yaml'
- assert_indexed @tempdir, 'yaml.Z'
assert_indexed @tempdir, "Marshal.#{@marshal_version}"
assert_indexed @tempdir, "Marshal.#{@marshal_version}.Z"
@@ -462,19 +388,6 @@ eighty characters.&lt;/pre&gt;
assert File.directory?(quickdir)
assert File.directory?(marshal_quickdir)
- assert_indexed quickdir, "index"
- assert_indexed quickdir, "index.rz"
-
- assert_indexed quickdir, "latest_index"
- assert_indexed quickdir, "latest_index.rz"
-
- assert_indexed quickdir, "#{@a1.spec_name}.rz"
- assert_indexed quickdir, "#{@a2.spec_name}.rz"
- assert_indexed quickdir, "#{@b2.spec_name}.rz"
- assert_indexed quickdir, "#{@c1_2.spec_name}.rz"
-
- assert_indexed quickdir, "#{@pl1.original_name}.gemspec.rz"
-
assert_indexed marshal_quickdir, "#{@a1.spec_name}.rz"
assert_indexed marshal_quickdir, "#{@a2.spec_name}.rz"
@@ -496,41 +409,17 @@ eighty characters.&lt;/pre&gt;
assert_match %r%^Loaded all gems$%, @ui.output
assert_match %r%^Generating Marshal quick index gemspecs for 10 gems$%,
@ui.output
- assert_match %r%^Generating YAML quick index gemspecs for 10 gems$%,
- @ui.output
assert_match %r%^Complete$%, @ui.output
assert_match %r%^Generating specs index$%, @ui.output
assert_match %r%^Generating latest specs index$%, @ui.output
- assert_match %r%^Generating quick index$%, @ui.output
- assert_match %r%^Generating latest index$%, @ui.output
assert_match %r%^Generating prerelease specs index$%, @ui.output
assert_match %r%^Generating Marshal master index$%, @ui.output
- assert_match %r%^Generating YAML master index for 10 gems \(this may take a while\)$%, @ui.output
assert_match %r%^Complete$%, @ui.output
assert_match %r%^Compressing indicies$%, @ui.output
assert_equal '', @ui.error
end
- def test_generate_index_master
- use_ui @ui do
- @indexer.generate_index
- end
-
- yaml_path = File.join @tempdir, 'yaml'
- dump_path = File.join @tempdir, "Marshal.#{@marshal_version}"
-
- yaml_index = YAML.load_file yaml_path
- dump_index = Marshal.load Gem.read_binary(dump_path)
-
- dump_index.each do |_,gem|
- gem.send :remove_instance_variable, :@loaded
- end
-
- assert_equal yaml_index, dump_index,
- "expected YAML and Marshal to produce identical results"
- end
-
def test_generate_index_specs
use_ui @ui do
@indexer.generate_index
diff --git a/test/rubygems/test_gem_install_update_options.rb b/test/rubygems/test_gem_install_update_options.rb
index 385fd9d544..9000c4f873 100644
--- a/test/rubygems/test_gem_install_update_options.rb
+++ b/test/rubygems/test_gem_install_update_options.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_installer_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_installer_test_case"
require 'rubygems/install_update_options'
require 'rubygems/command'
@@ -13,7 +19,7 @@ class TestGemInstallUpdateOptions < GemInstallerTestCase
end
def test_add_install_update_options
- args = %w[-i /install_to --rdoc --ri -E -f -t -w -P HighSecurity
+ args = %w[-i /install_to --rdoc --ri -E -f -w -P HighSecurity
--ignore-dependencies --format-exec --include-dependencies]
assert @cmd.handles?(args)
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 3fcfa4fedc..3e329a2967 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_installer_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_installer_test_case"
class TestGemInstaller < GemInstallerTestCase
@@ -58,10 +64,6 @@ load Gem.bin_path('a', 'my_exec', version)
assert_equal '', @ui.error
gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
- expected = <<-EOF
-#{Gem.ruby} extconf.rb
-#{Gem.ruby}: No such file or directory -- extconf.rb (LoadError)
- EOF
assert_match %r%#{Regexp.escape Gem.ruby} extconf\.rb%,
File.read(gem_make_out)
@@ -655,7 +657,6 @@ load Gem.bin_path('a', 'my_exec', version)
use_ui @ui do
Dir.chdir @tempdir do Gem::Builder.new(@spec).build end
- gem = File.join @tempdir, @spec.file_name
@installer.install
end
diff --git a/test/rubygems/test_gem_local_remote_options.rb b/test/rubygems/test_gem_local_remote_options.rb
index 05083f5d07..7f122d29a6 100644
--- a/test/rubygems/test_gem_local_remote_options.rb
+++ b/test/rubygems/test_gem_local_remote_options.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/local_remote_options'
require 'rubygems/command'
@@ -30,6 +36,21 @@ class TestGemLocalRemoteOptions < RubyGemTestCase
assert_equal true, @cmd.both?
end
+ def test_clear_sources_option
+ @cmd.add_local_remote_options
+
+ s = URI.parse "http://only-gems.example.com/"
+
+ @cmd.handle_options %W[--clear-sources --source #{s}]
+ assert_equal [s.to_s], Gem.sources
+ end
+
+ def test_clear_sources_option_idiot_proof
+ @cmd.add_local_remote_options
+ @cmd.handle_options %W[--clear-sources]
+ assert_equal Gem.default_sources, Gem.sources
+ end
+
def test_local_eh
assert_equal false, @cmd.local?
@@ -62,9 +83,11 @@ class TestGemLocalRemoteOptions < RubyGemTestCase
s3 = URI.parse 'http://other-gems.example.com/some_subdir'
s4 = URI.parse 'http://more-gems.example.com/' # Intentional duplicate
+ original_sources = Gem.sources.dup
@cmd.handle_options %W[--source #{s1} --source #{s2} --source #{s3} --source #{s4}]
- assert_equal [s1.to_s, s2.to_s, "#{s3}/"], Gem.sources
+ assert_equal [original_sources, s1.to_s, s2.to_s, "#{s3}/"].flatten,
+ Gem.sources
end
def test_update_sources_option
diff --git a/test/rubygems/test_gem_package_tar_header.rb b/test/rubygems/test_gem_package_tar_header.rb
index cda3a0d663..2f499a3e0d 100644
--- a/test/rubygems/test_gem_package_tar_header.rb
+++ b/test/rubygems/test_gem_package_tar_header.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_package_tar_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package'
class TestGemPackageTarHeader < TarTestCase
diff --git a/test/rubygems/test_gem_package_tar_input.rb b/test/rubygems/test_gem_package_tar_input.rb
index 6938e97eba..377c4e452f 100644
--- a/test/rubygems/test_gem_package_tar_input.rb
+++ b/test/rubygems/test_gem_package_tar_input.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_package_tar_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_input'
class TestGemPackageTarInput < TarTestCase
diff --git a/test/rubygems/test_gem_package_tar_output.rb b/test/rubygems/test_gem_package_tar_output.rb
index 0f2c0901ef..090f09284a 100644
--- a/test/rubygems/test_gem_package_tar_output.rb
+++ b/test/rubygems/test_gem_package_tar_output.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_package_tar_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_output'
class TestGemPackageTarOutput < TarTestCase
diff --git a/test/rubygems/test_gem_package_tar_reader.rb b/test/rubygems/test_gem_package_tar_reader.rb
index 38ad48a94d..a57f5355fa 100644
--- a/test/rubygems/test_gem_package_tar_reader.rb
+++ b/test/rubygems/test_gem_package_tar_reader.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_package_tar_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package'
class TestGemPackageTarReader < TarTestCase
diff --git a/test/rubygems/test_gem_package_tar_reader_entry.rb b/test/rubygems/test_gem_package_tar_reader_entry.rb
index 5323474541..1b39b2fd2d 100644
--- a/test/rubygems/test_gem_package_tar_reader_entry.rb
+++ b/test/rubygems/test_gem_package_tar_reader_entry.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_package_tar_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package'
class TestGemPackageTarReaderEntry < TarTestCase
diff --git a/test/rubygems/test_gem_package_tar_writer.rb b/test/rubygems/test_gem_package_tar_writer.rb
index d819065a41..8a4c951286 100644
--- a/test/rubygems/test_gem_package_tar_writer.rb
+++ b/test/rubygems/test_gem_package_tar_writer.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_package_tar_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_package_tar_test_case"
require 'rubygems/package/tar_writer'
class TestTarWriter < TarTestCase
diff --git a/test/rubygems/test_gem_package_task.rb b/test/rubygems/test_gem_package_task.rb
index 2e6710f4ac..11ed69e02b 100644
--- a/test/rubygems/test_gem_package_task.rb
+++ b/test/rubygems/test_gem_package_task.rb
@@ -1,8 +1,14 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems'
require 'rubygems/package_task'
-class TestGemPackageTask < MiniTest::Unit::TestCase
+class TestGemPackageTask < RubyGemTestCase
def test_gem_package
gem = Gem::Specification.new do |g|
diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb
index 686493511f..ac8a65bf7a 100644
--- a/test/rubygems/test_gem_platform.rb
+++ b/test/rubygems/test_gem_platform.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/platform'
require 'rbconfig'
@@ -117,7 +123,6 @@ class TestGemPlatform < RubyGemTestCase
def test_initialize_platform
platform = Gem::Platform.new 'cpu-my_platform1'
- expected = Gem::Platform.new platform
assert_equal 'cpu', platform.cpu
assert_equal 'my_platform', platform.os
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index d6b78dc7cc..fbeb19c239 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'ostruct'
require 'webrick'
require 'rubygems/remote_fetcher'
@@ -372,7 +378,7 @@ gems:
uri.user, uri.password = 'domain%5Cuser', 'bar'
fetcher = Gem::RemoteFetcher.new uri.to_s
proxy = fetcher.instance_variable_get("@proxy_uri")
- assert_equal 'domain\user', URI.unescape(proxy.user)
+ assert_equal 'domain\user', fetcher.unescape(proxy.user)
assert_equal 'bar', proxy.password
assert_data_from_proxy fetcher.fetch_path(@server_uri)
end
@@ -383,7 +389,7 @@ gems:
fetcher = Gem::RemoteFetcher.new uri.to_s
proxy = fetcher.instance_variable_get("@proxy_uri")
assert_equal 'user', proxy.user
- assert_equal 'my pass', URI.unescape(proxy.password)
+ assert_equal 'my pass', fetcher.unescape(proxy.password)
assert_data_from_proxy fetcher.fetch_path(@server_uri)
end
end
@@ -406,8 +412,8 @@ gems:
ENV['http_proxy_pass'] = 'my bar'
fetcher = Gem::RemoteFetcher.new nil
proxy = fetcher.instance_variable_get("@proxy_uri")
- assert_equal 'foo\user', URI.unescape(proxy.user)
- assert_equal 'my bar', URI.unescape(proxy.password)
+ assert_equal 'foo\user', fetcher.unescape(proxy.user)
+ assert_equal 'my bar', fetcher.unescape(proxy.password)
assert_data_from_proxy fetcher.fetch_path(@server_uri)
end
end
@@ -562,7 +568,7 @@ gems:
end
end
- conn = { 'gems.example.com:80' => conn }
+ conn = { "#{Thread.current.object_id}:gems.example.com:80" => conn }
fetcher.instance_variable_set :@connections, conn
data = fetcher.open_uri_or_path 'http://gems.example.com/redirect'
@@ -581,7 +587,7 @@ gems:
res
end
- conn = { 'gems.example.com:80' => conn }
+ conn = { "#{Thread.current.object_id}:gems.example.com:80" => conn }
fetcher.instance_variable_set :@connections, conn
e = assert_raises Gem::RemoteFetcher::FetchError do
@@ -646,11 +652,13 @@ gems:
def assert_error(exception_class=Exception)
got_exception = false
+
begin
yield
- rescue exception_class => ex
+ rescue exception_class
got_exception = true
end
+
assert got_exception, "Expected exception conforming to #{exception_class}"
end
diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb
index a70dd0fd8e..03f3ddd5e7 100644
--- a/test/rubygems/test_gem_requirement.rb
+++ b/test/rubygems/test_gem_requirement.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require "rubygems/requirement"
class TestGemRequirement < RubyGemTestCase
@@ -216,9 +222,9 @@ class TestGemRequirement < RubyGemTestCase
refute_satisfied_by "2.0", "~> 1.4.4"
refute_satisfied_by "1.1.pre", "~> 1.0.0"
- assert_satisfied_by "1.1.pre", "~> 1.1"
+ refute_satisfied_by "1.1.pre", "~> 1.1"
refute_satisfied_by "2.0.a", "~> 1.0"
- assert_satisfied_by "2.0.a", "~> 2.0"
+ refute_satisfied_by "2.0.a", "~> 2.0"
end
def test_satisfied_by_eh_multiple
diff --git a/test/rubygems/test_gem_security.rb b/test/rubygems/test_gem_security.rb
new file mode 100644
index 0000000000..38128e6992
--- /dev/null
+++ b/test/rubygems/test_gem_security.rb
@@ -0,0 +1,96 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
+require 'rubygems/security'
+
+class TestGemSecurity < RubyGemTestCase
+
+ def test_class_build_cert
+ name = OpenSSL::X509::Name.parse "CN=nobody/DC=example"
+ key = OpenSSL::PKey::RSA.new 512
+ opt = { :cert_age => 60 }
+
+ cert = Gem::Security.build_cert name, key, opt
+
+ assert_kind_of OpenSSL::X509::Certificate, cert
+
+ assert_equal 2, cert.version
+ assert_equal 0, cert.serial
+ assert_equal key.public_key.to_pem, cert.public_key.to_pem
+ assert_in_delta Time.now, cert.not_before, 10
+ assert_in_delta Time.now + 60, cert.not_after, 10
+ assert_equal name.to_s, cert.subject.to_s
+
+ assert_equal 3, cert.extensions.length
+
+ constraints = cert.extensions.find { |ext| ext.oid == 'basicConstraints' }
+ assert_equal 'CA:FALSE', constraints.value
+
+ key_usage = cert.extensions.find { |ext| ext.oid == 'keyUsage' }
+ assert_equal 'Digital Signature, Key Encipherment, Data Encipherment',
+ key_usage.value
+
+ key_ident = cert.extensions.find { |ext| ext.oid == 'subjectKeyIdentifier' }
+ assert_equal 59, key_ident.value.length
+
+ assert_equal name.to_s, cert.issuer.to_s
+ assert_equal name.to_s, cert.subject.to_s
+ end
+
+ def test_class_build_self_signed_cert
+ email = 'nobody@example'
+ opt = {
+ :cert_age => 60,
+ :key_size => 512,
+ :save_cert => false,
+ :save_key => false,
+ }
+
+ result = Gem::Security.build_self_signed_cert email, opt
+
+ key = result[:key]
+
+ assert_kind_of OpenSSL::PKey::RSA, key
+ # assert_equal 512, key.something_here
+
+ cert = result[:cert]
+
+ assert_equal '/CN=nobody/DC=example', cert.issuer.to_s
+ end
+
+ def test_class_sign_cert
+ name = OpenSSL::X509::Name.parse "CN=nobody/DC=example"
+ key = OpenSSL::PKey::RSA.new 512
+ cert = OpenSSL::X509::Certificate.new
+
+ cert.subject = name
+ cert.public_key = key.public_key
+
+ signed = Gem::Security.sign_cert cert, key, cert
+
+ assert cert.verify key
+ assert_equal name.to_s, signed.subject.to_s
+ end
+
+ def test_class_email_to_name
+ munger = Gem::Security::OPT[:munge_re]
+
+ assert_equal '/CN=nobody/DC=example',
+ Gem::Security.email_to_name('nobody@example', munger).to_s
+
+ assert_equal '/CN=nobody/DC=example/DC=com',
+ Gem::Security.email_to_name('nobody@example.com', munger).to_s
+
+ assert_equal '/CN=no.body/DC=example',
+ Gem::Security.email_to_name('no.body@example', munger).to_s
+
+ assert_equal '/CN=no_body/DC=example',
+ Gem::Security.email_to_name('no+body@example', munger).to_s
+ end
+
+end
+
diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb
index 8f8a9cae05..f7ba61a4b5 100644
--- a/test/rubygems/test_gem_server.rb
+++ b/test/rubygems/test_gem_server.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/server'
require 'stringio'
@@ -92,7 +98,7 @@ class TestGemServer < RubyGemTestCase
def test_listen
util_listen
- out, err = capture_io do
+ capture_io do
@server.listen
end
@@ -102,109 +108,11 @@ class TestGemServer < RubyGemTestCase
def test_listen_addresses
util_listen
- out, err = capture_io do
+ capture_io do
@server.listen %w[a b]
end
-
- assert_equal 2, @server.server.listeners.length
- end
-
- def test_quick_a_1_gemspec_rz
- data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert @res['date']
- assert_equal 'application/x-deflate', @res['content-type']
-
- spec = YAML.load Gem.inflate(@res.body)
- assert_equal 'a', spec.name
- assert_equal Gem::Version.new(1), spec.version
- end
-
- def test_quick_a_1_mswin32_gemspec_rz
- a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
-
- data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert @res['date']
- assert_equal 'application/x-deflate', @res['content-type']
-
- spec = YAML.load Gem.inflate(@res.body)
- assert_equal 'a', spec.name
- assert_equal Gem::Version.new(1), spec.version
- assert_equal Gem::Platform.local, spec.platform
- end
-
- def test_quick_common_substrings
- ab1 = quick_gem 'ab', '1'
-
- data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert @res['date']
- assert_equal 'application/x-deflate', @res['content-type']
-
- spec = YAML.load Gem.inflate(@res.body)
- assert_equal 'a', spec.name
- assert_equal Gem::Version.new(1), spec.version
- end
-
- def test_quick_index
- data = StringIO.new "GET /quick/index HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'text/plain', @res['content-type']
- assert_equal "a-1\na-2", @res.body
- end
- def test_quick_index_rz
- data = StringIO.new "GET /quick/index.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'application/x-deflate', @res['content-type']
- assert_equal "a-1\na-2", Gem.inflate(@res.body)
- end
-
- def test_quick_latest_index
- data = StringIO.new "GET /quick/latest_index HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'text/plain', @res['content-type']
- assert_equal 'a-2', @res.body
- end
-
- def test_quick_latest_index_rz
- data = StringIO.new "GET /quick/latest_index.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'application/x-deflate', @res['content-type']
- assert_equal 'a-2', Gem.inflate(@res.body)
+ assert_equal 2, @server.server.listeners.length
end
def test_quick_missing
@@ -236,7 +144,7 @@ class TestGemServer < RubyGemTestCase
end
def test_quick_marshal_a_1_mswin32_gemspec_rz
- a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
+ quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
@req.parse data
@@ -305,38 +213,6 @@ class TestGemServer < RubyGemTestCase
Marshal.load(Gem.gunzip(@res.body))
end
- def test_yaml
- data = StringIO.new "GET /yaml.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.yaml @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'text/plain', @res['content-type']
-
- si = Gem::SourceIndex.new
- si.add_specs @a1, @a2
-
- assert_equal si, YAML.load(@res.body)
- end
-
- def test_yaml_Z
- data = StringIO.new "GET /yaml.#{Gem.marshal_version}.Z HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.yaml @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'application/x-deflate', @res['content-type']
-
- si = Gem::SourceIndex.new
- si.add_specs @a1, @a2
-
- assert_equal si, YAML.load(Gem.inflate(@res.body))
- end
-
def util_listen
webrick = Object.new
webrick.instance_variable_set :@listeners, []
diff --git a/test/rubygems/test_gem_source_index.rb b/test/rubygems/test_gem_source_index.rb
index 40dfeb95c1..95ea94451d 100644
--- a/test/rubygems/test_gem_source_index.rb
+++ b/test/rubygems/test_gem_source_index.rb
@@ -1,13 +1,13 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/source_index'
require 'rubygems/config_file'
-class Gem::SourceIndex
- public :fetcher, :fetch_bulk_index, :fetch_quick_index,
- :find_missing, :gems, :remove_extra,
- :update_with_missing, :unzip
-end
-
class TestGemSourceIndex < RubyGemTestCase
def setup
@@ -116,19 +116,14 @@ end
fp.write 'raise Exception, "epic fail"'
end
- use_ui @ui do
+ out, err = capture_io do
assert_equal nil, Gem::SourceIndex.load_specification(spec_file)
end
- assert_equal '', @ui.output
-
- expected = <<-EOF
-WARNING: #<Exception: epic fail>
-raise Exception, "epic fail"
-WARNING: Invalid .gemspec format in '#{spec_file}'
- EOF
+ assert_equal '', out
- assert_equal expected, @ui.error
+ expected = "Invalid gemspec in [#{spec_file}]: epic fail\n"
+ assert_equal expected, err
end
def test_self_load_specification_interrupt
@@ -163,14 +158,13 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
fp.write '1 +'
end
- use_ui @ui do
+ out, err = capture_io do
assert_equal nil, Gem::SourceIndex.load_specification(spec_file)
end
- assert_equal '', @ui.output
+ assert_equal '', out
- assert_match(/syntax error/, @ui.error)
- assert_match(/1 \+/, @ui.error)
+ assert_match(/syntax error/, err)
end
def test_self_load_specification_system_exit
@@ -198,23 +192,6 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
# TODO
end
- def test_fetcher
- assert_equal @fetcher, @source_index.fetcher
- end
-
- def test_find_missing
- missing = @source_index.find_missing [@b2.full_name]
- assert_equal [@b2.full_name], missing
- end
-
- def test_find_missing_none_missing
- missing = @source_index.find_missing [
- @a1.full_name, @a2.full_name, @c1_2.full_name
- ]
-
- assert_equal [], missing
- end
-
def test_find_name
assert_equal [@a1, @a2, @a3a], @source_index.find_name('a')
assert_equal [@a2], @source_index.find_name('a', '= 2')
@@ -359,27 +336,6 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
assert_equal 'source index not created from disk', e.message
end
- def test_remove_extra
- @source_index.add_spec @a1
- @source_index.add_spec @a2
- @source_index.add_spec @pl1
-
- @source_index.remove_extra [@a1.full_name, @pl1.full_name]
-
- assert_equal [@a1.full_name],
- @source_index.gems.map { |n,s| n }.sort
- end
-
- def test_remove_extra_no_changes
- gems = [@a1.full_name, @a2.full_name]
- @source_index.add_spec @a1
- @source_index.add_spec @a2
-
- @source_index.remove_extra gems
-
- assert_equal gems, @source_index.gems.map { |n,s| n }.sort
- end
-
def test_remove_spec
deleted = @source_index.remove_spec 'a-1'
@@ -442,20 +398,5 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
assert_match(/^[a-f0-9]{64}$/, sig)
end
- def test_unzip
- input = "x\234+\316\317MU(I\255(\001\000\021\350\003\232"
- assert_equal 'some text', @source_index.unzip(input)
- end
-
- def util_setup_bulk_fetch(compressed)
- source_index = @source_index.dump
-
- if compressed then
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}.Z"] = util_zip source_index
- else
- @fetcher.data["#{@gem_repo}Marshal.#{@marshal_version}"] = source_index
- end
- end
-
end
diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb
index 95b74d9bfe..517247b98f 100644
--- a/test/rubygems/test_gem_spec_fetcher.rb
+++ b/test/rubygems/test_gem_spec_fetcher.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/spec_fetcher'
class TestGemSpecFetcher < RubyGemTestCase
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 97e2615fe2..573610b52d 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'stringio'
require 'rubygems/specification'
@@ -777,7 +783,6 @@ Gem::Specification.new do |s|
s.summary = %q{this is a summary}
if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION}
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -832,7 +837,6 @@ Gem::Specification.new do |s|
s.test_files = [\"test/suite.rb\"]
if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -1175,21 +1179,6 @@ end
end
end
- def test_validate_rubyforge_project
- util_setup_validate
-
- Dir.chdir @tempdir do
- @a1.rubyforge_project = ''
-
- use_ui @ui do
- @a1.validate
- end
-
- assert_equal "WARNING: no rubyforge_project specified\n",
- @ui.error, 'error'
- end
- end
-
def test_validate_rubygems_version
util_setup_validate
@@ -1258,7 +1247,9 @@ end
specfile.write "raise 'boom'"
specfile.close
begin
- Gem::Specification.load(specfile.path)
+ capture_io do
+ Gem::Specification.load(specfile.path)
+ end
rescue => e
name_rexp = Regexp.new(Regexp.escape(specfile.path))
assert e.backtrace.grep(name_rexp).any?
diff --git a/test/rubygems/test_gem_stream_ui.rb b/test/rubygems/test_gem_stream_ui.rb
index 97f6f09833..60bd3032a8 100644
--- a/test/rubygems/test_gem_stream_ui.rb
+++ b/test/rubygems/test_gem_stream_ui.rb
@@ -1,5 +1,12 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/user_interaction'
+require 'timeout'
class TestGemStreamUI < RubyGemTestCase
@@ -28,6 +35,7 @@ class TestGemStreamUI < RubyGemTestCase
@err = StringIO.new
@in.extend IsTty
+ @out.extend IsTty
@sui = Gem::StreamUI.new @in, @out, @err
end
@@ -109,32 +117,94 @@ class TestGemStreamUI < RubyGemTestCase
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
end
- def test_proress_reporter_silent_nil
+ def test_progress_reporter_silent_nil
@cfg.verbose = nil
reporter = @sui.progress_reporter 10, 'hi'
assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
end
- def test_proress_reporter_silent_false
+ def test_progress_reporter_silent_false
@cfg.verbose = false
reporter = @sui.progress_reporter 10, 'hi'
assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
assert_equal "", @out.string
end
- def test_proress_reporter_simple
+ def test_progress_reporter_simple
@cfg.verbose = true
reporter = @sui.progress_reporter 10, 'hi'
assert_kind_of Gem::StreamUI::SimpleProgressReporter, reporter
assert_equal "hi\n", @out.string
end
- def test_proress_reporter_verbose
+ def test_progress_reporter_verbose
@cfg.verbose = 0
reporter = @sui.progress_reporter 10, 'hi'
assert_kind_of Gem::StreamUI::VerboseProgressReporter, reporter
assert_equal "hi\n", @out.string
end
-end
+ def test_download_reporter_silent_nil
+ @cfg.verbose = nil
+ reporter = @sui.download_reporter
+ reporter.fetch 'a.gem', 1024
+ assert_kind_of Gem::StreamUI::SilentDownloadReporter, reporter
+ assert_equal "", @out.string
+ end
+
+ def test_download_reporter_silent_false
+ @cfg.verbose = false
+ reporter = @sui.download_reporter
+ reporter.fetch 'a.gem', 1024
+ assert_kind_of Gem::StreamUI::SilentDownloadReporter, reporter
+ assert_equal "", @out.string
+ end
+
+ def test_download_reporter_anything
+ @cfg.verbose = 0
+ reporter = @sui.download_reporter
+ assert_kind_of Gem::StreamUI::VerboseDownloadReporter, reporter
+ end
+
+ def test_verbose_download_reporter
+ @cfg.verbose = true
+ reporter = @sui.download_reporter
+ reporter.fetch 'a.gem', 1024
+ assert_equal "Fetching: a.gem", @out.string
+ end
+ def test_verbose_download_reporter_progress
+ @cfg.verbose = true
+ reporter = @sui.download_reporter
+ reporter.fetch 'a.gem', 1024
+ reporter.update 512
+ assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)", @out.string
+ end
+
+ def test_verbose_download_reporter_progress_once
+ @cfg.verbose = true
+ reporter = @sui.download_reporter
+ reporter.fetch 'a.gem', 1024
+ reporter.update 510
+ reporter.update 512
+ assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)", @out.string
+ end
+
+ def test_verbose_download_reporter_progress_complete
+ @cfg.verbose = true
+ reporter = @sui.download_reporter
+ reporter.fetch 'a.gem', 1024
+ reporter.update 510
+ reporter.done
+ assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)\rFetching: a.gem (100%)\n", @out.string
+ end
+
+ def test_verbose_download_reporter_no_tty
+ @out.tty = false
+
+ @cfg.verbose = true
+ reporter = @sui.download_reporter
+ reporter.fetch 'a.gem', 1024
+ assert_equal "", @out.string
+ end
+end
diff --git a/test/rubygems/test_gem_text.rb b/test/rubygems/test_gem_text.rb
new file mode 100644
index 0000000000..b800c5f58c
--- /dev/null
+++ b/test/rubygems/test_gem_text.rb
@@ -0,0 +1,49 @@
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
+require "rubygems/text"
+
+class TestGemText < RubyGemTestCase
+ include Gem::Text
+
+ def test_format_text
+ assert_equal "text to\nwrap", format_text("text to wrap", 8)
+ end
+
+ def test_format_text_indent
+ assert_equal " text to\n wrap", format_text("text to wrap", 8, 2)
+ end
+
+ def test_format_text_none
+ assert_equal "text to wrap", format_text("text to wrap", 40)
+ end
+
+ def test_format_text_none_indent
+ assert_equal " text to wrap", format_text("text to wrap", 40, 2)
+ end
+
+ def test_levenshtein_distance_add
+ assert_equal 2, levenshtein_distance("zentest", "zntst")
+ assert_equal 2, levenshtein_distance("zntst", "zentest")
+ end
+
+ def test_levenshtein_distance_empty
+ assert_equal 5, levenshtein_distance("abcde", "")
+ assert_equal 5, levenshtein_distance("", "abcde")
+ end
+
+ def test_levenshtein_distance_remove
+ assert_equal 3, levenshtein_distance("zentest", "zentestxxx")
+ assert_equal 3, levenshtein_distance("zentestxxx", "zentest")
+ end
+
+ def test_levenshtein_distance_replace
+ assert_equal 2, levenshtein_distance("zentest", "ZenTest")
+ assert_equal 7, levenshtein_distance("xxxxxxx", "ZenTest")
+ assert_equal 7, levenshtein_distance("zentest", "xxxxxxx")
+ end
+end
diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb
index d12ef032b9..9d42d9bcde 100644
--- a/test/rubygems/test_gem_uninstaller.rb
+++ b/test/rubygems/test_gem_uninstaller.rb
@@ -1,4 +1,10 @@
-require_relative 'gem_installer_test_case'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gem_installer_test_case"
require 'rubygems/uninstaller'
class TestGemUninstaller < GemInstallerTestCase
diff --git a/test/rubygems/test_gem_validator.rb b/test/rubygems/test_gem_validator.rb
index 51dad524f3..c7f23dcae8 100644
--- a/test/rubygems/test_gem_validator.rb
+++ b/test/rubygems/test_gem_validator.rb
@@ -1,5 +1,11 @@
-require_relative 'gemutilities'
-require_relative 'simple_gem'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
+require "test/rubygems/simple_gem"
require 'rubygems/validator'
class TestGemValidator < RubyGemTestCase
diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb
index f3692682b6..a3fbe24f15 100644
--- a/test/rubygems/test_gem_version.rb
+++ b/test/rubygems/test_gem_version.rb
@@ -1,5 +1,11 @@
-require_relative 'gemutilities'
-require 'rubygems/version'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
+require "rubygems/version"
class TestGemVersion < RubyGemTestCase
@@ -11,6 +17,10 @@ class TestGemVersion < RubyGemTestCase
assert_bumped_version_equal "5.3", "5.2.4.a"
end
+ def test_bump_alphanumeric
+ assert_bumped_version_equal "5.3", "5.2.4.a10"
+ end
+
def test_bump_trailing_zeros
assert_bumped_version_equal "5.1", "5.0.0"
end
@@ -32,14 +42,16 @@ class TestGemVersion < RubyGemTestCase
end
def test_eql_eh
- assert_version_eql "1.2", "1.2"
- refute_version_eql "1.2", "1.2.0"
- refute_version_eql "1.2", "1.3"
+ assert_version_eql "1.2", "1.2"
+ refute_version_eql "1.2", "1.2.0"
+ refute_version_eql "1.2", "1.3"
+ refute_version_eql "1.2.b1", "1.2.b.1"
end
- def test_equals
- assert_version_equal "1.2", "1.2"
- refute_version_equal "1.2", "1.3"
+ def test_equals2
+ assert_version_equal "1.2", "1.2"
+ refute_version_equal "1.2", "1.3"
+ assert_version_equal "1.2.b1", "1.2.b.1"
end
# REVISIT: consider removing as too impl-bound
@@ -88,13 +100,16 @@ class TestGemVersion < RubyGemTestCase
end
def test_spaceship
- assert_equal( 0, v("1.0") <=> v("1.0.0"))
- assert_equal( 1, v("1.0") <=> v("1.0.a"))
- assert_equal( 1, v("1.8.2") <=> v("0.0.0"))
- assert_equal( 1, v("1.8.2") <=> v("1.8.2.a"))
- assert_equal( 1, v("1.8.2.b") <=> v("1.8.2.a"))
- assert_equal(-1, v("1.8.2.a") <=> v("1.8.2"))
- assert_equal( 0, v("") <=> v("0"))
+ assert_equal( 0, v("1.0") <=> v("1.0.0"))
+ assert_equal( 1, v("1.0") <=> v("1.0.a"))
+ assert_equal( 1, v("1.8.2") <=> v("0.0.0"))
+ assert_equal( 1, v("1.8.2") <=> v("1.8.2.a"))
+ assert_equal( 1, v("1.8.2.b") <=> v("1.8.2.a"))
+ assert_equal(-1, v("1.8.2.a") <=> v("1.8.2"))
+ assert_equal( 1, v("1.8.2.a10") <=> v("1.8.2.a9"))
+ assert_equal( 0, v("") <=> v("0"))
+
+ assert_nil v("1.0") <=> "whatever"
end
def test_spermy_recommendation
diff --git a/test/rubygems/test_gem_version_option.rb b/test/rubygems/test_gem_version_option.rb
index af0b7bf662..a0b4eac380 100644
--- a/test/rubygems/test_gem_version_option.rb
+++ b/test/rubygems/test_gem_version_option.rb
@@ -1,4 +1,10 @@
-require_relative 'gemutilities'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
require 'rubygems/command'
require 'rubygems/version_option'
diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb
index 524b20d82b..dcbb8770f8 100644
--- a/test/rubygems/test_kernel.rb
+++ b/test/rubygems/test_kernel.rb
@@ -1,5 +1,10 @@
-require_relative 'gemutilities'
-require 'rubygems/package'
+######################################################################
+# This file is imported from the rubygems project.
+# DO NOT make modifications in this repo. They _will_ be reverted!
+# File a patch instead and assign it to Ryan Davis or Eric Hodel.
+######################################################################
+
+require "test/rubygems/gemutilities"
class TestKernel < RubyGemTestCase
@@ -20,21 +25,18 @@ class TestKernel < RubyGemTestCase
def test_gem
assert gem('a', '= 1'), "Should load"
assert $:.any? { |p| %r{a-1/lib} =~ p }
- assert $:.any? { |p| %r{a-1/bin} =~ p }
end
def test_gem_redundent
assert gem('a', '= 1'), "Should load"
refute gem('a', '= 1'), "Should not load"
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
- assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
end
def test_gem_overlapping
assert gem('a', '= 1'), "Should load"
refute gem('a', '>= 1'), "Should not load"
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
- assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
end
def test_gem_conflicting
@@ -47,13 +49,14 @@ class TestKernel < RubyGemTestCase
assert_match(/activate a \(= 2, runtime\)/, ex.message)
assert_match(/activated a-1/, ex.message)
assert_equal 'a', ex.name
- assert_equal Gem::Requirement.new('= 2'), ex.version_requirement
+ assert_equal Gem::Requirement.new('= 2'), ex.requirement
assert $:.any? { |p| %r{a-1/lib} =~ p }
- assert $:.any? { |p| %r{a-1/bin} =~ p }
refute $:.any? { |p| %r{a-2/lib} =~ p }
- refute $:.any? { |p| %r{a-2/bin} =~ p }
end
+ def test_gem_not_adding_bin
+ assert gem('a', '= 1'), "Should load"
+ refute $:.any? { |p| %r{a-1/bin} =~ p }
+ end
end
-