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.
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 |
# File 'lib/sprinkle/installers/installer.rb', line 6 def initialize(package, = {}, &block) @package = package @options = 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
32 33 34 35 36 37 38 |
# File 'lib/sprinkle/installers/installer.rb', line 32 def method_missing(sym, *args, &block) unless args.empty? # mutate if not set @options[sym] = *args unless @options[sym] end @options[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 @options end |
#package ⇒ Object
Returns the value of attribute package.
4 5 6 |
# File 'lib/sprinkle/installers/installer.rb', line 4 def package @package end |
Instance Method Details
#defaults(deployment) ⇒ Object
12 13 14 15 16 |
# File 'lib/sprinkle/installers/installer.rb', line 12 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
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sprinkle/installers/installer.rb', line 18 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 |