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



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

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
# File 'lib/generators/saikuro.rb', line 5

def emit
  MetricFu.saikuro[:input_directory] = format_directories
 
  options_string = MetricFu.saikuro.inject("") do |options, option|
    options + "--#{option.join(' ')} "
  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



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

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

#to_hObject



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

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