Sha256: e862b2642cd7120851f7ae153053b8a072fd67242702342cf231816077c5c892

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

#! /usr/bin/env ruby
require 'main'
require 'yaml'

#example usage. In the root of a project 'churn', or 'churn --help'
Main do
  option('minimum_churn_count', 'c') do
    argument :required
    cast :int
    default 3
  end

  option('yaml', 'y') do
    cast :boolean
    default false
  end

  option('ignore_files', 'i') do
    cast :string
    argument :optional
    default ''
  end

  option('start_date', 's') do
    cast :string
    argument :optional
    default ''
  end

  option('data_directory', 'd') do
    cast :string
    argument :optional
    default ''
  end

  def report_churn(output_string)
    require File.join(File.dirname(__FILE__), '..', 'lib', 'churn', 'churn_calculator')
    result = Churn::ChurnCalculator.new({:minimum_churn_count => params['minimum_churn_count'].value, :ignore_files => params['ignore_files'].value, :start_date => params['start_date'].value, :data_directory => params['data_directory'].value}).report(output_string)
    unless output_string
      result = YAML::dump(result)
    end
    result
  end

  def run
    report = report_churn(!params['yaml'].value)
    puts report
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
churn-0.0.33 bin/churn
churn-0.0.32 bin/churn
churn-0.0.31 bin/churn
churn-0.0.30 bin/churn