Class: Sprinkle::Installers::Installer
- Defined in:
- lib/sprinkle/installers/installer.rb
Instance Attribute Summary collapse
-
#delivery ⇒ Object
Returns the value of attribute delivery.
-
#options ⇒ Object
Returns the value of attribute options.
-
#package ⇒ Object
Returns the value of attribute package.
-
#post(stage, *commands) ⇒ Object
Returns the value of attribute post.
-
#pre(stage, *commands) ⇒ Object
Returns the value of attribute pre.
Instance Method Summary collapse
- #defaults(deployment) ⇒ Object
-
#initialize(package, options = {}, &block) ⇒ Installer
constructor
A new instance of Installer.
- #method_missing(sym, *args, &block) ⇒ Object
- #process(roles) ⇒ Object
Constructor Details
#initialize(package, options = {}, &block) ⇒ Installer
6 7 8 9 10 11 |
# File 'lib/sprinkle/installers/installer.rb', line 6 def initialize(package, = {}, &block) @package = package = @pre = {}; @post = {} self.instance_eval(&block) if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/sprinkle/installers/installer.rb', line 43 def method_missing(sym, *args, &block) unless args.empty? # mutate if not set [sym] = *args unless [sym] end [sym] || @package.send(sym, *args, &block) # try the parents options if unknown end |
Instance Attribute Details
#delivery ⇒ Object
Returns the value of attribute delivery.
4 5 6 |
# File 'lib/sprinkle/installers/installer.rb', line 4 def delivery @delivery end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/sprinkle/installers/installer.rb', line 4 def end |
#package ⇒ Object
Returns the value of attribute package.
4 5 6 |
# File 'lib/sprinkle/installers/installer.rb', line 4 def package @package end |
#post(stage, *commands) ⇒ Object
Returns the value of attribute post.
4 5 6 |
# File 'lib/sprinkle/installers/installer.rb', line 4 def post @post end |
#pre(stage, *commands) ⇒ Object
Returns the value of attribute pre.
4 5 6 |
# File 'lib/sprinkle/installers/installer.rb', line 4 def pre @pre end |
Instance Method Details
#defaults(deployment) ⇒ Object
23 24 25 26 27 |
# File 'lib/sprinkle/installers/installer.rb', line 23 def defaults(deployment) defaults = deployment.defaults[self.class.name.split(/::/).last.downcase.to_sym] self.instance_eval(&defaults) if defaults @delivery = deployment.style end |
#process(roles) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sprinkle/installers/installer.rb', line 29 def process(roles) raise 'Unknown command delivery target' unless @delivery if logger.debug? sequence = install_sequence; sequence = sequence.join('; ') if sequence.is_a? Array logger.debug "#{@package.name} install sequence: #{sequence} for roles: #{roles}\n" end unless Sprinkle::OPTIONS[:testing] logger.info "--> Installing #{package.name} for roles: #{roles}" @delivery.process(@package.name, install_sequence, roles) end end |