Sha256: fab6ddeaa58d16fceab6d14fa75cd97507c846e9e5cef20458269ee9d2a06c38

Contents?: true

Size: 1.13 KB

Versions: 19

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "dry/monads"
require "pathname"
require "sod"
require "spek"

module Gemsmith
  module CLI
    module Actions
      # Handles the install action.
      class Install < Sod::Action
        include Import[:logger]
        include Dry::Monads[:result]

        description "Install gem for local development."

        ancillary "Optionally computes gem package based on current directory."

        on %w[-i --install], argument: "[GEM]"

        default { Pathname.pwd.basename }

        def initialize(installer: Tools::Installer.new, loader: Spek::Loader, **)
          super(**)
          @installer = installer
          @loader = loader
        end

        def call name = nil
          case installer.call loader.call("#{name || default}.gemspec")
            in Success(spec) then logger.info { "Installed: #{spec.package_name}." }
            in Failure(message) then log_error { message }
            else log_error { "Unable to handle install action." }
          end
        end

        private

        attr_reader :installer, :loader

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gemsmith-22.1.0 lib/gemsmith/cli/actions/install.rb
gemsmith-22.0.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.10.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.9.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.6.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.5.1 lib/gemsmith/cli/actions/install.rb
gemsmith-21.5.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.4.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.3.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.2.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.1.0 lib/gemsmith/cli/actions/install.rb
gemsmith-21.0.0 lib/gemsmith/cli/actions/install.rb
gemsmith-20.7.0 lib/gemsmith/cli/actions/install.rb
gemsmith-20.6.1 lib/gemsmith/cli/actions/install.rb
gemsmith-20.6.0 lib/gemsmith/cli/actions/install.rb
gemsmith-20.5.0 lib/gemsmith/cli/actions/install.rb
gemsmith-20.4.0 lib/gemsmith/cli/actions/install.rb
gemsmith-20.3.0 lib/gemsmith/cli/actions/install.rb
gemsmith-20.2.1 lib/gemsmith/cli/actions/install.rb