erubis-bmp 2.7.0.bmp

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.txt +828 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.txt +10 -0
  5. data/benchmark/bench.rb +313 -0
  6. data/benchmark/bench_context.yaml +141 -0
  7. data/benchmark/mybench2.rb +266 -0
  8. data/benchmark/pibench.rb +163 -0
  9. data/benchmark/templates/_footer.html +4 -0
  10. data/benchmark/templates/_header.html +52 -0
  11. data/benchmark/templates/bench_erb.rhtml +29 -0
  12. data/benchmark/templates/bench_erubis.rhtml +29 -0
  13. data/benchmark/templates/bench_eruby.rhtml +29 -0
  14. data/bin/erubis +10 -0
  15. data/contrib/erubis-run.rb +132 -0
  16. data/doc/Rookbook.yaml +106 -0
  17. data/doc/docstyle.css +209 -0
  18. data/doc/users-guide.html +3551 -0
  19. data/doc/users-guide.txt +3631 -0
  20. data/examples/basic/Makefile +58 -0
  21. data/examples/basic/example.ec +42 -0
  22. data/examples/basic/example.ecpp +33 -0
  23. data/examples/basic/example.ejava +45 -0
  24. data/examples/basic/example.ejs +16 -0
  25. data/examples/basic/example.eperl +16 -0
  26. data/examples/basic/example.ephp +17 -0
  27. data/examples/basic/example.eruby +15 -0
  28. data/examples/basic/example.escheme +26 -0
  29. data/examples/pi-xhtml/ExamplePage.xhtml +80 -0
  30. data/examples/pi-xhtml/Makefile +17 -0
  31. data/examples/pi-xhtml/my/User.java +19 -0
  32. data/examples/pi-xhtml/my/Util.java +54 -0
  33. data/examples/pi/Makefile +54 -0
  34. data/examples/pi/example.ec +42 -0
  35. data/examples/pi/example.ejava +45 -0
  36. data/examples/pi/example.ejs +16 -0
  37. data/examples/pi/example.eperl +16 -0
  38. data/examples/pi/example.ephp +17 -0
  39. data/examples/pi/example.eruby +15 -0
  40. data/examples/pi/example.escheme +26 -0
  41. data/lib/erubis.rb +73 -0
  42. data/lib/erubis/context.rb +83 -0
  43. data/lib/erubis/converter.rb +357 -0
  44. data/lib/erubis/engine.rb +120 -0
  45. data/lib/erubis/engine/ec.rb +117 -0
  46. data/lib/erubis/engine/ecpp.rb +113 -0
  47. data/lib/erubis/engine/ejava.rb +110 -0
  48. data/lib/erubis/engine/ejavascript.rb +119 -0
  49. data/lib/erubis/engine/enhanced.rb +126 -0
  50. data/lib/erubis/engine/eperl.rb +95 -0
  51. data/lib/erubis/engine/ephp.rb +99 -0
  52. data/lib/erubis/engine/eruby.rb +125 -0
  53. data/lib/erubis/engine/escheme.rb +114 -0
  54. data/lib/erubis/engine/optimized.rb +127 -0
  55. data/lib/erubis/enhancer.rb +723 -0
  56. data/lib/erubis/error.rb +23 -0
  57. data/lib/erubis/evaluator.rb +88 -0
  58. data/lib/erubis/generator.rb +85 -0
  59. data/lib/erubis/helper.rb +47 -0
  60. data/lib/erubis/helpers/rails_form_helper.rb +197 -0
  61. data/lib/erubis/helpers/rails_helper.rb +353 -0
  62. data/lib/erubis/local-setting.rb +9 -0
  63. data/lib/erubis/main.rb +516 -0
  64. data/lib/erubis/preprocessing.rb +58 -0
  65. data/lib/erubis/tiny.rb +144 -0
  66. data/lib/erubis/util.rb +22 -0
  67. data/setup.rb +1331 -0
  68. data/test/Rookbook.yaml +42 -0
  69. data/test/assert-text-equal.rb +44 -0
  70. data/test/test-engines.rb +425 -0
  71. data/test/test-enhancers.rb +646 -0
  72. data/test/test-erubis.rb +887 -0
  73. data/test/test-index-cgi.rb +191 -0
  74. data/test/test-main.rb +752 -0
  75. data/test/test-users-guide.rb +73 -0
  76. data/test/test.rb +45 -0
  77. data/test/testutil.rb +111 -0
  78. metadata +121 -0
