Class: Gemsmith::CLI::Actions::Edit

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

Overview

Handles the edit action for editing an installed gem.

Instance Method Summary collapse

Constructor Details

#initialize(picker: Spek::Picker, editor: Tools::Editor.new) ⇒ Edit

Returns a new instance of Edit.



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

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

Instance Method Details

#call(gem_name) ⇒ Object



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

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