class Quality::CommandOutputProcessor
Class processes output from a code quality command, tweaking it for editor output and counting the number of violations found
Attributes
emacs_format[RW]
file[RW]
found_output[R]
violations[R]
Public Class Methods
new()
click to toggle source
# File lib/quality/command_output_processor.rb, line 10 def initialize @emacs_format = false @found_output = false @violations = 0 end
Public Instance Methods
process(&count_violations_on_line)
click to toggle source
# File lib/quality/command_output_processor.rb, line 16 def process(&count_violations_on_line) process_file(file, &count_violations_on_line) end
Private Instance Methods
preprocess_line_for_emacs()
click to toggle source
# File lib/quality/command_output_processor.rb, line 46 def preprocess_line_for_emacs case @current_line when /^ *(\S*.rb:[0-9]*) *(.*)/ "#{Regexp.last_match[1]}: #{Regexp.last_match[2]}\n" when /^ *(.*) +(\S*.rb:[0-9]*) *(.*)/ "#{Regexp.last_match[2]}: #{Regexp.last_match[1]}\n" else @current_line end end
process_file(file, &count_violations_on_line)
click to toggle source
# File lib/quality/command_output_processor.rb, line 22 def process_file(file, &count_violations_on_line) out = '' out += process_line(&count_violations_on_line) while (@current_line = file.gets) out end
process_line() { |current_line| ... }
click to toggle source
# File lib/quality/command_output_processor.rb, line 36 def process_line(&block) @found_output = true @violations += if block yield @current_line else 1 end processed_output end
processed_output()
click to toggle source
# File lib/quality/command_output_processor.rb, line 28 def processed_output if emacs_format preprocess_line_for_emacs else @current_line end end