Class: EY::Serverside::DeployHook::CallbackContext
- Inherits:
-
Object
- Object
- EY::Serverside::DeployHook::CallbackContext
show all
- Includes:
- Shell::Helpers
- Defined in:
- lib/engineyard-serverside/deploy_hook.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#debug, #info, #logged_system, #verbose?, #warning
Constructor Details
#initialize(config, shell, hook_path) ⇒ CallbackContext
Returns a new instance of CallbackContext.
70
71
72
73
74
75
76
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 70
def initialize(config, shell, hook_path)
@configuration = config
@configuration.set_framework_envs
@shell = shell
@node = config.node
@hook_path = hook_path
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
86
87
88
89
90
91
92
93
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 86
def method_missing(meth, *args, &blk)
if @configuration.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}"
@configuration.send(meth, *args, &blk)
else
super
end
end
|
Instance Attribute Details
#hook_path ⇒ Object
Returns the value of attribute hook_path.
68
69
70
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 68
def hook_path
@hook_path
end
|
#shell ⇒ Object
Returns the value of attribute shell.
68
69
70
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 68
def shell
@shell
end
|
Instance Method Details
#config ⇒ Object
78
79
80
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 78
def config
@configuration
end
|
#inspect ⇒ Object
82
83
84
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 82
def inspect
"#<DeployHook::CallbackContext #{hook_path.inspect}>"
end
|
#on_app_master(&blk) ⇒ Object
convenience functions for running on certain instance types
116
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 116
def on_app_master(&blk) on_roles(%w[solo app_master], &blk) end
|
#on_app_servers(&blk) ⇒ Object
117
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 117
def on_app_servers(&blk) on_roles(%w[solo app_master app], &blk) end
|
#on_app_servers_and_utilities(&blk) ⇒ Object
118
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 118
def on_app_servers_and_utilities(&blk) on_roles(%w[solo app_master app util], &blk) end
|
#on_utilities(*names, &blk) ⇒ Object
120
121
122
123
124
125
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 120
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) ⇒ Boolean
95
96
97
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 95
def respond_to?(*a)
@configuration.respond_to?(*a) || super
end
|
#run(cmd) ⇒ Object
99
100
101
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 99
def run(cmd)
shell.logged_system(Escape.shell_command(["sh", "-l", "-c", cmd])).success?
end
|
#run!(cmd) ⇒ Object
103
104
105
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 103
def run!(cmd)
run(cmd) or raise("run!: Command failed. #{cmd}")
end
|
#sudo(cmd) ⇒ Object
107
108
109
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 107
def sudo(cmd)
shell.logged_system(Escape.shell_command(["sudo", "sh", "-l", "-c", cmd])).success?
end
|
#sudo!(cmd) ⇒ Object
111
112
113
|
# File 'lib/engineyard-serverside/deploy_hook.rb', line 111
def sudo!(cmd)
sudo(cmd) or raise("sudo!: Command failed. #{cmd}")
end
|