Class: Inspec::Resources::FileSystemResource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(partition) ⇒ FileSystemResource

Returns a new instance of FileSystemResource.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/resources/filesystem.rb', line 19

def initialize(partition)
  @partition = partition
  @cache = nil
  # select file system manager
  @fsman = nil

  os = inspec.os
  if os.linux?
    @fsman = LinuxFileSystemResource.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

Instance Attribute Details

#partitionObject (readonly)

Returns the value of attribute partition.



17
18
19
# File 'lib/resources/filesystem.rb', line 17

def partition
  @partition
end

Instance Method Details

#infoObject



35
36
37
38
39
# File 'lib/resources/filesystem.rb', line 35

def info
  return @cache if !@cache.nil?
  return {} if @fsman.nil?
  @cache = @fsman.info(@partition)
end

#nameObject



55
56
57
58
# File 'lib/resources/filesystem.rb', line 55

def name
  info = @fsman.info(@partition)
  info[:name]
end

#sizeObject



45
46
47
48
# File 'lib/resources/filesystem.rb', line 45

def size
  info = @fsman.info(@partition)
  info[:size]
end

#to_sObject



41
42
43
# File 'lib/resources/filesystem.rb', line 41

def to_s
  "FileSystem #{@partition}"
end

#typeObject



50
51
52
53
# File 'lib/resources/filesystem.rb', line 50

def type
  info = @fsman.info(@partition)
  info[:type]
end