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'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ ChurnOptions

Returns a new instance of ChurnOptions.



13
14
15
16
17
18
19
20
21
22
# File 'lib/churn/options.rb', line 13

def initialize()
  @data_directory      = DEFAULT_CHURN_DIRECTORY
  @minimum_churn_count = DEFAULT_MINIMUM_CHURN_COUNT
  @ignores             = '/dev/null'
  @start_date          = DEFAULT_START_TIME
  @history             = nil
  @name                = nil
  @file_extension      = nil
  @file_prefix         = nil
end

Instance Attribute Details

#data_directory ⇒ Object

Returns the value of attribute data_directory.



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

def data_directory
  @data_directory
end

#file_extension ⇒ Object

Returns the value of attribute file_extension.



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

def file_extension
  @file_extension
end

#file_prefix ⇒ Object

Returns the value of attribute file_prefix.



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

def file_prefix
  @file_prefix
end

#history ⇒ Object

Returns the value of attribute history.



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

def history
  @history
end

#ignores ⇒ Object

Returns the value of attribute ignores.



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

def ignores
  @ignores
end

#minimum_churn_count ⇒ Object

Returns the value of attribute minimum_churn_count.



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

def minimum_churn_count
  @minimum_churn_count
end

#name ⇒ Object

Returns the value of attribute name.



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

def name
  @name
end

#start_date ⇒ Object

Returns the value of attribute start_date.



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

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
# File 'lib/churn/options.rb', line 24

def set_options(options = {})
  @data_directory      = options.fetch(:data_directory){ @data_directory } unless options[:data_directory]==''
  @file_extension      = options.fetch(:file_extension){ @file_extension } unless options[:file_extension]==''
  @file_prefix      = options.fetch(:file_prefix){ @file_prefix } unless options[:file_prefix]==''
  @minimum_churn_count = options.fetch(:minimum_churn_count){ @minimum_churn_count }.to_i
  @ignores             = (options.fetch(:ignore_files){ options[: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

  self
end