Sha256: 45af1272cb8e3ded70c3bac9f7ab09184896173402ba15c84ef684c6a492f349

Contents?: true

Size: 888 Bytes

Versions: 5

Compression:

Stored size: 888 Bytes

Contents

module Upstart::Exporter::Options
  class Global < Hash
    include Upstart::Exporter::Errors

    DEFAULTS = {
      'helper_dir' => '/var/local/upstart_helpers/',
      'upstart_dir' => '/etc/init/',
      'run_user' => 'service',
      'prefix' => 'fb-'
    }

    CONF = '/etc/upstart-exporter.yaml'

    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

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
upstart-exporter-0.1.4 lib/upstart-exporter/options/global.rb
upstart-exporter-0.1.3 lib/upstart-exporter/options/global.rb
upstart-exporter-0.1.2 lib/upstart-exporter/options/global.rb
upstart-exporter-0.1.1 lib/upstart-exporter/options/global.rb
upstart-exporter-0.1.0 lib/upstart-exporter/options/global.rb