module Gemsmith::Helpers::CLI

Command Line Interface (CLI) helpers for the CLI class.

Public Instance Methods

inspect_gem(specification, method) click to toggle source
# File lib/gemsmith/helpers/cli.rb, line 35
def inspect_gem specification, method
  return unless specification

  Gem::Inspector.new.public_send method, Gem::Specification.new(specification.spec_file)
rescue Versionaire::Errors::Conversion => error
  say_status :error, error.message, :red
end
pick_gem(gems, name) click to toggle source

:reek: FeatureEnvy :reek: TooManyStatements

# File lib/gemsmith/helpers/cli.rb, line 21
def pick_gem gems, name
  answer = ask "Enter selection:"
  return if answer == "q"

  answer = answer.to_i

  if (1..gems.size).cover? answer
    Gem::Specification.find name, gems[answer - 1].version.version
  else
    say_status :error, "Invalid option: #{answer}", :red
    nil
  end
end
print_gems(gems) click to toggle source
process_gem(name, method) click to toggle source

:reek: TooManyStatements

# File lib/gemsmith/helpers/cli.rb, line 44
def process_gem name, method
  specs = Gem::Specification.find_all name
  spec_count = specs.size

  if spec_count == 1
    inspect_gem specs.first, method
  elsif spec_count > 1
    print_gems specs
    inspect_gem pick_gem(specs, name), method
  else
    say_status :error, "Unable to find gem: #{name}.", :red and ""
  end
end