class Churn::ChurnOptions

responsible for storing the churn configuration

Constants

DEFAULT_CHURN_DIRECTORY
DEFAULT_MINIMUM_CHURN_COUNT
DEFAULT_REPORT_HOST
DEFAULT_START_TIME

Attributes

data_directory[RW]
history[RW]
ignores[RW]
minimum_churn_count[RW]
name[RW]
report_host[RW]
start_date[RW]

Public Class Methods

new() click to toggle source
# File lib/churn/options.rb, line 14
def initialize()
  @data_directory      = DEFAULT_CHURN_DIRECTORY
  @minimum_churn_count = DEFAULT_MINIMUM_CHURN_COUNT
  @ignores             = '/dev/null'
  @start_date          = DEFAULT_START_TIME
  @history             = nil
  @report_host         = nil
  @name                = nil
end

Public Instance Methods

set_options(options = {}) click to toggle source
# File lib/churn/options.rb, line 24
def set_options(options = {})
  @data_directory      = options.fetch(:data_directory){ @data_directory } unless options[:data_directory]==''
  @minimum_churn_count = options.fetch(:minimum_churn_count){ @minimum_churn_count }.to_i
  @ignores             = (options.fetch(:ignores){ @ignores }).to_s.split(',').map(&:strip)
  @ignores << '/dev/null' unless @ignores.include?('/dev/null')
  @start_date          = options[:start_date] if !options[:start_date].nil? && options[:start_date]!=''
  @history             = options[:history] if !options[:history].nil? && options[:history]!=''
  if @history=='true'
    @history = DEFAULT_START_TIME
  end
  if !options[:report].nil? && options[:report]!='' 
    @report_host         = options[:report]
    if @report_host=='true'
      @report_host = DEFAULT_REPORT_HOST
    end
  end

  @name = options[:name] if !options[:name].nil? && options[:name]!=''
  if !@report_host.nil? && @name.nil?
    raise ArgumentError.new "If you are reporting churn results you must pass a valid github project name in the form of username/project_name"
  end

  self
end