Sha256: b189a49b10dc8f4d006f3589bd1abba4ddc3e703284a56d0e228fc38a653e1ae

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "pathname"

module Milestoner
  module Configuration
    module Transformers
      module Gems
        # Conditionally updates project name based on specification name.
        class Name
          include Import[:spec_loader]
          include Dry::Monads[:result]

          def initialize(key = :project_name, path: "#{Pathname.pwd.basename}.gemspec", **)
            super(**)
            @key = key
            @path = path
          end

          def call attributes
            attributes.fetch key do
              value = spec_loader.call(path).name
              attributes.merge! key => value if value
            end

            Success attributes
          end

          private

          attr_reader :key, :path
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
milestoner-18.12.0 lib/milestoner/configuration/transformers/gems/name.rb