Class: Wright::Resource::Package
- Inherits:
-
Wright::Resource
- Object
- Wright::Resource
- Wright::Resource::Package
- Extended by:
- Forwardable
- Defined in:
- lib/wright/resource/package.rb
Overview
Package resource, represents a package.
Instance Attribute Summary collapse
-
#options ⇒ String+
The options passed to the package manager.
-
#version ⇒ String
The package version to install or remove.
Attributes inherited from Wright::Resource
#action, #ignore_failure, #name, #resource_name
Instance Method Summary collapse
-
#initialize(name, args = {}) ⇒ Package
constructor
Initializes a Package.
-
#install ⇒ Bool
Installs the Package.
-
#installed? ⇒ Bool
true
if the package is installed. -
#installed_versions ⇒ Array<String>
The installed package versions.
-
#remove ⇒ Bool
(also: #uninstall)
Removes the Package.
Methods inherited from Wright::Resource
Constructor Details
#initialize(name, args = {}) ⇒ Package
Initializes a Package.
41 42 43 44 45 46 |
# File 'lib/wright/resource/package.rb', line 41 def initialize(name, args = {}) super @action = args.fetch(:action, :install) @version = args.fetch(:version, nil) @options = args.fetch(:options, nil) end |
Instance Attribute Details
#options ⇒ String+
Returns the options passed to the package manager.
32 33 34 |
# File 'lib/wright/resource/package.rb', line 32 def @options end |
#version ⇒ String
Returns the package version to install or remove.
28 29 30 |
# File 'lib/wright/resource/package.rb', line 28 def version @version end |
Instance Method Details
#install ⇒ Bool
Installs the Package.
60 61 62 63 64 |
# File 'lib/wright/resource/package.rb', line 60 def install might_update_resource do provider.install end end |
#installed? ⇒ Bool
Returns true
if the package is installed.
54 |
# File 'lib/wright/resource/package.rb', line 54 def_delegator :provider, :installed? |
#installed_versions ⇒ Array<String>
Returns the installed package versions.
50 |
# File 'lib/wright/resource/package.rb', line 50 def_delegator :provider, :installed_versions |
#remove ⇒ Bool Also known as: uninstall
Removes the Package.
70 71 72 73 74 |
# File 'lib/wright/resource/package.rb', line 70 def remove might_update_resource do provider.remove end end |