@@ -0,0 +1,29 @@
1
+ <tbody>
2
+ <%
3
+ n = 0
4
+ for item in list
5
+ n += 1
6
+ %>
7
+ <tr class="<%= n % 2 == 0 ? 'even' : 'odd' %>">
8
+ <td style="text-align: center"><%= n %></td>
9
+ <td>
10
+ <a href="/stocks/<%= item['symbol'] %>"><%= item['symbol'] %></a>
11
+ </td>
12
+ <td>
13
+ <a href="<%= item['url'] %>"><%= item['name'] %></a>
14
+ </td>
15
+ <td>
16
+ <strong><%= item['price'] %></strong>
17
+ </td>
18
+ <% if item['change'] < 0.0 %>
19
+ <td class="minus"><%= item['change'] %></td>
20
+ <td class="minus"><%= item['ratio'] %></td>
21
+ <% else %>
22
+ <td><%= item['change'] %></td>
23
+ <td><%= item['ratio'] %></td>
24
+ <% end %>
25
+ </tr>
26
+ <%
27
+ end
28
+ %>
29
+ </tbody>
@@ -0,0 +1,29 @@
1
+ <tbody>
2
+ <%
3
+ n = 0
4
+ for item in list
5
+ n += 1
6
+ %>
7
+ <tr class="<%= n % 2 == 0 ? 'even' : 'odd' %>">
8
+ <td style="text-align: center"><%= n %></td>
9
+ <td>
10
+ <a href="/stocks/<%= item['symbol'] %>"><%= item['symbol'] %></a>
11
+ </td>
12
+ <td>
13
+ <a href="<%= item['url'] %>"><%= item['name'] %></a>
14
+ </td>
15
+ <td>
16
+ <strong><%= item['price'] %></strong>
17
+ </td>
18
+ <% if item['change'] < 0.0 %>
19
+ <td class="minus"><%= item['change'] %></td>
20
+ <td class="minus"><%= item['ratio'] %></td>
21
+ <% else %>
22
+ <td><%= item['change'] %></td>
23
+ <td><%= item['ratio'] %></td>
24
+ <% end %>
25
+ </tr>
26
+ <%
27
+ end
28
+ %>
29
+ </tbody>
@@ -0,0 +1,29 @@
1
+ <tbody>
2
+ <%
3
+ n = 0
4
+ for item in list
5
+ n += 1
6
+ %>
7
+ <tr class="<%= n % 2 == 0 ? 'even' : 'odd' %>">
8
+ <td style="text-align: center"><%= n %></td>
9
+ <td>
10
+ <a href="/stocks/<%= item['symbol'] %>"><%= item['symbol'] %></a>
11
+ </td>
12
+ <td>
13
+ <a href="<%= item['url'] %>"><%= item['name'] %></a>
14
+ </td>
15
+ <td>
16
+ <strong><%= item['price'] %></strong>
17
+ </td>
18
+ <% if item['change'] < 0.0 %>
19
+ <td class="minus"><%= item['change'] %></td>
20
+ <td class="minus"><%= item['ratio'] %></td>
21
+ <% else %>
22
+ <td><%= item['change'] %></td>
23
+ <td><%= item['ratio'] %></td>
24
+ <% end %>
25
+ </tr>
26
+ <%
27
+ end
28
+ %>
29
+ </tbody>
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###
4
+ ### $Release:$
5
+ ### $Copyright$
6
+ ###
7
+
8
+ require 'erubis/main'
9
+
10
+ Erubis::Main.main(ARGV)
@@ -0,0 +1,132 @@
1
+ =begin
2
+
3
+ = apache/erubis-run.rb
4
+
5
+ Copyright (C) 2007 Andrew R Jackson <arjackson at acm dot org>
6
+
7
+ Built from original by Shugo Maeda:
8
+ Copyright (C) 2001 Shugo Maeda <shugo@modruby.net>
9
+
10
+ All rights reserved.
11
+
12
+ Redistribution and use in source and binary forms, with or without
13
+ modification, are permitted provided that the following conditions
14
+ are met:
15
+ 1. Redistributions of source code must retain the above copyright
16
+ notice, this list of conditions and the following disclaimer.
17
+ 2. Redistributions in binary form must reproduce the above copyright
18
+ notice, this list of conditions and the following disclaimer in the
19
+ documentation and/or other materials provided with the distribution.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22
+ ANY EXPRESS OR IMPLIED WAreqANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ IMPLIED WAreqANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTEreqUPTION)
28
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31
+ SUCH DAMAGE.
32
+
33
+ == Overview
34
+
35
+ Apache::ErubisRun handles eRuby files with erubis
36
+
37
+ == Example of httpd.conf
38
+
39
+ RubyRequire apache/erubis-run
40
+ <Location /eruby>
41
+ SetHandler ruby-object
42
+ RubyHandler Apache::ErubisRun.instance
43
+ </Location>
44
+
45
+ =end
46
+
47
+ require "singleton"
48
+ require "tempfile"
49
+ require "eruby" # Still needed to bring in a couple useful helper methods
50
+ require "erubis"
51
+
52
+ module Erubis
53
+ @@cgi = nil
54
+
55
+ def self.cgi
56
+ return @@cgi
57
+ end
58
+
59
+ def self.cgi=(cgi)
60
+ @@cgi = cgi
61
+ end
62
+ end
63
+
64
+ module Apache
65
+ class ErubisRun
66
+ include Singleton
67
+
68
+ def handler(req)
69
+ status = check_request(req)
70
+ return status if(status != OK)
71
+
72
+ filename = req.filename.dup
73
+ filename.untaint
74
+ erubis = compile(filename)
75
+ prerun(req)
76
+ begin
77
+ run(erubis, filename)
78
+ ensure
79
+ postrun(req)
80
+ end
81
+
82
+ return OK
83
+ end
84
+
85
+ private
86
+
87
+ def initialize
88
+ @compiler = nil
89
+ end
90
+
91
+ def check_request(req)
92
+ if(req.method_number == M_OPTIONS)
93
+ req.allowed |= (1 << M_GET)
94
+ req.allowed |= (1 << M_POST)
95
+ return DECLINED
96
+ end
97
+ if(req.finfo.mode == 0)
98
+ return NOT_FOUND
99
+ end
100
+ return OK
101
+ end
102
+
103
+ def compile(filename)
104
+ @compiler = Erubis::Eruby.load_file(filename) # use caching version as much as possible
105
+ return @compiler
106
+ end
107
+
108
+ def prerun(req)
109
+ Erubis.cgi = nil
110
+ req.setup_cgi_env
111
+ Apache.chdir_file(req.filename)
112
+ end
113
+
114
+ def run(erubis, filename)
115
+ binding = eval_string_wrap("binding")
116
+ puts erubis.result(binding) # eval the code in the context of the same binding ERuby uses
117
+ end
118
+
119
+ def postrun(req)
120
+ if(cgi = Erubis.cgi)
121
+ # TODO: pull the content type header from the cgi object, if set there?
122
+ elsif(req.sync_output or req.sync_header)
123
+ # Do nothing: header has already been sent
124
+ else
125
+ unless(req.content_type)
126
+ req.content_type = format("text/html;")
127
+ end
128
+ req.send_http_header
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,106 @@
1
+ preparation*: |
2
+ def untabify(str, width=8)
3
+ list = str.split(/\t/)
4
+ last = list.pop
5
+ sb = ''
6
+ list.each do |s|
7
+ column = (n = s.rindex(?\n)) ? s.length - n - 1 : s.length
8
+ n = width - (column % width)
9
+ sb << s << (' ' * n)
10
+ end
11
+ sb << last
12
+ return sb
13
+ end
14
+
15
+
16
+ properties:
17
+ - tagfile : html-css
18
+
19
+
20
+ parameters:
21
+ - u : users-guide
22
+ - all : [ $(u).html ]
23
+
24
+
25
+ recipes:
26
+
27
+ - product: :default
28
+ ingreds: [ :all ]
29
+
30
+ - product: :doc
31
+ ingreds: [ users-guide.html ]
32
+
33
+ - product: :clear
34
+ method*: |
35
+ rm_rf 'guide.d', '*.html'
36
+
37
+ - product: :clean
38
+ method*: |
39
+ rm_rf 'guide.d', '*.toc.html'
40
+
41
+ - product: :all
42
+ ingreds: [ $(all) ]
43
+
44
+ - product: $(u).html
45
+ ingreds: [ $(u).txt ]
46
+ byprods: [ $(u).toc.html ]
47
+ method*: |
48
+ dir = "../test/data/$(u)"
49
+ mkdir_p dir
50
+ rm_rf "#{dir}/*"
51
+ sys "retrieve -d #{dir} #{@ingred}"
52
+ for filename in Dir.glob("#{dir}/*.*_filter")
53
+ content = File.read(filename)
54
+ name = (filename =~ /\.(\w+)_filter$/) && $1
55
+ case name
56
+ when 'comment'
57
+ content.gsub!(/\s*\#.*$/, '')
58
+ fname = filename.sub(/\.comment_filter$/, '')
59
+ File.open(fname, 'w') {|f| f.write(content) }
60
+ when 'split'
61
+ contents = content.split(/^\$ /).select{|s| !s.empty?}.collect{|s| '$ '+s}
62
+ i = 0
63
+ for cont in contents
64
+ i += 1
65
+ fname = filename.sub(/\.(\w+).(\w+)_filter$/, "#{i}.\\1")
66
+ File.open(fname, 'w') { |f| f.write(cont) }
67
+ end
68
+ end
69
+ File.unlink(filename)
70
+ end
71
+ sys "kwaser -t $(tagfile) -T #{@ingred} > #{@byprod}"
72
+ sys "kwaser -t $(tagfile) #{@ingred} > #{@product}"
73
+ rm "#{@byprod}"
74
+
75
+ - product: :test
76
+ ingreds: [ $(u).html ]
77
+ method*: |
78
+ currdir = Dir.pwd
79
+ chdir '../test' do
80
+ sys 'ruby test-users-guide.rb'
81
+ end
82
+
83
+ - product: notext.txt
84
+ ingreds: [ ../test/test-notext.yaml, Rookbook.yaml ]
85
+ desc: create 'notext.txt' from 'test-notext.yaml'
86
+ method*: |
87
+ require 'yaml'
88
+ s = untabify(File.read(@ingred))
89
+ list = []
90
+ YAML.load_documents(s) { |ydoc| list << ydoc }
91
+ list.flatten!
92
+ entry = list.first
93
+ ydoc = {}
94
+ list.each do |hash|
95
+ %w[input output].each do |key|
96
+ hash[key].gsub!(/^\./, '') if hash.key?(key)
97
+ end
98
+ ydoc[hash['name']] = hash
99
+ end
100
+ text = entry['document']
101
+ require 'erubis'
102
+ eruby = Erubis::Eruby.new(text, :pattern=>'\[% %\]')
103
+ #p ydoc.keys
104
+ #puts eruby.src
105
+ result = eruby.result(binding())
106
+ File.open(@product, 'w') { |f| f.write(result) }
@@ -0,0 +1,209 @@
1
+ body {
2
+ background-color:#FFFFFF;
3
+ }
4
+
5
+ .mainbody {
6
+ color:#333333;
7
+ line-height:150%;
8
+ margin: 5px 30px 5px 30px;
9
+ }
10
+
11
+ a:link, a:active, a:hover {
12
+ color:#CC6600;
13
+ }
14
+
15
+ a:visited {
16
+ color:#DD9900;
17
+ }
18
+
19
+ p {
20
+ color:#333333;
21
+ line-height:150%;
22
+ }
23
+
24
+ pre {
25
+ width: 100%;
26
+ line-height:130%;
27
+ white-space:pre;
28
+ }
29
+
30
+ pre.program {
31
+ border-style:solid;
32
+ border-width:1px;
33
+ border-color:#6699FF;
34
+ color:#333333;
35
+ background-color:#DDEEFF;
36
+ padding:8px 9px 8px 9px;
37
+ margin:0px;
38
+ word-break:break-all;
39
+ }
40
+
41
+ pre.terminal {
42
+ border-style:solid;
43
+ border-width:1;
44
+ border-color:#999999;
45
+ color:#333333;
46
+ background-color:#E0E0E0;
47
+ padding:9px 10px 9px 10px;
48
+ margin:0px;
49
+ word-break:break-all;
50
+ }
51
+
52
+ pre.output {
53
+ border-style:solid;
54
+ border-width:1px;
55
+ border-color:#CCCCCC;
56
+ color:#333333;
57
+ background-color:#FFFFFF;
58
+ padding:8px 9px 8px 9px;
59
+ margin:0px;
60
+ word-break:break-all;
61
+ }
62
+
63
+
64
+ pre strong {
65
+ color: #990000;
66
+ font-weight: bold;
67
+ }
68
+
69
+
70
+ .program_caption {
71
+ margin-top: 20px;
72
+ }
73
+
74
+ .terminal_caption {
75
+ margin-top: 20px;
76
+ }
77
+
78
+ .output_caption {
79
+ margin-top: 20px;
80
+ }
81
+
82
+
83
+ ul,ol,dl {
84
+ /* margin:0px; */
85
+ /* padding:0px; */
86
+ color:#333333;
87
+ line-height:140%;
88
+ }
89
+
90
+ .dt2, .dt3 {
91
+ font-weight:bold;
92
+ }
93
+
94
+ .table1 {
95
+ padding:2px;
96
+ color:#333333;
97
+ background-color:#DDDDCC;
98
+ line-height:130%;
99
+ /*
100
+ border-width:1px;
101
+ border-style:solid;
102
+ border-color:#FFFFFF;
103
+ */
104
+ margin:5;
105
+ }
106
+
107
+ .th1, .th2 {
108
+ padding:1px;
109
+ color:#333333;
110
+ /* background-color:#DDDDCC; */
111
+ background-color:#CCCCBB;
112
+ line-height:130%;
113
+ }
114
+
115
+ .td1, .th2 {
116
+ padding:1px;
117
+ color:#333333;
118
+ background-color:#EEEEDD;
119
+ line-height:130%;
120
+ }
121
+
122
+ .caption1, .caption2 {
123
+ /* font-size:x-small; */
124
+ color:#333333;
125
+ }
126
+
127
+ .table2 {
128
+ padding:1px;
129
+ color:#333333;
130
+ background-color:#DDDDCC;
131
+ line-height:130%;
132
+ /*
133
+ border-width:1px;
134
+ border-style:solid;
135
+ border-color:#FFFFFF;
136
+ */
137
+ margin:5;
138
+ }
139
+
140
+ h1, .chapter, .doctitle {
141
+ color:#333333;
142
+ font-weight:bold;
143
+ padding:30px 0px 10px 0px;
144
+ }
145
+
146
+ h2, .section {
147
+ color:#333333;
148
+ font-weight:bold;
149
+ border-style:solid;
150
+ border-color:#6699FF;
151
+ border-width:0px 0px 2px 30px;
152
+ padding:10px 20px 0px 5px;
153
+ }
154
+
155
+ h3, .subsection {
156
+ color:#333333;
157
+ font-weight:bold;
158
+ border-style:solid;
159
+ border-color:#6699FF;
160
+ border-width: 0px 0px 0px 15px;
161
+ padding: 10px 20px 0px 5px;
162
+ }
163
+
164
+ .em {
165
+ font-weight:bold;
166
+ }
167
+
168
+ .toc {
169
+ /* font-size:small; */
170
+ /* line-height:100%; */
171
+ }
172
+
173
+ .footnote {
174
+ font-size:small;
175
+ }
176
+
177
+ div.note, div.tips {
178
+ background-color:#FFFFDD;
179
+ border-style:solid;
180
+ border-width:0px 1px 0px 1px;
181
+ border-color:#DDDD66;
182
+ color:#333300;
183
+ /* font-size:small; */
184
+ line-height:120%;
185
+ margin-top: 10px;
186
+ padding: 5px 20px 5px 20px;
187
+ }
188
+
189
+ div.note span.caption, div.tips span.caption {
190
+ color: #C60;
191
+ }
192
+
193
+ .figure {
194
+ /*
195
+ border-width:1px;
196
+ border-color:#DDDD66;
197
+ white-space:pre;
198
+ */
199
+ }
200
+
201
+ strong {
202
+ color: #630;
203
+ font-weight; bold;
204
+ }
205
+
206
+
207
+ em {
208
+ font-style: italic;
209
+ }