Finished gem-izing it

This commit is contained in:
2024-12-11 11:20:08 -06:00
parent 12c82281dc
commit fd803a090a
7 changed files with 48 additions and 44 deletions

View File

@@ -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

View File

@@ -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

40
lib/rubyqa/templates.rb Executable file
View File

@@ -0,0 +1,40 @@
module RubyQA
module Template
require 'erb'
BASE_REPORT_TEMPLATE=ERB.new(<<ERB, trim_mode: '-')
RubyQA Test Report
QA Date: <%= Time.now.strftime("%Y/%m/%d %l:%M:%S %p %Z") %>
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(<<EOF, :trim_mode => '-')
==============================================
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

View File

@@ -1,24 +0,0 @@
module RubyQA::Templates
require 'erb'
BASE_REPORT=ERB.new(<<ERB, trim_mode: '-')
RubyQA Test Report
QA Date: <%= Time.now.strftime("%Y/%m/%d %l:%M:%S %p %Z") %>
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

View File

@@ -1,12 +0,0 @@
module RubyQA::Template
BASE_TEST_TEMPLATE = ERB.new <<EOF, :trim_mode => '-'
==============================================
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