Class: Milestoner::Commits::Categorizer

Inherits:
Object
  • Object
show all
Defined in:
lib/milestoner/commits/categorizer.rb

Overview

Retrieves and categorizes Git repository commit tagged or untagged history.

Instance Method Summary collapse

Constructor Details

#initialize(collector: Collector.new) ⇒ Categorizer

Returns a new instance of Categorizer.



14
15
16
17
18
19
20
# 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

Instance Method Details

#call(min: Collector::MIN, max: Collector::MAX) ⇒ Object



22
23
24
25
26
# 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