ruby-qa/lib/manager.rb
2024-07-17 13:14:28 -04:00

57 lines
1.1 KiB
Ruby

module RubyQA
class Manager
attr_reader :resources, :hosts
@@tests = Array.new
@@hosts = Array.new
def self.tests
@@tests
end
def self.hosts
@@hosts
end
def self.add_host(host)
@@hosts << host
register_resources(host)
update_resources(host)
end
def self.register_resources (host)
Resource.all_resources.each do |resource|
host.add_resource(resource)
end
end
def self.update_resources (host)
host.update_resources
end
def self.new_test(name, options={}, &test_proc)
if not options.has_key? :disabled
@@tests << Test.new(name, **options, &test_proc)
elsif options[:disabled] != true
@@tests << Test.new(name, **options, &test_proc)
end
end
def self.run_tests
@@hosts.each do |host|
tests = @@tests.select{|test| test.valid_host(host)}
tests.each do |test|
test.run(host)
end
end
end
def self.report (template = nil)
if template
puts template.result(binding)
else
puts @@tests.map(&:report).join("\n")
end
end
end
end