class Milestoner::Commits::Categorizer
Retrieves and categorizes Git repository commit tagged or untagged history.
Attributes
collector[R]
labels[R]
pattern[R]
Public Class Methods
new(collector: Collector.new, **)
click to toggle source
Calls superclass method
# File lib/milestoner/commits/categorizer.rb, line 14 def initialize(collector: Collector.new, **) @collector = collector super(**) @labels = settings.commit_categories.pluck :label @pattern = labels.empty? ? // : Regexp.union(labels) end
Public Instance Methods
call(min: Collector::MIN, max: Collector::MAX)
click to toggle source
# File lib/milestoner/commits/categorizer.rb, line 22 def call min: Collector::MIN, max: Collector::MAX collect(min, max).each_value { |commits| commits.sort_by!(&:subject) } .values .flatten end
Private Instance Methods
categories()
click to toggle source
# File lib/milestoner/commits/categorizer.rb, line 43 def categories labels.reduce({}) { |group, prefix| group.merge prefix => [] } .merge! "Unknown" => [] end
collect(min, max)
click to toggle source
# File lib/milestoner/commits/categorizer.rb, line 32 def collect min, max collector.call(min:, max:) .value_or(Core::EMPTY_ARRAY) .each .with_object categories do |commit, collection| category = commit.subject[pattern] key = collection.key?(category) ? category : "Unknown" collection[key] << commit end end