Class: Cwb::Config
- Inherits:
-
Object
- Object
- Cwb::Config
- Defined in:
- lib/cwb/config.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
Returns the value of attribute node.
Class Method Summary collapse
Instance Method Summary collapse
-
#complete? ⇒ Boolean
Determines whether all strictly required attributes that are necessary for communication with the cwb-server are available.
- #deep_fetch(*keys) ⇒ Object
-
#initialize(node = {}) ⇒ Config
constructor
A new instance of Config.
- #provider_instance_id ⇒ Object
- #provider_name ⇒ Object
- #server ⇒ Object
Constructor Details
#initialize(node = {}) ⇒ Config
Returns a new instance of Config.
19 20 21 |
# File 'lib/cwb/config.rb', line 19 def initialize(node = {}) @node = node end |
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
5 6 7 |
# File 'lib/cwb/config.rb', line 5 def node @node end |
Class Method Details
.exists_in_dir?(dir) ⇒ Boolean
7 8 9 |
# File 'lib/cwb/config.rb', line 7 def self.exists_in_dir?(dir) File.exists?(self.config_file(dir)) end |
.from_dir(dir) ⇒ Object
11 12 13 |
# File 'lib/cwb/config.rb', line 11 def self.from_dir(dir) self.from_file(self.config_file(dir)) end |
.from_file(file) ⇒ Object
15 16 17 |
# File 'lib/cwb/config.rb', line 15 def self.from_file(file) self.new(YAML.load_file(file)) end |
Instance Method Details
#complete? ⇒ Boolean
Determines whether all strictly required attributes that are necessary for communication with the cwb-server are available.
30 31 32 33 |
# File 'lib/cwb/config.rb', line 30 def complete? args = [server, provider_name, provider_instance_id] args.map { |value| value.empty? }.none? end |
#deep_fetch(*keys) ⇒ Object
23 24 25 |
# File 'lib/cwb/config.rb', line 23 def deep_fetch(*keys) @node.deep_fetch(*keys, default: '') end |
#provider_instance_id ⇒ Object
43 44 45 |
# File 'lib/cwb/config.rb', line 43 def provider_instance_id deep_fetch("benchmark", "provider_instance_id") end |
#provider_name ⇒ Object
39 40 41 |
# File 'lib/cwb/config.rb', line 39 def provider_name deep_fetch("benchmark", "provider_name") end |
#server ⇒ Object
35 36 37 |
# File 'lib/cwb/config.rb', line 35 def server deep_fetch("cwb", "server") end |