Class: Inspec::Resources::WindowsHotfix

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/resources/windows_hotfix.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hotfix_id = nil) ⇒ WindowsHotfix

Returns a new instance of WindowsHotfix.



16
17
18
19
20
21
22
23
24
25
# File 'lib/inspec/resources/windows_hotfix.rb', line 16

def initialize(hotfix_id = nil)
  @id = hotfix_id.upcase
  @content = nil
  os = inspec.os
  return skip_resource "The `windows_hotfix` resource is not a feature of your OS." unless os.windows?

  query = "get-hotfix -id #{@id}"
  cmd = inspec.powershell(query)
  @content = cmd.stdout
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



14
15
16
# File 'lib/inspec/resources/windows_hotfix.rb', line 14

def content
  @content
end

Instance Method Details

#installed?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/inspec/resources/windows_hotfix.rb', line 31

def installed?
  return false if @content.nil?

  @content.include?(@id)
end

#to_sObject



27
28
29
# File 'lib/inspec/resources/windows_hotfix.rb', line 27

def to_s
  "Windows Hotfix #{@id}"
end