Class: Chef::Provider::Package::Windows::Exe
- Inherits:
-
Object
- Object
- Chef::Provider::Package::Windows::Exe
- Includes:
- Mixin::ShellOut
- Defined in:
- lib/chef/provider/package/windows/exe.rb
Instance Attribute Summary collapse
-
#installer_type ⇒ Object
readonly
Returns the value of attribute installer_type.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#new_resource ⇒ Object
readonly
Returns the value of attribute new_resource.
-
#uninstall_entries ⇒ Object
readonly
Returns the value of attribute uninstall_entries.
Instance Method Summary collapse
-
#expand_options(options) ⇒ Object
From Chef::Provider::Package.
-
#initialize(resource, installer_type, uninstall_entries) ⇒ Exe
constructor
A new instance of Exe.
- #install_package ⇒ Object
-
#installed_version ⇒ Object
Returns a version if the package is installed or nil if it is not.
- #package_version ⇒ Object
- #remove_package ⇒ Object
Constructor Details
#initialize(resource, installer_type, uninstall_entries) ⇒ Exe
Returns a new instance of Exe.
29 30 31 32 33 34 |
# File 'lib/chef/provider/package/windows/exe.rb', line 29 def initialize(resource, installer_type, uninstall_entries) @new_resource = resource @logger = new_resource.logger @installer_type = installer_type @uninstall_entries = uninstall_entries end |
Instance Attribute Details
#installer_type ⇒ Object (readonly)
Returns the value of attribute installer_type.
38 39 40 |
# File 'lib/chef/provider/package/windows/exe.rb', line 38 def installer_type @installer_type end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
37 38 39 |
# File 'lib/chef/provider/package/windows/exe.rb', line 37 def logger @logger end |
#new_resource ⇒ Object (readonly)
Returns the value of attribute new_resource.
36 37 38 |
# File 'lib/chef/provider/package/windows/exe.rb', line 36 def new_resource @new_resource end |
#uninstall_entries ⇒ Object (readonly)
Returns the value of attribute uninstall_entries.
39 40 41 |
# File 'lib/chef/provider/package/windows/exe.rb', line 39 def uninstall_entries @uninstall_entries end |
Instance Method Details
#expand_options(options) ⇒ Object
From Chef::Provider::Package
42 43 44 |
# File 'lib/chef/provider/package/windows/exe.rb', line 42 def () ? " #{}" : "" end |
#install_package ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chef/provider/package/windows/exe.rb', line 56 def install_package logger.trace("#{new_resource} installing #{new_resource.installer_type} package '#{new_resource.source}'") shell_out!( [ "start", "\"\"", "/wait", "\"#{new_resource.source}\"", unattended_flags, (new_resource.), "& exit %%%%ERRORLEVEL%%%%", ].join(" "), default_env: false, timeout: new_resource.timeout, returns: new_resource.returns, sensitive: new_resource.sensitive ) end |
#installed_version ⇒ Object
Returns a version if the package is installed or nil if it is not.
47 48 49 50 |
# File 'lib/chef/provider/package/windows/exe.rb', line 47 def installed_version logger.trace("#{new_resource} checking package version") current_installed_version end |
#package_version ⇒ Object
52 53 54 |
# File 'lib/chef/provider/package/windows/exe.rb', line 52 def package_version new_resource.version end |
#remove_package ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/chef/provider/package/windows/exe.rb', line 71 def remove_package uninstall_version = new_resource.version || current_installed_version uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) } .map(&:uninstall_string).uniq.each do |uninstall_string| logger.trace("Registry provided uninstall string for #{new_resource} is '#{uninstall_string}'") shell_out!(uninstall_command(uninstall_string), default_env: false, timeout: new_resource.timeout, returns: new_resource.returns) end end |