Sha256: 30d31740a80ab46b3812e6e809173a2942f9be17f1fb8ae5c0a0cd5c14df5d78

Contents?: true

Size: 788 Bytes

Versions: 3

Compression:

Stored size: 788 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", **)
            @key = key
            @path = path
            super(**)
          end

          def call attributes
            attributes.fetch(key) { spec_loader.call(path).name }
                      .then { |value| Success attributes.merge!(key => value) }
          end

          private

          attr_reader :key, :path
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
milestoner-17.11.0 lib/milestoner/configuration/transformers/gems/name.rb
milestoner-17.10.0 lib/milestoner/configuration/transformers/gems/name.rb
milestoner-17.9.0 lib/milestoner/configuration/transformers/gems/name.rb