class RubyYacht::Runner::Implode

This class provides a command for destroying the local docker environment.

Public Class Methods

command() click to toggle source

The name of the command.

# File lib/ruby_yacht/runner/implode.rb, line 5
def self.command; 'implode'; end
description() click to toggle source

The description of the command.

# File lib/ruby_yacht/runner/implode.rb, line 8
def self.description
  "Destroy your local environment"
end

Public Instance Methods

run() click to toggle source

This method runs the logic of the command.

# File lib/ruby_yacht/runner/implode.rb, line 13
def run
  projects.each do |project|
    system_prefix = project.system_prefix
  
    machines = backtick("docker ps -a | grep #{system_prefix}").split("\n").map { |line| line.split(/\s+/)[0] }
    machines.each do |machine|
      docker "rm -f #{machine}"
    end
  
    images = backtick("docker images | grep #{system_prefix}").split("\n").map { |line| line.split(/\s+/)[0] }
    images.each do |image|
      docker "rmi #{image}"
    end
  end

  backtick("docker images -q --filter dangling=true").split("\n").each do |image|
    docker "rmi #{image}"
  end
end