Class: MetricFu::RailsBestPractices
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
4
5
6
7
|
# File 'lib/generators/rails_best_practices.rb', line 4
def self.verify_dependencies!
`rails_best_practices --help`
raise 'sudo gem install rails_best_practices # if you want the rails_best_practices tasks' unless $?.success?
end
|
Instance Method Details
#analyze ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/generators/rails_best_practices.rb', line 14
def analyze
@matches = @output.chomp.split("\n").map{|m| m.split(" - ") }
total = @matches.pop
2.times { @matches.pop } @matches.reject! {|array| array.empty? }
@matches.map! do |match|
file, line = match[0].split(':')
problem = match[1]
{:file => file, :line => line, :problem => problem}
end
@rails_best_practices_results = {:total => total, :problems => @matches}
end
|
#emit ⇒ Object
10
11
12
|
# File 'lib/generators/rails_best_practices.rb', line 10
def emit
@output = `rails_best_practices .`
end
|
#to_h ⇒ Object
27
28
29
|
# File 'lib/generators/rails_best_practices.rb', line 27
def to_h
{:rails_best_practices => @rails_best_practices_results}
end
|