Sha256: 81daca1e0509fe879b393fa833a7dad46683ea5e6e4389e5069c68d8a7575b0b

Contents?: true

Size: 815 Bytes

Versions: 9

Compression:

Stored size: 815 Bytes

Contents

module MetricFu
  class ChurnGenerator < Generator
    def self.metric
      :churn
    end

    ###
    # options available are what can be passed to churn_calculator
    # https://github.com/danmayer/churn#library-options
    ###
    def emit
      @output = run(options)
    end

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

    # ensure hash only has the :churn key
    def to_h
      { churn: @churn[:churn] }
    end

    # @param args [Hash] churn metric run options
    # @return [Hash] churn results
    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
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
metric_fu-4.13.0 lib/metric_fu/metrics/churn/generator.rb
fastruby-metric_fu-5.0.0 lib/metric_fu/metrics/churn/generator.rb
code_metric_fu-4.14.4 lib/metric_fu/metrics/churn/generator.rb
code_metric_fu-4.14.3 lib/metric_fu/metrics/churn/generator.rb
code_metric_fu-4.14.2 lib/metric_fu/metrics/churn/generator.rb
code_metric_fu-4.14.1 lib/metric_fu/metrics/churn/generator.rb
code_metric_fu-4.14.0 lib/metric_fu/metrics/churn/generator.rb
metric_fu-4.12.0 lib/metric_fu/metrics/churn/generator.rb
metric_fu-4.11.4 lib/metric_fu/metrics/churn/generator.rb