Sha256: 056ed2c273f6f76059edff40d8aa4ab002cb453240a65d0e8d613d427230148e

Contents?: true

Size: 919 Bytes

Versions: 17

Compression:

Stored size: 919 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, **dependencies
          super(**dependencies)

          @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

17 entries across 17 versions & 1 rubygems

Version Path
gemsmith-19.3.0 lib/gemsmith/cli/actions/install.rb
gemsmith-19.2.0 lib/gemsmith/cli/actions/install.rb
gemsmith-19.1.0 lib/gemsmith/cli/actions/install.rb
gemsmith-19.0.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.9.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.8.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.7.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.6.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.5.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.4.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.3.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.2.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.1.1 lib/gemsmith/cli/actions/install.rb
gemsmith-18.1.0 lib/gemsmith/cli/actions/install.rb
gemsmith-18.0.2 lib/gemsmith/cli/actions/install.rb
gemsmith-18.0.1 lib/gemsmith/cli/actions/install.rb
gemsmith-18.0.0 lib/gemsmith/cli/actions/install.rb