class Deck::Container
Attributes
meta[R]
Public Class Methods
new()
click to toggle source
# 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? @meta[sub.class.register_name] = sub else @information[sub.class.register_name] = sub end end end
Public Instance Methods
build_command()
click to toggle source
# 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()
click to toggle source
# File lib/deck/container.rb, line 42 def image_name "#{repository.to_s}/#{name.to_s}:#{tag.to_s}" end
method_missing(name, *args, &block)
click to toggle source
# 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 handle_meta(name, *args, &block) if @meta.include? name.to_sym raise NoMethodError, "do not define such method : #{name.inspect}" end
run_command()
click to toggle source
# File lib/deck/container.rb, line 46 def run_command "docker run #{image_name}" end
Private Instance Methods
handle_information(name, *args, &block)
click to toggle source
# File lib/deck/container.rb, line 57 def handle_information(name, *args, &block) if args.nil? || args.empty? @information[name.to_sym].send :get else info = @information[name.to_sym] value = info.send :set, *args @call_order << name.to_sym unless @call_order.include? name.to_sym and not info.class.repeatable? value end end
handle_meta(name, *args, &block)
click to toggle source
# File lib/deck/container.rb, line 68 def handle_meta(name, *args, &block) if args.nil? || args.empty? @meta[name.to_sym].send :get else @meta[name.to_sym].send :set, *args end end