Class: Sprinkle::Deployment::Deployment
- Defined in:
- lib/sprinkle/deployment.rb
Instance Attribute Summary collapse
-
#defaults ⇒ Object
:nodoc:.
-
#style ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#active_policies ⇒ Object
:nodoc:.
-
#delivery(type, &block) ⇒ Object
Specifies which Sprinkle::Actors to use for delivery.
-
#initialize(&block) ⇒ Deployment
constructor
:nodoc:.
-
#method_missing(sym, *args, &block) ⇒ Object
:nodoc:.
-
#process ⇒ Object
:nodoc:.
Constructor Details
#initialize(&block) ⇒ Deployment
:nodoc:
49 50 51 52 53 54 |
# File 'lib/sprinkle/deployment.rb', line 49 def initialize(&block) #:nodoc: @defaults = {} @style = nil self.instance_eval(&block) raise 'No delivery mechanism defined' unless @style end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Attribute Details
#defaults ⇒ Object
:nodoc:
47 48 49 |
# File 'lib/sprinkle/deployment.rb', line 47 def defaults @defaults end |
Instance Method Details
#active_policies ⇒ Object
:nodoc:
75 76 77 78 79 80 81 82 |
# File 'lib/sprinkle/deployment.rb', line 75 def active_policies #:nodoc: if role=Sprinkle::OPTIONS[:only_role] role=role.to_sym POLICIES.select {|x| [x.roles].flatten.include?(role) } else POLICIES end end |
#delivery(type, &block) ⇒ Object
Specifies which Sprinkle::Actors to use for delivery. Although all actors jobs are the same: to run remote commands on a server, you may have a personal preference. The block you pass is used to configure the actor. For more information on what configuration options are available, view the corresponding Sprinkle::Actors page.
61 62 63 64 65 |
# File 'lib/sprinkle/deployment.rb', line 61 def delivery(type, &block) #:doc: type=type.to_s.titleize type="SSH" if type=="Ssh" @style = ("Sprinkle::Actors::" + type).constantize.new(&block) end |
#process ⇒ Object
:nodoc:
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/sprinkle/deployment.rb', line 84 def process #:nodoc: active_policies.each do |policy| policy.process(self) end rescue Sprinkle::Errors::RemoteCommandFailure => e e.print_summary exit 1 rescue Sprinkle::Errors::TransferFailure => e e.print_summary exit 2 ensure # do any cleanup our actor may need to close network sockets, etc @style.teardown if @style.respond_to?(:teardown) end |