Class: ExistClient::Config
- Inherits:
-
Object
- Object
- ExistClient::Config
- Defined in:
- lib/exist_client/config.rb
Constant Summary collapse
- DEFAULT_CUTOFF_HOUR =
5
- DEFAULT_DATA_PATH =
"~/.exist"
Class Method Summary collapse
- .config_file ⇒ Object
- .cutoff_hour ⇒ Object
- .data_path ⇒ Object
- .data_path_for(reporter) ⇒ Object
- .enabled_reporters ⇒ Object
- .last_report_date_file ⇒ Object
- .plugin_for(reporter) ⇒ Object
- .set_data_path(relative_data_path) ⇒ Object
- .setup(relative_data_path = DEFAULT_DATA_PATH) ⇒ Object
Class Method Details
.config_file ⇒ Object
29 30 31 |
# File 'lib/exist_client/config.rb', line 29 def config_file @config_file ||= data_path.join("config.yml") end |
.cutoff_hour ⇒ Object
33 34 35 |
# File 'lib/exist_client/config.rb', line 33 def cutoff_hour config_values.fetch("cutoff_hour", DEFAULT_CUTOFF_HOUR) end |
.data_path ⇒ Object
25 26 27 |
# File 'lib/exist_client/config.rb', line 25 def data_path @data_path ||= Pathname.new(DEFAULT_DATA_PATH). end |
.data_path_for(reporter) ⇒ Object
37 38 39 |
# File 'lib/exist_client/config.rb', line 37 def data_path_for(reporter) data_path.join(reporter.metric_name) end |
.enabled_reporters ⇒ Object
49 50 51 |
# File 'lib/exist_client/config.rb', line 49 def enabled_reporters @enabled_reporters ||= plugins.keys.map { |reporter| constantize(reporter) } end |
.last_report_date_file ⇒ Object
45 46 47 |
# File 'lib/exist_client/config.rb', line 45 def last_report_date_file data_path.join("last_report_date") end |
.plugin_for(reporter) ⇒ Object
41 42 43 |
# File 'lib/exist_client/config.rb', line 41 def plugin_for(reporter) @plugins.fetch(reporter.metric_name) end |
.set_data_path(relative_data_path) ⇒ Object
21 22 23 |
# File 'lib/exist_client/config.rb', line 21 def set_data_path(relative_data_path) @data_path = Pathname.new(relative_data_path). end |
.setup(relative_data_path = DEFAULT_DATA_PATH) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/exist_client/config.rb', line 9 def setup(relative_data_path = DEFAULT_DATA_PATH) set_data_path(relative_data_path) puts " Creating directory at #{data_path}" data_path.mkpath puts " Creating config file at #{config_file}" config_file.write("") last_report_date_file.write("2000-01-01") end |