Sha256: 74e70072c2524f876fd869f2facc2de60b1be7f7899acd15d61edb68b819f1a2

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "dry/monads"
require "pathname"
require "sod"
require "spek"

module Gemsmith
  module CLI
    module Actions
      # Handles the publish action.
      class Publish < Sod::Action
        include Import[:logger]
        include Dry::Monads[:result]

        description "Publish gem to remote gem server."

        ancillary "Optionally computes gem package based on current directory."

        on %w[-p --publish], argument: "[GEM]"

        default { Pathname.pwd.basename }

        def initialize(publisher: Tools::Publisher.new, loader: Spek::Loader, **)
          super(**)
          @publisher = publisher
          @loader = loader
        end

        def call name = nil
          case publisher.call loader.call("#{name || default}.gemspec")
            in Success(spec) then logger.info { "Published: #{spec.package_name}." }
            in Failure(message) then log_error { message }
            else log_error { "Unable to handle publish action." }
          end
        end

        private

        attr_reader :publisher, :loader

        def log_error(&) = logger.error(&)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gemsmith-21.10.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.9.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.6.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.5.1 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.5.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.4.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.3.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.2.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.1.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-21.0.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-20.7.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-20.6.1 lib/gemsmith/cli/actions/publish.rb
gemsmith-20.6.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-20.5.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-20.4.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-20.3.0 lib/gemsmith/cli/actions/publish.rb
gemsmith-20.2.1 lib/gemsmith/cli/actions/publish.rb