Class: ConfigCurator::PackageLookup
- Inherits:
-
Object
- Object
- ConfigCurator::PackageLookup
- Includes:
- Utils
- Defined in:
- lib/config_curator/package_lookup.rb
Overview
Defined Under Namespace
Classes: LookupFailed
Constant Summary collapse
- TOOLS =
Default list of supported package tools.
{ dpkg: 'dpkg', pacman: 'pacman', pkgng: 'pkg', brew: 'brew' }
Instance Attribute Summary collapse
-
#tool ⇒ Symbol
The package tool to use for this instance.
-
#tools ⇒ Hash
Package tools that support package lookup ordered by preference.
Instance Method Summary collapse
-
#initialize(tool: nil) ⇒ PackageLookup
constructor
A new instance of PackageLookup.
-
#installed?(package) ⇒ Boolean
Checks if package is installed.
Constructor Details
#initialize(tool: nil) ⇒ PackageLookup
Returns a new instance of PackageLookup.
29 30 31 |
# File 'lib/config_curator/package_lookup.rb', line 29 def initialize(tool: nil) self.tool = tool end |
Instance Attribute Details
#tool ⇒ Symbol
The package tool to use for this instance.
42 43 44 |
# File 'lib/config_curator/package_lookup.rb', line 42 def tool @tool end |
#tools ⇒ Hash
Package tools that support package lookup ordered by preference. Each key is an identifier and each value is the command to check for.
36 37 38 |
# File 'lib/config_curator/package_lookup.rb', line 36 def tools @tools end |
Instance Method Details
#installed?(package) ⇒ Boolean
Checks if package is installed.
55 56 57 58 59 60 61 62 |
# File 'lib/config_curator/package_lookup.rb', line 55 def installed?(package) fail LookupFailed, 'No supported package tool found.' if tool.nil? cmd = tools[tool] fail LookupFailed, "Package tool '#{cmd}' not found." if command?(cmd).nil? send tool, package end |