class RSpectre::Tracker

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/rspectre/tracker.rb, line 7
def initialize
  super(Hash.new { Set.new }, Hash.new { Set.new })
end

Public Instance Methods

correct_offenses() click to toggle source
# File lib/rspectre/tracker.rb, line 28
def correct_offenses
  registry.flat_map { |type, locations| (locations - tracker[type]).to_a }
    .group_by(&:file)
    .transform_values { |nodes| nodes.map(&:node) }
    .each do |file, nodes|
      AutoCorrector.new(file, nodes).correct
    end
end
offenses?() click to toggle source
# File lib/rspectre/tracker.rb, line 24
def offenses?
  offenses.any?
end
record(type, node) click to toggle source
# File lib/rspectre/tracker.rb, line 15
def record(type, node)
  tracker[type] <<= node
end
register(type, node) click to toggle source
# File lib/rspectre/tracker.rb, line 11
def register(type, node)
  registry[type] <<= node
end
report_offenses() click to toggle source
# File lib/rspectre/tracker.rb, line 19
def report_offenses
  offenses.each(&:warn)
  abort
end

Private Instance Methods

offenses() click to toggle source
# File lib/rspectre/tracker.rb, line 39
def offenses
  registry.flat_map do |type, locations|
    missing = locations - tracker[type]

    missing.map { |node| Offense.parse(type, node) }
  end
end