Sha256: 634010b1e1e19a51d58cca5548547d4a4e61e9505d5f31bdc4f383d3a1dadfc0
Contents?: true
Size: 1.68 KB
Versions: 4
Compression:
Stored size: 1.68 KB
Contents
# module Hdcore @log = Logger.new(STDOUT) # Default configuration values @config = { api_endpoint: 'https://core.hostdime.com/api/v1', public_key: nil, private_key: nil } @valid_config_keys = @config.keys class << self # Configure HDCore with an options hash. # @param [Hash] opts Configuration options hash # @option opts [String] :api_endpoint ('core.hostdime.com/api/v1') The HDCore API endpoint URI # @option opts [String] :public_key Your HDCore public key # @option opts [String] :private_key Your HDCore private key def configure opts = {} opts.each do |key, val| config[key.to_sym] = val if @valid_config_keys.include? key.to_sym end end # Configure HDCore with an external yaml config file. # @param [String] path_to_yaml_file Absolute path to yaml config file def configure_with path_to_yaml_file begin config = YAML::load(IO.read(path_to_yaml_file)) rescue Errno::ENOENT log.warn "YAML config file not found: using defaults instead"; return rescue Psych::SyntaxError log.warn "YAML config file has invalid syntax: using defaults instead"; return end configure(config) end # Current configuration hash def config @config end # For logging purposes def log @log end # @return [Bool] True if there are configuration keys that have no assigned value. def missing_config_values? config.values.include? nil end # @return [Array] Configuration keys that have no assigned value. def missing_config_values config.select{|k,v| v.nil?}.keys end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hdcore-0.0.5 | lib/hdcore/hdcore.rb |
hdcore-0.0.4 | lib/hdcore/hdcore.rb |
hdcore-0.0.3 | lib/hdcore/hdcore.rb |
hdcore-0.0.2 | lib/hdcore/hdcore.rb |