Module: MountParser
- Included in:
- Inspec::Resources::FileResource, Inspec::Resources::Mount
- Defined in:
- lib/utils/parser.rb
Instance Method Summary collapse
-
#parse_mount_options(mount_line, compatibility = false) ⇒ Object
this parses the output of mount command (only tested on linux) this method expects only one line of the mount output.
Instance Method Details
#parse_mount_options(mount_line, compatibility = false) ⇒ Object
this parses the output of mount command (only tested on linux) this method expects only one line of the mount output
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/utils/parser.rb', line 68 def (mount_line, compatibility = false) mount = mount_line.scan(/\S+/) # parse device and type = { device: mount[0], type: mount[4] } if compatibility == false # parse options as array [:options] = mount[5].gsub(/\(|\)/, '').split(',') else # parse options as serverspec uses it, tbis is deprecated [:options] = {} mount[5].gsub(/\(|\)/, '').split(',').each do |option| name, val = option.split('=') if val.nil? val = true elsif val =~ /^\d+$/ # parse numbers val = val.to_i end [:options][name.to_sym] = val end end end |