Class: Inspec::Resources::ImmutableFlagCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/resources/file.rb

Overview

Helper class for immutable matcher.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inspec, file) ⇒ ImmutableFlagCheck

Returns a new instance of ImmutableFlagCheck.



408
409
410
411
# File 'lib/inspec/resources/file.rb', line 408

def initialize(inspec, file)
  @inspec = inspec
  @file_path = file.path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



407
408
409
# File 'lib/inspec/resources/file.rb', line 407

def file_path
  @file_path
end

#inspecObject (readonly)

Returns the value of attribute inspec.



407
408
409
# File 'lib/inspec/resources/file.rb', line 407

def inspec
  @inspec
end

Instance Method Details

#find_utility_or_error(utility_name) ⇒ Object



413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/inspec/resources/file.rb', line 413

def find_utility_or_error(utility_name)
  [
    "/usr/sbin/#{utility_name}",
    "/sbin/#{utility_name}",
    "/usr/bin/#{utility_name}",
    "/bin/#{utility_name}",
    "#{utility_name}",
  ].each do |cmd|
    return cmd if inspec.command(cmd).exist?
  end

  raise Inspec::Exceptions::ResourceFailed, "Could not find `#{utility_name}`"
end