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
Constant Summary
Constants included from Mixin::ShellOut
Mixin::ShellOut::DEPRECATED_OPTIONS
Instance Attribute Summary collapse
-
#installer_type ⇒ Object
readonly
Returns the value of attribute installer_type.
-
#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
Methods included from Mixin::ShellOut
#run_command_compatible_options, #shell_out, #shell_out!, #shell_out_with_systems_locale, #shell_out_with_systems_locale!
Constructor Details
#initialize(resource, installer_type, uninstall_entries) ⇒ Exe
Returns a new instance of Exe.
29 30 31 32 33 |
# File 'lib/chef/provider/package/windows/exe.rb', line 29 def initialize(resource, installer_type, uninstall_entries) @new_resource = resource @installer_type = installer_type @uninstall_entries = uninstall_entries end |
Instance Attribute Details
#installer_type ⇒ Object (readonly)
Returns the value of attribute installer_type.
36 37 38 |
# File 'lib/chef/provider/package/windows/exe.rb', line 36 def installer_type @installer_type end |
#new_resource ⇒ Object (readonly)
Returns the value of attribute new_resource.
35 36 37 |
# File 'lib/chef/provider/package/windows/exe.rb', line 35 def new_resource @new_resource end |
#uninstall_entries ⇒ Object (readonly)
Returns the value of attribute uninstall_entries.
37 38 39 |
# File 'lib/chef/provider/package/windows/exe.rb', line 37 def uninstall_entries @uninstall_entries end |
Instance Method Details
#expand_options(options) ⇒ Object
From Chef::Provider::Package
40 41 42 |
# File 'lib/chef/provider/package/windows/exe.rb', line 40 def () ? " #{}" : "" end |
#install_package ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/chef/provider/package/windows/exe.rb', line 54 def install_package Chef::Log.debug("#{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(" "), timeout: new_resource.timeout, returns: new_resource.returns ) end |
#installed_version ⇒ Object
Returns a version if the package is installed or nil if it is not.
45 46 47 48 |
# File 'lib/chef/provider/package/windows/exe.rb', line 45 def installed_version Chef::Log.debug("#{new_resource} checking package version") current_installed_version end |
#package_version ⇒ Object
50 51 52 |
# File 'lib/chef/provider/package/windows/exe.rb', line 50 def package_version new_resource.version end |
#remove_package ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/chef/provider/package/windows/exe.rb', line 69 def remove_package uninstall_version = new_resource.version || current_installed_version uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) } .map { |version| version.uninstall_string }.uniq.each do |uninstall_string| Chef::Log.debug("Registry provided uninstall string for #{new_resource} is '#{uninstall_string}'") shell_out!(uninstall_command(uninstall_string), { returns: new_resource.returns }) end end |