Class: Serverspec::Type::ConsulBase
- Inherits:
-
ApiBase
- Object
- Base
- ApiBase
- Serverspec::Type::ConsulBase
show all
- Defined in:
- lib/serverspec_extra_types/types/consul_base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(name = nil, acl_token = nil, options = {}) ⇒ ConsulBase
Returns a new instance of ConsulBase.
11
12
13
14
15
|
# File 'lib/serverspec_extra_types/types/consul_base.rb', line 11
def initialize(name = nil, acl_token = nil, options = {})
super(name, options)
@token = acl_token
@url_base = property[:variables][:consul_url] || 'http://localhost:8500'
end
|
Instance Method Details
#[](key) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/serverspec_extra_types/types/consul_base.rb', line 17
def [](key)
value = inspection
key.split('.').each do |k|
is_index = k.start_with?('[') && k.end_with?(']')
value = value[is_index ? k[1..-2].to_i : k]
end
value
end
|
#inspection ⇒ Object
30
31
32
33
34
|
# File 'lib/serverspec_extra_types/types/consul_base.rb', line 30
def inspection
puts get_inspection.stdout
puts get_inspection.stderr
@inspection ||= ::MultiJson.load(get_inspection.stdout)[0]
end
|
#url ⇒ Object
26
27
28
|
# File 'lib/serverspec_extra_types/types/consul_base.rb', line 26
def url
@url_base
end
|