Sha256: dd20d0308ed14f2bbe8be354db0dfd418abf2b606154fc1a3b0ef44a19daadfd

Contents?: true

Size: 866 Bytes

Versions: 5

Compression:

Stored size: 866 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "pathname"
require "refinements/hash"

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]

          using Refinements::Hash

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

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

            Success attributes
          end

          private

          attr_reader :key, :path
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
milestoner-18.3.0 lib/milestoner/configuration/transformers/gems/name.rb
milestoner-18.2.0 lib/milestoner/configuration/transformers/gems/name.rb
milestoner-18.1.0 lib/milestoner/configuration/transformers/gems/name.rb
milestoner-18.0.1 lib/milestoner/configuration/transformers/gems/name.rb
milestoner-18.0.0 lib/milestoner/configuration/transformers/gems/name.rb