diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-09 21:38:59 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-09 21:38:59 +0000 |
commit | 31c94ffeb5f09d09ac2c86fc9e6614e38251a43d () | |
tree | 10e44506238c7af3d7c9d822111996731726e38d /lib/rubygems/commands | |
parent | a6afbaeb3be396c0fdea3b9077d9256c59edcfca (diff) |
Update to RubyGems 1.3.4 r2223
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/rubygems/commands/check_command.rb | 17 | ||||
-rw-r--r-- | lib/rubygems/commands/cleanup_command.rb | 27 | ||||
-rw-r--r-- | lib/rubygems/commands/contents_command.rb | 60 | ||||
-rw-r--r-- | lib/rubygems/commands/generate_index_command.rb | 106 | ||||
-rw-r--r-- | lib/rubygems/commands/install_command.rb | 120 | ||||
-rw-r--r-- | lib/rubygems/commands/query_command.rb | 73 | ||||
-rw-r--r-- | lib/rubygems/commands/rdoc_command.rb | 130 | ||||
-rw-r--r-- | lib/rubygems/commands/search_command.rb | 56 | ||||
-rw-r--r-- | lib/rubygems/commands/server_command.rb | 24 | ||||
-rw-r--r-- | lib/rubygems/commands/setup_command.rb | 353 | ||||
-rw-r--r-- | lib/rubygems/commands/sources_command.rb | 5 | ||||
-rw-r--r-- | lib/rubygems/commands/specification_command.rb | 59 | ||||
-rw-r--r-- | lib/rubygems/commands/uninstall_command.rb | 132 | ||||
-rw-r--r-- | lib/rubygems/commands/unpack_command.rb | 26 | ||||
-rw-r--r-- | lib/rubygems/commands/update_command.rb | 33 | ||||
-rw-r--r-- | lib/rubygems/commands/which_command.rb | 2 |
16 files changed, 924 insertions, 299 deletions
@@ -21,6 +21,10 @@ class Gem::Commands::CheckCommand < Gem::Command options[:alien] = true end add_option('-t', '--test', "Run unit tests for gem") do |value, options| options[:test] = true end @@ -38,16 +42,17 @@ class Gem::Commands::CheckCommand < Gem::Command if options[:alien] say "Performing the 'alien' operation" - Gem::Validator.new.alien.each do |key, val| - if(val.size > 0) say "#{key} has #{val.size} problems" val.each do |error_entry| - say "\t#{error_entry.path}:" - say "\t#{error_entry.problem}" - say end else - say "#{key} is error-free" end say end @@ -1,6 +1,7 @@ require 'rubygems/command' require 'rubygems/source_index' require 'rubygems/dependency_list' class Gem::Commands::CleanupCommand < Gem::Command @@ -22,6 +23,13 @@ class Gem::Commands::CleanupCommand < Gem::Command "--no-dryrun" end def usage # :nodoc: "#{program_name} [GEMNAME ...]" end @@ -41,7 +49,8 @@ class Gem::Commands::CleanupCommand < Gem::Command unless options[:args].empty? then options[:args].each do |gem_name| - specs = Gem.cache.search(/^#{gem_name}$/i) specs.each do |spec| gems_to_cleanup << spec end @@ -56,7 +65,6 @@ class Gem::Commands::CleanupCommand < Gem::Command primary_gems[spec.name].version != spec.version } - uninstall_command = Gem::CommandManager.instance['uninstall'] deplist = Gem::DependencyList.new gems_to_cleanup.uniq.each do |spec| deplist.add spec end @@ -69,14 +77,21 @@ class Gem::Commands::CleanupCommand < Gem::Command say "Attempting to uninstall #{spec.full_name}" options[:args] = [spec.name] - options[:version] = "= #{spec.version}" - options[:executables] = false - uninstaller = Gem::Uninstaller.new spec.name, options begin uninstaller.uninstall - rescue Gem::DependencyRemovalException, Gem::GemNotInHomeException => e say "Unable to uninstall #{spec.full_name}:" say "\t#{e.class}: #{e.message}" @@ -11,6 +11,11 @@ class Gem::Commands::ContentsCommand < Gem::Command add_version_option add_option('-s', '--spec-dir a,b,c', Array, "Search for gems under specific paths") do |spec_dirs, options| options[:specdirs] = spec_dirs @@ -20,6 +25,11 @@ class Gem::Commands::ContentsCommand < Gem::Command "Only return files in the Gem's lib_dirs") do |lib_only, options| options[:lib_only] = lib_only end end def arguments # :nodoc: @@ -27,46 +37,60 @@ class Gem::Commands::ContentsCommand < Gem::Command end def defaults_str # :nodoc: - "--no-lib-only" end def usage # :nodoc: - "#{program_name} GEMNAME" end def execute version = options[:version] || Gem::Requirement.default - gem = get_one_gem_name - s = options[:specdirs].map do |i| [i, File.join(i, "specifications")] end.flatten - path_kind = if s.empty? then - s = Gem::SourceIndex.installed_spec_directories "default gem paths" else "specified path" end - si = Gem::SourceIndex.from_gems_in(*s) - gem_spec = si.find_name(gem, version).last - unless gem_spec then - say "Unable to find gem '#{gem}' in #{path_kind}" - if Gem.configuration.verbose then - say "\nDirectories searched:" - s.each { |dir| say dir } end - terminate_interaction - end - files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files - files.each do |f| - say File.join(gem_spec.full_gem_path, f) end end @@ -1,55 +1,131 @@ require 'rubygems/command' require 'rubygems/indexer' class Gem::Commands::GenerateIndexCommand < Gem::Command def initialize super 'generate_index', 'Generates the index files for a gem server directory', - :directory => '.' add_option '-d', '--directory=DIRNAME', 'repository base dir containing gems subdir' do |dir, options| options[:directory] = File.expand_path dir end end def defaults_str # :nodoc: - "--directory ." end def description # :nodoc: <<-EOF The generate_index command creates a set of indexes for serving gems statically. The command expects a 'gems' directory under the path given to -the --directory option. When done, it will generate a set of files like this: - gems/ # .gem files you want to index quick/index quick/index.rz # quick index manifest - quick/<gemname>.gemspec.rz # legacy YAML quick index file - quick/Marshal.<version>/<gemname>.gemspec.rz # Marshal 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. EOF end def execute if not File.exist?(options[:directory]) or not File.directory?(options[:directory]) then alert_error "unknown directory name #{directory}." terminate_interaction 1 else - indexer = Gem::Indexer.new options[:directory] - indexer.generate_index end end @@ -6,6 +6,11 @@ require 'rubygems/local_remote_options' require 'rubygems/validator' require 'rubygems/version_option' class Gem::Commands::InstallCommand < Gem::Command include Gem::VersionOption @@ -14,11 +19,11 @@ class Gem::Commands::InstallCommand < Gem::Command def initialize defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({ - :generate_rdoc => true, - :generate_ri => true, :format_executable => false, - :test => false, - :version => Gem::Requirement.default, }) super 'install', 'Install a gem into the local repository', defaults @@ -43,11 +48,51 @@ class Gem::Commands::InstallCommand < Gem::Command The install command installs local or remote gem into a gem repository. For gems with executables ruby installs a wrapper file into the executable -directory by deault. This can be overridden with the --no-wrappers option. The wrapper allows you to choose among alternate gem versions using _version_. For example `rake _0.7.3_ --version` will run rake version 0.7.3 if a newer version is also installed. EOF end @@ -65,24 +110,11 @@ version is also installed. ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9' - install_options = { - :env_shebang => options[:env_shebang], - :domain => options[:domain], - :force => options[:force], - :format_executable => options[:format_executable], - :ignore_dependencies => options[:ignore_dependencies], - :install_dir => options[:install_dir], - :security_policy => options[:security_policy], - :wrappers => options[:wrappers], - :bin_dir => options[:bin_dir], - :development => options[:development], - } - exit_code = 0 get_all_gem_names.each do |gem_name| begin - inst = Gem::DependencyInstaller.new install_options inst.install gem_name, options[:version] inst.installed_gems.each do |spec| @@ -96,46 +128,40 @@ version is also installed. rescue Gem::GemNotFoundException => e alert_error e.message exit_code |= 2 -# rescue => e -# # TODO: Fix this handle to allow the error to propagate to -# # the top level handler. Examine the other errors as -# # well. This implementation here looks suspicious to me -- -# # JimWeirich (4/Jan/05) -# alert_error "Error installing gem #{gem_name}: #{e.message}" -# return end end unless installed_gems.empty? then gems = installed_gems.length == 1 ? 'gem' : 'gems' say "#{installed_gems.length} #{gems} installed" - end - # NOTE: *All* of the RI documents must be generated first. - # For some reason, RI docs cannot be generated after any RDoc - # documents are generated. - if options[:generate_ri] then - installed_gems.each do |gem| - Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri - end - Gem::DocManager.update_ri_cache - end - if options[:generate_rdoc] then - installed_gems.each do |gem| - 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.search(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) then - Gem::Uninstaller.new(spec.name, :version => spec.version.version).uninstall end end end @@ -2,9 +2,11 @@ require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/spec_fetcher' require 'rubygems/version_option' class Gem::Commands::QueryCommand < Gem::Command include Gem::LocalRemoteOptions include Gem::VersionOption @@ -43,6 +45,11 @@ class Gem::Commands::QueryCommand < Gem::Command options[:all] = value end add_local_remote_options end @@ -54,6 +61,7 @@ class Gem::Commands::QueryCommand < Gem::Command exit_code = 0 name = options[:name] if options[:installed] then if name.source.empty? then @@ -72,6 +80,10 @@ class Gem::Commands::QueryCommand < Gem::Command dep = Gem::Dependency.new name, Gem::Requirement.default if local? then if ui.outs.tty? or both? then say say "*** LOCAL GEMS ***" @@ -98,8 +110,13 @@ class Gem::Commands::QueryCommand < Gem::Command begin fetcher = Gem::SpecFetcher.fetcher - spec_tuples = fetcher.find_matching dep, all, false rescue Gem::RemoteFetcher::FetchError => e raise unless fetcher.warn_legacy e do require 'rubygems/source_info_cache' @@ -145,6 +162,12 @@ class Gem::Commands::QueryCommand < Gem::Command version end.reverse seen = {} matching_tuples.delete_if do |(name, version,_),_| @@ -174,6 +197,28 @@ class Gem::Commands::QueryCommand < Gem::Command end entry << "\n" authors = "Author#{spec.authors.length > 1 ? 's' : ''}: " authors << spec.authors.join(', ') entry << format_text(authors, 68, 4) @@ -187,6 +232,12 @@ class Gem::Commands::QueryCommand < Gem::Command entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4) end if spec.loaded_from then if matching_tuples.length == 1 then loaded_from = File.dirname File.dirname(spec.loaded_from) @@ -209,25 +260,5 @@ class Gem::Commands::QueryCommand < Gem::Command say output.join(options[:details] ? "\n\n" : "\n") end - ## - # Used for wrapping and indenting text - - def format_text(text, wrap, indent=0) - result = [] - work = text.dup - - while work.length > wrap - if work =~ /^(.{0,#{wrap}})[ \n]/o then - result << $1 - work.slice!(0, $&.length) - else - result << work.slice!(0, wrap) - end - end - - result << work if work.length.nonzero? - result.join("\n").gsub(/^/, " " * indent) - end - end @@ -2,81 +2,75 @@ require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/doc_manager' -module Gem - module Commands - class RdocCommand < Command - include VersionOption - - def initialize - super('rdoc', - 'Generates RDoc for pre-installed gems', - { - :version => Gem::Requirement.default, - :include_rdoc => true, - :include_ri => true, - }) - add_option('--all', - 'Generate RDoc/RI documentation for all', - 'installed gems') do |value, options| - options[:all] = value - end - add_option('--[no-]rdoc', - 'Include RDoc generated documents') do - |value, options| - options[:include_rdoc] = value - end - add_option('--[no-]ri', - 'Include RI generated documents' - ) do |value, options| - options[:include_ri] = value - end - add_version_option - end - def arguments # :nodoc: - "GEMNAME gem to generate documentation for (unless --all)" - end - def defaults_str # :nodoc: - "--version '#{Gem::Requirement.default}' --rdoc --ri" - end - def usage # :nodoc: - "#{program_name} [args]" end - def execute - if options[:all] - specs = Gem::SourceIndex.from_installed_gems.collect { |name, spec| - spec - } - else - gem_name = get_one_gem_name - specs = Gem::SourceIndex.from_installed_gems.search( - gem_name, options[:version]) - end - - if specs.empty? - fail "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}" - end - - if options[:include_ri] - specs.each do |spec| - Gem::DocManager.new(spec).generate_ri - end - - Gem::DocManager.update_ri_cache - end - - if options[:include_rdoc] - specs.each do |spec| - Gem::DocManager.new(spec).generate_rdoc - end - end - - true end end end end @@ -1,37 +1,31 @@ require 'rubygems/command' require 'rubygems/commands/query_command' -module Gem - module Commands - - class SearchCommand < QueryCommand - - def initialize - super( - 'search', - 'Display all gems whose name contains STRING' - ) - remove_option('--name-matches') - end - - def arguments # :nodoc: - "STRING fragment of gem name to search for" - end - - def defaults_str # :nodoc: - "--local --no-details" - end - - def usage # :nodoc: - "#{program_name} [STRING]" - end - - def execute - string = get_one_optional_argument - options[:name] = /#{string}/i - super - end - end end end @@ -7,7 +7,23 @@ class Gem::Commands::ServerCommand < Gem::Command super 'server', 'Documentation and gem repository HTTP server', :port => 8808, :gemdir => Gem.dir, :daemon => false - add_option '-p', '--port=PORT', Integer, 'port to listen on' do |port, options| options[:port] = port end @@ -37,6 +53,12 @@ for gem installation. To install gems from a running server, use `gem install GEMNAME --source http://gem_server_host:8808` EOF end @@ -0,0 +1,353 @@ @@ -3,9 +3,12 @@ require 'rubygems/command' require 'rubygems/remote_fetcher' require 'rubygems/source_info_cache' require 'rubygems/spec_fetcher' class Gem::Commands::SourcesCommand < Gem::Command def initialize super 'sources', 'Manage the sources and cache file RubyGems uses to search for gems' @@ -30,6 +33,8 @@ class Gem::Commands::SourcesCommand < Gem::Command add_option '-u', '--update', 'Update source cache' do |value, options| options[:update] = value end end def defaults_str @@ -12,7 +12,8 @@ class Gem::Commands::SpecificationCommand < Gem::Command def initialize super 'specification', 'Display gem specification (in yaml)', - :domain => :local, :version => Gem::Requirement.default add_version_option('examine') add_platform_option @@ -22,26 +23,62 @@ class Gem::Commands::SpecificationCommand < Gem::Command options[:all] = true end add_local_remote_options end def arguments # :nodoc: - "GEMFILE name of gem to show the gemspec for" end def defaults_str # :nodoc: - "--local --version '#{Gem::Requirement.default}'" end def usage # :nodoc: - "#{program_name} [GEMFILE]" end def execute specs = [] - gem = get_one_gem_name dep = Gem::Dependency.new gem, options[:version] if local? then if File.exist? gem then specs << Gem::Format.from_file_by_path(gem).spec rescue nil @@ -63,7 +100,17 @@ class Gem::Commands::SpecificationCommand < Gem::Command terminate_interaction 1 end - output = lambda { |s| say s.to_yaml; say "\n" } if options[:all] then specs.each(&output) @@ -2,72 +2,82 @@ require 'rubygems/command' require 'rubygems/version_option' require 'rubygems/uninstaller' -module Gem - module Commands - class UninstallCommand < Command - - include VersionOption - - def initialize - super 'uninstall', 'Uninstall gems from the local repository', - :version => Gem::Requirement.default - - add_option('-a', '--[no-]all', - 'Uninstall all matching versions' - ) do |value, options| - options[:all] = value - end - - add_option('-I', '--[no-]ignore-dependencies', - 'Ignore dependency requirements while', - 'uninstalling') do |value, options| - options[:ignore] = value - end - - add_option('-x', '--[no-]executables', - 'Uninstall applicable executables without', - 'confirmation') do |value, options| - options[:executables] = value - end - - add_option('-i', '--install-dir DIR', - 'Directory to uninstall gem from') do |value, options| - options[:install_dir] = File.expand_path(value) - end - - add_option('-n', '--bindir DIR', - 'Directory to remove binaries from') do |value, options| - options[:bin_dir] = File.expand_path(value) - end - - add_version_option - add_platform_option - end - def arguments # :nodoc: - "GEMNAME name of gem to uninstall" - end - def defaults_str # :nodoc: - "--version '#{Gem::Requirement.default}' --no-force " \ - "--install-dir #{Gem.dir}" - end - def usage # :nodoc: - "#{program_name} GEMNAME [GEMNAME ...]" - end - def execute - get_all_gem_names.each do |gem_name| - begin - Gem::Uninstaller.new(gem_name, options).uninstall - rescue Gem::GemNotInHomeException => e - spec = e.spec - alert("In order to remove #{spec.name}, please execute:\n" \ - "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}") - end - end end end end end @@ -12,7 +12,7 @@ class Gem::Commands::UnpackCommand < Gem::Command :version => Gem::Requirement.default, :target => Dir.pwd - add_option('--target', 'target directory for unpacking') do |value, options| options[:target] = value end @@ -35,18 +35,20 @@ class Gem::Commands::UnpackCommand < Gem::Command # TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for # this, so that it works for uninstall as well. (And check other commands # at the same time.) def execute - gemname = get_one_gem_name - path = get_path(gemname, options[:version]) - - if path then - basename = File.basename(path).sub(/\.gem$/, '') - target_dir = File.expand_path File.join(options[:target], basename) - FileUtils.mkdir_p target_dir - Gem::Installer.new(path, :unpack => true).unpack target_dir - say "Unpacked gem: '#{target_dir}'" - else - alert_error "Gem '#{gemname}' not installed." end end @@ -16,9 +16,9 @@ class Gem::Commands::UpdateCommand < Gem::Command super 'update', 'Update the named gems (or all installed gems) in the local repository', :generate_rdoc => true, - :generate_ri => true, - :force => false, - :test => false add_install_update_options @@ -80,20 +80,27 @@ class Gem::Commands::UpdateCommand < Gem::Command gems_to_update.uniq.sort.each do |name| next if updated.any? { |spec| spec.name == name } say "Updating #{name}" - installer.install name installer.installed_gems.each do |spec| updated << spec - say "Successfully installed #{spec.full_name}" end end if gems_to_update.include? "rubygems-update" then Gem.source_index.refresh! - update_gems = Gem.source_index.search 'rubygems-update' latest_update_gem = update_gems.sort_by { |s| s.version }.last @@ -106,6 +113,20 @@ class Gem::Commands::UpdateCommand < Gem::Command say "Nothing to update" else say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}" end end end @@ -46,7 +46,7 @@ class Gem::Commands::WhichCommand < Gem::Command end say "(checking gem #{spec.full_name} for #{arg})" if - Gem.configuration.verbose end paths = find_paths arg, dirs |