class Gemsmith::Tools::Pusher

Pushes a gem package to remote gem server.

Attributes

command[R]

Public Class Methods

new(command: Gem::CommandManager.new, **) click to toggle source
Calls superclass method
# File lib/gemsmith/tools/pusher.rb, line 13
def initialize(command: Gem::CommandManager.new, **)
  super(**)
  @command = command
end

Public Instance Methods

call(specification) click to toggle source
# File lib/gemsmith/tools/pusher.rb, line 18
def call specification
  command.run ["push", specification.package_path.to_s, *one_time_password]
  Success specification
rescue Gem::Exception => error
  Failure error.message
end

Private Instance Methods

check_yubikey() click to toggle source
# File lib/gemsmith/tools/pusher.rb, line 40
def check_yubikey
  executor.capture3("command", "-v", "ykman")
          .then do |stdout, stderr, status|
            if status.success?
              Success stdout.chomp
            else
              logger.debug { "Unable to find YubiKey Manager. #{stderr}." }
              Failure()
            end
          end
end
one_time_password() click to toggle source

:reek: TooManyStatements

# File lib/gemsmith/tools/pusher.rb, line 30
def one_time_password
  return Core::EMPTY_ARRAY if check_yubikey.failure?

  executor.capture3(check_yubikey.success, "oath", "accounts", "code", "--single", "RubyGems")
          .then { |stdout, _stderr, status| status.success? ? ["--otp", stdout.chomp] : [] }
rescue Errno::ENOENT => error
  logger.debug { "Unable to obtain YubiKey One-Time Password. #{error}." }
  Core::EMPTY_ARRAY
end