Class: MetricFu::ChurnGenerator

Inherits:
Generator show all
Defined in:
lib/metric_fu/metrics/churn/generator.rb

Instance Attribute Summary

Attributes inherited from Generator

#options, #result, #template

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

#generate_result, generators, get_generator, #initialize, #metric, #metric_config, metric_directory, #metric_directory, not_implemented, #remove_excluded_files, #round_to_tenths, #run!

Constructor Details

This class inherits a constructor from MetricFu::Generator

Class Method Details

.metricObject



3
4
5
# File 'lib/metric_fu/metrics/churn/generator.rb', line 3

def self.metric
  :churn
end

Instance Method Details

#analyzeObject



15
16
17
18
19
20
21
22
# File 'lib/metric_fu/metrics/churn/generator.rb', line 15

def analyze
  if @output.nil? || @output.size.zero?
    @churn = { churn: {} }
  else
    @churn = @output
  end
  @churn
end

#emitObject

options available are what can be passed to churn_calculator github.com/danmayer/churn#library-options



11
12
13
# File 'lib/metric_fu/metrics/churn/generator.rb', line 11

def emit
  @output = run(options)
end

#run(args) ⇒ Hash

Returns churn results.

Parameters:

  • args (Hash)

    churn metric run options

Returns:

  • (Hash)

    churn results



31
32
33
34
35
# File 'lib/metric_fu/metrics/churn/generator.rb', line 31

def run(args)
  # @note passing in false to report will return a hash
  #    instead of the default String
  ::Churn::ChurnCalculator.new(args).report(false)
end

#to_hObject

ensure hash only has the :churn key



25
26
27
# File 'lib/metric_fu/metrics/churn/generator.rb', line 25

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