Class: Wright::Resource::Package

Inherits:
Wright::Resource show all
Extended by:
Forwardable
Defined in:
lib/wright/resource/package.rb

Overview

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

Attributes inherited from Wright::Resource

#action, #ignore_failure, #name, #resource_name

Instance Method Summary collapse

Methods inherited from Wright::Resource

#log_error, #might_update_resource, #on_update=, #provider_for_resource, #provider_name, #resource_class, #run_action, #run_update_action

Constructor Details

#initialize(name) ⇒ Package

Initializes a Package.


37
38
39
40
41
42
# File 'lib/wright/resource/package.rb', line 37

def initialize(name)
  super
  @version = nil
  @options = nil
  @action = :install
end

Instance Attribute Details

#optionsString+


32
33
34
# File 'lib/wright/resource/package.rb', line 32

def options
  @options
end

#versionString


28
29
30
# File 'lib/wright/resource/package.rb', line 28

def version
  @version
end

Instance Method Details

#installBool

Installs the Package.


56
57
58
59
60
# File 'lib/wright/resource/package.rb', line 56

def install
  might_update_resource do
    @provider.install
  end
end

#installed?Bool


50
# File 'lib/wright/resource/package.rb', line 50

def_delegator :@provider, :installed?

#installed_versionsArray<String>


46
# File 'lib/wright/resource/package.rb', line 46

def_delegator :@provider, :installed_versions

#removeBool Also known as: uninstall

Removes the Package.


66
67
68
69
70
# File 'lib/wright/resource/package.rb', line 66

def remove
  might_update_resource do
    @provider.remove
  end
end