Sha256: ac1c77d603a8aea1e7fd17bb1ba6ef2c954fc316c52d6fd5cda997aa70c6ef41

Contents?: true

Size: 895 Bytes

Versions: 7

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "spek"

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

        def initialize(installer: Tools::Installer.new, loader: Spek::Loader, **)
          super(**)
          @installer = installer
          @loader = loader
        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

        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/install.rb
gemsmith-19.7.0 lib/gemsmith/cli/actions/install.rb
gemsmith-19.6.0 lib/gemsmith/cli/actions/install.rb
gemsmith-19.5.2 lib/gemsmith/cli/actions/install.rb
gemsmith-19.5.1 lib/gemsmith/cli/actions/install.rb
gemsmith-19.5.0 lib/gemsmith/cli/actions/install.rb
gemsmith-19.4.0 lib/gemsmith/cli/actions/install.rb