Class: VagrantPlugins::Vocker::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Vocker::Config
- Defined in:
- lib/vocker/config.rb
Instance Attribute Summary collapse
-
#containers ⇒ Object
readonly
Returns the value of attribute containers.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #merge(other) ⇒ Object
- #pull_images(*images) ⇒ Object
- #run(*args) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 |
# File 'lib/vocker/config.rb', line 9 def initialize @images = Set.new @containers = Hash.new @version = :latest end |
Instance Attribute Details
#containers ⇒ Object (readonly)
Returns the value of attribute containers.
6 7 8 |
# File 'lib/vocker/config.rb', line 6 def containers @containers end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
6 7 8 |
# File 'lib/vocker/config.rb', line 6 def images @images end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/vocker/config.rb', line 7 def version @version end |
Instance Method Details
#merge(other) ⇒ Object
37 38 39 40 41 |
# File 'lib/vocker/config.rb', line 37 def merge(other) super.tap do |result| result.pull_images *(other.images + self.images) end end |
#pull_images(*images) ⇒ Object
15 16 17 |
# File 'lib/vocker/config.rb', line 15 def pull_images(*images) @images += images.map(&:to_s) end |
#run(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vocker/config.rb', line 19 def run(*args) container_name = args.shift params = {} if args.empty? params[:image] = container_name elsif args.first.is_a?(String) params[:image] = args.shift params[:cmd] = container_name else params = args.shift params[:cmd] ||= container_name end # TODO: Validate provided parameters before assignment @containers[container_name.to_s] = params end |