Class: DevDock::DevBind
- Inherits:
-
Object
- Object
- DevDock::DevBind
- Defined in:
- lib/dev_dock/binds.rb
Overview
binds are a type of mount which just map what is on the host into the container
Instance Attribute Summary collapse
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #create ⇒ Object
- #exist? ⇒ Boolean
- #host_path ⇒ Object
-
#initialize(internal_volumes, source, target, permissions) ⇒ DevBind
constructor
A new instance of DevBind.
- #parent_volume ⇒ Object
- #to_argument ⇒ Object
Constructor Details
#initialize(internal_volumes, source, target, permissions) ⇒ DevBind
Returns a new instance of DevBind.
11 12 13 14 15 16 |
# File 'lib/dev_dock/binds.rb', line 11 def initialize(internal_volumes, source, target, ) @internal_volumes = internal_volumes @source = source @target = target @permissions = end |
Instance Attribute Details
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
9 10 11 |
# File 'lib/dev_dock/binds.rb', line 9 def @permissions end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
9 10 11 |
# File 'lib/dev_dock/binds.rb', line 9 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
9 10 11 |
# File 'lib/dev_dock/binds.rb', line 9 def target @target end |
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dev_dock/binds.rb', line 22 def create if not exist? if not File.directory?(@source) FileUtils.mkdir_p(File.dirname(@source)) FileUtils.touch(@source) else FileUtils.mkdir_p(@source) end end end |
#exist? ⇒ Boolean
18 19 20 |
# File 'lib/dev_dock/binds.rb', line 18 def exist? File.exist?(@source) end |
#host_path ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dev_dock/binds.rb', line 33 def host_path if @internal_volumes internal, host = parent_volume # just need to take out the part of the path which is internal, and # replace it with the host volume. relative = @source.slice(internal.length, @source.length) if relative.length == 0 host else File.join(host, relative) end else @source end end |
#parent_volume ⇒ Object
49 50 51 |
# File 'lib/dev_dock/binds.rb', line 49 def parent_volume @internal_volumes.find { |internal, host| @source.index(internal) == 0 } end |
#to_argument ⇒ Object
53 54 55 |
# File 'lib/dev_dock/binds.rb', line 53 def to_argument [host_path, @target, @permissions].compact.join(':') end |