Class: Churn::ChurnOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/churn/options.rb

Overview

responsible for storing the churn configuration

Constant Summary collapse

DEFAULT_CHURN_DIRECTORY =
"tmp/churn"
DEFAULT_MINIMUM_CHURN_COUNT =
5
DEFAULT_START_TIME =
'3 months ago'
DEFAULT_REPORT_HOST =
'http://churn.picoappz.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChurnOptions

Returns a new instance of ChurnOptions.



14
15
16
17
18
19
20
21
22
# 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

Instance Attribute Details

#data_directoryObject

Returns the value of attribute data_directory.



12
13
14
# File 'lib/churn/options.rb', line 12

def data_directory
  @data_directory
end

#historyObject

Returns the value of attribute history.



12
13
14
# File 'lib/churn/options.rb', line 12

def history
  @history
end

#ignoresObject

Returns the value of attribute ignores.



12
13
14
# File 'lib/churn/options.rb', line 12

def ignores
  @ignores
end

#minimum_churn_countObject

Returns the value of attribute minimum_churn_count.



12
13
14
# File 'lib/churn/options.rb', line 12

def minimum_churn_count
  @minimum_churn_count
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/churn/options.rb', line 12

def name
  @name
end

#report_hostObject

Returns the value of attribute report_host.



12
13
14
# File 'lib/churn/options.rb', line 12

def report_host
  @report_host
end

#start_dateObject

Returns the value of attribute start_date.



12
13
14
# File 'lib/churn/options.rb', line 12

def start_date
  @start_date
end

Instance Method Details

#set_options(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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