Class: Niman::Provisioner
- Inherits:
-
Object
- Object
- Niman::Provisioner
- Defined in:
- lib/niman/provisioner.rb
Instance Attribute Summary collapse
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(installer, filehandler, shell, instructions) ⇒ Provisioner
constructor
A new instance of Provisioner.
- #run ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(installer, filehandler, shell, instructions) ⇒ Provisioner
Returns a new instance of Provisioner.
7 8 9 10 11 12 |
# File 'lib/niman/provisioner.rb', line 7 def initialize(installer, filehandler, shell, instructions) @installer = installer @filehandler = filehandler @shell = shell @instructions = Array(instructions) end |
Instance Attribute Details
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
5 6 7 |
# File 'lib/niman/provisioner.rb', line 5 def instructions @instructions end |
Instance Method Details
#errors ⇒ Object
18 19 20 |
# File 'lib/niman/provisioner.rb', line 18 def errors @instructions.map(&:errors).flatten.join("\n") end |
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/niman/provisioner.rb', line 22 def run raise Niman::ConfigError, self.errors unless self.valid? @instructions.each do |instruction| yield(instruction) if block_given? if is_file(instruction) @filehandler.run(instruction) elsif instruction.respond_to?(:command) command(instruction) else @installer.install(instruction) end if instruction.respond_to?(:files) custom_package_files(instruction) end if instruction.respond_to?(:commands) custom_package_exec(instruction) end end end |
#valid? ⇒ Boolean
14 15 16 |
# File 'lib/niman/provisioner.rb', line 14 def valid? @instructions.all?(&:valid?) end |