Module: Focuslight::Config

Defined in:
lib/focuslight/config.rb

Constant Summary collapse

DEFAULT_DATADIR =
File.expand_path('data', "#{__dir__}/../..")
DEFAULT_LOG_PATH =
File.expand_path('log/application.log', "#{__dir__}/../..")

Class Method Summary collapse

Class Method Details

.get(name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/focuslight/config.rb', line 7

def self.get(name)
  case name
  when :datadir
    ENV.fetch('DATADIR', DEFAULT_DATADIR)
  when :float_support
    ENV.fetch('FLOAT_SUPPORT', false)
  when :dburl
    ENV.fetch('DBURL', 'sqlite://data/gforecast.db')
  when :dbtimeout
    ENV.fetch('DBURL', '60000').to_i
  when :log_path
    ENV.fetch('LOG_PATH', DEFAULT_LOG_PATH)
  when :log_level
    ENV.fetch('LOG_LEVEL', 'info')
  when :log_shift_age
    ENV.fetch('LOG_SHIFT_AGE', '0')
  when :log_shift_size
    ENV.fetch('LOG_SHIFT_SIZE', '1048576')
  else
    raise ArgumentError, 'unknown configuration keyword'
  end
end