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
Instance Method Summary collapse
- #arguments ⇒ Object
- #description ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ YankCommand
constructor
A new instance of YankCommand.
- #unyank_gem(version, platform, api_key) ⇒ Object
- #usage ⇒ Object
- #yank_gem(version, platform, api_key) ⇒ Object
Constructor Details
#initialize ⇒ YankCommand
Returns a new instance of YankCommand.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubygems/commands/yank_command.rb', line 22 def initialize super 'yank', description add_version_option("remove") add_platform_option("remove") add_option('--undo') do |value, | [:undo] = true end add_option('-k', '--key KEY_NAME', 'Use API key from your gem credentials file') do |value, | [:key] = value end end |
Instance Method Details
#arguments ⇒ Object
14 15 16 |
# File 'lib/rubygems/commands/yank_command.rb', line 14 def arguments "GEM name of gem" end |
#description ⇒ Object
10 11 12 |
# File 'lib/rubygems/commands/yank_command.rb', line 10 def description 'Remove a specific gem version release from RubyGems.org' end |
#execute ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubygems/commands/yank_command.rb', line 36 def execute sign_in version = get_version_from_requirements([:version]) platform = get_platform_from_requirements() api_key = Gem.configuration.rubygems_api_key api_key = Gem.configuration.api_keys[[:key].to_sym] if [:key] if !version.nil? if [:undo] unyank_gem(version, platform, api_key) else yank_gem(version, platform, api_key) end else say "A version argument is required: #{usage}" terminate_interaction end end |
#unyank_gem(version, platform, api_key) ⇒ Object
60 61 62 63 |
# File 'lib/rubygems/commands/yank_command.rb', line 60 def unyank_gem(version, platform, api_key) say "Unyanking gem from RubyGems.org..." yank_api_request(:put, version, platform, "api/v1/gems/unyank", api_key) end |
#usage ⇒ Object
18 19 20 |
# File 'lib/rubygems/commands/yank_command.rb', line 18 def usage "#{program_name} GEM -v VERSION [-p PLATFORM] [--undo] [--key KEY_NAME]" end |
#yank_gem(version, platform, api_key) ⇒ Object
55 56 57 58 |
# File 'lib/rubygems/commands/yank_command.rb', line 55 def yank_gem(version, platform, api_key) say "Yanking gem from RubyGems.org..." yank_api_request(:delete, version, platform, "api/v1/gems/yank", api_key) end |