Class: Gemsmith::CLI::Actions::View

Inherits:
Sod::Action
  • Object
show all
Defined in:
lib/gemsmith/cli/actions/view.rb

Overview

Handles the view action for viewing an installed gem in default browser.

Instance Method Summary collapse

Constructor Details

#initialize(picker: Spek::Picker, viewer: Tools::Viewer.new) ⇒ View

Returns a new instance of View.



19
20
21
22
23
# File 'lib/gemsmith/cli/actions/view.rb', line 19

def initialize(picker: Spek::Picker, viewer: Tools::Viewer.new, **)
  super(**)
  @picker = picker
  @viewer = viewer
end

Instance Method Details

#call(gem_name) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/gemsmith/cli/actions/view.rb', line 25

def call gem_name
  case picker.call(gem_name).bind { |spec| viewer.call spec }
    in Success(spec) then logger.info { "Viewing: #{spec.named_version}." }
    in Failure(message) then log_error { message }
    else log_error { "Unable to handle view action." }
  end
end