class Niman::Provisioner
Attributes
instructions[R]
Public Class Methods
new(installer, filehandler, shell, instructions)
click to toggle source
# File lib/niman/provisioner.rb, line 7 def initialize(installer, filehandler, shell, instructions) @installer = installer @filehandler = filehandler @shell = shell @instructions = Array(instructions) end
Public Instance Methods
errors()
click to toggle source
# File lib/niman/provisioner.rb, line 18 def errors @instructions.map(&:errors).flatten.join("\n") end
run() { |instruction| ... }
click to toggle source
# 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?()
click to toggle source
# File lib/niman/provisioner.rb, line 14 def valid? @instructions.all?(&:valid?) end
Private Instance Methods
command(instruction)
click to toggle source
# File lib/niman/provisioner.rb, line 61 def command(instruction) mode = case instruction.use_sudo when :sudo true when :no_sudo false end @shell.exec(instruction.command, mode) end
custom_package_exec(instruction)
click to toggle source
# File lib/niman/provisioner.rb, line 50 def custom_package_exec(instruction) return if instruction.commands.nil? instruction.commands.each { |cmd| command(cmd) } end
custom_package_files(instruction)
click to toggle source
# File lib/niman/provisioner.rb, line 55 def custom_package_files(instruction) Array(instruction.files).each do |file| @filehandler.run(file) end end
is_file(instruction)
click to toggle source
# File lib/niman/provisioner.rb, line 45 def is_file(instruction) instruction.respond_to?(:path) && instruction.respond_to?(:content) end