class EY::Serverside::Callbacks::Executor::Ruby::Context
Attributes
configuration[R]
hook[R]
shell[R]
Public Class Methods
new(config, shell, hook)
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 14 def initialize(config, shell, hook) @configuration = config @configuration.set_framework_envs @shell = shell @node = config.node @hook = hook end
Public Instance Methods
config()
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 22 def config @configuration end
inspect()
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 26 def inspect "#<Callbacks::Executor::Ruby::Context #{hook.path.inspect}>" end
method_missing(meth, *args, &blk)
click to toggle source
Calls superclass method
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 30 def method_missing(meth, *args, &blk) if config.respond_to?(meth) shell.warning "Use of `#{meth}` (via method_missing) is deprecated in favor of `config.#{meth}` for improved error messages and compatibility.\n\tin #{hook.path}" config.send(meth, *args, &blk) else super end end
on_app_master(&blk)
click to toggle source
convenience functions for running on certain instance types
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 60 def on_app_master(&blk) on_roles(%w[solo app_master], &blk) end
on_app_servers(&blk)
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 61 def on_app_servers(&blk) on_roles(%w[solo app_master app], &blk) end
on_app_servers_and_utilities(&blk)
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 62 def on_app_servers_and_utilities(&blk) on_roles(%w[solo app_master app util], &blk) end
on_utilities(*names, &blk)
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 64 def on_utilities(*names, &blk) names.flatten! on_roles(%w[util]) do blk.call if names.empty? || names.include?(config.current_name) end end
respond_to?(*a)
click to toggle source
Calls superclass method
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 39 def respond_to?(*a) config.respond_to?(*a) || super end
run(cmd)
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 43 def run(cmd) shell.logged_system(Escape.shell_command(["sh", "-l", "-c", cmd])).success? end
run!(cmd)
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 47 def run!(cmd) run(cmd) or raise("run!: Command failed. #{cmd}") end
sudo(cmd)
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 51 def sudo(cmd) shell.logged_system(Escape.shell_command(["sudo", "sh", "-l", "-c", cmd])).success? end
sudo!(cmd)
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 55 def sudo!(cmd) sudo(cmd) or raise("sudo!: Command failed. #{cmd}") end
Private Instance Methods
on_roles(desired_roles) { || ... }
click to toggle source
# File lib/engineyard-serverside/callbacks/executor/ruby/context.rb, line 72 def on_roles(desired_roles) yield if desired_roles.any? { |role| config.current_roles.include?(role) } end