Class: Wright::Resource::Package
- Inherits:
-
Wright::Resource
- Object
- Wright::Resource
- Wright::Resource::Package
- Defined in:
- lib/wright/resource/package.rb
Overview
Public: Package resource, represents a package.
Examples
vim = Wright::Resource::Package.new('vim')
vim.installed_versions
# => []
vim.install
vim.installed_versions
# => ["2:7.3.547-7"]
htop = Wright::Resource::Package.new('htop')
htop.installed_versions
# => ["1.0.1-1"]
htop.remove
htop.installed_versions
# => []
Instance Attribute Summary collapse
-
#version ⇒ Object
Public: Get/Set the package version to install/remove.
Attributes inherited from Wright::Resource
#action, #ignore_failure, #name, #resource_name
Instance Method Summary collapse
-
#initialize(name) ⇒ Package
constructor
Public: Initialize a Package.
-
#install ⇒ Object
Public: Install the Package.
-
#installed_versions ⇒ Object
Public: Get the installed version of a package.
-
#remove ⇒ Object
Public: Remove the Package.
Methods inherited from Wright::Resource
Constructor Details
#initialize(name) ⇒ Package
Public: Initialize a Package.
name - The package name.
30 31 32 33 34 |
# File 'lib/wright/resource/package.rb', line 30 def initialize(name) super @version = nil @action = :install end |
Instance Attribute Details
#version ⇒ Object
Public: Get/Set the package version to install/remove.
25 26 27 |
# File 'lib/wright/resource/package.rb', line 25 def version @version end |
Instance Method Details
#install ⇒ Object
Public: Install the Package.
Returns true if the package was updated and false otherwise.
46 47 48 49 50 |
# File 'lib/wright/resource/package.rb', line 46 def install might_update_resource do @provider.install end end |
#installed_versions ⇒ Object
Public: Get the installed version of a package.
Returns an array of installed package version Strings.
39 40 41 |
# File 'lib/wright/resource/package.rb', line 39 def installed_versions @provider.installed_versions end |
#remove ⇒ Object
Public: Remove the Package.
Returns true if the package was updated and false otherwise.
55 56 57 58 59 |
# File 'lib/wright/resource/package.rb', line 55 def remove might_update_resource do @provider.remove end end |