Class: Inspec::Resources::Mount
- Inherits:
-
Object
- Object
- Inspec::Resources::Mount
show all
- Includes:
- MountParser
- Defined in:
- lib/resources/mount.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#parse_mount_options
Constructor Details
#initialize(path) ⇒ Mount
Returns a new instance of Mount.
24
25
26
27
28
|
# File 'lib/resources/mount.rb', line 24
def initialize(path)
@path = path
return skip_resource 'The `mount` resource is not supported on your OS yet.' if !inspec.os.linux?
@file = inspec.backend.file(@path)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/resources/mount.rb', line 40
def method_missing(name)
return nil if !file.mounted?
mounted = file.mounted
return nil if mounted.nil? || mounted.stdout.nil?
line = mounted.stdout
line = mounted.stdout.lines.to_a.last if mounted.stdout.lines.count > 1
@mount_options ||= parse_mount_options(line)
@mount_options[name]
end
|
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
22
23
24
|
# File 'lib/resources/mount.rb', line 22
def file
@file
end
|
Instance Method Details
#count ⇒ Object
34
35
36
37
38
|
# File 'lib/resources/mount.rb', line 34
def count
mounted = file.mounted
return nil if mounted.nil? || mounted.stdout.nil?
mounted.stdout.lines.count
end
|
#mounted? ⇒ Boolean
30
31
32
|
# File 'lib/resources/mount.rb', line 30
def mounted?
file.mounted?
end
|
#to_s ⇒ Object
55
56
57
|
# File 'lib/resources/mount.rb', line 55
def to_s
"Mount #{@path}"
end
|