Class: DevDock::DevVolume
- Inherits:
-
Object
- Object
- DevDock::DevVolume
- Defined in:
- lib/dev_dock/volumes.rb
Overview
Volume which is needed for the development environment
Instance Method Summary collapse
-
#create ⇒ Object
creates the volume if it does not exist.
-
#exist? ⇒ Boolean
returns true if the volume exists.
-
#initialize(image_name, path) ⇒ DevVolume
constructor
A new instance of DevVolume.
- #name ⇒ Object
- #path ⇒ Object
-
#remove ⇒ Object
removes the volume if it exists.
Constructor Details
#initialize(image_name, path) ⇒ DevVolume
Returns a new instance of DevVolume.
12 13 14 15 |
# 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 |
Instance Method Details
#create ⇒ Object
creates the volume if it does not exist
33 34 35 36 37 38 39 |
# 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? ⇒ Boolean
returns true if the volume exists
26 27 28 29 30 |
# 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 ⇒ Object
17 18 19 |
# File 'lib/dev_dock/volumes.rb', line 17 def name @name end |
#path ⇒ Object
21 22 23 |
# File 'lib/dev_dock/volumes.rb', line 21 def path @path end |