Class: Deck::Container
- Inherits:
-
Object
- Object
- Deck::Container
- Defined in:
- lib/deck/container.rb
Defined Under Namespace
Classes: Add, Archive, Cmd, Env, Expose, From, Name, Publish, Repository, Start, Tag, Variable, WorkDir
Instance Attribute Summary collapse
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
- #build_command ⇒ Object
- #image_name ⇒ Object
-
#initialize ⇒ Container
constructor
A new instance of Container.
- #method_missing(name, *args, &block) ⇒ Object
- #run_command ⇒ Object
Constructor Details
#initialize ⇒ Container
Returns a new instance of Container.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/deck/container.rb', line 18 def initialize @information = {} @meta = {} @call_order = [] self.class.constants.each do |sub| sub = self.class.const_get(sub).new if sub.class. @meta[sub.class.register_name] = sub else @information[sub.class.register_name] = sub end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
50 51 52 53 54 |
# File 'lib/deck/container.rb', line 50 def method_missing(name, *args, &block) return handle_information(name, *args, &block) if @information.include? name.to_sym return (name, *args, &block) if @meta.include? name.to_sym raise NoMethodError, "do not define such method : #{name.inspect}" end |
Instance Attribute Details
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
16 17 18 |
# File 'lib/deck/container.rb', line 16 def @meta end |
Instance Method Details
#build_command ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/deck/container.rb', line 32 def build_command dockerfile = '' @call_order.each do |info| command = @information[info].build_command(@information) dockerfile += "#{command}\n" unless command.nil? @information[info].next if @information[info].class.include? Deck::Repeatable end dockerfile end |
#image_name ⇒ Object
42 43 44 |
# File 'lib/deck/container.rb', line 42 def image_name "#{repository.to_s}/#{name.to_s}:#{tag.to_s}" end |
#run_command ⇒ Object
46 47 48 |
# File 'lib/deck/container.rb', line 46 def run_command "docker run #{image_name}" end |