Class: Git::Lint::Collector

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

Instance Method Summary collapse

Constructor Details

#initializeCollector

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

Returns:

  • (Boolean)


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

def empty?
  collection.empty?
end

#errors?Boolean

Returns:

  • (Boolean)


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

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

#issues?Boolean

Returns:

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



55
56
57
# File 'lib/git/lint/collector.rb', line 55

def to_h
  collection
end

#total_commitsObject



51
52
53
# File 'lib/git/lint/collector.rb', line 51

def total_commits
  collection.keys.size
end

#total_errorsObject



43
44
45
# File 'lib/git/lint/collector.rb', line 43

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

#total_issuesObject



47
48
49
# File 'lib/git/lint/collector.rb', line 47

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

#total_warningsObject



39
40
41
# File 'lib/git/lint/collector.rb', line 39

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

#warnings?Boolean

Returns:

  • (Boolean)


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

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