Class: MetricFu::Flay
Instance Attribute Summary
Attributes inherited from Generator
#report, #template
Instance Method Summary
collapse
Methods inherited from Generator
class_name, #create_metric_dir_if_missing, #create_output_dir_if_missing, generate_report, #generate_report, #initialize, metric_directory, #metric_directory, #round_to_tenths
Instance Method Details
#analyze ⇒ Object
11
12
13
|
# File 'lib/generators/flay.rb', line 11
def analyze
@matches = @output.chomp.split("\n\n").map{|m| m.split("\n ") }
end
|
#emit ⇒ Object
6
7
8
9
|
# File 'lib/generators/flay.rb', line 6
def emit
files_to_flay = MetricFu.flay[:dirs_to_flay].map{|dir| Dir[File.join(dir, "**/*.rb")] }
@output = `flay #{files_to_flay.join(" ")}`
end
|
#to_h ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/generators/flay.rb', line 15
def to_h
target = []
total_score = @matches.shift.first.split('=').last.strip
@matches.each do |problem|
reason = problem.shift.strip
lines_info = problem.map do |full_line|
name, line = full_line.split(":")
{:name => name.strip, :line => line.strip}
end
target << [:reason => reason, :matches => lines_info]
end
{:flay => {:total_score => total_score, :matches => target.flatten}}
end
|