class AutomateIt::PackageManager

PackageManager

The PackageManager provides a way to manage packages, e.g., install, uninstall and query if the Apache package is installed with APT.

Examples:

package_manager.installed?("apache2") # => false
package_manager.install("apache2") # => true
package_manager.installed?("apache2") # => true
package_manager.uninstall("apache2") # => true
package_manager.not_installed("apache2") # => true

Commands can accept arrays:

package_manager.install("apache2", "bash")
package_manager.installed? %w(apache2 bash)

Commands can also accept a single, annotated string as a manifest – useful for installing large numbers of packages at once:

package_manager.install <<HERE, :with => :apt
  # One per line
  apache
  bash

  # Or many on the same line
  sysvconfig sysv-rc-conf
HERE

Commands can also accept a hash of names to paths – necessary for installing packages stored on the filesystem:

# Is the package called "TracTags" installed? If not, run the installer
# with the "/tmp/tractags_latest" path as an argument:
package.manager.install({"TracTags" => "/tmp/tractags_latest"}, :with => :egg)

Public Instance Methods

add(*packages) click to toggle source

Alias for install

# File lib/automateit/package_manager.rb, line 39
def add(*packages) dispatch_to(:install, *packages) end
install(*packages) click to toggle source

Install these packages. Returns true if any packages are installed successfully; or false if all packages were already installed.

# File lib/automateit/package_manager.rb, line 60
def install(*packages) dispatch(*packages) end
installed?(*packages) click to toggle source

Are these packages installed?

Options:

  • :details – Returns an array containing the boolean result value and an array with a subset of installed packages. Boolean, defaults to false.

# File lib/automateit/package_manager.rb, line 49
def installed?(*packages) dispatch(*packages) end
not_installed?(*packages) click to toggle source

Are these packages not installed?

Options:

  • :details – Returns an array containing the boolean result value and an array with a subset of packages not installed. Boolean, defaults to false.

# File lib/automateit/package_manager.rb, line 56
def not_installed?(*packages) dispatch(*packages) end
remove(*packages) click to toggle source

Alias for uninstall

# File lib/automateit/package_manager.rb, line 42
def remove(*packages) dispatch_to(:uninstall, *packages) end
uninstall(*packages) click to toggle source

Uninstall these packages. Returns true if any packages are uninstalled successfully; or false if none of the packages are installed.

# File lib/automateit/package_manager.rb, line 64
def uninstall(*packages) dispatch(*packages) end