class Greener::Checker::Base
Base
checker class
Attributes
violations[R]
Public Class Methods
new(ast, path, config)
click to toggle source
# File lib/greener/checker/base.rb, line 7 def initialize(ast, path, config) @ast = ast @path = path @config = config @violations = [] end
Public Instance Methods
feature()
click to toggle source
For readability in checker subclasses
# File lib/greener/checker/base.rb, line 41 def feature @ast end
log_violation(line, col, msg = nil, raw_txt = nil)
click to toggle source
Adds violation data to the @violations array
# File lib/greener/checker/base.rb, line 25 def log_violation(line, col, msg = nil, raw_txt = nil) # Set defaults for last 2 params if not overridden raw_txt ||= raw_line(line) msg ||= message violation = {} violation[:file] = @path violation[:line] = line violation[:column] = col violation[:text_of_line] = raw_txt violation[:message] = msg @violations << violation end
message()
click to toggle source
Read the violation message text set in the checker subclass
# File lib/greener/checker/base.rb, line 20 def message self.class::MSG end
raw_line(num)
click to toggle source
Given a num, returns the full text corresponding to that line number in the file
# File lib/greener/checker/base.rb, line 46 def raw_line(num) open(@path).each_line.take(num).last end
run()
click to toggle source
Method invoked when a checker is applied to a file
# File lib/greener/checker/base.rb, line 16 def run end