class Inspec::Resources::Packages
Public Class Methods
new(pattern)
click to toggle source
# File lib/inspec/resources/packages.rb, line 23 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
Public Instance Methods
to_s()
click to toggle source
# File lib/inspec/resources/packages.rb, line 40 def to_s "Packages #{@pattern.class == String ? @pattern : @pattern.inspect}" end
Private Instance Methods
filtered_packages()
click to toggle source
# File lib/inspec/resources/packages.rb, line 63 def filtered_packages warn "The packages resource is not yet supported on OS #{inspec.os.name}" if resource_skipped? @list end
pattern_regexp(p)
click to toggle source
# File lib/inspec/resources/packages.rb, line 53 def pattern_regexp(p) if p.class == String Regexp.new(Regexp.escape(p)) elsif p.class == Regexp p else raise 'Invalid name argument to packages resource, please use a "string" or /regexp/' end end