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_data_dir_if_missing, #create_metric_dir_if_missing, #create_output_dir_if_missing, generate_report, #generate_report, #initialize, #metric_directory, metric_directory, #remove_excluded_files, #round_to_tenths, #to_graph, verify_dependencies!
Instance Method Details
#analyze ⇒ Object
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
54
55
56
57
58
59
60
|
# File 'lib/generators/saikuro.rb', line 29
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
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/generators/saikuro.rb', line 5
def emit
relative_path = [File.dirname(__FILE__), '..', '..',
'vendor', 'saikuro', 'saikuro.rb']
saikuro = File.expand_path(File.join(relative_path))
MetricFu.saikuro[:input_directory] = format_directories
options_string = MetricFu.saikuro.inject("") do |options, option|
options + "--#{option.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
|
24
25
26
27
|
# File 'lib/generators/saikuro.rb', line 24
def format_directories
dirs = MetricFu.saikuro[:input_directory].join(" | ")
"\"#{dirs}\""
end
|
#saikuro_results ⇒ Object
75
76
77
|
# File 'lib/generators/saikuro.rb', line 75
def saikuro_results
Dir.glob("#{metric_directory}/**/*.html")
end
|
#to_h ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/generators/saikuro.rb', line 62
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
|