Sha256: 168e85dc7465ba9340b5a28e367073746e9a05cfd07d57fda89100d28efaed01

Contents?: true

Size: 890 Bytes

Versions: 7

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "spek"

module Gemsmith
  module CLI
    module Actions
      # Handles the edit action for editing an installed gem.
      class Edit
        include Gemsmith::Import[:kernel, :logger]
        include Dry::Monads[:result]

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

        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 error { message }
            else error { "Unable to handle edit action." }
          end
        end

        private

        attr_reader :picker, :editor

        def error(&) = logger.error(&)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gemsmith-19.8.0 lib/gemsmith/cli/actions/edit.rb
gemsmith-19.7.0 lib/gemsmith/cli/actions/edit.rb
gemsmith-19.6.0 lib/gemsmith/cli/actions/edit.rb
gemsmith-19.5.2 lib/gemsmith/cli/actions/edit.rb
gemsmith-19.5.1 lib/gemsmith/cli/actions/edit.rb
gemsmith-19.5.0 lib/gemsmith/cli/actions/edit.rb
gemsmith-19.4.0 lib/gemsmith/cli/actions/edit.rb