Method: Inspec::Resources::Packages#initialize

Defined in:
lib/resources/packages.rb

#initialize(pattern) ⇒ Packages

Returns a new instance of Packages.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/resources/packages.rb', line 24

def initialize(pattern)
  os = inspec.os
  if os.debian?
    @pkgs = Debs.new(inspec)
  elsif os.redhat? || %w{suse amazon fedora}.include?(os[:family])
    @pkgs = Rpms.new(inspec)
  else
    return skip_resource "The packages resource is not yet supported on OS #{inspec.os.name}"
  end

  @pattern = pattern_regexp(pattern)
  all_pkgs = @pkgs.build_package_list
  @list = all_pkgs.find_all do |hm|
    hm[:name] =~ @pattern
  end
end