Permalink
Browse files

Merge branch 'rubygems-2.0.7'

  • Loading branch information...
2 parents a6af6c1 + ff0eeab commit c4a1b9a7d7103cb739ecc1babcd94d06f9b632d1 @BanzaiMan BanzaiMan committed Sep 3, 2013
Showing with 334 additions and 141 deletions.
  1. +8 −3 lib/ruby/shared/rubygems.rb
  2. +9 −1 lib/ruby/shared/rubygems/commands/help_command.rb
  3. +4 −6 lib/ruby/shared/rubygems/commands/list_command.rb
  4. +1 −1 lib/ruby/shared/rubygems/commands/owner_command.rb
  5. +15 −13 lib/ruby/shared/rubygems/commands/pristine_command.rb
  6. +2 −1 lib/ruby/shared/rubygems/commands/push_command.rb
  7. +11 −6 lib/ruby/shared/rubygems/commands/query_command.rb
  8. +19 −3 lib/ruby/shared/rubygems/commands/search_command.rb
  9. +35 −23 lib/ruby/shared/rubygems/commands/setup_command.rb
  10. +1 −1 lib/ruby/shared/rubygems/commands/specification_command.rb
  11. +1 −1 lib/ruby/shared/rubygems/commands/update_command.rb
  12. +8 −0 lib/ruby/shared/rubygems/core_ext/kernel_require.rb
  13. +3 −1 lib/ruby/shared/rubygems/defaults.rb
  14. +0 −1 lib/ruby/shared/rubygems/dependency_installer.rb
  15. +1 −1 lib/ruby/shared/rubygems/dependency_resolver.rb
  16. +2 −2 lib/ruby/shared/rubygems/errors.rb
  17. +10 −3 lib/ruby/shared/rubygems/ext/builder.rb
  18. +7 −2 lib/ruby/shared/rubygems/ext/ext_conf_builder.rb
  19. +14 −4 lib/ruby/shared/rubygems/gemcutter_utilities.rb
  20. +24 −6 lib/ruby/shared/rubygems/installer.rb
  21. +0 −1 lib/ruby/shared/rubygems/package.rb
  22. +5 −2 lib/ruby/shared/rubygems/package_task.rb
  23. +2 −0 lib/ruby/shared/rubygems/platform.rb
  24. +4 −0 lib/ruby/shared/rubygems/psych_tree.rb
  25. +7 −2 lib/ruby/shared/rubygems/remote_fetcher.rb
  26. +77 −57 lib/ruby/shared/rubygems/specification.rb
  27. +64 −0 lib/ruby/shared/rubygems/test_case.rb
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = '2.0.3'
+ VERSION = '2.0.7'
end
# Must be first since it unloads the prelude from 1.9.2
@@ -36,9 +36,9 @@ module Gem
#
# Further RubyGems documentation can be found at:
#
+# * {RubyGems Guides}[http://guides.rubygems.org]
# * {RubyGems API}[http://rubygems.rubyforge.org/rdoc] (also available from
# <tt>gem server</tt>)
-# * {RubyGems Bookshelf}[http://rubygem.org]
#
# == RubyGems Plugins
#
@@ -173,7 +173,12 @@ def self.try_activate path
# 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
@@ -113,7 +113,15 @@ def execute
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
@@ -7,9 +7,8 @@
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 @@ def usage # :nodoc:
end
def execute
- name = get_one_optional_argument || ''
- options[:name] = /^#{name}/i
-
+ string = get_one_optional_argument || ''
+ options[:name] = /^#{string}/i
super
end
@@ -73,7 +73,7 @@ def manage_owners method, name, owners
request.add_field "Authorization", api_key
end
- with_response response
+ with_response response, "Removing #{owner}"
rescue
# ignore
end
@@ -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',
@@ -20,7 +21,8 @@ def initialize
end
add_option('--[no-]extensions',
- 'Restore gems with extensions') do |value, options|
+ 'Restore gems with extensions',
+ 'in addition to regular gems') do |value, options|
options[:extensions] = value
end
@@ -37,28 +39,28 @@ def arguments # :nodoc:
end
def defaults_str # :nodoc:
- "--all --extensions"
+ '--extensions'
end
def description # :nodoc:
<<-EOF
-The pristine command compares the installed gems with the contents of the
-cached gem and restores any files that don't match the cached gem's copy.
+The pristine command compares an installed gem with the contents of its
+cached .gem file and restores any files that don't match the cached .gem's
+copy.
-If you have made modifications to your installed gems, the pristine command
-will revert them. After all the gem's files have been checked all bin stubs
-for the gem are regenerated.
+If you have made modifications to an installed gem, the pristine command
+will revert them. All extensions are rebuilt and all bin stubs for the gem
+are regenerated after checking for modifications.
-If the cached gem cannot be found, you will need to use `gem install` to
-revert the gem.
+If the cached gem cannot be found it will be downloaded.
-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 a gem
+with an extension.
EOF
end
def usage # :nodoc:
- "#{program_name} [args]"
+ "#{program_name} [GEMNAME ...]"
end
def execute
@@ -20,7 +20,8 @@ def usage # :nodoc:
end
def initialize
- super 'push', description
+ super 'push', description, :host => self.host
+
add_proxy_option
add_key_option
@@ -14,7 +14,7 @@ def initialize(name = 'query',
summary = 'Query gem information in local or remote repositories')
super name, summary,
:name => //, :domain => :local, :details => false, :versions => true,
- :installed => false, :version => Gem::Requirement.default
+ :installed => nil, :version => Gem::Requirement.default
add_option('-i', '--[no-]installed',
'Check for installed gem') do |value, options|
@@ -67,15 +67,20 @@ def execute
name = options[:name]
prerelease = options[:prerelease]
- if options[:installed] then
+ unless options[:installed].nil? then
if name.source.empty? then
alert_error "You must specify a gem name"
exit_code |= 4
- elsif installed? name, options[:version] then
- say "true"
else
- say "false"
- exit_code |= 1
+ installed = installed? name, options[:version]
+ installed = !installed unless options[:installed]
+
+ if installed then
+ say "true"
+ else
+ say "false"
+ exit_code |= 1
+ end
end
terminate_interaction exit_code
@@ -1,17 +1,33 @@
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'
+
+ defaults[:domain] = :remote
+ 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
@@ -159,29 +159,7 @@ def execute
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 @@ def remove_old_lib_files lib_dir
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'
@@ -28,7 +28,7 @@ def initialize
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
@@ -94,7 +94,7 @@ def update_gem name, version = Gem::Requirement.default
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}"
@@ -4,8 +4,12 @@
# See LICENSE.txt for permissions.
#++
+require 'monitor'
+
module Kernel
+ RUBYGEMS_ACTIVATION_MONITOR = Monitor.new # :nodoc:
+
if defined?(gem_original_require) then
# Ruby ships with a custom_require, override its require
remove_method :require
@@ -32,6 +36,8 @@ module Kernel
# that file has already been loaded is preserved.
def require path
+ RUBYGEMS_ACTIVATION_MONITOR.enter
+
spec = Gem.find_unresolved_default_spec(path)
if spec
Gem.remove_unresolved_default_spec(spec)
@@ -111,6 +117,8 @@ def require path
end
raise load_error
+ ensure
+ RUBYGEMS_ACTIVATION_MONITOR.exit
end
private :require
@@ -54,7 +54,9 @@ def self.default_rubygems_dirs
# 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
##
@@ -63,7 +63,6 @@ def initialize(options = {})
# 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
@@ -349,7 +349,7 @@ def ==(other)
when Dependency
@dependency == other
when DependencyRequest
- @dependency == other.dep && @requester == other.requester
+ @dependency == other.dependency && @requester == other.requester
else
false
end
@@ -62,10 +62,10 @@ def add_platform(platform)
##
# 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
Oops, something went wrong.

0 comments on commit c4a1b9a

Please sign in to comment.