File: amrita.rb

package info (click to toggle)
amrita 1.0.2-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 1,880 kB
  • ctags: 1,363
  • sloc: ruby: 9,159; xml: 978; makefile: 111
file content (55 lines) | stat: -rw-r--r-- 907 bytes parent folder | download | duplicates (4)
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
require "amrita/template"
include Amrita


TEMPLATE = <<END
<html>
<head>
<title id="title"></title>
</head>
<body>
<h1 id="title"></h1>
<table border="1">
  <tr><th>name</th><th>author</th><th>webpage</tr>
  <tr id="table">
    <td id="name"></td>
    <td id="author"></td>
    <td><a id="webpage"></a></td>
  </tr>
</table>
</body>
</html>
END

table = File::open("bench.dat").collect do |line|
  items = line.chomp.split('|')
  {
    :name=>items[0],
    :author=>items[1],
    :webpage=> a(:href=>items[2]) { items[3] },
  }
end


data = {
  :title => 'amrita benchmark',
  :table => table
}

cnt = ARGV.shift.to_i

tmpl = TemplateText.new(TEMPLATE)
case ARGV.shift
when "preformat"
  tmpl.pre_format = true
when "compiler"
  tmpl.use_compiler = true
when "usehint"
  tmpl.use_compiler = true
  tmpl.set_hint_by_sample_data(data)
end

cnt.times  do
  tmpl.expand(STDOUT, data)  # without compiling
end