Sha256: 3b2fb041d15e3ba6fde27b0ac9c830032baa4036e4b555533498e9a52fdf530e

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 publish action.
      class Publish
        include Dry::Monads[:result]

        def initialize publisher: Tools::Publisher.new, loader: Gems::Loader, container: Container
          @publisher = publisher
          @loader = loader
          @container = container
        end

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

        private

        attr_reader :publisher, :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/publish.rb