Class: Churn::ChurnOptions
- Inherits:
-
Object
- Object
- Churn::ChurnOptions
- 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
-
#data_directory ⇒ Object
Returns the value of attribute data_directory.
-
#history ⇒ Object
Returns the value of attribute history.
-
#ignores ⇒ Object
Returns the value of attribute ignores.
-
#minimum_churn_count ⇒ Object
Returns the value of attribute minimum_churn_count.
-
#name ⇒ Object
Returns the value of attribute name.
-
#report_host ⇒ Object
Returns the value of attribute report_host.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
Instance Method Summary collapse
-
#initialize ⇒ ChurnOptions
constructor
A new instance of ChurnOptions.
- #set_options(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ ChurnOptions
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_directory ⇒ Object
Returns the value of attribute data_directory.
12 13 14 |
# File 'lib/churn/options.rb', line 12 def data_directory @data_directory end |
#history ⇒ Object
Returns the value of attribute history.
12 13 14 |
# File 'lib/churn/options.rb', line 12 def history @history end |
#ignores ⇒ Object
Returns the value of attribute ignores.
12 13 14 |
# File 'lib/churn/options.rb', line 12 def ignores @ignores end |
#minimum_churn_count ⇒ Object
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 |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/churn/options.rb', line 12 def name @name end |
#report_host ⇒ Object
Returns the value of attribute report_host.
12 13 14 |
# File 'lib/churn/options.rb', line 12 def report_host @report_host end |
#start_date ⇒ Object
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 ( = {}) @data_directory = .fetch(:data_directory){ @data_directory } unless [:data_directory]=='' @minimum_churn_count = .fetch(:minimum_churn_count){ @minimum_churn_count }.to_i @ignores = (.fetch(:ignores){ @ignores }).to_s.split(',').map(&:strip) @ignores << '/dev/null' unless @ignores.include?('/dev/null') @start_date = [:start_date] if ![:start_date].nil? && [:start_date]!='' @history = [:history] if ![:history].nil? && [:history]!='' if @history=='true' @history = DEFAULT_START_TIME end if ![:report].nil? && [:report]!='' @report_host = [:report] if @report_host=='true' @report_host = DEFAULT_REPORT_HOST end end @name = [:name] if ![:name].nil? && [: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 |