Class: Git::Lint::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/git/lint/collector.rb

Overview

Collects and categorizes, by severity, all issues (if any).

Instance Method Summary collapse

Constructor Details

#initializeCollector

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

#clearObject



18
# File 'lib/git/lint/collector.rb', line 18

def clear = collection.clear && self

#empty?Boolean

Returns:

  • (Boolean)


20
# File 'lib/git/lint/collector.rb', line 20

def empty? = collection.empty?

#errors?Boolean

Returns:

  • (Boolean)


24
# File 'lib/git/lint/collector.rb', line 24

def errors? = collection.values.flatten.any?(&:error?)

#issues?Boolean

Returns:

  • (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_hObject



36
# File 'lib/git/lint/collector.rb', line 36

def to_h = collection

#total_commitsObject



34
# File 'lib/git/lint/collector.rb', line 34

def total_commits = collection.keys.size

#total_errorsObject



30
# File 'lib/git/lint/collector.rb', line 30

def total_errors = collection.values.flatten.count(&:error?)

#total_issuesObject



32
# File 'lib/git/lint/collector.rb', line 32

def total_issues = collection.values.flatten.count(&:invalid?)

#total_warningsObject



28
# File 'lib/git/lint/collector.rb', line 28

def total_warnings = collection.values.flatten.count(&:warning?)

#warnings?Boolean

Returns:

  • (Boolean)


22
# File 'lib/git/lint/collector.rb', line 22

def warnings? = collection.values.flatten.any?(&:warning?)