Method: Inspec::Metadata#is_supported

Defined in:
lib/inspec/metadata.rb

#is_supported(os, entry) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/inspec/metadata.rb', line 43

def is_supported(os, entry)
  name, family, release = support_fields(entry)

  # return true if the backend matches the supported OS's
  # fields act as masks, i.e. any value configured for os-name, os-family,
  # or release must be met by the backend; any field that is nil acts as
  # a glob expression i.e. is true

  # os name is both saved in :family and :name, so check both
  name_ok = name.nil? ||
            os[:name] == name || os[:family] == name

  family_check = family.to_s + '?'
  family_ok = family.nil? || os[:family] == family ||
              (
                os.respond_to?(family_check) &&
                # this call will return true if the family matches
                os.method(family_check).call
              )

  release_ok = release.nil? || os[:release] == release

  # we want to make sure that all matchers are true
  name_ok && family_ok && release_ok
end