Sha256: 45e95c41aef7506c1a49a5777a028499892e001564806ca7823755ee0eddd327

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

require "gitt"

module Milestoner
  module Commits
    module Enrichers
      # Enriches a commit colleague by using cache.
      class Colleague
        include Milestoner::Import[:cache]

        def initialize(key:, parser: Gitt::Parsers::Person.new, **)
          super(**)
          @key = key
          @parser = parser
        end

        def call(commit) = commit.find_trailers(key).bind { |trailers| users_for(trailers).compact }

        private

        attr_reader :key, :parser

        def users_for(trailers) = trailers.map { |trailer| user_for parser.call(trailer.value) }

        def user_for person
          cache.read(:users) { find person.name }
               .value_or(nil)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
milestoner-18.12.0 lib/milestoner/commits/enrichers/colleague.rb