Class: MetricFu::Churn

Inherits:
Generator show all
Defined in:
lib/generators/churn.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, metric_directory, #metric_directory, #remove_excluded_files, #round_to_tenths, #to_graph

Constructor Details

#initialize(options = {}) ⇒ Churn

Returns a new instance of Churn.


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

def initialize(options={})
  super
end

Class Method Details

.verify_dependencies!Object


9
10
11
12
# File 'lib/generators/churn.rb', line 9

def self.verify_dependencies!
  result = `churn --help`
  raise 'sudo gem install churn # if you want the churn tasks' unless result.match(/churn/)
end

Instance Method Details

#analyzeObject


21
22
23
24
25
26
27
# File 'lib/generators/churn.rb', line 21

def analyze
  if @output.match(/fatal: Not a git repository/)
    @churn = [:churn => {}]
  else
    @churn = YAML::load(@output)
  end
end

#emitObject


15
16
17
18
19
# File 'lib/generators/churn.rb', line 15

def emit
  @output = `churn --yaml`
  yaml_start = @output.index("---")
  @output = @output[yaml_start...@output.length] if yaml_start
end

#to_hObject


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

def to_h
  {:churn => @churn[:churn]}
end