Sha256: e5b05d4a17fbb3377119a4fba811620d3d770cb403b2023b39129dd744f30050

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

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

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