Module: Rum
- Defined in:
- lib/rumrunner.rb,
lib/rumrunner/init.rb,
lib/rumrunner/docker.rb,
lib/rumrunner/version.rb,
lib/rumrunner/manifest.rb,
lib/rumrunner/application.rb,
lib/rumrunner/dsl_definition.rb
Defined Under Namespace
Modules: DSL, Docker Classes: Application, Error, Manifest
Constant Summary collapse
- VERSION =
"0.2.4"
Class Method Summary collapse
Class Method Details
.init(input = nil, stdin = $stdin, stdout = $stdout, stderr = $stderr) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rumrunner/init.rb', line 5 def init(input = nil, stdin = $stdin, stdout = $stdout, stderr = $stderr) # Get image name from stdin stderr.write "Docker image name [#{default = File.split(Dir.pwd).last}]: " input ||= stdin.gets.chomp image = Docker::Image.parse(input.empty? ? default : input) # Begin Rumfile stdout.write "#!/usr/bin/env ruby\n" stdout.write "rum :\"#{image.family}\" do\n" # Put stages if File.exists? "Dockerfile" stages = File.read("Dockerfile").scan(/^FROM .*? AS (.*?)$/).flatten stages.reverse.zip(stages.reverse[1..-1]).reverse.each do |stage, dep| if dep.nil? stdout.write " stage :\"#{stage}\"\n" else stdout.write " stage :\"#{stage}\" => :\"#{dep}\"\n" end end unless stages.empty? end # Fin stdout.write "end\n" end |