Class: MetricFu::FlayGenerator
Instance Attribute Summary
Attributes inherited from Generator
#options, #result, #template
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Generator
#generate_result, generators, get_generator, #initialize, #metric, #metric_config, metric_directory, #metric_directory, not_implemented, #remove_excluded_files, #round_to_tenths, #run!, #silence_streams
Class Method Details
.metric ⇒ Object
3
4
5
|
# File 'lib/metric_fu/metrics/flay/generator.rb', line 3
def self.metric
:flay
end
|
Instance Method Details
#analyze ⇒ Object
12
13
14
|
# File 'lib/metric_fu/metrics/flay/generator.rb', line 12
def analyze
@matches = @output.chomp.split("\n\n").map { |m| m.split("\n ") }
end
|
#calculate_result(matches) ⇒ Object
TODO: move into analyze method
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/metric_fu/metrics/flay/generator.rb', line 21
def calculate_result(matches)
total_score = matches.shift.first.split("=").last.strip
target = []
matches.each do |problem|
reason = problem.shift.strip
lines_info = problem.map do |full_line|
name, line = full_line.split(":").map(&:strip)
{ name: name, line: line }
end
target << [reason: reason, matches: lines_info]
end
{
total_score: total_score,
total: "Total Score #{total_score}",
matches: target.flatten
}
end
|
#emit ⇒ Object
7
8
9
10
|
# File 'lib/metric_fu/metrics/flay/generator.rb', line 7
def emit
args = "#{minimum_duplication_mass} #{dirs_to_flay}"
@output = run!(args)
end
|
#to_h ⇒ Object
16
17
18
|
# File 'lib/metric_fu/metrics/flay/generator.rb', line 16
def to_h
{ flay: calculate_result(@matches) }
end
|