Sha256: 8052c191ecbb2a5184d1c5f4334673e5f246b117ff316b9021b0961afc0cf5f1

Contents?: true

Size: 939 Bytes

Versions: 4

Compression:

Stored size: 939 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "spek"

module Gemsmith
  module CLI
    module Actions
      # Handles the install action.
      class Install
        include Dry::Monads[:result]

        def initialize installer: Tools::Installer.new, loader: Spek::Loader, container: Container
          @installer = installer
          @loader = loader
          @container = container
        end

        def call configuration
          case installer.call loader.call("#{configuration.project_name}.gemspec")
            in Success(spec) then logger.info { "Installed: #{spec.package_name}." }
            in Failure(message) then error { message }
            else error { "Unable to handle install action." }
          end
        end

        private

        attr_reader :installer, :loader, :container

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

        def logger = container[__method__]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gemsmith-17.0.1 lib/gemsmith/cli/actions/install.rb
gemsmith-17.0.0 lib/gemsmith/cli/actions/install.rb
gemsmith-16.2.0 lib/gemsmith/cli/actions/install.rb
gemsmith-16.1.0 lib/gemsmith/cli/actions/install.rb