class DevDock::DevVolume
Volume which is needed for the development environment
Public Class Methods
new(image_name, path)
click to toggle source
# File lib/dev_dock/volumes.rb, line 12 def initialize(image_name, path) @path = path @name = DevDock::Util::snake_case("dev_dock_#{image_name}#{path}") end
Public Instance Methods
create()
click to toggle source
creates the volume if it does not exist
# File lib/dev_dock/volumes.rb, line 33 def create Log::debug("Checking volume #{@name} for path #{@path}") if !exist? Log::info("Creating volume #{@name}") Docker::Volume.create(@name) end end
exist?()
click to toggle source
returns true if the volume exists
# File lib/dev_dock/volumes.rb, line 26 def exist? volumes = Docker::Util.parse_json(Docker.connection.get('/volumes'))["Volumes"] Log::debug("Volumes in docker: #{volumes}") not volumes.nil? and volumes.any? { |volume| volume['Name'] == @name } end
name()
click to toggle source
# File lib/dev_dock/volumes.rb, line 17 def name @name end
path()
click to toggle source
# File lib/dev_dock/volumes.rb, line 21 def path @path end
remove()
click to toggle source
removes the volume if it exists
# File lib/dev_dock/volumes.rb, line 42 def remove Log::debug("Checking volume #{@name} for path #{@path}") if exist? Log::info("Removing volume #{@name})") Docker::Volume.get(@name).remove end end