Sha256: 7fa5c665297bc3caf92e9480a2a92fb66e1f1861dea61d80f4f2598f20074bc3

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"

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

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

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

            Success attributes
          end

          private

          attr_reader :key
        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/project/author.rb