Sha256: 606633c9e4e85bc9e7d9be08caee78169e486dad6ba5a7d8325464270130a048
Contents?: true
Size: 846 Bytes
Versions: 25
Compression:
Stored size: 846 Bytes
Contents
module Sys # # Get an array of mounted filesystems (as fancy objects) # def self.mounts if linux? IO.popen(["findmnt", "--raw"]) { |io| io.drop(1).map { |line| Mount.new line } } else raise NotImplementedError.new("I dunno, how do you find mounts on #{os}?") end end class Mount attr_accessor :dev, :type, :options def initialize(line) @path, @dev, @type, @options = line.strip.split(' ') @options = @options.split(",") end def system? (path =~ %r{^/(sys|dev|proc|run/user|tmp)}) or dev == "systemd-1" end def inspect "#{type}: #{path} (#{dev})" end def to_s "#{path} (#{dev})" end def path # Unescape findmnt's hex codes Path.new "#{eval %{"#{@path}"}}/" end def dirname path.dirs.last end end end
Version data entries
25 entries across 25 versions & 1 rubygems