Sha256: 8c5e965318d3cc1c6ec3af463b809b9ad871df014fea8f13cb7b2c6d64d3c7d6

Contents?: true

Size: 777 Bytes

Versions: 5

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

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

module Milestoner
  module Configuration
    module Transformers
      module Project
        # Conditionally updates author based on Git user.
        class Author
          include Import[:git]
          include Dry::Monads[:result]

          using Refinements::Hash

          def initialize(key = :project_author, **)
            @key = key
            super(**)
          end

          def call attributes
            attributes.fetch key do
              git.get("user.name", nil).bind { |value| attributes.merge!(key => value).compress! }
            end

            Success attributes
          end

          private

          attr_reader :key
        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/project/author.rb
milestoner-18.2.0 lib/milestoner/configuration/transformers/project/author.rb
milestoner-18.1.0 lib/milestoner/configuration/transformers/project/author.rb
milestoner-18.0.1 lib/milestoner/configuration/transformers/project/author.rb
milestoner-18.0.0 lib/milestoner/configuration/transformers/project/author.rb