Class: Longshoreman
- Inherits:
-
Object
- Object
- Longshoreman
- Defined in:
- lib/longshoreman.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#container ⇒ Object
Returns the value of attribute container.
-
#image ⇒ Object
Returns the value of attribute image.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#get_host_ip ⇒ Object
Figure out which IP address the Docker host is at.
-
#initialize(image = nil, name = nil, extra_args = {}) ⇒ Longshoreman
constructor
A new instance of Longshoreman.
Constructor Details
#initialize(image = nil, name = nil, extra_args = {}) ⇒ Longshoreman
Returns a new instance of Longshoreman.
5 6 7 8 9 10 11 12 |
# File 'lib/longshoreman.rb', line 5 def initialize(image = nil, name = nil, extra_args = {}) Docker. = { :write_timeout => 300, :read_timeout => 300 } Docker.validate_version! @ip = get_host_ip @container = Longshoreman::Container.new(image, name, extra_args) @image = Longshoreman::Image.new end |
Instance Attribute Details
#container ⇒ Object
Returns the value of attribute container.
38 39 40 |
# File 'lib/longshoreman.rb', line 38 def container @container end |
#image ⇒ Object
Returns the value of attribute image.
39 40 41 |
# File 'lib/longshoreman.rb', line 39 def image @image end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
37 38 39 |
# File 'lib/longshoreman.rb', line 37 def ip @ip end |
Instance Method Details
#cleanup ⇒ Object
32 33 34 35 |
# File 'lib/longshoreman.rb', line 32 def cleanup @container.cleanup @image.cleanup end |
#get_host_ip ⇒ Object
Figure out which IP address the Docker host is at
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/longshoreman.rb', line 15 def get_host_ip # Let the crazy one-liner definition begin: # Docker.url.split(':')[1][2..-1] # Docker.url = tcp://192.168.123.205:2375 # split(':') = ["tcp", "//192.168.123.205", "2375"] # [1] = "//192.168.123.205" # [2..-1] = "192.168.123.205" # This last bit prunes the leading // url = Docker.url case url.split(':')[0] when 'unix' "127.0.0.1" when 'tcp' url.split(':')[1][2..-1] end end |