inspec/lib/resources/os.rb
Lynn Frank 2857d07151 Fixes resource examples
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>
2019-03-19 11:25:41 -05:00

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