class Cirun::Runner
Public Class Methods
new(opts)
click to toggle source
# File lib/cirun/runner.rb, line 5 def initialize(opts) @opts = opts end
Public Instance Methods
run()
click to toggle source
# File lib/cirun/runner.rb, line 15 def run update_image ruby_short = @opts.ruby.split('-').first cmd = "docker run -#{@opts.print ? 'i' : ''}t --env RUBY_VERSION=ruby-#{ruby_short} --env DB=#{@opts.database} --env REDMINE=redmine-#{@opts.redmine} --env PLUGIN=#{@opts.plugin} --env DEPENDENT=#{@opts.dependent} --mount type=bind,source=#{`pwd`.chomp},target=/var/www/ruby-#{ruby_short}/#{@opts.database}/redmine-#{@opts.redmine}/plugins/#{@opts.plugin} redmineup/#{@opts.plugin} /root/run_local.sh" @opts.print ? print(cmd) : execute(cmd) end
update_image()
click to toggle source
# File lib/cirun/runner.rb, line 9 def update_image puts "Pulling redmineup/#{@opts.plugin}, please wait" unless @opts.print cmd = "docker pull redmineup/#{@opts.plugin}" execute(cmd, @opts.print) end
Private Instance Methods
execute(cmd, silently = false)
click to toggle source
# File lib/cirun/runner.rb, line 24 def execute(cmd, silently = false) puts "Running:\n#{cmd}" unless silently Open3.popen3(cmd) do |stdin, stdout, stderr| while (line = stdout.gets) puts line unless silently end puts stderr.read unless silently end end
print(command)
click to toggle source
# File lib/cirun/runner.rb, line 34 def print(command) puts command end