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.



413
414
415
416
# File 'lib/inspec/resources/file.rb', line 413

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

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



412
413
414
# File 'lib/inspec/resources/file.rb', line 412

def file_path
  @file_path
end

#inspecObject (readonly)

Returns the value of attribute inspec.



412
413
414
# File 'lib/inspec/resources/file.rb', line 412

def inspec
  @inspec
end

Instance Method Details

#find_utility_or_error(utility_name) ⇒ Object



418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/inspec/resources/file.rb', line 418

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