Class: Git::Lint::Collector
- Inherits:
-
Object
- Object
- Git::Lint::Collector
- Defined in:
- lib/git/lint/collector.rb
Instance Method Summary collapse
- #add(analyzer) ⇒ Object
- #empty? ⇒ Boolean
- #errors? ⇒ Boolean
-
#initialize ⇒ Collector
constructor
A new instance of Collector.
- #issues? ⇒ Boolean
- #retrieve(id) ⇒ Object
- #to_h ⇒ Object
- #total_commits ⇒ Object
- #total_errors ⇒ Object
- #total_issues ⇒ Object
- #total_warnings ⇒ Object
- #warnings? ⇒ Boolean
Constructor Details
#initialize ⇒ Collector
Returns a new instance of Collector.
10 11 12 |
# File 'lib/git/lint/collector.rb', line 10 def initialize @collection = Hash.new { |default, missing_id| default[missing_id] = [] } end |
Instance Method Details
#add(analyzer) ⇒ Object
14 15 16 17 |
# File 'lib/git/lint/collector.rb', line 14 def add analyzer collection[analyzer.commit] << analyzer analyzer end |
#empty? ⇒ Boolean
23 24 25 |
# File 'lib/git/lint/collector.rb', line 23 def empty? collection.empty? end |
#errors? ⇒ Boolean
31 32 33 |
# File 'lib/git/lint/collector.rb', line 31 def errors? collection.values.flatten.any?(&:error?) end |
#issues? ⇒ Boolean
35 36 37 |
# File 'lib/git/lint/collector.rb', line 35 def issues? collection.values.flatten.any?(&:invalid?) end |
#retrieve(id) ⇒ Object
19 20 21 |
# File 'lib/git/lint/collector.rb', line 19 def retrieve id collection[id] end |
#to_h ⇒ Object
55 56 57 |
# File 'lib/git/lint/collector.rb', line 55 def to_h collection end |
#total_commits ⇒ Object
51 52 53 |
# File 'lib/git/lint/collector.rb', line 51 def total_commits collection.keys.size end |
#total_errors ⇒ Object
43 44 45 |
# File 'lib/git/lint/collector.rb', line 43 def total_errors collection.values.flatten.count(&:error?) end |
#total_issues ⇒ Object
47 48 49 |
# File 'lib/git/lint/collector.rb', line 47 def total_issues collection.values.flatten.count(&:invalid?) end |
#total_warnings ⇒ Object
39 40 41 |
# File 'lib/git/lint/collector.rb', line 39 def total_warnings collection.values.flatten.count(&:warning?) end |
#warnings? ⇒ Boolean
27 28 29 |
# File 'lib/git/lint/collector.rb', line 27 def warnings? collection.values.flatten.any?(&:warning?) end |