Class: ExistClient::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/exist_client/config.rb

Constant Summary collapse

DEFAULT_CUTOFF_HOUR =
5
DEFAULT_DATA_PATH =
"~/.exist"

Class Method Summary collapse

Class Method Details

.config_fileObject



29
30
31
# File 'lib/exist_client/config.rb', line 29

def config_file
  @config_file ||= data_path.join("config.yml")
end

.cutoff_hourObject



33
34
35
# File 'lib/exist_client/config.rb', line 33

def cutoff_hour
  config_values.fetch("cutoff_hour", DEFAULT_CUTOFF_HOUR)
end

.data_pathObject



25
26
27
# File 'lib/exist_client/config.rb', line 25

def data_path
  @data_path ||= Pathname.new(DEFAULT_DATA_PATH).expand_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_reportersObject



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_fileObject



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).expand_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