class Egg::Configuration
Reads and Processes the egg_config.rb file.
Attributes
dotenv[RW]
ssh_support[RW]
supervisor[RW]
Public Class Methods
load(file)
click to toggle source
Based on rubygems' specification load: github.com/rubygems/rubygems/blob/0749715e4bd9e7f0fb631a352ddc649574da91c1/lib/rubygems/specification.rb#L1146
# File lib/egg/configuration.rb, line 13 def self.load(file) code = File.read file config = eval code, binding, file # rubocop:disable Security/Eval return config if config.is_a? Egg::Configuration rescue SignalException, SystemExit raise rescue SyntaxError, StandardError => e warn "Invalid configuration in [#{file}]: #{e}" warn e.backtrace.join("\n") end
new(&configuration_block)
click to toggle source
# File lib/egg/configuration.rb, line 29 def initialize(&configuration_block) self.ssh_support = false self.dotenv = DotenvUtil.new(File.read(".env.template")) if File.exist?(".env.template") instance_eval(&configuration_block) self end
Public Instance Methods
after_startup(&block)
click to toggle source
# File lib/egg/configuration.rb, line 36 def after_startup(&block) @after_startup = block end
docker_exec(app, command) { |output_read| ... }
click to toggle source
You may pass a block to docker_exec
to read the output in a controlled manner.
# File lib/egg/configuration.rb, line 41 def docker_exec(app, command) print "docker-compose exec #{app} #{command}\n" Open3.popen2(%(docker-compose exec #{app} #{command})) do |_input, output, wait_thread| output_read = output.read print output_read + "\n" yield output_read if block_given? wait_thread.value.success? || raise(StandardError, "docker_exec exited with #{wait_thread.value.to_i}") end end
docker_pull_build()
click to toggle source
# File lib/egg/configuration.rb, line 67 def docker_pull_build system("docker-compose pull") system("docker-compose build") || raise($CHILD_STATUS) end
docker_run(app, command) { |output_read| ... }
click to toggle source
You may pass a block to docker_run
to read the output in a controlled manner.
# File lib/egg/configuration.rb, line 52 def docker_run(app, command) print "docker-compose run #{app} #{command}\n" Open3.popen2(%(docker-compose run #{app} #{command})) do |_input, output, wait_thread| output_read = output.read print output_read + "\n" yield output_read if block_given? wait_thread.value.success? || raise(StandardError, "docker_run exited with #{wait_thread.value.to_i}") end end
run_setup()
click to toggle source
# File lib/egg/configuration.rb, line 62 def run_setup docker_pull_build run_after_startup end
Private Instance Methods
run_after_startup()
click to toggle source
# File lib/egg/configuration.rb, line 74 def run_after_startup return unless @after_startup print "Running after-startup block\n" @after_startup.call end