class Pingity::Config
Constants
- DEFAULT_OPTIONS
- ENV_VARIABLE_PREFIX
Public Class Methods
new(options = nil)
click to toggle source
# File lib/pingity/config.rb, line 13 def initialize(options = nil) @options = DEFAULT_OPTIONS.dup if (options) @options.merge!(options) end ENV.each do |variable, value| next unless (variable.match(ENV_VARIABLE_PREFIX)) key_name = variable.sub(ENV_VARIABLE_PREFIX, '').downcase next if (key_name.empty?) @options[key_name.to_sym] = value end config_path = File.expand_path(@options[:config_path]) if (config_path and !config_path.empty? and File.exist?(config_path)) config = YAML.load(File.read(config_path)) @options.merge!(Hash[ config.collect do |k, v| [ k.to_sym, v ] end ]) end end
Public Instance Methods
transport()
click to toggle source
# File lib/pingity/config.rb, line 47 def transport :net_http end
valid?()
click to toggle source
# File lib/pingity/config.rb, line 43 def valid? !!(@api_key and !@api_key.empty?) end