erbse 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +3 -0
- data/Gemfile +3 -0
- data/README.md +40 -22
- data/Rakefile +13 -0
- data/lib/erbse.rb +3 -6
- data/lib/erbse/converter.rb +41 -241
- data/lib/erbse/eruby.rb +114 -0
- data/lib/erbse/template.rb +14 -0
- data/lib/erbse/version.rb +1 -1
- data/test/erbse_test.rb +14 -0
- data/test/test_helper.rb +2 -0
- metadata +9 -149
- data/CHANGES.txt +0 -828
- data/bin/erubis +0 -10
- data/lib/erbse/context.rb +0 -83
- data/lib/erbse/engine.rb +0 -114
- data/lib/erbse/engine/ec.rb +0 -117
- data/lib/erbse/engine/ecpp.rb +0 -113
- data/lib/erbse/engine/ejava.rb +0 -110
- data/lib/erbse/engine/ejavascript.rb +0 -119
- data/lib/erbse/engine/enhanced.rb +0 -126
- data/lib/erbse/engine/eperl.rb +0 -95
- data/lib/erbse/engine/ephp.rb +0 -99
- data/lib/erbse/engine/eruby.rb +0 -119
- data/lib/erbse/engine/escheme.rb +0 -114
- data/lib/erbse/engine/optimized.rb +0 -127
- data/lib/erbse/enhancer.rb +0 -723
- data/lib/erbse/error.rb +0 -23
- data/lib/erbse/evaluator.rb +0 -88
- data/lib/erbse/generator.rb +0 -85
- data/lib/erbse/helper.rb +0 -47
- data/lib/erbse/helpers/rails_form_helper.rb +0 -197
- data/lib/erbse/helpers/rails_helper.rb +0 -353
- data/lib/erbse/main.rb +0 -516
- data/lib/erbse/preprocessing.rb +0 -58
- data/lib/erbse/tiny.rb +0 -144
- data/lib/erbse/util.rb +0 -22
- data/test/assert-text-equal.rb +0 -44
- data/test/data/users-guide/Example.ejava +0 -55
- data/test/data/users-guide/array_example.result +0 -9
- data/test/data/users-guide/arraybuffer_example.result +0 -9
- data/test/data/users-guide/bipattern-example.rhtml +0 -4
- data/test/data/users-guide/bipattern_example.result +0 -6
- data/test/data/users-guide/bufvar-example.rb +0 -10
- data/test/data/users-guide/bufvar-example.result +0 -17
- data/test/data/users-guide/context.rb +0 -6
- data/test/data/users-guide/context.yaml +0 -8
- data/test/data/users-guide/def_method.rb +0 -14
- data/test/data/users-guide/def_method.result +0 -3
- data/test/data/users-guide/escape_example.result +0 -9
- data/test/data/users-guide/example.ec +0 -27
- data/test/data/users-guide/example.ecpp +0 -30
- data/test/data/users-guide/example.ejs +0 -20
- data/test/data/users-guide/example.eperl +0 -18
- data/test/data/users-guide/example.ephp +0 -18
- data/test/data/users-guide/example.eruby +0 -6
- data/test/data/users-guide/example.escheme +0 -28
- data/test/data/users-guide/example1.eruby +0 -6
- data/test/data/users-guide/example1.rb +0 -17
- data/test/data/users-guide/example1.result +0 -16
- data/test/data/users-guide/example10.rb +0 -4
- data/test/data/users-guide/example10.result +0 -17
- data/test/data/users-guide/example10.xhtml +0 -14
- data/test/data/users-guide/example10_x.result +0 -17
- data/test/data/users-guide/example11.php +0 -20
- data/test/data/users-guide/example11.result +0 -23
- data/test/data/users-guide/example11.rhtml +0 -21
- data/test/data/users-guide/example11_C.result +0 -10
- data/test/data/users-guide/example11_N.result +0 -16
- data/test/data/users-guide/example11_U.result +0 -16
- data/test/data/users-guide/example11_php.result +0 -15
- data/test/data/users-guide/example1_x.result +0 -9
- data/test/data/users-guide/example2.eruby +0 -7
- data/test/data/users-guide/example2.rb +0 -10
- data/test/data/users-guide/example2.result +0 -27
- data/test/data/users-guide/example2_trim.result +0 -10
- data/test/data/users-guide/example2_x.result +0 -10
- data/test/data/users-guide/example3.eruby +0 -6
- data/test/data/users-guide/example3.rb +0 -10
- data/test/data/users-guide/example31.result +0 -22
- data/test/data/users-guide/example32.result +0 -4
- data/test/data/users-guide/example3_e.result +0 -8
- data/test/data/users-guide/example4.eruby +0 -3
- data/test/data/users-guide/example4.rb +0 -11
- data/test/data/users-guide/example4.result +0 -10
- data/test/data/users-guide/example4_x.result +0 -5
- data/test/data/users-guide/example5.eruby +0 -6
- data/test/data/users-guide/example5.rb +0 -16
- data/test/data/users-guide/example5.result +0 -7
- data/test/data/users-guide/example6.rb +0 -12
- data/test/data/users-guide/example6.result +0 -7
- data/test/data/users-guide/example7.eruby +0 -8
- data/test/data/users-guide/example71.result +0 -13
- data/test/data/users-guide/example72.result +0 -13
- data/test/data/users-guide/example8.eruby +0 -6
- data/test/data/users-guide/example8_ruby.result +0 -7
- data/test/data/users-guide/example8_yaml.result +0 -7
- data/test/data/users-guide/example9.eruby +0 -3
- data/test/data/users-guide/example9.rb +0 -8
- data/test/data/users-guide/example9.result +0 -9
- data/test/data/users-guide/example91.result +0 -5
- data/test/data/users-guide/example92.result +0 -4
- data/test/data/users-guide/example_c.result +0 -32
- data/test/data/users-guide/example_java.result +0 -56
- data/test/data/users-guide/example_js.result +0 -22
- data/test/data/users-guide/example_perl.result +0 -20
- data/test/data/users-guide/example_php.result +0 -19
- data/test/data/users-guide/example_scheme.result +0 -30
- data/test/data/users-guide/example_scheme_display.result +0 -29
- data/test/data/users-guide/fasteruby-example.rb +0 -8
- data/test/data/users-guide/fasteruby-example.result +0 -18
- data/test/data/users-guide/fasteruby.rb +0 -11
- data/test/data/users-guide/fasteruby.result +0 -38
- data/test/data/users-guide/fasteruby.rhtml +0 -15
- data/test/data/users-guide/headerfooter-example.eruby +0 -9
- data/test/data/users-guide/headerfooter-example2.rb +0 -8
- data/test/data/users-guide/headerfooter-example2.rhtml +0 -10
- data/test/data/users-guide/headerfooter_example.result +0 -11
- data/test/data/users-guide/headerfooter_example2.result +0 -13
- data/test/data/users-guide/interpolation_example.result +0 -9
- data/test/data/users-guide/main_program1.rb +0 -8
- data/test/data/users-guide/main_program1.result +0 -6
- data/test/data/users-guide/main_program2.rb +0 -8
- data/test/data/users-guide/main_program2.result +0 -6
- data/test/data/users-guide/nocode-example.eruby +0 -14
- data/test/data/users-guide/nocode-php.result +0 -20
- data/test/data/users-guide/nocode_example.result +0 -15
- data/test/data/users-guide/normal-eruby-test.eruby +0 -9
- data/test/data/users-guide/normal_eruby_test.result +0 -11
- data/test/data/users-guide/notext-example.eruby +0 -14
- data/test/data/users-guide/notext-example.php +0 -19
- data/test/data/users-guide/notext-php.result +0 -20
- data/test/data/users-guide/notext_example.result +0 -16
- data/test/data/users-guide/percentline-example.rhtml +0 -6
- data/test/data/users-guide/percentline_example.result +0 -9
- data/test/data/users-guide/prefixedline-example.rb +0 -9
- data/test/data/users-guide/prefixedline-example.rhtml +0 -6
- data/test/data/users-guide/prefixedline_example.result +0 -9
- data/test/data/users-guide/printenable_example.result +0 -4
- data/test/data/users-guide/printenabled-example.eruby +0 -3
- data/test/data/users-guide/printenabled-example.rb +0 -8
- data/test/data/users-guide/printstatement_example.result +0 -8
- data/test/data/users-guide/simplify_example.result +0 -9
- data/test/data/users-guide/stderr.log +0 -3
- data/test/data/users-guide/stdout_exmple.result +0 -9
- data/test/data/users-guide/stringbuffer_example.result +0 -9
- data/test/data/users-guide/tail_260.result +0 -4
- data/test/data/users-guide/tailnewline.rhtml +0 -3
- data/test/data/users-guide/template1.rhtml +0 -4
- data/test/data/users-guide/template2.rhtml +0 -4
- data/test/test-engines.rb +0 -425
- data/test/test-enhancers.rb +0 -646
- data/test/test-erubis.rb +0 -887
- data/test/test-index-cgi.rb +0 -191
- data/test/test-main.rb +0 -752
- data/test/test-users-guide.rb +0 -73
- data/test/test.rb +0 -45
- data/test/testutil.rb +0 -111
data/test/test-users-guide.rb
DELETED
@@ -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
|
data/test/test.rb
DELETED
@@ -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
|
data/test/testutil.rb
DELETED
@@ -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
|