Permalink
Browse files

Update Rubygems to 1.8.12

  • Loading branch information...
1 parent 13d2f75 commit 740c8295a2df7825d61a6f6d9efd8bc572b6ebb1 @evanphx evanphx committed Dec 16, 2011
Showing with 3,791 additions and 2,304 deletions.
  1. +306 −286 lib/rubygems.rb
  2. +7 −6 lib/rubygems/builder.rb
  3. +6 −4 lib/rubygems/command.rb
  4. +16 −2 lib/rubygems/command_manager.rb
  5. +13 −11 lib/rubygems/commands/build_command.rb
  6. +1 −1 lib/rubygems/commands/cert_command.rb
  7. +15 −21 lib/rubygems/commands/cleanup_command.rb
  8. +17 −14 lib/rubygems/commands/contents_command.rb
  9. +23 −45 lib/rubygems/commands/dependency_command.rb
  10. +7 −4 lib/rubygems/commands/fetch_command.rb
  11. +2 −1 lib/rubygems/commands/install_command.rb
  12. +4 −4 lib/rubygems/commands/lock_command.rb
  13. +5 −8 lib/rubygems/commands/outdated_command.rb
  14. +3 −2 lib/rubygems/commands/owner_command.rb
  15. +34 −20 lib/rubygems/commands/pristine_command.rb
  16. +8 −4 lib/rubygems/commands/push_command.rb
  17. +9 −6 lib/rubygems/commands/query_command.rb
  18. +1 −1 lib/rubygems/commands/server_command.rb
  19. +3 −4 lib/rubygems/commands/setup_command.rb
  20. +8 −23 lib/rubygems/commands/specification_command.rb
  21. +2 −1 lib/rubygems/commands/stale_command.rb
  22. +11 −0 lib/rubygems/commands/uninstall_command.rb
  23. +59 −21 lib/rubygems/commands/unpack_command.rb
  24. +26 −14 lib/rubygems/commands/update_command.rb
  25. +6 −10 lib/rubygems/commands/which_command.rb
  26. +20 −11 lib/rubygems/config_file.rb
  27. +32 −6 lib/rubygems/custom_require.rb
  28. +30 −14 lib/rubygems/defaults.rb
  29. +84 −9 lib/rubygems/dependency.rb
  30. +55 −44 lib/rubygems/dependency_installer.rb
  31. +53 −10 lib/rubygems/dependency_list.rb
  32. +70 −0 lib/rubygems/deprecate.rb
  33. +16 −15 lib/rubygems/doc_manager.rb
  34. +1 −1 lib/rubygems/ext/builder.rb
  35. +2 −2 lib/rubygems/ext/rake_builder.rb
  36. +1 −1 lib/rubygems/format.rb
  37. +3 −5 lib/rubygems/gem_openssl.rb
  38. +75 −5 lib/rubygems/gem_path_searcher.rb
  39. +3 −1 lib/rubygems/gem_runner.rb
  40. +33 −0 lib/rubygems/gemcutter_utilities.rb
  41. +117 −122 lib/rubygems/indexer.rb
  42. +118 −94 lib/rubygems/installer.rb
  43. +40 −34 lib/rubygems/installer_test_case.rb
  44. +2 −2 lib/rubygems/local_remote_options.rb
  45. +12 −4 lib/rubygems/mock_gem_ui.rb
  46. +2 −26 lib/rubygems/package.rb
  47. +12 −7 lib/rubygems/package/tar_input.rb
  48. +1 −1 lib/rubygems/package/tar_writer.rb
  49. +1 −1 lib/rubygems/package_task.rb
  50. +70 −0 lib/rubygems/path_support.rb
  51. +12 −2 lib/rubygems/platform.rb
  52. +94 −51 lib/rubygems/remote_fetcher.rb
  53. +42 −2 lib/rubygems/requirement.rb
  54. +2 −1 lib/rubygems/security.rb
  55. +67 −67 lib/rubygems/server.rb
  56. +118 −65 lib/rubygems/source_index.rb
  57. +23 −11 lib/rubygems/spec_fetcher.rb
  58. +1,552 −983 lib/rubygems/specification.rb
  59. +61 −0 lib/rubygems/syck_hack.rb
  60. +212 −71 lib/rubygems/test_case.rb
  61. +15 −2 lib/rubygems/test_utilities.rb
  62. +1 −1 lib/rubygems/text.rb
  63. +69 −59 lib/rubygems/uninstaller.rb
  64. +77 −60 lib/rubygems/user_interaction.rb
  65. +1 −1 lib/rubygems/validator.rb
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -38,15 +38,15 @@ def build
@signer = sign
write_package
say success if Gem.configuration.verbose
- @spec.file_name
+ File.basename @spec.cache_file
end
def success
<<-EOM
Successfully built RubyGem
Name: #{@spec.name}
Version: #{@spec.version}
- File: #{@spec.file_name}
+ File: #{File.basename @spec.cache_file}
EOM
end
@@ -73,16 +73,17 @@ def sign
end
def write_package
- open @spec.file_name, 'wb' do |gem_io|
+ file_name = File.basename @spec.cache_file
+ open file_name, 'wb' do |gem_io|
Gem::Package.open gem_io, 'w', @signer do |pkg|
yaml = @spec.to_yaml
pkg.metadata = yaml
@spec.files.each do |file|
- next if File.directory? file
- next if file == @spec.file_name # Don't add gem onto itself
+ next if File.directory?(file)
+ next if file == file_name # Don't add gem onto itself
- stat = File.stat file
+ stat = File.stat(file)
mode = stat.mode & 0777
size = stat.size
View
@@ -404,10 +404,12 @@ def create_option_parser
end
end
- @parser.separator nil
- @parser.separator " Summary:"
- wrap(@summary, 80 - 4).split("\n").each do |line|
- @parser.separator " #{line.strip}"
+ if @summary then
+ @parser.separator nil
+ @parser.separator " Summary:"
+ wrap(@summary, 80 - 4).split("\n").each do |line|
+ @parser.separator " #{line.strip}"
+ end
end
if description then
@@ -38,6 +38,13 @@ def self.instance
end
##
+ # Reset the authoritative instance of the command manager.
+
+ def self.reset
+ @command_manager = nil
+ end
+
+ ##
# Register all the subcommands supported by the gem command.
def initialize
@@ -81,6 +88,13 @@ def register_command(command)
end
##
+ # Unregister the Symbol +command+ as a gem command.
+
+ def unregister_command(command)
+ @commands.delete command
+ end
+
+ ##
# Return the registered command from the command name.
def [](command_name)
@@ -160,7 +174,7 @@ def load_and_instantiate(command_name)
retried = false
begin
- commands.const_get const_name
+ commands.const_get(const_name).new
rescue NameError
raise if retried
@@ -173,7 +187,7 @@ def load_and_instantiate(command_name)
Gem.configuration.backtrace
end
retry
- end.new
+ end
end
end
@@ -17,32 +17,34 @@ def usage # :nodoc:
def execute
gemspec = get_one_gem_name
- if File.exist?(gemspec)
- specs = load_gemspecs(gemspec)
- specs.each do |spec|
+
+ if File.exist? gemspec
+ spec = load_gemspec gemspec
+
+ if spec then
Gem::Builder.new(spec).build
+ else
+ alert_error "Error loading gemspec. Aborting."
+ terminate_interaction 1
end
else
alert_error "Gemspec file not found: #{gemspec}"
+ terminate_interaction 1
end
end
- def load_gemspecs(filename)
+ def load_gemspec filename
if yaml?(filename)
- result = []
open(filename) do |f|
begin
- while not f.eof? and spec = Gem::Specification.from_yaml(f)
- result << spec
- end
+ Gem::Specification.from_yaml(f)
rescue Gem::EndOfYAMLException
- # OK
+ nil
end
end
else
- result = [Gem::Specification.load(filename)]
+ Gem::Specification.load(filename) # can return nil
end
- result
end
def yaml?(filename)
@@ -50,7 +50,7 @@ def initialize
'Build private key and self-signed',
'certificate for EMAIL_ADDR.') do |value, options|
vals = Gem::Security.build_self_signed_cert(value)
- File.chmod 0600, vals[:key_path]
+ FileUtils.chmod 0600, vals[:key_path]
say "Public Cert: #{vals[:cert_path]}"
say "Private Key: #{vals[:key_path]}"
say "Don't forget to move the key file to somewhere private..."
@@ -1,5 +1,4 @@
require 'rubygems/command'
-require 'rubygems/source_index'
require 'rubygems/dependency_list'
require 'rubygems/uninstaller'
@@ -38,28 +37,20 @@ def execute
say "Cleaning up installed gems..."
primary_gems = {}
- Gem.source_index.each do |name, spec|
+ Gem::Specification.each do |spec|
if primary_gems[spec.name].nil? or
primary_gems[spec.name].version < spec.version then
primary_gems[spec.name] = spec
end
end
- gems_to_cleanup = []
-
- unless options[:args].empty? then
- options[:args].each do |gem_name|
- dep = Gem::Dependency.new gem_name, Gem::Requirement.default
- specs = Gem.source_index.search dep
- specs.each do |spec|
- gems_to_cleanup << spec
- end
- end
- else
- Gem.source_index.each do |name, spec|
- gems_to_cleanup << spec
- end
- end
+ gems_to_cleanup = unless options[:args].empty? then
+ options[:args].map do |gem_name|
+ Gem::Specification.find_all_by_name gem_name
+ end.flatten
+ else
+ Gem::Specification.to_a
+ end
gems_to_cleanup = gems_to_cleanup.select { |spec|
primary_gems[spec.name].version != spec.version
@@ -70,6 +61,8 @@ def execute
deps = deplist.strongly_connected_components.flatten.reverse
+ original_path = Gem.path
+
deps.each do |spec|
if options[:dryrun] then
say "Dry Run Mode: Would uninstall #{spec.full_name}"
@@ -83,20 +76,21 @@ def execute
:version => "= #{spec.version}",
}
- if Gem.user_dir == spec.installation_path then
- uninstall_options[:install_dir] = spec.installation_path
- end
+ uninstall_options[:user_install] = Gem.user_dir == spec.base_dir
uninstaller = Gem::Uninstaller.new spec.name, uninstall_options
begin
uninstaller.uninstall
rescue Gem::DependencyRemovalException, Gem::InstallError,
- Gem::GemNotInHomeException => e
+ Gem::GemNotInHomeException, Gem::FilePermissionError => e
say "Unable to uninstall #{spec.full_name}:"
say "\t#{e.class}: #{e.message}"
end
end
+
+ # Restore path Gem::Uninstaller may have change
+ Gem.use_paths(*original_path)
end
say "Clean Up Complete"
@@ -52,24 +52,24 @@ def execute
end.flatten
path_kind = if spec_dirs.empty? then
- spec_dirs = Gem::SourceIndex.installed_spec_directories
+ spec_dirs = Gem::Specification.dirs
"default gem paths"
else
"specified path"
end
- si = Gem::SourceIndex.from_gems_in(*spec_dirs)
-
gem_names = if options[:all] then
- si.map { |_, spec| spec.name }
+ Gem::Specification.map(&:name)
else
get_all_gem_names
end
gem_names.each do |name|
- gem_spec = si.find_name(name, version).last
+ # HACK: find_by_name fails for some reason... ARGH
+ # How many places must we embed our resolve logic?
+ spec = Gem::Specification.find_all_by_name(name, version).last
- unless gem_spec then
+ unless spec then
say "Unable to find gem '#{name}' in #{path_kind}"
if Gem.configuration.verbose then
@@ -80,16 +80,19 @@ def execute
terminate_interaction 1 if gem_names.length == 1
end
- files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
+ gem_path = spec.full_gem_path
+ extra = "/{#{spec.require_paths.join ','}}" if options[:lib_only]
+ glob = "#{gem_path}#{extra}/**/*"
+ files = Dir[glob]
+
+ gem_path = File.join gem_path, '' # add trailing / if missing
+
+ files.sort.each do |file|
+ next if File.directory? file
- files.each do |f|
- path = if options[:prefix] then
- File.join gem_spec.full_gem_path, f
- else
- f
- end
+ file = file.sub gem_path, '' unless options[:prefix]
- say path
+ say file
end
end
end
Oops, something went wrong.

0 comments on commit 740c829

Please sign in to comment.