Class: Git::Lint::Collector
- Inherits:
-
Object
- Object
- Git::Lint::Collector
- Defined in:
- lib/git/lint/collector.rb
Overview
Collects and categorizes, by severity, all issues (if any).
Instance Method Summary collapse
- #add(analyzer) ⇒ Object
- #clear ⇒ 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.
7 8 9 |
# File 'lib/git/lint/collector.rb', line 7 def initialize @collection = Hash.new { |default, missing_id| default[missing_id] = [] } end |
Instance Method Details
#add(analyzer) ⇒ Object
11 12 13 14 |
# File 'lib/git/lint/collector.rb', line 11 def add analyzer collection[analyzer.commit] << analyzer analyzer end |
#clear ⇒ Object
18 |
# File 'lib/git/lint/collector.rb', line 18 def clear = collection.clear && self |
#empty? ⇒ Boolean
20 |
# File 'lib/git/lint/collector.rb', line 20 def empty? = collection.empty? |
#errors? ⇒ Boolean
24 |
# File 'lib/git/lint/collector.rb', line 24 def errors? = collection.values.flatten.any?(&:error?) |
#issues? ⇒ Boolean
26 |
# File 'lib/git/lint/collector.rb', line 26 def issues? = collection.values.flatten.any?(&:invalid?) |
#retrieve(id) ⇒ Object
16 |
# File 'lib/git/lint/collector.rb', line 16 def retrieve(id) = collection[id] |
#to_h ⇒ Object
36 |
# File 'lib/git/lint/collector.rb', line 36 def to_h = collection |
#total_commits ⇒ Object
34 |
# File 'lib/git/lint/collector.rb', line 34 def total_commits = collection.keys.size |
#total_errors ⇒ Object
30 |
# File 'lib/git/lint/collector.rb', line 30 def total_errors = collection.values.flatten.count(&:error?) |
#total_issues ⇒ Object
32 |
# File 'lib/git/lint/collector.rb', line 32 def total_issues = collection.values.flatten.count(&:invalid?) |
#total_warnings ⇒ Object
28 |
# File 'lib/git/lint/collector.rb', line 28 def total_warnings = collection.values.flatten.count(&:warning?) |
#warnings? ⇒ Boolean
22 |
# File 'lib/git/lint/collector.rb', line 22 def warnings? = collection.values.flatten.any?(&:warning?) |