Class: Inspec::Resources::Mount
- Inherits:
-
Object
- Object
- Inspec::Resources::Mount
show all
- Defined in:
- lib/inspec/resources/mount.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ Mount
Returns a new instance of Mount.
20
21
22
23
24
25
|
# File 'lib/inspec/resources/mount.rb', line 20
def initialize(path)
@path = path
@mount_manager = mount_manager_for_os
return skip_resource "The `mount` resource is not supported on your OS yet." if @mount_manager.nil?
@file = inspec.backend.file(@path)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/inspec/resources/mount.rb', line 37
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 ||= @mount_manager.parse_mount_options(line)
@mount_options[name]
end
|
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
18
19
20
|
# File 'lib/inspec/resources/mount.rb', line 18
def file
@file
end
|
Instance Method Details
#count ⇒ Object
31
32
33
34
35
|
# File 'lib/inspec/resources/mount.rb', line 31
def count
mounted = file.mounted
return nil if mounted.nil? || mounted.stdout.nil?
mounted.stdout.lines.count
end
|
#mounted? ⇒ Boolean
27
28
29
|
# File 'lib/inspec/resources/mount.rb', line 27
def mounted?
file.mounted?
end
|
#to_s ⇒ Object
52
53
54
|
# File 'lib/inspec/resources/mount.rb', line 52
def to_s
"Mount #{@path}"
end
|