erbse 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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,119 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
- require 'erubis/engine'
7
- require 'erubis/enhancer'
8
-
9
-
10
- module Erubis
11
-
12
-
13
- module JavascriptGenerator
14
- include Generator
15
-
16
- def self.supported_properties() # :nodoc:
17
- list = []
18
- #list << [:indent, '', "indent spaces (ex. ' ')"]
19
- #list << [:bufvar, '_buf', "output buffer variable name"]
20
- list << [:docwrite, true, "use 'document.write()' when true"]
21
- return list
22
- end
23
-
24
- def init_generator(properties={})
25
- super
26
- @escapefunc ||= 'escape'
27
- @indent = properties[:indent] || ''
28
- @bufvar = properties[:bufvar] || '_buf'
29
- @docwrite = properties[:docwrite] != false # '!= false' will be removed in the next release
30
- end
31
-
32
- def add_preamble(src)
33
- src << "#{@indent}var #{@bufvar} = [];"
34
- end
35
-
36
- def escape_text(text)
37
- @@table_ ||= { "\r"=>"\\r", "\n"=>"\\n\\\n", "\t"=>"\\t", '"'=>'\\"', "\\"=>"\\\\" }
38
- return text.gsub!(/[\r\n\t"\\]/) { |m| @@table_[m] } || text
39
- end
40
-
41
- def add_indent(src, indent)
42
- src << (src.empty? || src[-1] == ?\n ? indent : ' ')
43
- end
44
-
45
- def add_text(src, text)
46
- return if text.empty?
47
- add_indent(src, @indent)
48
- src << @bufvar << '.push("'
49
- s = escape_text(text)
50
- if s[-1] == ?\n
51
- s[-2, 2] = ''
52
- src << s << "\");\n"
53
- else
54
- src << s << "\");"
55
- end
56
- end
57
-
58
- def add_stmt(src, code)
59
- src << code
60
- end
61
-
62
- def add_expr_literal(src, code)
63
- add_indent(src, @indent)
64
- code.strip!
65
- src << "#{@bufvar}.push(#{code});"
66
- end
67
-
68
- def add_expr_escaped(src, code)
69
- add_expr_literal(src, escaped_expr(code))
70
- end
71
-
72
- def add_expr_debug(src, code)
73
- add_indent(src, @indent)
74
- code.strip!
75
- src << "alert(\"*** debug: #{code}=\"+(#{code}));"
76
- end
77
-
78
- def add_postamble(src)
79
- src << "\n" if src[-1] == ?;
80
- if @docwrite
81
- src << @indent << 'document.write(' << @bufvar << ".join(\"\"));\n"
82
- else
83
- src << @indent << @bufvar << ".join(\"\");\n"
84
- end
85
- end
86
-
87
- end
88
-
89
-
90
- ##
91
- ## engine for JavaScript
92
- ##
93
- class Ejavascript < Basic::Engine
94
- include JavascriptGenerator
95
- end
96
-
97
-
98
- class EscapedEjavascript < Ejavascript
99
- include EscapeEnhancer
100
- end
101
-
102
-
103
- #class XmlEjavascript < Ejavascript
104
- # include EscapeEnhancer
105
- #end
106
-
107
-
108
- class PI::Ejavascript < PI::Engine
109
- include JavascriptGenerator
110
-
111
- def init_converter(properties={})
112
- @pi = 'js'
113
- super(properties)
114
- end
115
-
116
- end
117
-
118
-
119
- end
@@ -1,126 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
- require 'erubis/enhancer'
7
- require 'erubis/engine/eruby'
8
-
9
-
10
- module Erubis
11
-
12
-
13
- #--
14
- ## moved to engine/ruby.rb
15
- #class EscapedEruby < Eruby
16
- # include EscapeEnhancer
17
- #end
18
- #++
19
-
20
-
21
- #--
22
- ### (obsolete)
23
- #class FastEruby < Eruby
24
- # include FastEnhancer
25
- #end
26
- #++
27
-
28
-
29
- class StdoutEruby < Eruby
30
- include StdoutEnhancer
31
- end
32
-
33
-
34
- class PrintOutEruby < Eruby
35
- include PrintOutEnhancer
36
- end
37
-
38
-
39
- class PrintEnabledEruby < Eruby
40
- include PrintEnabledEnhancer
41
- end
42
-
43
-
44
- class ArrayEruby < Eruby
45
- include ArrayEnhancer
46
- end
47
-
48
-
49
- class ArrayBufferEruby < Eruby
50
- include ArrayBufferEnhancer
51
- end
52
-
53
-
54
- class StringBufferEruby < Eruby
55
- include StringBufferEnhancer
56
- end
57
-
58
-
59
- class StringIOEruby < Eruby
60
- include StringIOEnhancer
61
- end
62
-
63
-
64
- class ErboutEruby < Eruby
65
- include ErboutEnhancer
66
- end
67
-
68
-
69
- class NoTextEruby < Eruby
70
- include NoTextEnhancer
71
- end
72
-
73
-
74
- class NoCodeEruby < Eruby
75
- include NoCodeEnhancer
76
- end
77
-
78
-
79
- class SimplifiedEruby < Eruby
80
- include SimplifyEnhancer
81
- end
82
-
83
-
84
- class StdoutSimplifiedEruby < Eruby
85
- include StdoutEnhancer
86
- include SimplifyEnhancer
87
- end
88
-
89
-
90
- class PrintOutSimplifiedEruby < Eruby
91
- include PrintOutEnhancer
92
- include SimplifyEnhancer
93
- end
94
-
95
-
96
- class BiPatternEruby < Eruby
97
- include BiPatternEnhancer
98
- end
99
-
100
-
101
- class PercentLineEruby < Eruby
102
- include PercentLineEnhancer
103
- end
104
-
105
-
106
- class PrefixedLineEruby < Eruby
107
- include PrefixedLineEnhancer
108
- end
109
-
110
-
111
- class HeaderFooterEruby < Eruby
112
- include HeaderFooterEnhancer
113
- end
114
-
115
-
116
- class DeleteIndentEruby < Eruby
117
- include DeleteIndentEnhancer
118
- end
119
-
120
-
121
- class InterpolationEruby < Eruby
122
- include InterpolationEnhancer
123
- end
124
-
125
-
126
- end
@@ -1,95 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
- require 'erubis/engine'
7
- require 'erubis/enhancer'
8
-
9
-
10
- module Erubis
11
-
12
-
13
- module PerlGenerator
14
- include Generator
15
-
16
- def self.supported_properties() # :nodoc:
17
- return [
18
- [:func, 'print', "function name"],
19
- ]
20
- end
21
-
22
- def init_generator(properties={})
23
- super
24
- @escapefunc ||= 'encode_entities'
25
- @func = properties[:func] || 'print'
26
- end
27
-
28
- def add_preamble(src)
29
- src << "use HTML::Entities; ";
30
- end
31
-
32
- def escape_text(text)
33
- return text.gsub!(/['\\]/, '\\\\\&') || text
34
- end
35
-
36
- def add_text(src, text)
37
- src << @func << "('" << escape_text(text) << "'); " unless text.empty?
38
- end
39
-
40
- def add_expr_literal(src, code)
41
- code.strip!
42
- src << @func << "(" << code << "); "
43
- end
44
-
45
- def add_expr_escaped(src, code)
46
- add_expr_literal(src, escaped_expr(code))
47
- end
48
-
49
- def add_expr_debug(src, code)
50
- code.strip!
51
- s = code.gsub(/\'/, "\\'")
52
- src << @func << "('*** debug: #{code}=', #{code}, \"\\n\");"
53
- end
54
-
55
- def add_stmt(src, code)
56
- src << code
57
- end
58
-
59
- def add_postamble(src)
60
- src << "\n" unless src[-1] == ?\n
61
- end
62
-
63
- end
64
-
65
-
66
- ##
67
- ## engine for Perl
68
- ##
69
- class Eperl < Basic::Engine
70
- include PerlGenerator
71
- end
72
-
73
-
74
- class EscapedEperl < Eperl
75
- include EscapeEnhancer
76
- end
77
-
78
-
79
- #class XmlEperl < Eperl
80
- # include EscapeEnhancer
81
- #end
82
-
83
-
84
- class PI::Eperl < PI::Engine
85
- include PerlGenerator
86
-
87
- def init_converter(properties={})
88
- @pi = 'perl'
89
- super(properties)
90
- end
91
-
92
- end
93
-
94
-
95
- end
@@ -1,99 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
- require 'erubis/engine'
7
- require 'erubis/enhancer'
8
-
9
-
10
- module Erubis
11
-
12
-
13
- module PhpGenerator
14
- include Generator
15
-
16
- def self.supported_properties() # :nodoc:
17
- return []
18
- end
19
-
20
- def init_generator(properties={})
21
- super
22
- @escapefunc ||= 'htmlspecialchars'
23
- end
24
-
25
- def add_preamble(src)
26
- # empty
27
- end
28
-
29
- def escape_text(text)
30
- return text.gsub!(/<\?xml\b/, '<<?php ?>?xml') || text
31
- end
32
-
33
- def add_text(src, text)
34
- src << escape_text(text)
35
- end
36
-
37
- def add_expr_literal(src, code)
38
- code.strip!
39
- src << "<?php echo #{code}; ?>"
40
- end
41
-
42
- def add_expr_escaped(src, code)
43
- add_expr_literal(src, escaped_expr(code))
44
- end
45
-
46
- def add_expr_debug(src, code)
47
- code.strip!
48
- s = code.gsub(/\'/, "\\'")
49
- src << "<?php error_log('*** debug: #{s}='.(#{code}), 0); ?>"
50
- end
51
-
52
- def add_stmt(src, code)
53
- src << "<?php"
54
- src << " " if code[0] != ?\ #
55
- if code[-1] == ?\n
56
- code.chomp!
57
- src << code << "?>\n"
58
- else
59
- src << code << "?>"
60
- end
61
- end
62
-
63
- def add_postamble(src)
64
- # empty
65
- end
66
-
67
- end
68
-
69
-
70
- ##
71
- ## engine for PHP
72
- ##
73
- class Ephp < Basic::Engine
74
- include PhpGenerator
75
- end
76
-
77
-
78
- class EscapedEphp < Ephp
79
- include EscapeEnhancer
80
- end
81
-
82
-
83
- #class XmlEphp < Ephp
84
- # include EscapeEnhancer
85
- #end
86
-
87
-
88
- class PI::Ephp < PI::Engine
89
- include PhpGenerator
90
-
91
- def init_converter(properties={})
92
- @pi = 'php'
93
- super(properties)
94
- end
95
-
96
- end
97
-
98
-
99
- end
@@ -1,119 +0,0 @@
1
- require 'erbse/enhancer'
2
-
3
-
4
- module Erbse
5
-
6
-
7
- ##
8
- ## code generator for Ruby
9
- ##
10
- module RubyGenerator
11
- include Generator
12
- #include ArrayBufferEnhancer
13
- include StringBufferEnhancer
14
-
15
- def init_generator(properties={})
16
- super
17
- @escapefunc ||= "Erubis::XmlHelper.escape_xml"
18
- @bufvar = properties[:bufvar] || "_buf"
19
- end
20
-
21
- def self.supported_properties() # :nodoc:
22
- return []
23
- end
24
-
25
- def escape_text(text)
26
- text.gsub(/['\\]/, '\\\\\&') # "'" => "\\'", '\\' => '\\\\'
27
- end
28
-
29
- def escaped_expr(code)
30
- return "#{@escapefunc}(#{code})"
31
- end
32
-
33
- #--
34
- #def add_preamble(src)
35
- # src << "#{@bufvar} = [];"
36
- #end
37
- #++
38
-
39
- def add_text(src, text)
40
- src << " #{@bufvar} << '" << escape_text(text) << "';" unless text.empty?
41
- end
42
-
43
- def add_stmt(src, code)
44
- #src << code << ';'
45
- src << code
46
- src << ';' unless code[-1] == ?\n
47
- end
48
-
49
- def add_expr_literal(src, code)
50
- src << " #{@bufvar} << (" << code << ').to_s;'
51
- end
52
-
53
- def add_expr_escaped(src, code)
54
- src << " #{@bufvar} << " << escaped_expr(code) << ';'
55
- end
56
-
57
- def add_expr_debug(src, code)
58
- code.strip!
59
- s = (code.dump =~ /\A"(.*)"\z/) && $1
60
- src << ' $stderr.puts("*** debug: ' << s << '=#{(' << code << ').inspect}");'
61
- end
62
-
63
- #--
64
- #def add_postamble(src)
65
- # src << "\n#{@bufvar}.join\n"
66
- #end
67
- #++
68
-
69
- end
70
-
71
-
72
- ##
73
- ## engine for Ruby
74
- ##
75
- class Eruby < Basic::Engine
76
- include RubyEvaluator
77
- include RubyGenerator
78
- end
79
-
80
-
81
- ##
82
- ## fast engine for Ruby
83
- ##
84
- class FastEruby < Eruby
85
- include InterpolationEnhancer
86
- end
87
-
88
-
89
- ##
90
- ## swtich '<%= %>' to escaped and '<%== %>' to not escaped
91
- ##
92
- class EscapedEruby < Eruby
93
- include EscapeEnhancer
94
- end
95
-
96
-
97
- ##
98
- ## sanitize expression (<%= ... %>) by default
99
- ##
100
- ## this is equivalent to EscapedEruby and is prepared only for compatibility.
101
- ##
102
- class XmlEruby < Eruby
103
- include EscapeEnhancer
104
- end
105
-
106
-
107
- class PI::Eruby < PI::Engine
108
- include RubyEvaluator
109
- include RubyGenerator
110
-
111
- def init_converter(properties={})
112
- @pi = 'rb'
113
- super(properties)
114
- end
115
-
116
- end
117
-
118
-
119
- end