diff --git a/lib/rubyqa.rb b/lib/rubyqa.rb index eac3bbf..e216ad6 100644 --- a/lib/rubyqa.rb +++ b/lib/rubyqa.rb @@ -1,9 +1,7 @@ #!/usr/bin/env ruby require_relative 'rubyqa/overrides' -require_relative 'rubyqa/templates/report' -require_relative 'rubyqa/templates/test' -require_relative 'rubyqa/interaction' +require_relative 'rubyqa/templates' require_relative 'rubyqa/manager' require_relative 'rubyqa/resource' require_relative 'rubyqa/runner' diff --git a/lib/rubyqa/manager.rb b/lib/rubyqa/manager.rb index fc54546..0eecd65 100644 --- a/lib/rubyqa/manager.rb +++ b/lib/rubyqa/manager.rb @@ -48,14 +48,14 @@ module RubyQA end def report (template = nil) - if template + if not template.nil? template.result(binding) else - @@tests.map(&:report).join("\n") + render end end end end - RubyQA::Template::BASE_REPORT_TEMPLATE.def_method(RubyQA::Manager, 'render') + RubyQA::Template::BASE_REPORT_TEMPLATE.def_method(RubyQA::Manager.class, 'render') end diff --git a/lib/rubyqa/overrides.rb b/lib/rubyqa/overrides.rb index 1abf10b..e582b87 100644 --- a/lib/rubyqa/overrides.rb +++ b/lib/rubyqa/overrides.rb @@ -1,4 +1,4 @@ -module RubyQA::Overrides +module RubyQA class ::String def red () "\e[0;31m#{self}\e[0m" end def red_background ()"\e[0;41m#{self}\e[0m" end diff --git a/lib/rubyqa/templates.rb b/lib/rubyqa/templates.rb new file mode 100755 index 0000000..92358e5 --- /dev/null +++ b/lib/rubyqa/templates.rb @@ -0,0 +1,40 @@ +module RubyQA + module Template + require 'erb' + BASE_REPORT_TEMPLATE=ERB.new(< +QA Runner: <%= ENV['USER'] %> +QA Tests: <%= Manager.tests.count %> +<% Manager.tests.each do |test| -%> +- "<%= test.name %>" +<% end -%> +QA Hosts: +<% Manager.hosts.each do |host| -%> +- <%= host.name %> (<%= host[:ip] %>) +<% end -%> + +############### +# Tests Begin # +############### + +<% Manager.tests.each do |test| -%> +<%= test.report %> +<% end -%> +ERB + + BASE_TEST_TEMPLATE = ERB.new(< '-') +============================================== +Test : "<%= @name %>" +<%- if not @description.empty? -%> +Description : "<%= @description %>" +<% end -%> +============================================== +<% @tests.each do |hostname,data| -%> +<%= hostname %> : <%= data[:status] %> <% if data[:context].has_key? :note %> (<%= data[:context][:note] %>) <% end %> +<% end -%> +EOF + + end +end diff --git a/lib/rubyqa/templates/report.rb b/lib/rubyqa/templates/report.rb deleted file mode 100755 index 1c08ce2..0000000 --- a/lib/rubyqa/templates/report.rb +++ /dev/null @@ -1,24 +0,0 @@ -module RubyQA::Templates - require 'erb' - BASE_REPORT=ERB.new(< -QA Runner: <%= ENV['USER'] %> -QA Tests: <%= Manager.tests.count %> -<% Manager.tests.each do |test| -%> -- "<%= test.name %>" -<% end -%> -QA Hosts: -<% Manager.hosts.each do |host| -%> -- <%= host.name %> (<%= host[:ip] %>) -<% end -%> - -############### -# Tests Begin # -############### - -<% Manager.tests.each do |test| -%> -<%= test.report %> -<% end -%> -ERB diff --git a/lib/rubyqa/templates/test.rb b/lib/rubyqa/templates/test.rb deleted file mode 100644 index b47bf13..0000000 --- a/lib/rubyqa/templates/test.rb +++ /dev/null @@ -1,12 +0,0 @@ -module RubyQA::Template - BASE_TEST_TEMPLATE = ERB.new < '-' -============================================== -Test : "<%= @name %>" -<%- if not @description.empty? -%> -Description : "<%= @description %>" -<% end -%> -============================================== -<% @tests.each do |hostname,data| -%> -<%= hostname %> : <%= data[:status] %> <% if data[:context].has_key? :note %> (<%= data[:context][:note] %>) <% end %> -<% end -%> -EOF diff --git a/rubyqa.gemspec b/rubyqa.gemspec index 41ada69..23e790e 100644 --- a/rubyqa.gemspec +++ b/rubyqa.gemspec @@ -6,9 +6,11 @@ Gem::Specification.new do |s| s.description = 'A Ruby based framework defining & orchestrating tests against a host or hosts' s.authors = ['Tristan Ancelet'] s.email = 'tristanancelet@yahoo.com' - s.homepatge = 'https://git.arcanium.tech/tristan/RubyQA' + s.homepage = 'https://git.arcanium.tech/tristan/RubyQA' s.executables += [ 'generate-qa','impromptu-qa'] s.files = Find::find('lib').select{|file| file =~ /rb/} + s.license = 'MIT' + s.required_ruby_version = ">= 2.7.0" s.add_dependency 'net-ssh', '~> 7.1', '>= 7.1.0' s.add_dependency 'net-ssh-telnet', '~> 0.3', '>= 0.3.0'