Sha256: cf69367974dc93edd86a3980a2ca1d2c7a82adaea2da50d4c0b0309164e522d7

Contents?: true

Size: 772 Bytes

Versions: 7

Compression:

Stored size: 772 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, **)
          @key = key
          @parser = parser
          super(**)
        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.commit(:users) { find person.name }
               .value_or(nil)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
milestoner-17.6.0 lib/milestoner/commits/enrichers/colleague.rb
milestoner-17.5.0 lib/milestoner/commits/enrichers/colleague.rb
milestoner-17.4.0 lib/milestoner/commits/enrichers/colleague.rb
milestoner-17.3.0 lib/milestoner/commits/enrichers/colleague.rb
milestoner-17.2.0 lib/milestoner/commits/enrichers/colleague.rb
milestoner-17.1.0 lib/milestoner/commits/enrichers/colleague.rb
milestoner-17.0.0 lib/milestoner/commits/enrichers/colleague.rb