class Inspec::Resources::FileSystemResource

Attributes

partition[R]

Public Class Methods

new(partition) click to toggle source
# File lib/inspec/resources/filesystem.rb, line 25
def initialize(partition)
  @partition = partition
  @cache = nil
  # select file system manager
  @fsman = nil

  os = inspec.os
  if os.unix?
    @fsman = UnixFileSystemResource.new(inspec)
  elsif os.windows?
    @fsman = WindowsFileSystemResource.new(inspec)
  else
    raise Inspec::Exceptions::ResourceSkipped, "The `filesystem` resource is not supported on your OS yet."
  end
end

Public Instance Methods

free_kb() click to toggle source
# File lib/inspec/resources/filesystem.rb, line 69
def free_kb
  info = @fsman.info(@partition)
  info[:free_kb]
end
info() click to toggle source
# File lib/inspec/resources/filesystem.rb, line 41
def info
  return @cache unless @cache.nil?
  return {} if @fsman.nil?

  @cache = @fsman.info(@partition)
end
name() click to toggle source
# File lib/inspec/resources/filesystem.rb, line 83
def name
  info = @fsman.info(@partition)
  info[:name]
end
percent_free() click to toggle source
# File lib/inspec/resources/filesystem.rb, line 74
def percent_free
  100 * free_kb / size_kb
end
size() click to toggle source
# File lib/inspec/resources/filesystem.rb, line 57
def size
  Inspec.deprecate(:property_filesystem_size, "The `size` property did not reliably use the correct units. Please use `size_kb` instead.")
  if inspec.os.windows?
    # On windows, we had a bug prior to #3767 in which the
    # 'size' value was be scaled to GB in powershell.
    # We now collect it in KB.
    (size_kb / (1024 * 1024)).to_i
  else
    size_kb
  end
end
size_kb() click to toggle source
# File lib/inspec/resources/filesystem.rb, line 52
def size_kb
  info = @fsman.info(@partition)
  info[:size_kb]
end
to_s() click to toggle source
# File lib/inspec/resources/filesystem.rb, line 48
def to_s
  "FileSystem #{@partition}"
end
type() click to toggle source
# File lib/inspec/resources/filesystem.rb, line 78
def type
  info = @fsman.info(@partition)
  info[:type]
end