Class: Settings
- Inherits:
-
Settingslogic
- Object
- Settingslogic
- Settings
- Defined in:
- lib/rest-ftp-daemon/settings.rb
Overview
Configuration class
Instance Method Summary collapse
-
#at(*path) ⇒ Object
Direct access to any depth.
-
#dump ⇒ Object
Dump whole settings set to readable YAML.
- #init_defaults ⇒ Object
- #newrelic_enabled? ⇒ Boolean
- #overwrite(options) ⇒ Object
Instance Method Details
#at(*path) ⇒ Object
Direct access to any depth
11 12 13 |
# File 'lib/rest-ftp-daemon/settings.rb', line 11 def at *path path.reduce(Settings) { |m, key| m && m[key.to_s] } end |
#dump ⇒ Object
Dump whole settings set to readable YAML
16 17 18 |
# File 'lib/rest-ftp-daemon/settings.rb', line 16 def dump to_hash.to_yaml(indent: 4, useheader: true, useversion: false ) end |
#init_defaults ⇒ 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 48 49 50 51 52 |
# File 'lib/rest-ftp-daemon/settings.rb', line 24 def init_defaults # Init host if missing Settings["host"] ||= `hostname`.to_s.chomp.split(".").first # Init PID file name if missing Settings["pidfile"] ||= "/tmp/#{APP_NICK}-#{Settings['host']}-#{Settings['port']}.pid" # Init NEWRELIC env if Settings.newrelic_enabled? # Enable module ENV["NEWRELIC_AGENT_ENABLED"] = "true" ENV["NEW_RELIC_MONITOR_MODE"] = "true" # License ENV["NEW_RELIC_LICENSE_KEY"] = Settings.at(:newrelic, :licence) # Appname platform = Settings.newrelic[:platform] || Settings["host"] Settings.newrelic[:app_name] ||= "#{APP_NICK}-#{platform}-#{Settings.namespace}" ENV["NEW_RELIC_APP_NAME"] = Settings.newrelic[:app_name] # Logfile ENV["NEW_RELIC_LOG"] = Settings.at(:logs, :newrelic) else ENV["NEWRELIC_AGENT_ENABLED"] = "false" end # That's it! end |
#newrelic_enabled? ⇒ Boolean
20 21 22 |
# File 'lib/rest-ftp-daemon/settings.rb', line 20 def newrelic_enabled? Settings.at(:newrelic) end |
#overwrite(options) ⇒ Object
54 55 56 |
# File 'lib/rest-ftp-daemon/settings.rb', line 54 def overwrite Settings.merge!() if .is_a? Enumerable end |