mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
32 lines
779 B
Ruby
32 lines
779 B
Ruby
# encoding: utf-8
|
|
# author: Dominik Richter
|
|
# author: Christoph Hartmann
|
|
|
|
module Inspec::Resources
|
|
class OSResource < Inspec.resource(1)
|
|
name 'os'
|
|
desc 'Use the os InSpec audit resource to test the platform on which the system is running.'
|
|
example "
|
|
describe os[:family] do
|
|
it { should eq 'redhat' }
|
|
end
|
|
"
|
|
|
|
# reuse helper methods from backend
|
|
%w{aix? redhat? debian? suse? bsd? solaris? linux? unix? windows?}.each do |os_family|
|
|
define_method(os_family.to_sym) do
|
|
inspec.backend.os.send(os_family)
|
|
end
|
|
end
|
|
|
|
def [](name)
|
|
# convert string to symbol
|
|
name = name.to_sym if name.is_a? String
|
|
inspec.backend.os[name]
|
|
end
|
|
|
|
def to_s
|
|
'Operating System Detection'
|
|
end
|
|
end
|
|
end
|