Class: Inspec::Resources::WindowsFeature
- Inherits:
- 
      Object
      
        - Object
- Inspec::Resources::WindowsFeature
 
- Defined in:
- lib/inspec/resources/windows_feature.rb
Instance Method Summary collapse
- 
  
    
      #info  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    returns the package description. 
- 
  
    
      #initialize(feature, method = nil)  ⇒ WindowsFeature 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of WindowsFeature. 
- 
  
    
      #installed?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    returns true if the package is installed. 
- #to_s ⇒ Object
Constructor Details
#initialize(feature, method = nil) ⇒ WindowsFeature
Returns a new instance of WindowsFeature.
| 28 29 30 31 32 | # File 'lib/inspec/resources/windows_feature.rb', line 28 def initialize(feature, method = nil) @feature = feature @method = method @cache = nil end | 
Instance Method Details
#info ⇒ Object
returns the package description
| 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | # File 'lib/inspec/resources/windows_feature.rb', line 40 def info return @cache unless @cache.nil? case @method when :powershell @cache = info_via_powershell(@feature) if @cache[:error] # TODO: Allow handling `Inspec::Exception` outside of initialize # See: https://github.com/inspec/inspec/issues/3237 # The below will fail the resource regardless of what is raised raise Inspec::Exceptions::ResourceFailed, @cache[:error] end when :dism @cache = info_via_dism(@feature) else @cache = info_via_powershell(@feature) @cache = info_via_dism(@feature) if @cache[:error] end @cache end | 
#installed? ⇒ Boolean
returns true if the package is installed
| 35 36 37 | # File 'lib/inspec/resources/windows_feature.rb', line 35 def installed? info[:installed] == true end | 
#to_s ⇒ Object
| 62 63 64 | # File 'lib/inspec/resources/windows_feature.rb', line 62 def to_s "Windows Feature '#{@feature}'" end |