Class: Inspec::Resources::PlatformResource
- Inherits:
- 
      Object
      
        - Object
- Inspec::Resources::PlatformResource
 
- Defined in:
- lib/resources/platform.rb
Direct Known Subclasses
Instance Method Summary collapse
- #[](key) ⇒ Object
- #families ⇒ Object
- #in_family?(family) ⇒ Boolean
- 
  
    
      #initialize  ⇒ PlatformResource 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of PlatformResource. 
- #name ⇒ Object
- #params ⇒ Object
- #platform?(name) ⇒ Boolean
- #supported?(supports) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ PlatformResource
| 17 18 19 | # File 'lib/resources/platform.rb', line 17 def initialize @platform = inspec.backend.platform end | 
Instance Method Details
#[](key) ⇒ Object
| 36 37 38 39 40 41 42 | # File 'lib/resources/platform.rb', line 36 def [](key) # convert string to symbol key = key.to_sym if key.is_a? String return name if key == :name @platform[key] end | 
#families ⇒ Object
| 28 29 30 | # File 'lib/resources/platform.rb', line 28 def families @platform.family_hierarchy end | 
#in_family?(family) ⇒ Boolean
| 49 50 51 | # File 'lib/resources/platform.rb', line 49 def in_family?(family) @platform.family_hierarchy.include?(family) end | 
#name ⇒ Object
| 32 33 34 | # File 'lib/resources/platform.rb', line 32 def name @platform.name end | 
#params ⇒ Object
| 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # File 'lib/resources/platform.rb', line 53 def params h = { name: name, families: families, release: release, } # Avoid adding Arch for APIs (not applicable) unless in_family?('api') h[:arch] = arch end h end | 
#platform?(name) ⇒ Boolean
| 44 45 46 47 | # File 'lib/resources/platform.rb', line 44 def platform?(name) @platform.name == name || @platform.family_hierarchy.include?(name) end | 
#supported?(supports) ⇒ Boolean
| 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | # File 'lib/resources/platform.rb', line 68 def supported?(supports) return true if supports.nil? || supports.empty? status = true supports.each do |s| s.each do |k, v| if %i(os_family os-family platform_family platform-family).include?(k) status = in_family?(v) elsif %i(os platform).include?(k) status = platform?(v) elsif %i(os_name os-name platform_name platform-name).include?(k) status = name == v elsif k == :release status = check_release(v) else status = false end break if status == false end return true if status == true end status end | 
#to_s ⇒ Object
| 93 94 95 | # File 'lib/resources/platform.rb', line 93 def to_s 'Platform Detection' end |