Class: Serverspec::Type::DockerBase

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/type/docker_base.rb

Direct Known Subclasses

DockerContainer, DockerImage

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#initialize, #inspect, #to_ary, #to_s

Constructor Details

This class inherits a constructor from Serverspec::Type::Base

Instance Method Details

#[](key) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/serverspec/type/docker_base.rb', line 9

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

#exist?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/serverspec/type/docker_base.rb', line 5

def exist?
  get_inspection.success?
end

#inspectionObject



18
19
20
# File 'lib/serverspec/type/docker_base.rb', line 18

def inspection
  @inspection ||= ::MultiJson.load(get_inspection.stdout)[0]
end