module Rum::Docker::Executable

Mixin to enable runtime Docker command manipulation.

Attributes

options[R]

The OPTIONS portion of a Docker command.

Public Class Methods

new(options:nil, &block) click to toggle source

Initialize Docker executable with OPTIONS and evaluate the &block if given.

# File lib/rumrunner/docker.rb, line 56
def initialize(options:nil, &block)
  @options = options || Options.new
  instance_eval(&block) if block_given?
end

Public Instance Methods

clear_options() click to toggle source

Clear all @options

# File lib/rumrunner/docker.rb, line 77
def clear_options
  @options = Options.new
  self
end
each() { |downcase| ... } click to toggle source

Yield Docker command word by word.

# File lib/rumrunner/docker.rb, line 63
def each
  self.class.name.split(/::/)[1..-1].each{|x| yield x.downcase }
  @options.each{|x| yield x }
end
method_missing(m, *args, &block) click to toggle source

Interpret missing methods as OPTION.

# File lib/rumrunner/docker.rb, line 70
def method_missing(m, *args, &block)
  @options.send(m, *args, &block)
  args.empty? ? @options[m] : self
end
to_s() click to toggle source

Convert Docker command to string.

# File lib/rumrunner/docker.rb, line 84
def to_s
  to_a.join(" ")
end
with_defaults(options = {}) click to toggle source

Assign default values to Docker command if not explicitly set.

Example:

Run.new(&block).with_defaults(user: "fizz")

Unless the &block contains a directive to set a value for user, it will be set to “fizz”.

# File lib/rumrunner/docker.rb, line 96
def with_defaults(options = {})
  options.reject{|k,v| @options.include? k }.each{|k,v| @options[k] << v }
  self
end