Class: DockerProcess

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

Overview

GOAL: have object which is used to create and manage docker contains based around the idea that we treat them like procs

Constant Summary collapse

@@image_name =
nil
@@properties =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ DockerProcess

Returns a new instance of DockerProcess.



25
26
27
28
29
# File 'lib/docker_process.rb', line 25

def initialize config
  raise 'image not set' if @@image_name.nil?
  raise 'properties not set' if @@properties.empty?
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



23
24
25
# File 'lib/docker_process.rb', line 23

def config
  @config
end

Class Method Details

.set_image_name(name) ⇒ Object



12
13
14
# File 'lib/docker_process.rb', line 12

def self.set_image_name name
  @@image_name = name
end

.set_properties(*properties) ⇒ Object



16
17
18
19
20
21
# File 'lib/docker_process.rb', line 16

def self.set_properties *properties
  raise 'can not reset properties' if !@@properties.empty?
  @@properties.map(&:to_sym).each do |property|
    @@properties << property
  end
end

Instance Method Details

#is_running?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
# File 'lib/docker_process.rb', line 39

def is_running?
  container = find_container
  if container
    container_is_running? container
  else
    false
  end
end

#recent_logsObject



48
49
50
# File 'lib/docker_process.rb', line 48

def recent_logs
  container_logs
end

#startObject



31
32
33
# File 'lib/docker_process.rb', line 31

def start
  start_container
end

#stopObject



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

def stop
  kill_and_delete_container
end