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 12 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 18 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 48 def preprocess_line_for_emacs if @current_line =~ /^ *(\S*.rb:[0-9]*) *(.*)/ Regexp.last_match[1] + ': ' + Regexp.last_match[2] + "\n" elsif @current_line =~ /^ *(.*) +(\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 24 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 38 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 30 def processed_output if emacs_format preprocess_line_for_emacs else @current_line end end