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,73 +0,0 @@
1
- ###
2
- ### $Release: 2.7.0 $
3
- ### copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ###
5
-
6
- require "#{File.dirname(__FILE__)}/test.rb"
7
-
8
-
9
- class KwarkUsersGuideTest < Test::Unit::TestCase
10
-
11
- DIR = File.expand_path(File.dirname(__FILE__) + '/data/users-guide')
12
- CWD = Dir.pwd()
13
-
14
-
15
- def setup
16
- Dir.chdir DIR
17
- end
18
-
19
-
20
- def teardown
21
- Dir.chdir CWD
22
- end
23
-
24
-
25
- def _test
26
- @name = (caller()[0] =~ /`(.*?)'/) && $1
27
- s = File.read(@filename)
28
- s =~ /\A\$ (.*?)\n/
29
- command = $1
30
- expected = $'
31
- if ruby19?
32
- case @name
33
- when 'test_main_program1_result'
34
- expected.sub!('["eruby", "items", "x", "_buf"]', '[:_buf, :eruby, :items, :x]')
35
- when 'test_main_program2_result'
36
- expected.sub!('["_context", "x", "_buf"]', '[:_buf, :x, :_context]')
37
- end
38
- elsif rubinius?
39
- command.sub!(/^ruby\b/, 'rbx')
40
- case @name
41
- when 'test_main_program1_result'
42
- expected.sub!('["eruby", "items", "x", "_buf"]', '["_buf", "eruby", "items", "x"]')
43
- when 'test_main_program2_result'
44
- expected.sub!('["_context", "x", "_buf"]', '["_buf", "x", "_context"]')
45
- end
46
- end
47
- result = `#{command}`
48
- assert_text_equal(expected, result)
49
- end
50
-
51
-
52
- Dir.chdir DIR do
53
- filenames = []
54
- filenames += Dir.glob('*.result')
55
- filenames += Dir.glob('*.source')
56
- filenames.each do |filename|
57
- name = filename.gsub(/[^\w]/, '_')
58
- s = <<-END
59
- def test_#{name}
60
- # $stderr.puts "*** debug: test_#{name}"
61
- @name = '#{name}'
62
- @filename = '#{filename}'
63
- _test()
64
- end
65
- END
66
- eval s
67
- end
68
- end
69
-
70
-
71
- self.post_definition()
72
-
73
- end
@@ -1,45 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
-
7
- unless defined?(TESTDIR)
8
- TESTDIR = File.dirname(__FILE__)
9
- LIBDIR = TESTDIR == '.' ? '../lib' : File.dirname(TESTDIR) + '/lib'
10
- $: << TESTDIR
11
- $: << LIBDIR
12
- end
13
-
14
-
15
- require 'test/unit'
16
- #require 'test/unit/ui/console/testrunner'
17
- require 'assert-text-equal'
18
- require 'yaml'
19
- require 'testutil'
20
- require 'erubis'
21
-
22
-
23
- Test::Unit::TestCase.class_eval do
24
- if RUBY_VERSION >= "1.9"
25
- ## minitest doesn't have 'name()' method
26
- def name
27
- @name || @__name__
28
- end
29
- def ruby19
30
- yield
31
- end
32
- else
33
- def ruby19
34
- end
35
- end
36
- end
37
-
38
-
39
- if $0 == __FILE__
40
- require "#{TESTDIR}/test-erubis.rb"
41
- require "#{TESTDIR}/test-engines.rb"
42
- require "#{TESTDIR}/test-enhancers.rb"
43
- require "#{TESTDIR}/test-main.rb"
44
- require "#{TESTDIR}/test-users-guide.rb"
45
- end
@@ -1,111 +0,0 @@
1
- ###
2
- ### $Release: 2.7.0 $
3
- ### copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ###
5
-
6
- require 'yaml'
7
-
8
- require 'test/unit/testcase'
9
-
10
-
11
-
12
- def ruby18? # :nodoc:
13
- RUBY_VERSION =~ /\A1.8/
14
- end
15
-
16
- def ruby19? # :nodoc:
17
- RUBY_VERSION =~ /\A1.9/
18
- end
19
-
20
- def rubinius? # :nodoc:
21
- defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
22
- end
23
-
24
-
25
-
26
- class Test::Unit::TestCase
27
-
28
-
29
- def self.load_yaml_datafile(filename, options={}, &block) # :nodoc:
30
- # read datafile
31
- s = File.read(filename)
32
- if filename =~ /\.rb$/
33
- s =~ /^__END__$/ or raise "*** error: __END__ is not found in '#{filename}'."
34
- s = $'
35
- end
36
- # untabify
37
- s = _untabify(s) unless options[:tabify] == false
38
- # load yaml document
39
- testdata_list = []
40
- YAML.load_documents(s) do |ydoc|
41
- if ydoc.is_a?(Hash)
42
- testdata_list << ydoc
43
- elsif ydoc.is_a?(Array)
44
- ydoc.each do |hash|
45
- raise "testdata should be a mapping." unless hash.is_a?(Hash)
46
- testdata_list << hash
47
- end
48
- else
49
- raise "testdata should be a mapping."
50
- end
51
- end
52
- # data check
53
- identkey = options[:identkey] || 'name'
54
- table = {}
55
- testdata_list.each do |hash|
56
- ident = hash[identkey]
57
- ident or raise "*** key '#{identkey}' is required but not found."
58
- table[ident] and raise "*** #{identkey} '#{ident}' is duplicated."
59
- table[ident] = hash
60
- yield(hash) if block
61
- end
62
- #
63
- return testdata_list
64
- end
65
-
66
-
67
- def self.define_testmethods(testdata_list, options={}, &block)
68
- identkey = options[:identkey] || 'name'
69
- testmethod = options[:testmethod] || '_test'
70
- testdata_list.each do |hash|
71
- yield(hash) if block
72
- ident = hash[identkey]
73
- s = "def test_#{ident}\n"
74
- hash.each do |key, val|
75
- s << " @#{key} = #{val.inspect}\n"
76
- end
77
- s << " #{testmethod}\n"
78
- s << "end\n"
79
- $stderr.puts "*** load_yaml_testdata(): eval_str=<<'END'\n#{s}END" if $DEBUG
80
- self.module_eval s
81
- end
82
- end
83
-
84
-
85
- def self.post_definition
86
- if ENV['TEST']
87
- target = "test_#{ENV['TEST']}"
88
- self.instance_methods.each do |method_name|
89
- m = method_name.to_s
90
- private m if m =~ /\Atest_/ && m != target
91
- end
92
- end
93
- end
94
-
95
-
96
- def self._untabify(str, width=8)
97
- return str if str.nil?
98
- list = str.split(/\t/, -1) # if 2nd arg is negative then split() doesn't remove tailing empty strings
99
- last = list.pop
100
- sb = ''
101
- list.each do |s|
102
- column = (n = s.rindex(?\n)) ? s.length - n - 1 : s.length
103
- n = width - (column % width)
104
- sb << s << (' ' * n)
105
- end
106
- sb << last if last
107
- return sb
108
- end
109
-
110
-
111
- end