Sha256: 1eaf3fc521c1cbdb6930dc801720a631e6fe4b2ace99ea0d69cf77aa052f3a66

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

        def initialize publisher: Tools::Publisher.new, loader: Spek::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

4 entries across 4 versions & 1 rubygems

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