Class: Upstart::Exporter::Options::Global
- Inherits:
-
Hash
- Object
- Hash
- Upstart::Exporter::Options::Global
- Includes:
- Errors
- Defined in:
- lib/upstart-exporter/options/global.rb
Constant Summary
- DEFAULTS =
{ 'helper_dir' => '/var/local/upstart_helpers/', 'upstart_dir' => '/etc/init/', 'run_user' => 'service', 'prefix' => 'fb-' }
- CONF =
'/etc/upstart-exporter.yaml'
Instance Method Summary (collapse)
-
- (Global) initialize
constructor
A new instance of Global.
Methods included from Errors
Constructor Details
- (Global) initialize
A new instance of Global
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/upstart-exporter/options/global.rb', line 14 def initialize super config = if FileTest.file?(CONF) YAML::load(File.read(CONF)) else $stderr.puts "#{CONF} not found" {} end error "#{CONF} is not a valid YAML config" unless config.is_a?(Hash) %w{helper_dir upstart_dir run_user prefix}.each do |param| value = if config[param] config[param] else $stderr.puts "Param #{param} is not set, taking default value #{DEFAULTS[param]}" DEFAULTS[param] end self[param.to_sym] = value end end |