summaryrefslogtreecommitdiffstats
path: root/report-generators/lib/reports.rb
blob: c61bb206aad8cf735cee0ea2b38df750bceaba3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Data about the various reports we support
require 'log'
require 'pathname'

module Reports
  Report = Struct.new(:short_desc, :desc, :path, :template)

  class ReportRegister
    attr_reader :reports

    private
    def add_report(sym, *args)
      @reports[sym] = Report.new(*args)
    end

    public
    def initialize()
      @reports = Hash.new

      add_report(:unit_test,
                 "Unit Tests",
                 "unit tests",
                 Pathname.new("reports/unit.html"),
                 Pathname.new("unit_test.rhtml"))

      add_report(:memcheck,
                 "Memory Tests",
                 "unit tests with valgrind memory checking",
                 Pathname.new("reports/memcheck.html"),
                 Pathname.new("memcheck.rhtml"))

      add_report(:unit_detail,
                 "Unit Test Detail",
                 "unit test detail",
                 Pathname.new("reports/unit_detail.html"), # FIXME replace this with a lambda
                 Pathname.new("unit_detail.rhtml"))
    end

    def get_report(sym)
      raise RuntimeError, "unknown report '#{sym}'" unless @reports.member?(sym)
      @reports[sym]
    end

    def each(&block)
      @reports.each(&block)
    end
  end
end