ruby-qa/lib/rubyqa/manager.rb

62 lines
1.3 KiB
Ruby
Raw Normal View History

2024-12-11 11:25:13 -05:00
module RubyQA
class Manager
attr_reader :resources, :hosts
@@tests = Array.new
@@hosts = Array.new
class << self
def tests
@@tests
end
def hosts
@@hosts
end
def add_host(host)
@@hosts << host
register_resources(host)
update_resources(host)
end
def register_resources (host)
Resource.all_resources.each do |resource|
host.add_resource(resource)
end
end
def update_resources (host)
host.update_resources
end
def 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 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 report (template = nil)
2024-12-11 12:20:08 -05:00
if not template.nil?
2024-12-11 11:25:13 -05:00
template.result(binding)
else
2024-12-11 12:20:08 -05:00
render
2024-12-11 11:25:13 -05:00
end
end
end
end
2024-12-11 12:20:08 -05:00
RubyQA::Template::BASE_REPORT_TEMPLATE.def_method(RubyQA::Manager.class, 'render')
2024-12-11 11:25:13 -05:00
end