Module: Deployinator::Helpers::PluginHelpers
- Included in:
- Deploy, Deployinator::Helpers
- Defined in:
- lib/deployinator/helpers/plugin.rb
Instance Attribute Summary collapse
-
#plugins ⇒ Object
Returns the value of attribute plugins.
Instance Method Summary collapse
- #notify_plugins(event, state) ⇒ Object
- #raise_event(event, extra_state = {}) ⇒ Object
- #register_plugins(stack) ⇒ Object
Instance Attribute Details
#plugins ⇒ Object
Returns the value of attribute plugins.
4 5 6 |
# File 'lib/deployinator/helpers/plugin.rb', line 4 def plugins @plugins end |
Instance Method Details
#notify_plugins(event, state) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/deployinator/helpers/plugin.rb', line 23 def notify_plugins(event, state) ret = nil unless plugins.nil? then @plugins.each do |plugin| begin new_ret = plugin.run(event, state) if ret.nil? then ret = new_ret end rescue => e raise "Error running plugin #{plugin} with exception #{e.to_s}" end end end ret end |
#raise_event(event, extra_state = {}) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/deployinator/helpers/plugin.rb', line 40 def raise_event(event, extra_state = {}) state = extra_state state[:username] = @username state[:stack] = @stack state[:stage] = @method state[:timestamp] = Time.now.to_i notify_plugins(event, state) end |
#register_plugins(stack) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/deployinator/helpers/plugin.rb', line 7 def register_plugins(stack) @plugins = [] global_plugins = Deployinator.global_plugins unless global_plugins.nil? then Deployinator.global_plugins.each do |klass| @plugins << Deployinator.const_get("#{klass}").new end end unless Deployinator.stack_plugins.nil? || Deployinator.stack_plugins[stack].nil? then Deployinator.stack_plugins[stack].each do |klass| @plugins << Deployinator.const_get("#{klass}").new end end end |