Class: DockerProcess
- Inherits:
-
Object
- Object
- DockerProcess
- 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
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
- .image_name ⇒ Object
- .properties ⇒ Object
- .set_image_name(name) ⇒ Object
- .set_properties(*new_properties) ⇒ Object
Instance Method Summary collapse
-
#initialize(config) ⇒ DockerProcess
constructor
A new instance of DockerProcess.
- #is_running? ⇒ Boolean
- #recent_logs ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config) ⇒ DockerProcess
Returns a new instance of DockerProcess.
36 37 38 39 40 |
# File 'lib/docker_process.rb', line 36 def initialize config raise 'image not set' if self.class.image_name.nil? raise 'properties not set' if self.class.properties.empty? @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
34 35 36 |
# File 'lib/docker_process.rb', line 34 def config @config end |
Class Method Details
.image_name ⇒ Object
13 14 15 |
# File 'lib/docker_process.rb', line 13 def self.image_name @image_name end |
.properties ⇒ Object
21 22 23 |
# File 'lib/docker_process.rb', line 21 def self.properties @properties end |
.set_image_name(name) ⇒ Object
17 18 19 |
# File 'lib/docker_process.rb', line 17 def self.set_image_name name @image_name = name end |
.set_properties(*new_properties) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/docker_process.rb', line 25 def self.set_properties *new_properties puts "setting properties: #{new_properties}" @properties ||= [] raise 'can not reset properties' if !@properties.empty? new_properties.map(&:to_sym).each do |property| @properties << property end end |
Instance Method Details
#is_running? ⇒ Boolean
50 51 52 53 54 55 56 57 |
# File 'lib/docker_process.rb', line 50 def is_running? container = find_container if container container_is_running? container else false end end |
#recent_logs ⇒ Object
59 60 61 |
# File 'lib/docker_process.rb', line 59 def recent_logs container_logs end |
#start ⇒ Object
42 43 44 |
# File 'lib/docker_process.rb', line 42 def start start_container end |
#stop ⇒ Object
46 47 48 |
# File 'lib/docker_process.rb', line 46 def stop kill_and_delete_container end |