class Gemsearch::Installer

Attributes

prompt[R]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/gemsearch/installer.rb, line 5
def initialize(opts = {})
  @prompt = opts.fetch(:prompt) { TTY::Prompt.new }
end

Public Instance Methods

install(selected_gem) click to toggle source
# File lib/gemsearch/installer.rb, line 9
def install(selected_gem)
  print_install_message(selected_gem)
  Bun.add("#{selected_gem["name"]}:#{selected_gem["version"]}")
  exit
rescue Bun::Errors::DuplicateGemError
  $stdout.puts prompt.decorate("Gem #{selected_gem["name"]} already present in the Gemfile. Aborting.", :red)
end

Private Instance Methods

print_install_message(selected_gem) click to toggle source