Class: MetricFu::Roodi

Inherits:
Generator show all
Defined in:
lib/generators/roodi.rb

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

Constructor Details

This class inherits a constructor from MetricFu::Generator

Class Method Details

.verify_dependencies!Object



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

def self.verify_dependencies!
  `roodi --help`
  raise 'sudo gem install roodi # if you want the roodi tasks' unless $?.success?
end

Instance Method Details

#analyzeObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/roodi.rb', line 17

def analyze
  @matches = @output.chomp.split("\n").map{|m| m.split(" - ") }
  total = @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
  @roodi_results = {:total => total, :problems => @matches}
end

#emitObject



10
11
12
13
14
15
# File 'lib/generators/roodi.rb', line 10

def emit
  files_to_analyze = MetricFu.roodi[:dirs_to_roodi].map{|dir| Dir[File.join(dir, "**/*.rb")] }
  files = remove_excluded_files(files_to_analyze.flatten)
  config = MetricFu.roodi[:roodi_config] ? "-config=#{MetricFu.roodi[:roodi_config]}" : ""
  @output = `roodi #{config} #{files.join(" ")}`
end

#to_hObject



29
30
31
# File 'lib/generators/roodi.rb', line 29

def to_h
  {:roodi => @roodi_results}
end