From 7083cebeaea83096128fc5ccb5f60bfbe5bcc939 Mon Sep 17 00:00:00 2001 From: drbrain Date: Mon, 8 Jul 2013 22:41:03 +0000 Subject: * lib/rubygems: Update to RubyGems 2.0.4. See https://github.com/rubygems/rubygems/blob/2.0/History.txt for changes git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems.rb | 9 +++- lib/rubygems/commands/help_command.rb | 10 ++++- lib/rubygems/commands/list_command.rb | 10 ++--- lib/rubygems/commands/owner_command.rb | 2 +- lib/rubygems/commands/pristine_command.rb | 9 ++-- lib/rubygems/commands/push_command.rb | 3 +- lib/rubygems/commands/search_command.rb | 20 +++++++-- lib/rubygems/commands/setup_command.rb | 58 ++++++++++++++++---------- lib/rubygems/commands/specification_command.rb | 2 +- lib/rubygems/commands/update_command.rb | 2 +- lib/rubygems/core_ext/kernel_require.rb | 8 ++++ lib/rubygems/defaults.rb | 4 +- lib/rubygems/dependency_installer.rb | 1 - lib/rubygems/dependency_resolver.rb | 2 +- lib/rubygems/errors.rb | 4 +- lib/rubygems/gemcutter_utilities.rb | 18 ++++++-- lib/rubygems/installer.rb | 11 ++++- lib/rubygems/package.rb | 1 - lib/rubygems/platform.rb | 2 + lib/rubygems/specification.rb | 50 +++++++++++----------- 20 files changed, 145 insertions(+), 81 deletions(-) (limited to 'lib') diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 3622f7102d..2c8dbee2a2 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.0.3' + VERSION = '2.0.4' end # Must be first since it unloads the prelude from 1.9.2 @@ -173,7 +173,12 @@ module Gem # require will try to activate the more specific version. spec = Gem::Specification.find_inactive_by_path path - return false unless spec + + unless spec + spec = Gem::Specification.find_by_path path + return true if spec && spec.activated? + return false + end begin spec.activate diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb index 8e3d97edd3..7f1fb486e0 100644 --- a/lib/rubygems/commands/help_command.rb +++ b/lib/rubygems/commands/help_command.rb @@ -113,7 +113,15 @@ platform. format = "#{' ' * margin_width}%-#{desc_width}s%s" command_manager.command_names.each do |cmd_name| - summary = command_manager[cmd_name].summary + command = command_manager[cmd_name] + + summary = + if command then + command.summary + else + "[No command found for #{cmd_name}, bug?]" + end + summary = wrap(summary, summary_width).split "\n" out << sprintf(format, cmd_name, summary.shift) until summary.empty? do diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb index d9b7a9535e..f3e5da9551 100644 --- a/lib/rubygems/commands/list_command.rb +++ b/lib/rubygems/commands/list_command.rb @@ -7,9 +7,8 @@ require 'rubygems/commands/query_command' class Gem::Commands::ListCommand < Gem::Commands::QueryCommand - def initialize(name = 'list', - summary = 'Display gems whose name starts with STRING') - super name, summary + def initialize + super 'list', 'Display gems whose name starts with STRING' remove_option('--name-matches') end @@ -27,9 +26,8 @@ class Gem::Commands::ListCommand < Gem::Commands::QueryCommand end def execute - name = get_one_optional_argument || '' - options[:name] = /^#{name}/i - + string = get_one_optional_argument || '' + options[:name] = /^#{string}/i super end diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb index 92674132e8..11e6e026fd 100644 --- a/lib/rubygems/commands/owner_command.rb +++ b/lib/rubygems/commands/owner_command.rb @@ -73,7 +73,7 @@ class Gem::Commands::OwnerCommand < Gem::Command request.add_field "Authorization", api_key end - with_response response + with_response response, "Removing #{owner}" rescue # ignore end diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index f7eb9014ea..f22fe11769 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -10,7 +10,8 @@ class Gem::Commands::PristineCommand < Gem::Command def initialize super 'pristine', 'Restores installed gems to pristine condition from files located in the gem cache', - :version => Gem::Requirement.default, :extensions => true, + :version => Gem::Requirement.default, + :extensions => true, :all => false add_option('--all', @@ -37,7 +38,7 @@ class Gem::Commands::PristineCommand < Gem::Command end def defaults_str # :nodoc: - "--all --extensions" + '--extensions' end def description # :nodoc: @@ -52,8 +53,8 @@ for the gem are regenerated. If the cached gem cannot be found, you will need to use `gem install` to revert the gem. -If --no-extensions is provided pristine will not attempt to restore gems with -extensions. +If --no-extensions is provided pristine will not attempt to restore gems +with extensions. EOF end diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index 2df00b0457..fccad206fa 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -20,7 +20,8 @@ class Gem::Commands::PushCommand < Gem::Command end def initialize - super 'push', description + super 'push', description, :host => self.host + add_proxy_option add_key_option diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb index 92d4b3672e..7810c85b36 100644 --- a/lib/rubygems/commands/search_command.rb +++ b/lib/rubygems/commands/search_command.rb @@ -1,17 +1,31 @@ require 'rubygems/command' -require 'rubygems/commands/list_command' +require 'rubygems/commands/query_command' -class Gem::Commands::SearchCommand < Gem::Commands::ListCommand +class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand def initialize super 'search', 'Display all gems whose name contains STRING' - @defaults[:domain] = :remote + remove_option '--name-matches' + end + + def arguments # :nodoc: + "STRING fragment of gem name to search for" end def defaults_str # :nodoc: "--remote --no-details" end + def usage # :nodoc: + "#{program_name} [STRING]" + end + + def execute + string = get_one_optional_argument + options[:name] = /#{string}/i + super + end + end diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 1cdc9f4c57..face77fae9 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -159,29 +159,7 @@ By default, this RubyGems will install gem as: options[:previous_version] = Gem::Version.new(options[:previous_version]) - release_notes = File.join Dir.pwd, 'History.txt' - - release_notes = if File.exist? release_notes then - history = File.read release_notes - history = history.sub(/^# coding:.*?^=/m, '') - - text = history.split(HISTORY_HEADER) - text.shift # correct an off-by-one generated by split - version_lines = history.scan(HISTORY_HEADER) - versions = history.scan(VERSION_MATCHER).flatten.map { |x| Gem::Version.new(x) } - - history_string = "" - - until versions.length == 0 or versions.shift < options[:previous_version] - history_string += version_lines.shift + text.shift - end - - history_string - else - "Oh-no! Unable to find release notes!" - end - - say release_notes + show_release_notes say say "-" * 78 @@ -458,6 +436,40 @@ abort "#{deprecation_message}" end end + def show_release_notes + release_notes = File.join Dir.pwd, 'History.txt' + + release_notes = + if File.exist? release_notes then + history = File.read release_notes + + history.force_encoding Encoding::UTF_8 if + Object.const_defined? :Encoding + + history = history.sub(/^# coding:.*?^=/m, '') + + text = history.split(HISTORY_HEADER) + text.shift # correct an off-by-one generated by split + version_lines = history.scan(HISTORY_HEADER) + versions = history.scan(VERSION_MATCHER).flatten.map do |x| + Gem::Version.new(x) + end + + history_string = "" + + until versions.length == 0 or + versions.shift < options[:previous_version] do + history_string += version_lines.shift + text.shift + end + + history_string + else + "Oh-no! Unable to find release notes!" + end + + say release_notes + end + def uninstall_old_gemcutter require 'rubygems/uninstaller' diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb index 63da5fef0f..b40dfd5f3c 100644 --- a/lib/rubygems/commands/specification_command.rb +++ b/lib/rubygems/commands/specification_command.rb @@ -28,7 +28,7 @@ class Gem::Commands::SpecificationCommand < Gem::Command options[:format] = :ruby end - add_option('--yaml', 'Output RUBY format') do |value, options| + add_option('--yaml', 'Output YAML format') do |value, options| options[:format] = :yaml end diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb index 66aef49b4d..a31de0071a 100644 --- a/lib/rubygems/commands/update_command.rb +++ b/lib/rubygems/commands/update_command.rb @@ -94,7 +94,7 @@ class Gem::Commands::UpdateCommand < Gem::Command say "Updating #{name}" begin - @installer.install name, version + @installer.install name, Gem::Requirement.new(version) success = true rescue Gem::InstallError => e alert_error "Error installing #{name}:\n\t#{e.message}" diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb index e6dfce644f..71062410cb 100755 --- a/lib/rubygems/core_ext/kernel_require.rb +++ b/lib/rubygems/core_ext/kernel_require.rb @@ -4,6 +4,8 @@ # See LICENSE.txt for permissions. #++ +require 'monitor' + module Kernel if defined?(gem_original_require) then @@ -31,7 +33,11 @@ module Kernel # The normal require functionality of returning false if # that file has already been loaded is preserved. + ACTIVATION_MONITOR = Monitor.new + def require path + ACTIVATION_MONITOR.enter + spec = Gem.find_unresolved_default_spec(path) if spec Gem.remove_unresolved_default_spec(spec) @@ -111,6 +117,8 @@ module Kernel end raise load_error + ensure + ACTIVATION_MONITOR.exit end private :require diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 9c5e303c0e..cc8dc722fc 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -54,7 +54,9 @@ module Gem # Path for gems in the user's home directory def self.user_dir - File.join Gem.user_home, '.gem', ruby_engine, ConfigMap[:ruby_version] + parts = [Gem.user_home, '.gem', ruby_engine] + parts << ConfigMap[:ruby_version] unless ConfigMap[:ruby_version].empty? + File.join parts end ## diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb index 256c91ee9c..6f19a310f7 100644 --- a/lib/rubygems/dependency_installer.rb +++ b/lib/rubygems/dependency_installer.rb @@ -63,7 +63,6 @@ class Gem::DependencyInstaller # HACK shouldn't change the global settings, needed for -i behavior # maybe move to the install command? See also github #442 Gem::Specification.dirs = @install_dir - Gem.ensure_gem_subdirectories @install_dir end options = DEFAULT_OPTIONS.merge options diff --git a/lib/rubygems/dependency_resolver.rb b/lib/rubygems/dependency_resolver.rb index e8b620f356..66f55eb9ad 100644 --- a/lib/rubygems/dependency_resolver.rb +++ b/lib/rubygems/dependency_resolver.rb @@ -349,7 +349,7 @@ module Gem when Dependency @dependency == other when DependencyRequest - @dependency == other.dep && @requester == other.requester + @dependency == other.dependency && @requester == other.requester else false end diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb index fdbe39b996..e296ef3127 100644 --- a/lib/rubygems/errors.rb +++ b/lib/rubygems/errors.rb @@ -62,10 +62,10 @@ module Gem ## # A wordy description of the error. def wordy - "Found %s (%), but was for platform%s %s" % + "Found %s (%s), but was for platform%s %s" % [@name, @version, - @platforms.size == 1 ? 's' : '', + @platforms.size == 1 ? '' : 's', @platforms.join(' ,')] end end diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index 474d07f775..04d7cd300f 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -38,7 +38,7 @@ module Gem::GemcutterUtilities say "Enter your #{pretty_host} credentials." say "Don't have an account yet? " + - "Create one at https://#{sign_in_host}/sign_up" + "Create one at #{sign_in_host}/sign_up" email = ask " Email: " password = ask_for_password "Password: " @@ -60,7 +60,14 @@ module Gem::GemcutterUtilities configured_host = Gem.host unless Gem.configuration.disable_default_gem_server - @host ||= ENV['RUBYGEMS_HOST'] || configured_host + @host ||= + begin + env_rubygems_host = ENV['RUBYGEMS_HOST'] + env_rubygems_host = nil if + env_rubygems_host and env_rubygems_host.empty? + + env_rubygems_host|| configured_host + end end def rubygems_api_request(method, path, host = nil, &block) @@ -79,7 +86,7 @@ module Gem::GemcutterUtilities Gem::RemoteFetcher.fetcher.request(uri, request_method, &block) end - def with_response(resp) + def with_response resp, error_prefix = nil case resp when Net::HTTPSuccess then if block_given? then @@ -88,7 +95,10 @@ module Gem::GemcutterUtilities say resp.body end else - say resp.body + message = resp.body + message = "#{error_prefix}: #{message}" if error_prefix + + say message terminate_interaction 1 # TODO: question this end end diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 4a41891b48..939bc9693d 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -331,8 +331,9 @@ class Gem::Installer # specifications directory. def write_spec - File.open(spec_file, "w") do |file| + open spec_file, 'w' do |file| file.puts spec.to_ruby_for_cache + file.fsync rescue nil # for filesystems without fsync(2) end end @@ -773,7 +774,13 @@ EOF def write_build_info_file return if @build_args.empty? - open spec.build_info_file, 'w' do |io| + build_info_dir = File.join gem_home, 'build_info' + + FileUtils.mkdir_p build_info_dir + + build_info_file = File.join build_info_dir, "#{spec.full_name}.info" + + open build_info_file, 'w' do |io| @build_args.each do |arg| io.puts arg end diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb index 1a064e12a6..957446257d 100644 --- a/lib/rubygems/package.rb +++ b/lib/rubygems/package.rb @@ -336,7 +336,6 @@ EOM open destination, 'wb', entry.header.mode do |out| out.write entry.read - out.fsync rescue nil # for filesystems without fsync(2) end say destination if Gem.configuration.really_verbose diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 7301153c4b..4a4674b72f 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -74,6 +74,7 @@ class Gem::Platform when /hpux(\d+)?/ then [ 'hpux', $1 ] when /^java$/, /^jruby$/ then [ 'java', nil ] when /^java([\d.]*)/ then [ 'java', $1 ] + when /^dalvik(\d+)?$/ then [ 'dalvik', $1 ] when /^dotnet$/ then [ 'dotnet', nil ] when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ] when /linux/ then [ 'linux', $1 ] @@ -155,6 +156,7 @@ class Gem::Platform when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ] when /^i\d86-linux/ then ['x86', 'linux', nil ] when 'java', 'jruby' then [nil, 'java', nil ] + when /^dalvik(\d+)?$/ then [nil, 'dalvik', $1 ] when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ] when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ] when 'powerpc-darwin' then ['powerpc', 'darwin', nil ] diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 0fca2ab619..02c1eeb0a1 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -5,6 +5,17 @@ # See LICENSE.txt for permissions. #++ +require 'rubygems/version' +require 'rubygems/requirement' +require 'rubygems/platform' +require 'rubygems/deprecate' + +# :stopdoc: +# date.rb can't be loaded for `make install` due to miniruby +# Date is needed for old gems that stored #date as Date instead of Time. +class Date; end +# :startdoc: + ## # The Specification class contains the information for a Gem. Typically # defined in a .gemspec file or a Rakefile, and looks like this: @@ -20,32 +31,19 @@ # s.homepage = 'https://rubygems.org/gems/example' # end # -# Starting in RubyGems 1.9.0, a Specification can hold arbitrary -# metadata. This metadata is accessed via Specification#metadata -# and has the following restrictions: +# Starting in RubyGems 1.9.0, a Specification can hold arbitrary +# metadata. This metadata is accessed via Specification#metadata +# and has the following restrictions: # -# * Must be a Hash object -# * All keys and values must be Strings -# * Keys can be a maximum of 128 bytes and values can be a -# maximum of 1024 bytes -# * All strings must be UTF8, no binary data is allowed +# * Must be a Hash object +# * All keys and values must be Strings +# * Keys can be a maximum of 128 bytes and values can be a +# maximum of 1024 bytes +# * All strings must be UTF8, no binary data is allowed # -# For example, to add metadata for the location of a bugtracker: +# For example, to add metadata for the location of a bugtracker: # # s.metadata = { "bugtracker" => "http://somewhere.com/blah" } -# - - -require 'rubygems/version' -require 'rubygems/requirement' -require 'rubygems/platform' -require 'rubygems/deprecate' - -# :stopdoc: -# date.rb can't be loaded for `make install` due to miniruby -# Date is needed for old gems that stored #date as Date instead of Time. -class Date; end -# :startdoc: class Gem::Specification @@ -918,7 +916,7 @@ class Gem::Specification result = Hash.new { |h,k| h[k] = {} } native = {} - Gem::Specification._all.reverse_each do |spec| + Gem::Specification.reverse_each do |spec| next if spec.version.prerelease? unless prerelease native[spec.name] = spec.version if spec.platform == Gem::Platform::RUBY @@ -995,7 +993,7 @@ class Gem::Specification # TODO: maybe we should switch to rubygems' version service? fetcher = Gem::SpecFetcher.fetcher - latest_specs.each do |local| + latest_specs(true).each do |local| dependency = Gem::Dependency.new local.name, ">= #{local.version}" remotes, _ = fetcher.search_for_dependency dependency remotes = remotes.map { |n, _| n.version } @@ -1236,7 +1234,7 @@ class Gem::Specification unless dependency.respond_to?(:name) && dependency.respond_to?(:version_requirements) - dependency = Gem::Dependency.new(dependency, requirements, type) + dependency = Gem::Dependency.new(dependency.to_s, requirements, type) end dependencies << dependency @@ -2270,7 +2268,7 @@ class Gem::Specification require 'rubygems/psych_tree' end - builder = Gem::NoAliasYAMLTree.create + builder = Gem::NoAliasYAMLTree.new({}) builder << self ast = builder.tree -- cgit v1.2.3