Sha256: 8af8851968e3a5bce41b64bac98ccd796b42ca134cfdf2b95e88659d4a6e5380

Contents?: true

Size: 758 Bytes

Versions: 3

Compression:

Stored size: 758 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_value(key) { git.get("user.name", nil).value_or(nil) }
                      .then { |value| Success attributes.merge!(key => value) }
          end

          private

          attr_reader :key
        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/project/author.rb
milestoner-17.10.0 lib/milestoner/configuration/transformers/project/author.rb
milestoner-17.9.0 lib/milestoner/configuration/transformers/project/author.rb