Class: Gem::Commands::YankCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::YankCommand
- Defined in:
- lib/rubygems-source-cli/commands/yank_command.rb
Constant Summary collapse
- RUBYGEMS_HOST =
"rubygems.org"
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(*args) ⇒ YankCommand
constructor
A new instance of YankCommand.
- #sign_into_rubygems ⇒ Object
- #unyank_gem(version, platform) ⇒ Object
- #yank_gem(version, platform) ⇒ Object
Constructor Details
#initialize(*args) ⇒ YankCommand
Returns a new instance of YankCommand.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubygems-source-cli/commands/yank_command.rb', line 4 def initialize(*args) super 'yank', description add_version_option("remove") add_platform_option("remove") add_option('--undo') do |value, | [:undo] = true end add_key_option add_option( '--host HOST', 'Yank from another gemcutter-compatible host' ) do |value, | [:host] = value end end |
Instance Method Details
#execute ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubygems-source-cli/commands/yank_command.rb', line 20 def execute sign_into_rubygems if host_is_rubygems? && !Gem.configuration.rubygems_api_key version = get_version_from_requirements([:version]) platform = get_platform_from_requirements() if !version.nil? if [:undo] unyank_gem(version, platform) else yank_gem(version, platform) end else say "A version argument is required: #{usage}" terminate_interaction end end |
#sign_into_rubygems ⇒ Object
47 48 49 |
# File 'lib/rubygems-source-cli/commands/yank_command.rb', line 47 def sign_into_rubygems sign_in end |
#unyank_gem(version, platform) ⇒ Object
42 43 44 45 |
# File 'lib/rubygems-source-cli/commands/yank_command.rb', line 42 def unyank_gem(version, platform) say "Unyanking gem from #{[:host] || 'Rubygems.org'}..." yank_api_request(:put, version, platform, "api/v1/gems/unyank") end |
#yank_gem(version, platform) ⇒ Object
37 38 39 40 |
# File 'lib/rubygems-source-cli/commands/yank_command.rb', line 37 def yank_gem(version, platform) say "Yanking gem from #{[:host] || 'Rubygems.org'}..." yank_api_request(:delete, version, platform, "api/v1/gems/yank") end |