Class: MetricFu::Flay
Instance Attribute Summary
Attributes inherited from Generator
#report, #template
Class Method Summary
collapse
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
Class Method Details
.verify_dependencies! ⇒ Object
5
6
7
8
|
# File 'lib/generators/flay.rb', line 5
def self.verify_dependencies!
`flay --help`
raise 'sudo gem install flay # if you want the flay tasks' unless $?.success?
end
|
Instance Method Details
#analyze ⇒ Object
16
17
18
|
# File 'lib/generators/flay.rb', line 16
def analyze
@matches = @output.chomp.split("\n\n").map{|m| m.split("\n ") }
end
|
#emit ⇒ Object
10
11
12
13
14
|
# File 'lib/generators/flay.rb', line 10
def emit
files_to_flay = MetricFu.flay[:dirs_to_flay].map{|dir| Dir[File.join(dir, "**/*.rb")] }
files = remove_excluded_files(files_to_flay.flatten)
@output = `flay #{files.join(" ")}`
end
|
#to_h ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/generators/flay.rb', line 20
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
|