Class: EY::Serverside::DeployHook
- Defined in:
- lib/engineyard-serverside/deploy_hook.rb
Defined Under Namespace
Classes: CallbackContext
Instance Attribute Summary
Attributes inherited from Task
Instance Method Summary collapse
- #callback_context ⇒ Object
-
#initialize(options) ⇒ DeployHook
constructor
A new instance of DeployHook.
- #run(hook) ⇒ Object
- #syntax_error(file) ⇒ Object
Methods inherited from Task
#require_custom_tasks, #roles, #sudo
Constructor Details
#initialize(options) ⇒ DeployHook
Returns a new instance of DeployHook.
4 5 6 |
# File 'lib/engineyard-serverside/deploy_hook.rb', line 4 def initialize() super(EY::Serverside::Deploy::Configuration.new()) end |
Instance Method Details
#callback_context ⇒ Object
8 9 10 |
# File 'lib/engineyard-serverside/deploy_hook.rb', line 8 def callback_context @context ||= CallbackContext.new(config) end |
#run(hook) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/engineyard-serverside/deploy_hook.rb', line 12 def run(hook) hook_path = "#{c.release_path}/deploy/#{hook}.rb" if File.exist?(hook_path) Dir.chdir(c.release_path) do puts "~> running deploy hook: deploy/#{hook}.rb" if desc = syntax_error(hook_path) hook_name = File.basename(hook_path) abort "*** [Error] Invalid Ruby syntax in hook: #{hook_name} ***\n*** #{desc.chomp} ***" else callback_context.instance_eval(IO.read(hook_path)) end end end end |
#syntax_error(file) ⇒ Object
27 28 29 30 |
# File 'lib/engineyard-serverside/deploy_hook.rb', line 27 def syntax_error(file) output = `ruby -c #{file} 2>&1` output unless output =~ /Syntax OK/ end |