summaryrefslogtreecommitdiffstats
path: root/report-generators/lib/reports.rb
blob: 57333324385cb6286d94c85902409936ba9a4a40 (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
# 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