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