erbse 0.0.1 → 0.0.2

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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +3 -0
  3. data/Gemfile +3 -0
  4. data/README.md +40 -22
  5. data/Rakefile +13 -0
  6. data/lib/erbse.rb +3 -6
  7. data/lib/erbse/converter.rb +41 -241
  8. data/lib/erbse/eruby.rb +114 -0
  9. data/lib/erbse/template.rb +14 -0
  10. data/lib/erbse/version.rb +1 -1
  11. data/test/erbse_test.rb +14 -0
  12. data/test/test_helper.rb +2 -0
  13. metadata +9 -149
  14. data/CHANGES.txt +0 -828
  15. data/bin/erubis +0 -10
  16. data/lib/erbse/context.rb +0 -83
  17. data/lib/erbse/engine.rb +0 -114
  18. data/lib/erbse/engine/ec.rb +0 -117
  19. data/lib/erbse/engine/ecpp.rb +0 -113
  20. data/lib/erbse/engine/ejava.rb +0 -110
  21. data/lib/erbse/engine/ejavascript.rb +0 -119
  22. data/lib/erbse/engine/enhanced.rb +0 -126
  23. data/lib/erbse/engine/eperl.rb +0 -95
  24. data/lib/erbse/engine/ephp.rb +0 -99
  25. data/lib/erbse/engine/eruby.rb +0 -119
  26. data/lib/erbse/engine/escheme.rb +0 -114
  27. data/lib/erbse/engine/optimized.rb +0 -127
  28. data/lib/erbse/enhancer.rb +0 -723
  29. data/lib/erbse/error.rb +0 -23
  30. data/lib/erbse/evaluator.rb +0 -88
  31. data/lib/erbse/generator.rb +0 -85
  32. data/lib/erbse/helper.rb +0 -47
  33. data/lib/erbse/helpers/rails_form_helper.rb +0 -197
  34. data/lib/erbse/helpers/rails_helper.rb +0 -353
  35. data/lib/erbse/main.rb +0 -516
  36. data/lib/erbse/preprocessing.rb +0 -58
  37. data/lib/erbse/tiny.rb +0 -144
  38. data/lib/erbse/util.rb +0 -22
  39. data/test/assert-text-equal.rb +0 -44
  40. data/test/data/users-guide/Example.ejava +0 -55
  41. data/test/data/users-guide/array_example.result +0 -9
  42. data/test/data/users-guide/arraybuffer_example.result +0 -9
  43. data/test/data/users-guide/bipattern-example.rhtml +0 -4
  44. data/test/data/users-guide/bipattern_example.result +0 -6
  45. data/test/data/users-guide/bufvar-example.rb +0 -10
  46. data/test/data/users-guide/bufvar-example.result +0 -17
  47. data/test/data/users-guide/context.rb +0 -6
  48. data/test/data/users-guide/context.yaml +0 -8
  49. data/test/data/users-guide/def_method.rb +0 -14
  50. data/test/data/users-guide/def_method.result +0 -3
  51. data/test/data/users-guide/escape_example.result +0 -9
  52. data/test/data/users-guide/example.ec +0 -27
  53. data/test/data/users-guide/example.ecpp +0 -30
  54. data/test/data/users-guide/example.ejs +0 -20
  55. data/test/data/users-guide/example.eperl +0 -18
  56. data/test/data/users-guide/example.ephp +0 -18
  57. data/test/data/users-guide/example.eruby +0 -6
  58. data/test/data/users-guide/example.escheme +0 -28
  59. data/test/data/users-guide/example1.eruby +0 -6
  60. data/test/data/users-guide/example1.rb +0 -17
  61. data/test/data/users-guide/example1.result +0 -16
  62. data/test/data/users-guide/example10.rb +0 -4
  63. data/test/data/users-guide/example10.result +0 -17
  64. data/test/data/users-guide/example10.xhtml +0 -14
  65. data/test/data/users-guide/example10_x.result +0 -17
  66. data/test/data/users-guide/example11.php +0 -20
  67. data/test/data/users-guide/example11.result +0 -23
  68. data/test/data/users-guide/example11.rhtml +0 -21
  69. data/test/data/users-guide/example11_C.result +0 -10
  70. data/test/data/users-guide/example11_N.result +0 -16
  71. data/test/data/users-guide/example11_U.result +0 -16
  72. data/test/data/users-guide/example11_php.result +0 -15
  73. data/test/data/users-guide/example1_x.result +0 -9
  74. data/test/data/users-guide/example2.eruby +0 -7
  75. data/test/data/users-guide/example2.rb +0 -10
  76. data/test/data/users-guide/example2.result +0 -27
  77. data/test/data/users-guide/example2_trim.result +0 -10
  78. data/test/data/users-guide/example2_x.result +0 -10
  79. data/test/data/users-guide/example3.eruby +0 -6
  80. data/test/data/users-guide/example3.rb +0 -10
  81. data/test/data/users-guide/example31.result +0 -22
  82. data/test/data/users-guide/example32.result +0 -4
  83. data/test/data/users-guide/example3_e.result +0 -8
  84. data/test/data/users-guide/example4.eruby +0 -3
  85. data/test/data/users-guide/example4.rb +0 -11
  86. data/test/data/users-guide/example4.result +0 -10
  87. data/test/data/users-guide/example4_x.result +0 -5
  88. data/test/data/users-guide/example5.eruby +0 -6
  89. data/test/data/users-guide/example5.rb +0 -16
  90. data/test/data/users-guide/example5.result +0 -7
  91. data/test/data/users-guide/example6.rb +0 -12
  92. data/test/data/users-guide/example6.result +0 -7
  93. data/test/data/users-guide/example7.eruby +0 -8
  94. data/test/data/users-guide/example71.result +0 -13
  95. data/test/data/users-guide/example72.result +0 -13
  96. data/test/data/users-guide/example8.eruby +0 -6
  97. data/test/data/users-guide/example8_ruby.result +0 -7
  98. data/test/data/users-guide/example8_yaml.result +0 -7
  99. data/test/data/users-guide/example9.eruby +0 -3
  100. data/test/data/users-guide/example9.rb +0 -8
  101. data/test/data/users-guide/example9.result +0 -9
  102. data/test/data/users-guide/example91.result +0 -5
  103. data/test/data/users-guide/example92.result +0 -4
  104. data/test/data/users-guide/example_c.result +0 -32
  105. data/test/data/users-guide/example_java.result +0 -56
  106. data/test/data/users-guide/example_js.result +0 -22
  107. data/test/data/users-guide/example_perl.result +0 -20
  108. data/test/data/users-guide/example_php.result +0 -19
  109. data/test/data/users-guide/example_scheme.result +0 -30
  110. data/test/data/users-guide/example_scheme_display.result +0 -29
  111. data/test/data/users-guide/fasteruby-example.rb +0 -8
  112. data/test/data/users-guide/fasteruby-example.result +0 -18
  113. data/test/data/users-guide/fasteruby.rb +0 -11
  114. data/test/data/users-guide/fasteruby.result +0 -38
  115. data/test/data/users-guide/fasteruby.rhtml +0 -15
  116. data/test/data/users-guide/headerfooter-example.eruby +0 -9
  117. data/test/data/users-guide/headerfooter-example2.rb +0 -8
  118. data/test/data/users-guide/headerfooter-example2.rhtml +0 -10
  119. data/test/data/users-guide/headerfooter_example.result +0 -11
  120. data/test/data/users-guide/headerfooter_example2.result +0 -13
  121. data/test/data/users-guide/interpolation_example.result +0 -9
  122. data/test/data/users-guide/main_program1.rb +0 -8
  123. data/test/data/users-guide/main_program1.result +0 -6
  124. data/test/data/users-guide/main_program2.rb +0 -8
  125. data/test/data/users-guide/main_program2.result +0 -6
  126. data/test/data/users-guide/nocode-example.eruby +0 -14
  127. data/test/data/users-guide/nocode-php.result +0 -20
  128. data/test/data/users-guide/nocode_example.result +0 -15
  129. data/test/data/users-guide/normal-eruby-test.eruby +0 -9
  130. data/test/data/users-guide/normal_eruby_test.result +0 -11
  131. data/test/data/users-guide/notext-example.eruby +0 -14
  132. data/test/data/users-guide/notext-example.php +0 -19
  133. data/test/data/users-guide/notext-php.result +0 -20
  134. data/test/data/users-guide/notext_example.result +0 -16
  135. data/test/data/users-guide/percentline-example.rhtml +0 -6
  136. data/test/data/users-guide/percentline_example.result +0 -9
  137. data/test/data/users-guide/prefixedline-example.rb +0 -9
  138. data/test/data/users-guide/prefixedline-example.rhtml +0 -6
  139. data/test/data/users-guide/prefixedline_example.result +0 -9
  140. data/test/data/users-guide/printenable_example.result +0 -4
  141. data/test/data/users-guide/printenabled-example.eruby +0 -3
  142. data/test/data/users-guide/printenabled-example.rb +0 -8
  143. data/test/data/users-guide/printstatement_example.result +0 -8
  144. data/test/data/users-guide/simplify_example.result +0 -9
  145. data/test/data/users-guide/stderr.log +0 -3
  146. data/test/data/users-guide/stdout_exmple.result +0 -9
  147. data/test/data/users-guide/stringbuffer_example.result +0 -9
  148. data/test/data/users-guide/tail_260.result +0 -4
  149. data/test/data/users-guide/tailnewline.rhtml +0 -3
  150. data/test/data/users-guide/template1.rhtml +0 -4
  151. data/test/data/users-guide/template2.rhtml +0 -4
  152. data/test/test-engines.rb +0 -425
  153. data/test/test-enhancers.rb +0 -646
  154. data/test/test-erubis.rb +0 -887
  155. data/test/test-index-cgi.rb +0 -191
  156. data/test/test-main.rb +0 -752
  157. data/test/test-users-guide.rb +0 -73
  158. data/test/test.rb +0 -45
  159. data/test/testutil.rb +0 -111
