class Dockmeister::ScriptRunner
Constants
- DOCKMEISTER_COMPOSE_FILE
Public Class Methods
new(base_path, services)
click to toggle source
# File lib/dockmeister/script_runner.rb, line 7 def initialize(base_path, services) @base_path = File.expand_path(base_path) @services = services end
Public Instance Methods
post_build!()
click to toggle source
# File lib/dockmeister/script_runner.rb, line 29 def post_build! run_with_prefix("post") end
pre_build!()
click to toggle source
# File lib/dockmeister/script_runner.rb, line 25 def pre_build! run_with_prefix("pre") end
run_script(script, working_directory = ".")
click to toggle source
# File lib/dockmeister/script_runner.rb, line 12 def run_script(script, working_directory = ".") puts "Running #{script}" success = Kernel.system(script_env_vars, script, chdir: working_directory) unless success STDERR.puts <<-eos A dockmeister init script failed. eos exit(1) end end
script_env_vars()
click to toggle source
# File lib/dockmeister/script_runner.rb, line 33 def script_env_vars { "DOCKMEISTER_COMPOSE_FILE" => dockmeister_compose_file_path } end
Private Instance Methods
dockmeister_compose_file_path()
click to toggle source
# File lib/dockmeister/script_runner.rb, line 52 def dockmeister_compose_file_path File.join(@base_path, DOCKMEISTER_COMPOSE_FILE) end
run_with_prefix(prefix)
click to toggle source
# File lib/dockmeister/script_runner.rb, line 41 def run_with_prefix(prefix) pattern = "#{prefix}*" @services.each do |service_name| service_directory = File.join(@base_path, service_name) Dir.glob(File.join(service_directory, "scripts", pattern)).each do |script| run_script(File.expand_path(script), service_directory) end end end