Class: RakeDocker::Container::Destroyer

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/rake_docker/container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#enhance_with_name, #find_container

Constructor Details

#initialize(name, opts = {}) ⇒ Destroyer

Returns a new instance of Destroyer.



259
260
261
262
# File 'lib/rake_docker/container.rb', line 259

def initialize(name, opts = {})
  @name = name
  @reporter = opts[:reporter] || NullReporter.new
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



257
258
259
# File 'lib/rake_docker/container.rb', line 257

def name
  @name
end

#reporterObject (readonly)

Returns the value of attribute reporter.



257
258
259
# File 'lib/rake_docker/container.rb', line 257

def reporter
  @reporter
end

Instance Method Details

#executeObject



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/rake_docker/container.rb', line 264

def execute
  reporter.checking_if_container_exists(name)
  container = find_container(name)
  if container
    reporter.container_exists(container)
    reporter.stopping_container(container)
    container.stop
    container.wait
    reporter.container_stopped(container)
    reporter.deleting_container(container)
    container.delete
    reporter.container_deleted(container)
  else
    reporter.container_does_not_exist(name)
  end
  reporter.done
end