Class: Gem::Commands::YankCommand

### Home Classes Methods

### In Files

- lib/rubygems/commands/yank_command.rb

### Parent

Gem::Command

### Methods

- ::new
- #arguments
- #description
- #execute
- #unyank_gem
- #usage
- #yank_gem

### Included Modules

- Gem::LocalRemoteOptions
- Gem::VersionOption
- Gem::GemcutterUtilities

### Class/Module Index

Quicksearch

- Gem
- Gem::Commands
- Gem::Commands::MigrateCommand
- Gem::Commands::TumbleCommand
- Gem::Commands::WebhookCommand
- Gem::Commands::YankCommand
- Gemcutter

No matching classes.

# Gem::Commands::YankCommand

### Public Class Methods

new() click to toggle source

    # 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, options|
        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

### Public Instance Methods

arguments() click to toggle source

    # File lib/rubygems/commands/yank_command.rb, line 14
    def arguments
      "GEM       name of gem"
    end

description() click to toggle source

    # File lib/rubygems/commands/yank_command.rb, line 10
    def description
      'Remove a specific gem version release from RubyGems.org'
    end

execute() click to toggle source

    # File lib/rubygems/commands/yank_command.rb, line 36
    def execute
      sign_in
      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.nil?
        if options[: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) click to toggle source

    # 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() click to toggle source

    # 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) click to toggle source

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.