class Baha::ContainerOptions::ExposedPorts
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/baha/container_options/exposed_ports.rb, line 6 def initialize(*args) super(:exposedports,*args) end
Public Instance Methods
apply(config)
click to toggle source
# File lib/baha/container_options/exposed_ports.rb, line 9 def apply(config) unless config.has_key?('ExposedPorts') config['ExposedPorts'] = {} end @value.each do |port| case port when Fixnum config['ExposedPorts']["#{port}/tcp"] = {} when String if port.match(/^\d+$/) config['ExposedPorts']["#{port}/tcp"] = {} else config['ExposedPorts'][port] = {} end end end end
validate!()
click to toggle source
# File lib/baha/container_options/exposed_ports.rb, line 27 def validate! raise ERROR("should be an array") unless @value.kind_of?(Array) @value.each_with_index do |item,index| if item.kind_of?(String) unless /(\d+)(\/(tcp|udp))?/ =~ item raise ERROR("#{index}: '#{item}' should be in the form 8080/tcp") end end end end