Module: Hdcore
- Defined in:
- lib/hdcore/hdcore.rb,
lib/hdcore/request.rb,
lib/hdcore/version.rb
Defined Under Namespace
Classes: Request
Constant Summary collapse
- VERSION =
"0.0.20"
Class Method Summary collapse
-
.config ⇒ Object
Current configuration hash.
-
.configure(opts = {}) ⇒ Object
Configure HDCore with an options hash.
-
.configure_with(path_to_yaml_file) ⇒ Object
Configure HDCore with an external yaml config file.
-
.log ⇒ Object
For logging purposes.
-
.missing_config_values ⇒ Array
Configuration keys that have no assigned value.
-
.missing_config_values? ⇒ Bool
True if there are configuration keys that have no assigned value.
Class Method Details
.config ⇒ Object
Current configuration hash
40 41 42 |
# File 'lib/hdcore/hdcore.rb', line 40 def config @config end |
.configure(opts = {}) ⇒ Object
Configure HDCore with an options hash.
19 20 21 22 23 |
# File 'lib/hdcore/hdcore.rb', line 19 def configure opts = {} opts.each do |key, val| config[key.to_sym] = val if @valid_config_keys.include? key.to_sym end end |
.configure_with(path_to_yaml_file) ⇒ Object
Configure HDCore with an external yaml config file.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/hdcore/hdcore.rb', line 27 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 |
.log ⇒ Object
For logging purposes
45 46 47 |
# File 'lib/hdcore/hdcore.rb', line 45 def log @log end |
.missing_config_values ⇒ Array
Returns Configuration keys that have no assigned value.
55 56 57 |
# File 'lib/hdcore/hdcore.rb', line 55 def missing_config_values config.select{|k,v| v.nil?}.keys end |
.missing_config_values? ⇒ Bool
Returns True if there are configuration keys that have no assigned value.
50 51 52 |
# File 'lib/hdcore/hdcore.rb', line 50 def missing_config_values? config.values.include? nil end |