erubis 2.6.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +16 -2
- data/README.txt +2 -1
- data/benchmark/bench.rb +1 -1
- data/bin/erubis +1 -1
- data/contrib/erubis +1 -1
- data/contrib/inline-require +1 -1
- data/doc-api/classes/Erubis.html +1 -1
- data/doc-api/classes/Erubis/Basic/Converter.html +3 -2
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +6 -3
- data/doc-api/classes/Erubis/DeleteIndentEnhancer.html +1 -1
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +6 -3
- data/doc-api/classes/Erubis/InterpolationEnhancer.html +7 -6
- data/doc-api/classes/Erubis/Main.html +26 -26
- data/doc-api/classes/Erubis/PI/Converter.html +5 -4
- data/doc-api/classes/Erubis/PI/TinyEruby.html +6 -5
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +3 -2
- data/doc-api/classes/Erubis/RubyEvaluator.html +18 -13
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +2 -1
- data/doc-api/classes/Erubis/TinyEruby.html +4 -3
- data/doc-api/created.rid +1 -1
- data/doc-api/files/README_txt.html +4 -3
- data/doc-api/files/erubis/context_rb.html +1 -1
- data/doc-api/files/erubis/converter_rb.html +2 -2
- data/doc-api/files/erubis/engine/ec_rb.html +1 -1
- data/doc-api/files/erubis/engine/ejava_rb.html +1 -1
- data/doc-api/files/erubis/engine/ejavascript_rb.html +1 -1
- data/doc-api/files/erubis/engine/enhanced_rb.html +1 -1
- data/doc-api/files/erubis/engine/eperl_rb.html +1 -1
- data/doc-api/files/erubis/engine/ephp_rb.html +1 -1
- data/doc-api/files/erubis/engine/eruby_rb.html +1 -1
- data/doc-api/files/erubis/engine/escheme_rb.html +1 -1
- data/doc-api/files/erubis/engine/optimized_rb.html +1 -1
- data/doc-api/files/erubis/engine_rb.html +1 -1
- data/doc-api/files/erubis/enhancer_rb.html +2 -2
- data/doc-api/files/erubis/error_rb.html +1 -1
- data/doc-api/files/erubis/evaluator_rb.html +2 -2
- data/doc-api/files/erubis/generator_rb.html +1 -1
- data/doc-api/files/erubis/helper_rb.html +1 -1
- data/doc-api/files/erubis/helpers/rails_form_helper_rb.html +1 -1
- data/doc-api/files/erubis/helpers/rails_helper_rb.html +1 -1
- data/doc-api/files/erubis/local-setting_rb.html +1 -1
- data/doc-api/files/erubis/main_rb.html +2 -2
- data/doc-api/files/erubis/preprocessing_rb.html +1 -1
- data/doc-api/files/erubis/tiny_rb.html +2 -2
- data/doc-api/files/erubis_rb.html +1 -1
- data/doc/users-guide.html +13 -11
- data/lib/erubis.rb +2 -2
- data/lib/erubis/context.rb +1 -1
- data/lib/erubis/converter.rb +6 -4
- data/lib/erubis/engine.rb +1 -1
- data/lib/erubis/engine/ec.rb +1 -1
- data/lib/erubis/engine/ejava.rb +1 -1
- data/lib/erubis/engine/ejavascript.rb +1 -1
- data/lib/erubis/engine/enhanced.rb +1 -1
- data/lib/erubis/engine/eperl.rb +1 -1
- data/lib/erubis/engine/ephp.rb +1 -1
- data/lib/erubis/engine/eruby.rb +1 -1
- data/lib/erubis/engine/escheme.rb +1 -1
- data/lib/erubis/engine/optimized.rb +1 -1
- data/lib/erubis/enhancer.rb +16 -7
- data/lib/erubis/error.rb +1 -1
- data/lib/erubis/evaluator.rb +17 -12
- data/lib/erubis/generator.rb +1 -1
- data/lib/erubis/helper.rb +1 -1
- data/lib/erubis/helpers/rails_form_helper.rb +1 -1
- data/lib/erubis/helpers/rails_helper.rb +1 -1
- data/lib/erubis/local-setting.rb +1 -1
- data/lib/erubis/main.rb +32 -31
- data/lib/erubis/preprocessing.rb +1 -1
- data/lib/erubis/tiny.rb +6 -4
- data/test/assert-text-equal.rb +1 -1
- data/test/assert-text-equal.rbc +0 -0
- data/test/data/users-guide/example1.rb +1 -0
- data/test/data/users-guide/main_program2.result +1 -1
- data/test/hoge.rb +5 -0
- data/test/test-engines.rb +5 -2
- data/test/test-engines.rbc +0 -0
- data/test/test-enhancers.rb +4 -2
- data/test/test-erubis.rb +11 -5
- data/test/test-erubis.rbc +0 -0
- data/test/test-main.rb +27 -6
- data/test/test-users-guide.rb +4 -2
- data/test/test-users-guide.rbc +0 -0
- data/test/test.rb +1 -1
- data/test/test.rbc +0 -0
- data/test/testutil.rb +29 -3
- data/test/testutil.rbc +0 -0
- metadata +9 -4
- data/lib/erubis/converter.rb: +0 -0
- data/test/data/users-guide/stderr.log +0 -3
data/lib/erubis/context.rb
CHANGED
data/lib/erubis/converter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.6.
|
2
|
+
## $Rev: 115 $
|
3
|
+
## $Release: 2.6.2 $
|
4
4
|
## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -168,7 +168,8 @@ module Erubis
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
171
|
-
rest = $' || input
|
171
|
+
#rest = $' || input # ruby1.8
|
172
|
+
rest = pos == 0 ? input : input[pos..-1] # ruby1.9
|
172
173
|
add_text(src, rest)
|
173
174
|
end
|
174
175
|
|
@@ -264,7 +265,8 @@ module Erubis
|
|
264
265
|
add_pi_expr(codebuf, expr1 || expr2, indicator1 || indicator2)
|
265
266
|
end
|
266
267
|
end
|
267
|
-
rest = $' || input
|
268
|
+
#rest = $' || input # ruby1.8
|
269
|
+
rest = pos == 0 ? input : input[pos..-1] # ruby1.9
|
268
270
|
add_text(codebuf, rest)
|
269
271
|
end
|
270
272
|
|
data/lib/erubis/engine.rb
CHANGED
data/lib/erubis/engine/ec.rb
CHANGED
data/lib/erubis/engine/ejava.rb
CHANGED
data/lib/erubis/engine/eperl.rb
CHANGED
data/lib/erubis/engine/ephp.rb
CHANGED
data/lib/erubis/engine/eruby.rb
CHANGED
data/lib/erubis/enhancer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.6.
|
2
|
+
## $Rev: 115 $
|
3
|
+
## $Release: 2.6.2 $
|
4
4
|
## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -360,7 +360,8 @@ module Erubis
|
|
360
360
|
add_expr(src, code, indicator)
|
361
361
|
end
|
362
362
|
end
|
363
|
-
rest = $' || input
|
363
|
+
#rest = $' || input # ruby1.8
|
364
|
+
rest = pos == 0 ? input : input[pos..-1] # ruby1.9
|
364
365
|
add_text(src, rest)
|
365
366
|
add_postamble(src)
|
366
367
|
return src
|
@@ -419,11 +420,14 @@ module Erubis
|
|
419
420
|
|
420
421
|
def add_text(src, text)
|
421
422
|
return unless text
|
423
|
+
m = nil
|
422
424
|
text.scan(@bipattern_regexp) do |txt, indicator, code|
|
425
|
+
m = Regexp.last_match
|
423
426
|
super(src, txt)
|
424
427
|
add_expr(src, code, '=' + indicator)
|
425
428
|
end
|
426
|
-
rest = $' || text
|
429
|
+
#rest = $' || text # ruby1.8
|
430
|
+
rest = m ? text[m.end(0)..-1] : text # ruby1.9
|
427
431
|
super(src, rest)
|
428
432
|
end
|
429
433
|
|
@@ -465,7 +469,8 @@ module Erubis
|
|
465
469
|
add_stmt(src, line)
|
466
470
|
end
|
467
471
|
end
|
468
|
-
rest = pos == 0 ? text : $'
|
472
|
+
#rest = pos == 0 ? text : $' # ruby1.8
|
473
|
+
rest = pos == 0 ? text : text[pos..-1] # ruby1.9
|
469
474
|
unless text2.empty?
|
470
475
|
text2 << rest if rest
|
471
476
|
rest = text2
|
@@ -535,7 +540,9 @@ module Erubis
|
|
535
540
|
HEADER_FOOTER_PATTERN = /(.*?)(^[ \t]*)?<!--\#(\w+):(.*?)\#-->([ \t]*\r?\n)?/m
|
536
541
|
|
537
542
|
def add_text(src, text)
|
543
|
+
m = nil
|
538
544
|
text.scan(HEADER_FOOTER_PATTERN) do |txt, lspace, word, content, rspace|
|
545
|
+
m = Regexp.last_match
|
539
546
|
flag_trim = @trim && lspace && rspace
|
540
547
|
super(src, txt)
|
541
548
|
content = "#{lspace}#{content}#{rspace}" if flag_trim
|
@@ -543,7 +550,8 @@ module Erubis
|
|
543
550
|
instance_variable_set("@#{word}", content)
|
544
551
|
super(src, rspace) if !flag_trim && rspace
|
545
552
|
end
|
546
|
-
rest = $' || text
|
553
|
+
#rest = $' || text # ruby1.8
|
554
|
+
rest = m ? text[m.end(0)..-1] : text # ruby1.9
|
547
555
|
super(src, rest)
|
548
556
|
end
|
549
557
|
|
@@ -636,7 +644,8 @@ module Erubis
|
|
636
644
|
end
|
637
645
|
end
|
638
646
|
end
|
639
|
-
rest = $' || input
|
647
|
+
#rest = $' || input # ruby1.8
|
648
|
+
rest = pos == 0 ? input : input[pos..-1] # ruby1.9
|
640
649
|
_add_text_to_str(str, rest)
|
641
650
|
add_text(src, str)
|
642
651
|
end
|
data/lib/erubis/error.rb
CHANGED
data/lib/erubis/evaluator.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.6.
|
2
|
+
## $Rev: 115 $
|
3
|
+
## $Release: 2.6.2 $
|
4
4
|
## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -54,20 +54,25 @@ module Erubis
|
|
54
54
|
def result(_binding_or_hash=TOPLEVEL_BINDING)
|
55
55
|
_arg = _binding_or_hash
|
56
56
|
if _arg.is_a?(Hash)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
_b = binding()
|
58
|
+
eval _arg.collect{|k,v| "#{k} = _arg[#{k.inspect}]; "}.join, _b
|
59
|
+
elsif _arg.is_a?(Binding)
|
60
|
+
_b = _arg
|
61
|
+
elsif _arg.nil?
|
62
|
+
_b = binding()
|
63
|
+
else
|
64
|
+
raise ArgumentError.new("#{self.class.name}#result(): argument should be Binding or Hash but passed #{_arg.class.name} object.")
|
61
65
|
end
|
62
|
-
return eval(@src,
|
66
|
+
return eval(@src, _b, (@filename || '(erubis'))
|
63
67
|
end
|
64
68
|
|
65
69
|
## invoke context.instance_eval(@src)
|
66
|
-
def evaluate(
|
67
|
-
|
68
|
-
#return
|
69
|
-
|
70
|
-
|
70
|
+
def evaluate(_context=Context.new)
|
71
|
+
_context = Context.new(_context) if _context.is_a?(Hash)
|
72
|
+
#return _context.instance_eval(@src, @filename || '(erubis)')
|
73
|
+
#@_proc ||= eval("proc { #{@src} }", Erubis::EMPTY_BINDING, @filename || '(erubis)')
|
74
|
+
@_proc ||= eval("proc { #{@src} }", binding(), @filename || '(erubis)')
|
75
|
+
return _context.instance_eval(&@_proc)
|
71
76
|
end
|
72
77
|
|
73
78
|
## if object is an Class or Module then define instance method to it,
|
data/lib/erubis/generator.rb
CHANGED
data/lib/erubis/helper.rb
CHANGED
data/lib/erubis/local-setting.rb
CHANGED
data/lib/erubis/main.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 2.6.
|
2
|
+
### $Rev: 116 $
|
3
|
+
### $Release: 2.6.2 $
|
4
4
|
### copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
5
5
|
###
|
6
6
|
|
@@ -52,34 +52,34 @@ module Erubis
|
|
52
52
|
@single_options = "hvxztTSbeBXNUC"
|
53
53
|
@arg_options = "pcrfKIlaE" #C
|
54
54
|
@option_names = {
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
55
|
+
'h' => :help,
|
56
|
+
'v' => :version,
|
57
|
+
'x' => :source,
|
58
|
+
'z' => :syntax,
|
59
|
+
'T' => :unexpand,
|
60
|
+
't' => :untabify, # obsolete
|
61
|
+
'S' => :intern,
|
62
|
+
'b' => :bodyonly,
|
63
|
+
'B' => :binding,
|
64
|
+
'p' => :pattern,
|
65
|
+
'c' => :context,
|
66
|
+
#'C' => :class,
|
67
|
+
'e' => :escape,
|
68
|
+
'r' => :requires,
|
69
|
+
'f' => :datafiles,
|
70
|
+
'K' => :kanji,
|
71
|
+
'I' => :includes,
|
72
|
+
'l' => :lang,
|
73
|
+
'a' => :action,
|
74
|
+
'E' => :enhancers,
|
75
|
+
'X' => :notext,
|
76
|
+
'N' => :linenum,
|
77
|
+
'U' => :unique,
|
78
|
+
'C' => :compact,
|
79
79
|
}
|
80
80
|
assert unless @single_options.length + @arg_options.length == @option_names.length
|
81
81
|
(@single_options + @arg_options).each_byte do |ch|
|
82
|
-
assert unless @option_names.key?(ch)
|
82
|
+
assert unless @option_names.key?(ch.chr)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -88,7 +88,7 @@ module Erubis
|
|
88
88
|
## parse command-line options
|
89
89
|
options, properties = parse_argv(argv, @single_options, @arg_options)
|
90
90
|
filenames = argv
|
91
|
-
options[
|
91
|
+
options['h'] = true if properties[:help]
|
92
92
|
opts = Object.new
|
93
93
|
arr = @option_names.collect { |ch, name| "def #{name}; @#{name}; end\n" }
|
94
94
|
opts.instance_eval arr.join
|
@@ -287,7 +287,7 @@ module Erubis
|
|
287
287
|
s = "enhancers:\n"
|
288
288
|
list = []
|
289
289
|
ObjectSpace.each_object(Module) do |m| list << m end
|
290
|
-
list.sort_by { |m| m.name }.each do |m|
|
290
|
+
list.sort_by { |m| m.name.to_s }.each do |m|
|
291
291
|
next unless m.name =~ /\AErubis::(.*)Enhancer\z/
|
292
292
|
name = $1
|
293
293
|
desc = m.desc
|
@@ -319,7 +319,7 @@ module Erubis
|
|
319
319
|
#
|
320
320
|
else # options
|
321
321
|
while optstr && !optstr.empty?
|
322
|
-
optchar = optstr[0]
|
322
|
+
optchar = optstr[0].chr
|
323
323
|
optstr[0,1] = ""
|
324
324
|
if arg_none.include?(optchar)
|
325
325
|
options[optchar] = true
|
@@ -472,7 +472,8 @@ module Erubis
|
|
472
472
|
|
473
473
|
def check_syntax(filename, src)
|
474
474
|
require 'open3'
|
475
|
-
|
475
|
+
command = (ENV['_'] || 'ruby') + ' -wc' # ENV['_'] stores command name
|
476
|
+
stdin, stdout, stderr = Open3.popen3(command)
|
476
477
|
stdin.write(src)
|
477
478
|
stdin.close
|
478
479
|
result = stdout.read()
|
data/lib/erubis/preprocessing.rb
CHANGED
data/lib/erubis/tiny.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 2.6.
|
2
|
+
## $Rev: 115 $
|
3
|
+
## $Release: 2.6.2 $
|
4
4
|
## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
5
5
|
##
|
6
6
|
|
@@ -43,7 +43,8 @@ module Erubis
|
|
43
43
|
src << " _buf << (" << code << ").to_s;"
|
44
44
|
end
|
45
45
|
end
|
46
|
-
rest = $' || input
|
46
|
+
#rest = $' || input # ruby1.8
|
47
|
+
rest = pos == 0 ? input : input[pos..-1] # ruby1.9
|
47
48
|
#src << " _buf << '" << escape_text(rest) << "';"
|
48
49
|
rest.gsub!(/['\\]/, '\\\\\&')
|
49
50
|
src << " _buf << '" << rest << "';" unless rest.empty?
|
@@ -113,7 +114,8 @@ module Erubis
|
|
113
114
|
end
|
114
115
|
end
|
115
116
|
end
|
116
|
-
rest = $' || input
|
117
|
+
#rest = $' || input # ruby1.8
|
118
|
+
rest = pos == 0 ? input : input[pos..-1] # ruby1.9
|
117
119
|
#src << " _buf << '" << escape_text(rest) << "';"
|
118
120
|
rest.gsub!(/['\\]/, '\\\\\&')
|
119
121
|
src << " _buf << '" << rest << "';" unless rest.empty?
|