mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +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>
36 lines
840 B
Ruby
36 lines
840 B
Ruby
# encoding: utf-8
|
|
|
|
require 'resources/platform'
|
|
|
|
module Inspec::Resources
|
|
class OSResource < PlatformResource
|
|
name 'os'
|
|
supports platform: 'unix'
|
|
supports platform: 'windows'
|
|
desc 'Use the os InSpec audit resource to test the platform on which the system is running.'
|
|
example <<~EXAMPLE
|
|
describe os[:family] do
|
|
it { should eq 'redhat' }
|
|
end
|
|
|
|
describe os.redhat? do
|
|
it { should eq true }
|
|
end
|
|
|
|
describe os.linux? do
|
|
it { should eq true }
|
|
end
|
|
EXAMPLE
|
|
|
|
# reuse helper methods from backend
|
|
%w{aix? redhat? debian? suse? bsd? solaris? linux? unix? windows? hpux? darwin?}.each do |os_family|
|
|
define_method(os_family.to_sym) do
|
|
@platform.send(os_family)
|
|
end
|
|
end
|
|
|
|
def to_s
|
|
'Operating System Detection'
|
|
end
|
|
end
|
|
end
|