Class: Inspec::Resources::FileSystemResource
- Inherits:
-
Object
- Object
- Inspec::Resources::FileSystemResource
- Defined in:
- lib/inspec/resources/filesystem.rb
Instance Attribute Summary collapse
-
#partition ⇒ Object
readonly
Returns the value of attribute partition.
Instance Method Summary collapse
- #free_kb ⇒ Object
- #info ⇒ Object
-
#initialize(partition) ⇒ FileSystemResource
constructor
A new instance of FileSystemResource.
- #name ⇒ Object
- #percent_free ⇒ Object
- #resource_id ⇒ Object
- #size ⇒ Object
- #size_kb ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(partition) ⇒ FileSystemResource
Returns a new instance of FileSystemResource.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/inspec/resources/filesystem.rb', line 25 def initialize(partition) @partition = partition @cache = nil # select file system manager @fsman = nil os = inspec.os if os.unix? @fsman = UnixFileSystemResource.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
#partition ⇒ Object (readonly)
Returns the value of attribute partition.
23 24 25 |
# File 'lib/inspec/resources/filesystem.rb', line 23 def partition @partition end |
Instance Method Details
#free_kb ⇒ Object
69 70 71 72 |
# File 'lib/inspec/resources/filesystem.rb', line 69 def free_kb info = @fsman.info(@partition) info[:free_kb] end |
#info ⇒ Object
41 42 43 44 45 46 |
# File 'lib/inspec/resources/filesystem.rb', line 41 def info return @cache unless @cache.nil? return {} if @fsman.nil? @cache = @fsman.info(@partition) end |
#name ⇒ Object
83 84 85 86 |
# File 'lib/inspec/resources/filesystem.rb', line 83 def name info = @fsman.info(@partition) info[:name] end |
#percent_free ⇒ Object
74 75 76 |
# File 'lib/inspec/resources/filesystem.rb', line 74 def percent_free 100 * free_kb / size_kb end |
#resource_id ⇒ Object
88 89 90 |
# File 'lib/inspec/resources/filesystem.rb', line 88 def resource_id partition end |
#size ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/inspec/resources/filesystem.rb', line 57 def size Inspec.deprecate(:property_filesystem_size, "The `size` property did not reliably use the correct units. Please use `size_kb` instead.") if inspec.os.windows? # On windows, we had a bug prior to #3767 in which the # 'size' value was be scaled to GB in powershell. # We now collect it in KB. (size_kb / (1024 * 1024)).to_i else size_kb end end |
#size_kb ⇒ Object
52 53 54 55 |
# File 'lib/inspec/resources/filesystem.rb', line 52 def size_kb info = @fsman.info(@partition) info[:size_kb] end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/inspec/resources/filesystem.rb', line 48 def to_s "FileSystem #{@partition}" end |
#type ⇒ Object
78 79 80 81 |
# File 'lib/inspec/resources/filesystem.rb', line 78 def type info = @fsman.info(@partition) info[:type] end |