@@ -1,8 +0,0 @@
1
- require 'erubis'
2
- input = File.read('example.eruby')
3
-
4
- puts "----- Erubis::Eruby -----"
5
- print Erubis::Eruby.new(input).src
6
-
7
- puts "----- Erubis::FastEruby -----"
8
- print Erubis::FastEruby.new(input).src
@@ -1,18 +0,0 @@
1
- $ ruby fasteruby-example.rb
2
- ----- Erubis::Eruby -----
3
- _buf = ''; _buf << '<div>
4
- '; for item in list
5
- _buf << ' <p>'; _buf << ( item ).to_s; _buf << '</p>
6
- <p>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</p>
7
- '; end
8
- _buf << '</div>
9
- ';
10
- _buf.to_s
11
- ----- Erubis::FastEruby -----
12
- _buf = ''; _buf << %Q`<div>\n`
13
- for item in list
14
- _buf << %Q` <p>#{ item }</p>
15
- <p>#{Erubis::XmlHelper.escape_xml( item )}</p>\n`
16
- end
17
- _buf << %Q`</div>\n`
18
- _buf.to_s
@@ -1,11 +0,0 @@
1
- require 'erubis'
2
- input = File.read('fasteruby.rhtml')
3
- eruby = Erubis::FastEruby.new(input) # create Eruby object
4
-
5
- puts "---------- script source ---"
6
- puts eruby.src
7
-
8
- puts "---------- result ----------"
9
- context = { :title=>'Example', :list=>['aaa', 'bbb', 'ccc'] }
10
- output = eruby.evaluate(context)
11
- print output
@@ -1,38 +0,0 @@
1
- $ ruby fasteruby.rb
2
- ---------- script source ---
3
- _buf = ''; _buf << %Q`<html>
4
- <body>
5
- <h1>#{Erubis::XmlHelper.escape_xml( @title )}</h1>
6
- <table>\n`
7
- i = 0
8
- for item in @list
9
- i += 1
10
- _buf << %Q` <tr>
11
- <td>#{ i }</td>
12
- <td>#{Erubis::XmlHelper.escape_xml( item )}</td>
13
- </tr>\n`
14
- end
15
- _buf << %Q` </table>
16
- </body>
17
- </html>\n`
18
- _buf.to_s
19
- ---------- result ----------
20
- <html>
21
- <body>
22
- <h1>Example</h1>
23
- <table>
24
- <tr>
25
- <td>1</td>
26
- <td>aaa</td>
27
- </tr>
28
- <tr>
29
- <td>2</td>
30
- <td>bbb</td>
31
- </tr>
32
- <tr>
33
- <td>3</td>
34
- <td>ccc</td>
35
- </tr>
36
- </table>
37
- </body>
38
- </html>
@@ -1,15 +0,0 @@
1
- <html>
2
- <body>
3
- <h1><%== @title %></h1>
4
- <table>
5
- <% i = 0 %>
6
- <% for item in @list %>
7
- <% i += 1 %>
8
- <tr>
9
- <td><%= i %></td>
10
- <td><%== item %></td>
11
- </tr>
12
- <% end %>
13
- </table>
14
- </body>
15
- </html>
@@ -1,9 +0,0 @@
1
- <!--#header:
2
- def list_items(items)
3
- #-->
4
- <% for item in items %>
5
- <b><%= item %></b>
6
- <% end %>
7
- <!--#footer:
8
- end
9
- #-->
@@ -1,8 +0,0 @@
1
- require 'erubis'
2
- class HeaderFooterEruby < Erubis::Eruby
3
- include Erubis::HeaderFooterEnhancer
4
- end
5
-
6
- input = File.read('headerfooter-example2.rhtml')
7
- eruby = HeaderFooterEruby.new(input)
8
- print eruby.src
@@ -1,10 +0,0 @@
1
- <?xml version="1.0"?>
2
- <html>
3
- <!--#header:
4
- def page(list)
5
- #-->
6
- :
7
- <!--#footer:
8
- end
9
- #-->
10
- </html>
@@ -1,11 +0,0 @@
1
- $ erubis -xE HeaderFooter headerfooter-example.eruby
2
-
3
- def list_items(items)
4
-
5
- _buf = ''; for item in items
6
- _buf << ' <b>'; _buf << ( item ).to_s; _buf << '</b>
7
- '; end
8
- _buf.to_s
9
-
10
- end
11
-
@@ -1,13 +0,0 @@
1
- $ erubis -xE HeaderFooter headerfooter-example2.rhtml
2
-
3
- def page(list)
4
-
5
- _buf = ''; _buf << '<?xml version="1.0"?>
6
- <html>
7
- '; _buf << ' :
8
- '; _buf << '</html>
9
- ';
10
- _buf.to_s
11
-
12
- end
13
-
@@ -1,9 +0,0 @@
1
- $ erubis -xE DeleteIndent example.eruby
2
- _buf = ''; _buf << '<div>
3
- '; for item in list
4
- _buf << '<p>'; _buf << ( item ).to_s; _buf << '</p>
5
- <p>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</p>
6
- '; end
7
- _buf << '</div>
8
- ';
9
- _buf.to_s
@@ -1,8 +0,0 @@
1
- require 'erubis'
2
- eruby = Erubis::Eruby.new(File.read('template1.rhtml'))
3
- items = ['foo', 'bar', 'baz']
4
- x = 1
5
- ## local variable 'x' and 'eruby' are passed to template as well as 'items'!
6
- print eruby.result(binding())
7
- ## local variable 'x' is changed unintendedly because it is changed in template!
8
- puts "** debug: x=#{x.inspect}" #=> "baz"
@@ -1,6 +0,0 @@
1
- $ ruby main_program1.rb
2
- item = foo
3
- item = bar
4
- item = baz
5
- ** debug: local variables=["eruby", "items", "x", "_buf"]
6
- ** debug: x="baz"
@@ -1,8 +0,0 @@
1
- require 'erubis'
2
- eruby = Erubis::Eruby.new(File.read('template2.rhtml'))
3
- items = ['foo', 'bar', 'baz']
4
- x = 1
5
- ## only 'items' are passed to template
6
- print eruby.evaluate(:items=>items)
7
- ## local variable 'x' is not changed!
8
- puts "** debug: x=#{x.inspect}" #=> 1
@@ -1,6 +0,0 @@
1
- $ ruby main_program2.rb
2
- item = foo
3
- item = bar
4
- item = baz
5
- ** debug: local variables=["_context", "x", "_buf"]
6
- ** debug: x=1
@@ -1,14 +0,0 @@
1
- <h3>List</h3>
2
- <% if !@list || @list.empty? %>
3
- <p>not found.</p>
4
- <% else %>
5
- <table>
6
- <tbody>
7
- <% @list.each_with_index do |item, i| %>
8
- <tr bgcolor="<%= i%2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
9
- <td><%= item %></td>
10
- </tr>
11
- <% end %>
12
- </tbody>
13
- </table>
14
- <% end %>
@@ -1,20 +0,0 @@
1
- $ erubis -l php --pi=php -N -E NoCode --trim=false notext-example.php
2
- 1: <html>
3
- 2: <body>
4
- 3: <h3>List</h3>
5
- 4:
6
- 5: <p>not found.</p>
7
- 6:
8
- 7: <table>
9
- 8: <tbody>
10
- 9:
11
- 10:
12
- 11: <tr bgcolor="">
13
- 12: <td></td>
14
- 13: </tr>
15
- 14:
16
- 15: </tbody>
17
- 16: </table>
18
- 17:
19
- 18: </body>
20
- 19: </html>
@@ -1,15 +0,0 @@
1
- $ erubis -xE NoCode notext-example.eruby
2
- <h3>List</h3>
3
-
4
- <p>not found.</p>
5
-
6
- <table>
7
- <tbody>
8
-
9
- <tr bgcolor="">
10
- <td></td>
11
- </tr>
12
-
13
- </tbody>
14
- </table>
15
-
@@ -1,9 +0,0 @@
1
- <%
2
- def list_items(items)
3
- %>
4
- <% for item in items %>
5
- <li><%= item %></li>
6
- <% end %>
7
- <%
8
- end
9
- %>
@@ -1,11 +0,0 @@
1
- $ erubis -x normal-eruby-test.eruby
2
- _buf = '';
3
- def list_items(items)
4
-
5
- for item in items
6
- _buf << '<li>'; _buf << ( item ).to_s; _buf << '</li>
7
- '; end
8
-
9
- end
10
-
11
- _buf.to_s
@@ -1,14 +0,0 @@
1
- <h3>List</h3>
2
- <% if !@list || @list.empty? %>
3
- <p>not found.</p>
4
- <% else %>
5
- <table>
6
- <tbody>
7
- <% @list.each_with_index do |item, i| %>
8
- <tr bgcolor="<%= i%2 == 0 ? '#FFCCCC' : '#CCCCFF' %>">
9
- <td><%= item %></td>
10
- </tr>
11
- <% end %>
12
- </tbody>
13
- </table>
14
- <% end %>
@@ -1,19 +0,0 @@
1
- <html>
2
- <body>
3
- <h3>List</h3>
4
- <?php if (!$list || count($list) == 0) { ?>
5
- <p>not found.</p>
6
- <?php } else { ?>
7
- <table>
8
- <tbody>
9
- <?php $i = 0; ?>
10
- <?php foreach ($list as $item) { ?>
11
- <tr bgcolor="<?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?>">
12
- <td><?php echo $item; ?></td>
13
- </tr>
14
- <?php } ?>
15
- </tbody>
16
- </table>
17
- <?php } ?>
18
- </body>
19
- </html>
@@ -1,20 +0,0 @@
1
- $ erubis -l php --pi=php -N -E NoText --trim=false notext-example.php
2
- 1:
3
- 2:
4
- 3:
5
- 4: <?php if (!$list || count($list) == 0) { ?>
6
- 5:
7
- 6: <?php } else { ?>
8
- 7:
9
- 8:
10
- 9: <?php $i = 0; ?>
11
- 10: <?php foreach ($list as $item) { ?>
12
- 11: <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?>
13
- 12: <?php echo $item; ?>
14
- 13:
15
- 14: <?php } ?>
16
- 15:
17
- 16:
18
- 17: <?php } ?>
19
- 18:
20
- 19:
@@ -1,16 +0,0 @@
1
- $ erubis -xE NoText notext-example.eruby
2
- _buf = '';
3
- if !@list || @list.empty?
4
-
5
- else
6
-
7
-
8
- @list.each_with_index do |item, i|
9
- _buf << ( i%2 == 0 ? '#FFCCCC' : '#CCCCFF' ).to_s;
10
- _buf << ( item ).to_s;
11
-
12
- end
13
-
14
-
15
- end
16
- _buf.to_s
@@ -1,6 +0,0 @@
1
- <ul>
2
- % for item in list
3
- <li><%= item %></li>
4
- % end
5
- </ul>
6
- %% lines with '%%'
@@ -1,9 +0,0 @@
1
- $ erubis -xE PercentLine percentline-example.rhtml
2
- _buf = ''; _buf << '<ul>
3
- '; for item in list
4
- _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
5
- '; end
6
- _buf << '</ul>
7
- % lines with \'%%\'
8
- ';
9
- _buf.to_s
@@ -1,9 +0,0 @@
1
- require 'erubis'
2
-
3
- class PrefixedLineEruby < Erubis::Eruby
4
- include Erubis::PrefixedLineEnhancer
5
- end
6
-
7
- input = File.read('prefixedline-example.rhtml')
8
- eruby = PrefixedLineEruby.new(input, :prefixchar=>'!') # default '%'
9
- print eruby.src
@@ -1,6 +0,0 @@
1
- <ul>
2
- ! for item in list
3
- <li><%= item %></li>
4
- ! end
5
- </ul>
6
- !! lines with '!!'
@@ -1,9 +0,0 @@
1
- $ ruby prefixedline-example.rb
2
- _buf = ''; _buf << '<ul>
3
- '; for item in list
4
- _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
5
- '; end
6
- _buf << '</ul>
7
- ! lines with \'!!\'
8
- ';
9
- _buf.to_s
@@ -1,4 +0,0 @@
1
- $ ruby printenabled-example.rb
2
- <b>aaa</b>
3
- <b>bbb</b>
4
- <b>ccc</b>
@@ -1,3 +0,0 @@
1
- <% for item in @list %>
2
- <b><% print item %></b>
3
- <% end %>
@@ -1,8 +0,0 @@
1
- require 'erubis'
2
- class PrintEnabledEruby < Erubis::Eruby
3
- include Erubis::PrintEnabledEnhancer
4
- end
5
- input = File.read('printenabled-example.eruby')
6
- eruby = PrintEnabledEruby.new(input)
7
- list = ['aaa', 'bbb', 'ccc']
8
- print eruby.evaluate(:list=>list)
@@ -1,8 +0,0 @@
1
- $ erubis -xE PrintOut example.eruby
2
- print '<div>
3
- '; for item in list
4
- print ' <p>'; print(( item ).to_s); print '</p>
5
- <p>'; print Erubis::XmlHelper.escape_xml( item ); print '</p>
6
- '; end
7
- print '</div>
8
- ';
@@ -1,9 +0,0 @@
1
- $ erubis -xE Simplify example.eruby
2
- _buf = ''; _buf << '<div>
3
- '; for item in list ; _buf << '
4
- <p>'; _buf << ( item ).to_s; _buf << '</p>
5
- <p>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</p>
6
- '; end ; _buf << '
7
- </div>
8
- ';
9
- _buf.to_s