class Pups::Docker
Public Class Methods
generate_env_arguments(config)
click to toggle source
# File lib/pups/docker.rb, line 6 def generate_env_arguments(config) output = [] config&.each do |k, v| if !v.to_s.empty? output << "--env #{k}=#{escape_user_string_literal(v)}" end end normalize_output(output) end
generate_expose_arguments(config)
click to toggle source
# File lib/pups/docker.rb, line 24 def generate_expose_arguments(config) output = [] config&.each do |c| if c.to_s.include?(":") output << "--publish #{c}" else output << "--expose #{c}" end end normalize_output(output) end
generate_label_arguments(config)
click to toggle source
# File lib/pups/docker.rb, line 44 def generate_label_arguments(config) output = [] config&.each do |k, v| output << "--label #{k}=#{escape_user_string_literal(v)}" end normalize_output(output) end
generate_link_arguments(config)
click to toggle source
# File lib/pups/docker.rb, line 16 def generate_link_arguments(config) output = [] config&.each do |c| output << "--link #{c['link']['name']}:#{c['link']['alias']}" end normalize_output(output) end
generate_volume_arguments(config)
click to toggle source
# File lib/pups/docker.rb, line 36 def generate_volume_arguments(config) output = [] config&.each do |c| output << "--volume #{c['volume']['host']}:#{c['volume']['guest']}" end normalize_output(output) end
Private Class Methods
escape_user_string_literal(str)
click to toggle source
# File lib/pups/docker.rb, line 53 def escape_user_string_literal(str) # We need to escape the following strings as they are more likely to contain # special characters than any of the other config variables on a Linux system: # - the value side of an environment variable # - the value side of a label. Shellwords.escape(str) end
normalize_output(output)
click to toggle source
# File lib/pups/docker.rb, line 61 def normalize_output(output) if output.empty? "" else output.join(" ") end end