Class: MetricFu::RailsBestPractices

Inherits:
Generator
  • Object
show all
Defined in:
lib/generators/rails_best_practices.rb

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

Constructor Details

This class inherits a constructor from MetricFu::Generator

Instance Method Details

#analyzeObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/rails_best_practices.rb', line 8

def analyze
  @matches = @output.chomp.split("\n").map{|m| m.split(" - ") }
  total = @matches.pop
  2.times { @matches.pop } # ignore wiki link
  @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

#emitObject



4
5
6
# File 'lib/generators/rails_best_practices.rb', line 4

def emit
  @output = `rails_best_practices .`
end

#to_hObject



21
22
23
# File 'lib/generators/rails_best_practices.rb', line 21

def to_h
  {:rails_best_practices => @rails_best_practices_results}
end