Class: Wright::Provider::Package

Inherits:
Wright::Provider show all
Defined in:
lib/wright/provider/package.rb,
lib/wright/provider/package/apt.rb,
lib/wright/provider/package/yum.rb,
lib/wright/provider/package/homebrew.rb

Overview

Package provider. Used as a base class for Resource::Package providers.

Direct Known Subclasses

Apt, Homebrew, Yum

Defined Under Namespace

Classes: Apt, Homebrew, Yum

Constant Summary

Constants inherited from Wright::Provider

PROVIDER_DIR

Instance Method Summary collapse

Methods inherited from Wright::Provider

#initialize, #updated?

Constructor Details

This class inherits a constructor from Wright::Provider

Instance Method Details

#installvoid

This method returns an undefined value.

Installs the package.


11
12
13
14
15
16
17
18
# File 'lib/wright/provider/package.rb', line 11

def install
  unless_uptodate(:install,
                  "package already installed: '#{package_name}'") do
    unless_dry_run("install package: '#{package_name}'") do
      install_package
    end
  end
end

#installed?Bool

Returns true if the package is installed, false otherwise.

Returns:

  • (Bool)

    true if the package is installed, false otherwise


39
40
41
42
43
44
45
# File 'lib/wright/provider/package.rb', line 39

def installed?
  if package_version
    installed_versions.include?(package_version)
  else
    !installed_versions.empty?
  end
end

#installed_versionsArray<String>

Returns the installed package versions.

Returns:

  • (Array<String>)

    the installed package versions


33
34
35
# File 'lib/wright/provider/package.rb', line 33

def installed_versions
  fail NotImplementedError
end

#removevoid

This method returns an undefined value.

Removes the package.


23
24
25
26
27
28
29
30
# File 'lib/wright/provider/package.rb', line 23

def remove
  unless_uptodate(:remove,
                  "package already removed: '#{package_name}'") do
    unless_dry_run("remove package: '#{package_name}'") do
      remove_package
    end
  end
end