Class: Sprinkle::Installers::PackageInstaller
- Defined in:
- lib/sprinkle/installers/package_installer.rb
Overview
This is a abstract class installer that most all the package installers inherit from (deb, *BSD pkg, rpm, etc)
Direct Known Subclasses
Apt, Brew, Deb, FreebsdPkg, OpenbsdPkg, OpensolarisPkg, Pacman, Rpm, Smart, Yum, Zypper
Instance Attribute Summary collapse
-
#packages ⇒ Object
holds the list of packages to be installed.
Attributes inherited from Installer
#delivery, #options, #package, #post, #pre
Class Method Summary collapse
-
.auto_api(*args) ⇒ Object
automatically sets up the api for package installation based on the class name.
Instance Method Summary collapse
-
#initialize(parent, *packages, &block) ⇒ PackageInstaller
constructor
:nodoc:.
-
#install_package(*names, &block) ⇒ Object
called by subclasses of PackageInstaller.
Methods inherited from Installer
#announce, api, #commands_from_block, #defer, #escape_shell_arg, inherited, #install_sequence, #method_missing, #per_host?, #post_process, #process, subclasses, verify_api
Methods included from Sudo
#sudo?, #sudo_cmd, #sudo_stack
Methods included from Attributes
Constructor Details
#initialize(parent, *packages, &block) ⇒ PackageInstaller
:nodoc:
10 11 12 13 14 |
# File 'lib/sprinkle/installers/package_installer.rb', line 10 def initialize(parent, *packages, &block) #:nodoc: = packages. super parent, , &block @packages = [*packages].flatten end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sprinkle::Installers::Installer
Instance Attribute Details
#packages ⇒ Object
holds the list of packages to be installed
8 9 10 |
# File 'lib/sprinkle/installers/package_installer.rb', line 8 def packages @packages end |
Class Method Details
.auto_api(*args) ⇒ Object
automatically sets up the api for package installation based on the class name
Apt becomes the method ‘apt`, etc
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sprinkle/installers/package_installer.rb', line 19 def self.auto_api(*args) method_name = args.first || self.to_s.underscore.split("/").last class_name = self.to_s api do method="def #{method_name}(*names, &block) install #{class_name}.new(self, *names, &block) end" eval(method) end end |
Instance Method Details
#install_package(*names, &block) ⇒ Object
called by subclasses of PackageInstaller
31 32 33 |
# File 'lib/sprinkle/installers/package_installer.rb', line 31 def install_package(*names, &block) #:nodoc: install Sprinkle::Installers::class.new(self, *names, &block) end |