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)


35
36
37
38
39
# File 'lib/inspec/resources/windows_hotfix.rb', line 35

def installed?
  return false if @content.nil?

  @content.include?(@id)
end

#resource_idObject



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

def resource_id
  @id || "windows_hotfix"
end

#to_sObject



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

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