Sha256: 22e8f4d68d1f6d22d4ca9da3c78a464ae9cb0fd5ac1daa9bcf2eb6896fde0262

Contents?: true

Size: 924 Bytes

Versions: 1

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"

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

        def initialize installer: Tools::Installer.new, loader: Gems::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

1 entries across 1 versions & 1 rubygems

Version Path
gemsmith-16.0.0 lib/gemsmith/cli/actions/install.rb