diff --git a/lib/manager.rb b/lib/manager.rb index 95a8849..15aec35 100644 --- a/lib/manager.rb +++ b/lib/manager.rb @@ -1,25 +1,30 @@ module RubyQA class Manager - attr_reader :resources + attr_reader :resources, :hosts @@tests = Array.new + @@hosts = Array.new - def initialize - @hosts = Array.new + def self.tests + @@tests end - def add_host(host) - @hosts << host + def self.hosts + @@hosts + end + + def self.add_host(host) + @@hosts << host register_resources(host) update_resources(host) end - def register_resources (host) + def self.register_resources (host) Resource.all_resources.each do |resource| host.add_resource(resource) end end - def update_resources (host) + def self.update_resources (host) host.update_resources end @@ -27,8 +32,8 @@ module RubyQA @@tests << Test.new(name, **options, &test_proc) end - def run_tests - @hosts.each do |host| + def self.run_tests + @@hosts.each do |host| tests = @@tests.select{|test| test.valid_host(host)} tests.each do |test| test.run(host) @@ -36,8 +41,12 @@ module RubyQA end end - def report - puts @@tests.map(&:report).join("\n") + def self.report (template = nil) + if template + puts template.result(binding) + else + puts @@tests.map(&:report).join("\n") + end end end end