Sha256: 248fac238d94471f5e6e5942fc20cf0066cc50ed0ed78683d613385ea9f1d4e8
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
require 'wright/provider' module Wright class Provider # Package provider. Used as a base class for Resource::Package # providers. class Package < Wright::Provider # Installs the package. # # @return [void] def install if uptodate?(:install) Wright.log.debug "package already installed: '#{@resource.name}'" return end install_package @updated = true end # Removes the package. # # @return [void] def remove if uptodate?(:remove) Wright.log.debug "package already removed: '#{@resource.name}'" return end remove_package @updated = true end private # @api public # Checks if the package is up-to-date for a given action. # # @param action [Symbol] the action. Currently supports # +:install+ and +:remove+. # # @return [Bool] +true+ if the package is up-to-date and +false+ # otherwise # @raise [ArgumentError] if the action is invalid def uptodate?(action) case action when :install package_installed? when :remove !package_installed? else fail ArgumentError, "invalid action '#{action}'" end end def package_installed? if @resource.version installed_versions.include?(@resource.version) else !installed_versions.empty? end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wright-0.2.0 | lib/wright/provider/package.rb |