Class: Gem::Commands::YankCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::YankCommand
- Includes:
- GemcutterUtilities, LocalRemoteOptions, VersionOption
- Defined in:
- lib/rubygems/commands/yank_command.rb
Constant Summary
Constants included from GemcutterUtilities
GemcutterUtilities::API_SCOPES, GemcutterUtilities::ERROR_CODE
Instance Attribute Summary
Attributes included from GemcutterUtilities
Attributes inherited from Gem::Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ YankCommand
constructor
A new instance of YankCommand.
-
#usage ⇒ Object
:nodoc:.
- #yank_gem(version, platform) ⇒ Object
Methods included from GemcutterUtilities
#add_key_option, #add_otp_option, #api_key, #mfa_unauthorized?, #otp, #rubygems_api_request, #set_api_key, #sign_in, #update_scope, #verify_api_key, #with_response
Methods included from Text
#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text
Methods included from VersionOption
#add_platform_option, #add_prerelease_option, #add_version_option, #get_platform_from_requirements
Methods included from LocalRemoteOptions
#accept_uri_http, #add_bulk_threshold_option, #add_clear_sources_option, #add_local_remote_options, #add_proxy_option, #add_source_option, #add_update_sources_option, #both?, #local?, #remote?
Methods inherited from Gem::Command
add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #begins?, build_args, build_args=, #check_deprecated_options, common_options, #defaults_str, #deprecate_option, #deprecated?, extra_args, extra_args=, #get_all_gem_names, #get_all_gem_names_and_versions, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #invoke_with_build_args, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, specific_extra_args_hash=, #when_invoked
Methods included from UserInteraction
#alert, #alert_error, #alert_warning, #ask, #ask_for_password, #ask_yes_no, #choose_from_list, #say, #terminate_interaction, #verbose
Methods included from DefaultUserInteraction
ui, #ui, ui=, #ui=, use_ui, #use_ui
Constructor Details
#initialize ⇒ YankCommand
Returns a new instance of YankCommand.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubygems/commands/yank_command.rb', line 30 def initialize super 'yank', 'Remove a pushed gem from the index' add_version_option("remove") add_platform_option("remove") add_otp_option add_option('--host HOST', 'Yank from another gemcutter-compatible host', ' (e.g. https://rubygems.org)') do |value, | [:host] = value end add_key_option @host = nil end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/rubygems/commands/yank_command.rb', line 22 def arguments # :nodoc: "GEM name of gem" end |
#description ⇒ Object
:nodoc:
12 13 14 15 16 17 18 19 20 |
# File 'lib/rubygems/commands/yank_command.rb', line 12 def description # :nodoc: <<-EOF The yank command permanently removes a gem you pushed to a server. Once you have pushed a gem several downloads will happen automatically via the webhooks. If you accidentally pushed passwords or other sensitive data you will need to change them immediately and yank your gem. EOF end |
#execute ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rubygems/commands/yank_command.rb', line 47 def execute @host = [:host] sign_in @host, scope: get_yank_scope version = get_version_from_requirements([:version]) platform = get_platform_from_requirements() if version yank_gem(version, platform) else say "A version argument is required: #{usage}" terminate_interaction end end |
#usage ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/rubygems/commands/yank_command.rb', line 26 def usage # :nodoc: "#{program_name} -v VERSION [-p PLATFORM] [--key KEY_NAME] [--host HOST] GEM" end |
#yank_gem(version, platform) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/rubygems/commands/yank_command.rb', line 63 def yank_gem(version, platform) say "Yanking gem from #{self.host}..." args = [:delete, version, platform, "api/v1/gems/yank"] response = yank_api_request(*args) say response.body end |