class MPM::PM::Provisioner


CLASS->PROVISIONER ————————-


Constants

DEFINITION_DSL_METHODS

CONSTANTS ——————————–


Public Class Methods

define(executable, os, &definition) click to toggle source

PM-PROVISIONERS->DEFINITION ————–


# File lib/mpm/pm/provisioner.rb, line 114
def self.define(executable, os, &definition)
  ::MPM.pm_provisioners.add Provisioner.new(executable, os, &definition)
end
get() click to toggle source

PM-PROVISIONERS->RETRIEVAL —————


# File lib/mpm/pm/provisioner.rb, line 121
def self.get
  pm_executable = ::MPM::Utility.get_pm_executable

  ::MPM.pm_provisioners.find do |pm_provisioner|
    pm_provisioner.executable == pm_executable
  end
end
new(executable, os, &definition) click to toggle source

INITIALIZE ——————————-


# File lib/mpm/pm/provisioner.rb, line 36
def initialize(executable, os, &definition)
  self.executable = executable
  self.os         = os
  self.definition = definition
  
  self.definitions_commands = Set.new
  self.extensions = Set.new

  # Evaluate the block/DSL
  self.instance_eval &self.definition
end

Public Instance Methods

exec_command(command_name, *arguments) click to toggle source

COMMAND->EXECUTION ———————–


# File lib/mpm/pm/provisioner.rb, line 77
def exec_command(command_name, *arguments)
  command = find_command command_name

  executable = ::MPM.pm_provisioner.executable

  # TEMPORARY: FIX:
  if executable == "apt-get"
    executable = "apt-cache" if [:search, :info].member? command_name.to_sym
    executable = "dpkg" if command_name.to_sym == :list
    executable = "dpkg-query" if command_name.to_sym == :search_installed
  end

  # Execute the command from the executable and the definition.
  command = [executable].concat(command[:definition].call(*arguments))

  # TEMPORARY: FIX:
  command.unshift("sudo") if executable == "apt-get"

  final_command = command.join(" ")

  puts ""

  puts [
    "---->",
    "[mpm]".colorize(:green),
    ":".bold,
    final_command.colorize(:light_black)
  ].join(" ")

  puts ""
  
  system final_command
end
extension(name, &definition) click to toggle source
# File lib/mpm/pm/provisioner.rb, line 60
def extension(name, &definition)
  new_extension = ::MPM::PM::Extension.new name, &definition
  self.extensions.add new_extension
end
find_command(command_name) click to toggle source

COMMAND->RETREIVAL ———————–


# File lib/mpm/pm/provisioner.rb, line 68
def find_command(command_name)
  self.definitions_commands.find do |definition_command|
    definition_command[:method_name] == command_name.to_sym
  end
end