mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
2857d07151
The opening and closing mechanic varied between all the various resources. This changes them all to use a HEREDOC with a tilde to remove leading whitespace. This removes the need for the special method to trim the `#print_example` method from shell. Signed-off-by: Franklin Webber <franklin.webber@gmail.com>
25 lines
740 B
Ruby
25 lines
740 B
Ruby
# encoding: utf-8
|
|
|
|
require 'resources/file'
|
|
|
|
module Inspec::Resources
|
|
class Directory < FileResource
|
|
name 'directory'
|
|
supports platform: 'unix'
|
|
supports platform: 'windows'
|
|
desc 'Use the directory InSpec audit resource to test if the file type is a directory. This is equivalent to using the file InSpec audit resource and the be_directory matcher, but provides a simpler and more direct way to test directories. All of the matchers available to file may be used with directory.'
|
|
example <<~EXAMPLE
|
|
describe directory('path') do
|
|
it { should be_directory }
|
|
end
|
|
EXAMPLE
|
|
|
|
def exist?
|
|
file.exist? && file.directory?
|
|
end
|
|
|
|
def to_s
|
|
"Directory #{source_path}"
|
|
end
|
|
end
|
|
end
|