diff options
-rw-r--r-- | lib/rubygems/commands/cert_command.rb | 24 | ||||
-rw-r--r-- | lib/rubygems/commands/cleanup_command.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/commands/contents_command.rb | 25 | ||||
-rw-r--r-- | lib/rubygems/commands/dependency_command.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/commands/environment_command.rb | 7 | ||||
-rw-r--r-- | lib/rubygems/commands/help_command.rb | 219 | ||||
-rw-r--r-- | lib/rubygems/commands/install_command.rb | 58 | ||||
-rw-r--r-- | lib/rubygems/commands/list_command.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/commands/open_command.rb | 74 | ||||
-rw-r--r-- | lib/rubygems/commands/owner_command.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/commands/search_command.rb | 10 | ||||
-rw-r--r-- | lib/rubygems/commands/setup_command.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/commands/uninstall_command.rb | 14 | ||||
-rw-r--r-- | lib/rubygems/commands/update_command.rb | 23 | ||||
-rw-r--r-- | lib/rubygems/commands/yank_command.rb | 21 |
15 files changed, 408 insertions, 85 deletions
@@ -129,23 +129,21 @@ class Gem::Commands::CertCommand < Gem::Command end def build_key # :nodoc: - if options[:key] then - options[:key] - else - passphrase = ask_for_password 'Passphrase for your Private Key:' - say "\n" - passphrase_confirmation = ask_for_password 'Please repeat the passphrase for your Private Key:' - say "\n" - raise Gem::CommandLineError, - "Passphrase and passphrase confirmation don't match" unless passphrase == passphrase_confirmation - key = Gem::Security.create_key - key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase - return key, key_path - end end def certificates_matching filter @@ -67,10 +67,10 @@ If no gems are named all gems in GEM_HOME are cleaned. say "Clean Up Complete" - if Gem.configuration.really_verbose then skipped = @default_gems.map { |spec| spec.full_name } - say "Skipped default gems: #{skipped.join ', '}" end end @@ -8,7 +8,8 @@ class Gem::Commands::ContentsCommand < Gem::Command def initialize super 'contents', 'Display the contents of the installed gems', - :specdirs => [], :lib_only => false, :prefix => true add_version_option @@ -32,6 +33,11 @@ class Gem::Commands::ContentsCommand < Gem::Command options[:prefix] = prefix end @path_kind = nil @spec_dirs = nil @version = nil @@ -65,7 +71,12 @@ prefix or only the files that are requireable. names = gem_names names.each do |name| - found = gem_contents name terminate_interaction 1 unless found or names.length > 1 end @@ -115,6 +126,16 @@ prefix or only the files that are requireable. true end def gem_names # :nodoc: if options[:all] then Gem::Specification.map(&:name) @@ -31,7 +31,7 @@ class Gem::Commands::DependencyCommand < Gem::Command end def arguments # :nodoc: - "GEMNAME name of gem to show dependencies for" end def defaults_str # :nodoc: @@ -50,7 +50,7 @@ use with other commands. end def usage # :nodoc: - "#{program_name} GEMNAME" end def fetch_remote_specs dependency # :nodoc: @@ -28,8 +28,9 @@ The RubyGems environment can be controlled through command line arguments, gemrc files, environment variables and built-in defaults. Command line argument defaults and some RubyGems defaults can be set in a -~/.gemrc file for individual users and a /etc/gemrc for all users. These -files are YAML files with the following YAML keys: :sources: A YAML array of remote gem repositories to install gems from :verbose: Verbosity of the gem command. false, true, and :really are the @@ -120,6 +121,8 @@ lib/rubygems/defaults/operating_system.rb out << " - SPEC CACHE DIRECTORY: #{Gem.spec_cache_dir}\n" out << " - RUBYGEMS PLATFORMS:\n" Gem.platforms.each do |platform| out << " - #{platform}\n" @@ -52,6 +52,183 @@ Some examples of 'gem' usage. gem update --system EOF PLATFORMS = <<-'EOF' RubyGems platforms are composed of three parts, a CPU, an OS, and a version. These values are taken from values in rbconfig.rb. You can view @@ -90,6 +267,16 @@ When building platform gems, set the platform in the gem specification to Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's platform. EOF # :startdoc: def initialize @@ -98,15 +285,6 @@ platform. @command_manager = Gem::CommandManager.instance end - def arguments # :nodoc: - args = <<-EOF - commands List all 'gem' commands - examples Show examples of 'gem' usage - <command> Show specific help for <command> - EOF - return args.gsub(/^\s+/, '') - end - def usage # :nodoc: "#{program_name} ARGUMENT" end @@ -114,19 +292,20 @@ platform. def execute arg = options[:args][0] - if begins? "commands", arg then - show_commands - - elsif begins? "options", arg then - say Gem::Command::HELP - - elsif begins? "examples", arg then - say EXAMPLES - elsif begins? "platforms", arg then - say PLATFORMS - elsif options[:help] then show_help elsif arg then @@ -21,6 +21,8 @@ class Gem::Commands::InstallCommand < Gem::Command def initialize defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({ :format_executable => false, :version => Gem::Requirement.default, :without_groups => [], }) @@ -69,6 +71,16 @@ class Gem::Commands::InstallCommand < Gem::Command o[:explain] = v end @installed_specs = [] end @@ -78,7 +90,7 @@ class Gem::Commands::InstallCommand < Gem::Command def defaults_str # :nodoc: "--both --version '#{Gem::Requirement.default}' --document --no-force\n" + - "--install-dir #{Gem.dir}" end def description # :nodoc: @@ -92,6 +104,25 @@ 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. If an extension fails to compile during gem installation the gem specification is not written out, but the gem remains unpacked in the repository. You may need to specify the path to the library's headers and @@ -204,23 +235,20 @@ to write the specification by hand. For example: install_gem_without_dependencies name, req else inst = Gem::DependencyInstaller.new options if options[:explain] - request_set = inst.resolve_dependencies name, req - puts "Gems to install:" - request_set.specs.map { |s| s.full_name }.sort.each do |s| - puts " #{s}" end return else - inst.install name, req end - @installed_specs.push(*inst.installed_gems) - show_install_errors inst.errors end end @@ -250,6 +278,14 @@ to write the specification by hand. For example: inst = Gem::Installer.new gem, options inst.install @installed_specs.push(inst.spec) end @@ -264,8 +300,10 @@ to write the specification by hand. For example: rescue Gem::InstallError => e 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, options[:domain] exit_code |= 2 end @@ -8,13 +8,13 @@ require 'rubygems/commands/query_command' class Gem::Commands::ListCommand < Gem::Commands::QueryCommand def initialize - super 'list', 'Display local gems whose name starts with STRING' remove_option('--name-matches') end def arguments # :nodoc: - "STRING start of gem name to look for" end def defaults_str # :nodoc: @@ -0,0 +1,74 @@ @@ -86,7 +86,9 @@ permission to. request.add_field "Authorization", api_key end - with_response response, "Removing #{owner}" rescue # ignore end @@ -4,7 +4,7 @@ require 'rubygems/commands/query_command' class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand def initialize - super 'search', 'Display remote gems whose name contains STRING' remove_option '--name-matches' @@ -12,7 +12,7 @@ class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand end def arguments # :nodoc: - "STRING fragment of gem name to search for" end def defaults_str # :nodoc: @@ -21,8 +21,8 @@ class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand def description # :nodoc: <<-EOF -The search command displays remote gems whose name contains the given -string. The --details option displays additional details from the gem but will take a little longer to complete as it must download the information @@ -33,7 +33,7 @@ To list local gems use the list command. end def usage # :nodoc: - "#{program_name} [STRING]" end end @@ -446,7 +446,7 @@ abort "#{deprecation_message}" 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 @@ -15,7 +15,7 @@ class Gem::Commands::UninstallCommand < Gem::Command def initialize super 'uninstall', 'Uninstall gems from the local repository', :version => Gem::Requirement.default, :user_install => true, - :check_dev => false add_option('-a', '--[no-]all', 'Uninstall all matching versions' @@ -76,6 +76,18 @@ class Gem::Commands::UninstallCommand < Gem::Command add_version_option add_platform_option end def arguments # :nodoc: @@ -16,6 +16,8 @@ class Gem::Commands::UpdateCommand < Gem::Command attr_reader :installer # :nodoc: def initialize super 'update', 'Update installed gems to the latest version', :document => %w[rdoc ri], @@ -45,7 +47,7 @@ class Gem::Commands::UpdateCommand < Gem::Command end def arguments # :nodoc: - "GEMNAME name of gem to update" end def defaults_str # :nodoc: @@ -56,13 +58,13 @@ class Gem::Commands::UpdateCommand < Gem::Command <<-EOF The update command will update your gems to the latest version. -The update comamnd does not remove the previous version. Use the cleanup command to remove old versions. EOF end def usage # :nodoc: - "#{program_name} GEMNAME [GEMNAME ...]" end def check_latest_rubygems version # :nodoc: @@ -97,10 +99,14 @@ command to remove old versions. updated = update_gems gems_to_update if updated.empty? then say "Nothing to update" else - say "Gems updated: #{updated.map { |spec| spec.name }.join ' '}" end end @@ -199,15 +205,11 @@ command to remove old versions. @installer ||= Gem::DependencyInstaller.new options - success = false - say "Updating #{name}" begin @installer.install name, Gem::Requirement.new(version) - success = true - rescue Gem::InstallError => e alert_error "Error installing #{name}:\n\t#{e.message}" - success = false end @installer.installed_gems.each do |spec| @@ -259,7 +261,7 @@ command to remove old versions. highest_installed_gems.each do |l_name, l_spec| next if not gem_names.empty? and - gem_names.all? { |name| /#{name}/ !~ l_spec.name } highest_remote_ver = highest_remote_version l_spec @@ -272,4 +274,3 @@ command to remove old versions. end end - @@ -44,10 +44,7 @@ as the reason for the removal request. options[:undo] = true end - add_option('-k', '--key KEY_NAME', - 'Use API key from your gem credentials file') do |value, options| - options[:key] = value - end end def execute @@ -55,14 +52,12 @@ as the reason for the removal request. version = get_version_from_requirements(options[:version]) platform = get_platform_from_requirements(options) - api_key = Gem.configuration.rubygems_api_key - api_key = Gem.configuration.api_keys[options[:key].to_sym] if options[:key] if version then if options[:undo] then - unyank_gem(version, platform, api_key) else - yank_gem(version, platform, api_key) end else say "A version argument is required: #{usage}" @@ -70,19 +65,19 @@ as the reason for the removal request. end end - def yank_gem(version, platform, api_key) say "Yanking gem from #{self.host}..." - yank_api_request(:delete, version, platform, "api/v1/gems/yank", api_key) end - def unyank_gem(version, platform, api_key) say "Unyanking gem from #{host}..." - yank_api_request(:put, version, platform, "api/v1/gems/unyank", api_key) end private - def yank_api_request(method, version, platform, api, api_key) name = get_one_gem_name response = rubygems_api_request(method, api) do |request| request.add_field("Authorization", api_key) |