inspec/lib/resources/sys_info.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

28 lines
810 B
Ruby

# encoding: utf-8
module Inspec::Resources
# this resource returns additional system informatio
class System < Inspec.resource(1)
name 'sys_info'
supports platform: 'unix'
supports platform: 'windows'
desc 'Use the user InSpec system resource to test for operating system properties.'
example <<~EXAMPLE
describe sys_info do
its('hostname') { should eq 'example.com' }
end
EXAMPLE
# returns the hostname of the local system
def hostname
os = inspec.os
if os.linux? || os.darwin?
inspec.command('hostname').stdout.chomp
elsif os.windows?
inspec.powershell('$env:computername').stdout.chomp
else
skip_resource 'The `sys_info.hostname` resource is not supported on your OS yet.'
end
end
end
end