+
+ # expose
+ read -r -d '' ports_ruby << 'RUBY'
+ require 'yaml'
+
+ input=STDIN.readlines.join
+ ports = []
+ input.split('_FILE_SEPERATOR_').each do |yml|
+ yml.strip!
+ begin
+ ports += (YAML.load(yml)['expose'] || [])
+ rescue Psych::SyntaxError => e
+ puts e
+ puts "*ERROR."
+ rescue => e
+ puts yml
+ p e
+ end
+ end
+ puts ports.map { |p| p.to_s.include?(':') ? "-p\n#{p}" : "--expose\n#{p}" }.join("\n")
+RUBY
+
+ tmp_input_file=$(mktemp)
+
+ echo "$input" > "$tmp_input_file"
+ raw=`exec cat "$tmp_input_file" | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e "$ports_ruby"`
+
+ rm -f "$tmp_input_file"
+
+ ports=()
+ ok=1
+ while read i; do
+ if [ "$i" == "*ERROR." ]; then
+ ok=0
+ elif [ -n "$i" ]; then
+ ports[${#ports[@]}]=$i
+ fi
+ done <<< "$raw"
+
+ if [ "$ok" -ne 1 ]; then
+ echo "${ports[@]}"
+ echo "YAML syntax error. Please check your containers/*.yml config files."
+ exit 1
+ fi
+
+ merge_user_args