Class: MetricFu::Saikuro
Defined Under Namespace
Classes: ParsingElement, SFile
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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/generators/saikuro.rb', line 21
def analyze
@files = []
saikuro_results.each do |path|
if Saikuro::SFile.is_valid_text_file?(path)
file = Saikuro::SFile.new(path)
if file
@files << file
end
end
end
@files = @files.sort_by do |file|
file.elements.
max {|a,b| a.complexity.to_i <=> b.complexity.to_i}.
complexity.to_i
end
@files.reverse!
klasses = []
@files.each {|f| klasses << f.elements}
klasses.flatten!
@classes = klasses.sort_by {|k| k.complexity.to_i}
@classes.reverse!
meths = []
@files.each {|f|
f.elements.each {|el|
el.defs.each {|defn|
defn.name = "#{el.name}##{defn.name}"
meths << defn}
}
}
meths = meths.sort_by {|meth| meth.complexity.to_i}
@meths = meths.reverse
end
|
#emit ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/generators/saikuro.rb', line 6
def emit
relative_path = [File.dirname(__FILE__), '..', '..',
'vendor', 'saikuro', 'saikuro.rb']
saikuro = File.expand_path(File.join(relative_path))
options_string = MetricFu.saikuro.inject("") do |o, h|
o + "--#{h.join(' ')} "
end
sh %{ruby "#{saikuro}" #{options_string}} do |ok, response|
unless ok
puts "Saikuro failed with exit status: #{response.exitstatus}"
exit 1
end
end
end
|
#saikuro_results ⇒ Object
68
69
70
|
# File 'lib/generators/saikuro.rb', line 68
def saikuro_results
Dir.glob("#{metric_directory}/**/*.html")
end
|
#to_h ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/generators/saikuro.rb', line 55
def to_h
files = @files.map do |file|
my_file = file.to_h
my_file[:filename] = file.filename
my_file
end
{:saikuro => {:files => files,
:classes => @classes.map {|c| c.to_h},
:methods => @meths.map {|m| m.to_h}
}
}
end
|