Class: MetricFu::Saikuro

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

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!

Constructor Details

This class inherits a constructor from MetricFu::Generator

Instance Method Details

#analyzeObject



26
27
28
29
30
# File 'lib/generators/saikuro.rb', line 26

def analyze
  @files = sort_files(assemble_files)
  @classes = sort_classes(assemble_classes(@files))
  @meths = sort_methods(assemble_methods(@files))
end

#emitObject



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

def emit 
  options_string = MetricFu.saikuro.inject("") do |options, option| 
    options + "--#{option.join(' ')} " unless option == :input_directory 
  end 
  
  MetricFu.saikuro[:input_directory].each do |input_dir| 
    options_string += "--input_directory #{input_dir} " 
  end 
  sh %{saikuro #{options_string}} do |ok, response| 
    unless ok 
      puts "Saikuro failed with exit status: #{response.exitstatus}" 
      exit 1 
    end 
  end 
end

#format_directoriesObject



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

def format_directories
  dirs = MetricFu.saikuro[:input_directory].join(" | ")
  "\"#{dirs}\""
end

#to_hObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/generators/saikuro.rb', line 32

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