Class: MPM::PM::Provisioner
- Inherits:
-
Object
- Object
- MPM::PM::Provisioner
- Defined in:
- lib/mpm/pm/provisioner.rb
Overview
CLASS->PROVISIONER ————————-
Constant Summary collapse
- DEFINITION_DSL_METHODS =
CONSTANTS ——————————–
%i( install uninstall search search_installed list update info )
Class Method Summary collapse
-
.define(executable, os, &definition) ⇒ Object
—————————————— PM-PROVISIONERS->DEFINITION ————– ——————————————.
-
.get ⇒ Object
—————————————— PM-PROVISIONERS->RETRIEVAL ————— ——————————————.
Instance Method Summary collapse
-
#exec_command(command_name, *arguments) ⇒ Object
—————————————— COMMAND->EXECUTION ———————– ——————————————.
- #extension(name, &definition) ⇒ Object
-
#find_command(command_name) ⇒ Object
—————————————— COMMAND->RETREIVAL ———————– ——————————————.
-
#initialize(executable, os, &definition) ⇒ Provisioner
constructor
—————————————— INITIALIZE ——————————- ——————————————.
Constructor Details
#initialize(executable, os, &definition) ⇒ Provisioner
INITIALIZE ——————————-
36 37 38 39 40 41 42 43 44 45 46 |
# 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 |
Class Method Details
.define(executable, os, &definition) ⇒ Object
PM-PROVISIONERS->DEFINITION ————–
114 115 116 |
# 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 ⇒ Object
PM-PROVISIONERS->RETRIEVAL —————
121 122 123 124 125 126 127 |
# 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 |
Instance Method Details
#exec_command(command_name, *arguments) ⇒ Object
COMMAND->EXECUTION ———————–
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# 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) ⇒ Object
60 61 62 63 |
# 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) ⇒ Object
COMMAND->RETREIVAL ———————–
68 69 70 71 72 |
# 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 |