Class: Cwb::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cwb/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nodeObject

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

Returns:

  • (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.

Returns:

  • (Boolean)


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_idObject



43
44
45
# File 'lib/cwb/config.rb', line 43

def provider_instance_id
  deep_fetch("benchmark", "provider_instance_id")
end

#provider_nameObject



39
40
41
# File 'lib/cwb/config.rb', line 39

def provider_name
  deep_fetch("benchmark", "provider_name")
end

#serverObject



35
36
37
# File 'lib/cwb/config.rb', line 35

def server
  deep_fetch("cwb", "server")
end