File indexing completed on 2024-05-05 04:49:43

0001 #!/usr/bin/env ruby
0002 ########################################################################################
0003 # HTML generator for Amarok's unit tests.                                              #
0004 # This program transforms test output from XML to HTML, using a XSL stylesheet.        #
0005 #                                                                                      #
0006 # Copyright (c) 2009 Mark Kretschmann <kretschmann@kde.org>                            #
0007 #                                                                                      #
0008 # This program is free software; you can redistribute it and/or modify it under        #
0009 # the terms of the GNU General Public License as published by the Free Software        #
0010 # Foundation; either version 2 of the License, or (at your option) any later           #
0011 # version.                                                                             #
0012 #                                                                                      #
0013 # This program is distributed in the hope that it will be useful, but WITHOUT ANY      #
0014 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      #
0015 # PARTICULAR PURPOSE. See the GNU General Public License for more details.             #
0016 #                                                                                      #
0017 # You should have received a copy of the GNU General Public License along with         #
0018 # this program.  If not, see <http://www.gnu.org/licenses/>.                           #
0019 ########################################################################################
0020 
0021 require 'xml/libxml'
0022 require 'xml/libxslt'
0023 
0024 
0025 XSL_FILE = 'AmarokTest.xsl'
0026 OUTPUT_FILE = 'Amarok.html'
0027 
0028 out = ""
0029 
0030 files = Dir["**/*.xml"].sort
0031 
0032 # Generate menu
0033 out += "<h1>Unit Tests</h1><h3><ul>"
0034 files.each do |path|
0035   out += "<li><a href='##{path}'>#{path.sub('.xml','')}</a></li>"
0036 end
0037 
0038 out += "</ul></h3><br/><br/>"
0039 
0040 files.each do |path|
0041   begin
0042     xslt = XML::XSLT.new
0043     xslt.xsl = XSL_FILE
0044     xslt.xml = path 
0045     out += "<a name='#{path}'>"
0046     out += xslt.serve
0047     out += "<br/><br/><hr noshade><br/><br/>"
0048   rescue
0049     print "exception"
0050   end
0051 end
0052 
0053 
0054 # Save to file
0055 File.new( OUTPUT_FILE, File::CREAT | File::RDWR | File::TRUNC ).write(out)
0056 
0057 
0058 print out
0059