erubis 2.6.4 → 2.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/CHANGES.txt +9 -2
  2. data/README.txt +1 -1
  3. data/benchmark/bench.rb +1 -2
  4. data/bin/erubis +1 -2
  5. data/contrib/erubis +43 -68
  6. data/contrib/inline-require +53 -27
  7. data/doc-api/classes/ActionView/TemplateHandlers/ErubisHandler.html +3 -3
  8. data/doc-api/classes/Erubis.html +1 -1
  9. data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +2 -2
  10. data/doc-api/classes/Erubis/ArrayEnhancer.html +2 -2
  11. data/doc-api/classes/Erubis/Basic/Converter.html +4 -4
  12. data/doc-api/classes/Erubis/BiPatternEnhancer.html +2 -2
  13. data/doc-api/classes/Erubis/CGenerator.html +10 -10
  14. data/doc-api/classes/Erubis/Context.html +7 -7
  15. data/doc-api/classes/Erubis/Converter.html +4 -4
  16. data/doc-api/classes/Erubis/DeleteIndentEnhancer.html +1 -1
  17. data/doc-api/classes/Erubis/Engine.html +5 -5
  18. data/doc-api/classes/Erubis/ErboutEnhancer.html +2 -2
  19. data/doc-api/classes/Erubis/EscapeEnhancer.html +1 -1
  20. data/doc-api/classes/Erubis/Evaluator.html +3 -3
  21. data/doc-api/classes/Erubis/Generator.html +10 -10
  22. data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +2 -2
  23. data/doc-api/classes/Erubis/Helpers/RailsFormHelper.html +25 -25
  24. data/doc-api/classes/Erubis/Helpers/RailsHelper.html +8 -8
  25. data/doc-api/classes/Erubis/Helpers/RailsHelper/TemplateConverter.html +4 -4
  26. data/doc-api/classes/Erubis/InterpolationEnhancer.html +5 -5
  27. data/doc-api/classes/Erubis/JavaGenerator.html +9 -9
  28. data/doc-api/classes/Erubis/JavascriptGenerator.html +10 -10
  29. data/doc-api/classes/Erubis/Main.html +6 -5
  30. data/doc-api/classes/Erubis/NoCodeEnhancer.html +5 -5
  31. data/doc-api/classes/Erubis/NoTextEnhancer.html +1 -1
  32. data/doc-api/classes/Erubis/OptimizedEruby.html +1 -1
  33. data/doc-api/classes/Erubis/OptimizedGenerator.html +12 -12
  34. data/doc-api/classes/Erubis/OptimizedXmlEruby.html +1 -1
  35. data/doc-api/classes/Erubis/PI/Converter.html +3 -3
  36. data/doc-api/classes/Erubis/PI/Ec.html +1 -1
  37. data/doc-api/classes/Erubis/PI/Ejava.html +1 -1
  38. data/doc-api/classes/Erubis/PI/Ejavascript.html +1 -1
  39. data/doc-api/classes/Erubis/PI/Eperl.html +1 -1
  40. data/doc-api/classes/Erubis/PI/Ephp.html +1 -1
  41. data/doc-api/classes/Erubis/PI/Eruby.html +1 -1
  42. data/doc-api/classes/Erubis/PI/Escheme.html +1 -1
  43. data/doc-api/classes/Erubis/PI/TinyEruby.html +4 -4
  44. data/doc-api/classes/Erubis/PercentLineEnhancer.html +1 -1
  45. data/doc-api/classes/Erubis/PerlGenerator.html +9 -9
  46. data/doc-api/classes/Erubis/PhpGenerator.html +9 -9
  47. data/doc-api/classes/Erubis/PreprocessingEruby.html +2 -2
  48. data/doc-api/classes/Erubis/PreprocessingHelper.html +3 -3
  49. data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +3 -3
  50. data/doc-api/classes/Erubis/PrintOutEnhancer.html +5 -5
  51. data/doc-api/classes/Erubis/RubyEvaluator.html +3 -3
  52. data/doc-api/classes/Erubis/RubyGenerator.html +8 -8
  53. data/doc-api/classes/Erubis/SchemeGenerator.html +10 -10
  54. data/doc-api/classes/Erubis/SimplifyEnhancer.html +1 -1
  55. data/doc-api/classes/Erubis/StdoutEnhancer.html +2 -2
  56. data/doc-api/classes/Erubis/StringBufferEnhancer.html +2 -2
  57. data/doc-api/classes/Erubis/TinyEruby.html +7 -8
  58. data/doc-api/classes/Erubis/XmlHelper.html +3 -3
  59. data/doc-api/created.rid +1 -1
  60. data/doc-api/files/README_txt.html +2 -2
  61. data/doc-api/files/erubis/context_rb.html +2 -2
  62. data/doc-api/files/erubis/converter_rb.html +2 -2
  63. data/doc-api/files/erubis/engine/ec_rb.html +2 -2
  64. data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
  65. data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
  66. data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
  67. data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
  68. data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
  69. data/doc-api/files/erubis/engine/eruby_rb.html +2 -2
  70. data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
  71. data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
  72. data/doc-api/files/erubis/engine_rb.html +2 -2
  73. data/doc-api/files/erubis/enhancer_rb.html +2 -2
  74. data/doc-api/files/erubis/error_rb.html +2 -2
  75. data/doc-api/files/erubis/evaluator_rb.html +2 -2
  76. data/doc-api/files/erubis/generator_rb.html +2 -2
  77. data/doc-api/files/erubis/helper_rb.html +2 -2
  78. data/doc-api/files/erubis/helpers/rails_form_helper_rb.html +2 -2
  79. data/doc-api/files/erubis/helpers/rails_helper_rb.html +2 -2
  80. data/doc-api/files/erubis/local-setting_rb.html +2 -2
  81. data/doc-api/files/erubis/main_rb.html +2 -2
  82. data/doc-api/files/erubis/preprocessing_rb.html +2 -2
  83. data/doc-api/files/erubis/tiny_rb.html +2 -2
  84. data/doc-api/files/erubis_rb.html +2 -2
  85. data/doc/users-guide.html +6 -6
  86. data/lib/erubis.rb +2 -3
  87. data/lib/erubis/context.rb +1 -2
  88. data/lib/erubis/converter.rb +1 -2
  89. data/lib/erubis/engine.rb +1 -2
  90. data/lib/erubis/engine/ec.rb +1 -2
  91. data/lib/erubis/engine/ejava.rb +1 -2
  92. data/lib/erubis/engine/ejavascript.rb +1 -2
  93. data/lib/erubis/engine/enhanced.rb +1 -2
  94. data/lib/erubis/engine/eperl.rb +1 -2
  95. data/lib/erubis/engine/ephp.rb +1 -2
  96. data/lib/erubis/engine/eruby.rb +1 -2
  97. data/lib/erubis/engine/escheme.rb +1 -2
  98. data/lib/erubis/engine/optimized.rb +1 -2
  99. data/lib/erubis/enhancer.rb +1 -2
  100. data/lib/erubis/error.rb +1 -2
  101. data/lib/erubis/evaluator.rb +1 -2
  102. data/lib/erubis/generator.rb +1 -2
  103. data/lib/erubis/helper.rb +1 -2
  104. data/lib/erubis/helpers/rails_form_helper.rb +1 -2
  105. data/lib/erubis/helpers/rails_helper.rb +1 -2
  106. data/lib/erubis/local-setting.rb +1 -2
  107. data/lib/erubis/main.rb +18 -21
  108. data/lib/erubis/preprocessing.rb +1 -2
  109. data/lib/erubis/tiny.rb +4 -6
  110. data/test/assert-text-equal.rb +1 -2
  111. data/test/test-engines.rb +1 -2
  112. data/test/test-enhancers.rb +1 -2
  113. data/test/test-erubis.rb +1 -2
  114. data/test/test-main.rb +36 -16
  115. data/test/test-users-guide.rb +1 -2
  116. data/test/test.rb +1 -2
  117. data/test/testutil.rb +3 -8
  118. metadata +2 -2
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Thu Jun 12 20:22:02 +0900 2008</td>
59
+ <td>Tue Jul 14 09:47:22 +0900 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -70,7 +70,7 @@
70
70
 
71
71
  <div id="description">
72
72
  <p>
73
- $Rev: 115 $ $Release: 2.6.4 $ copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
73
+ $Release: 2.6.5 $ copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
74
74
  </p>
75
75
 
76
76
  </div>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Wed Jan 30 23:27:58 +0900 2008</td>
59
+ <td>Tue Jul 14 09:47:22 +0900 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -70,7 +70,7 @@
70
70
 
71
71
  <div id="description">
72
72
  <p>
73
- $Rev: 99 $ $Release: 2.6.4 $ copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
73
+ $Release: 2.6.5 $ copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
74
74
  </p>
75
75
 
76
76
  </div>
@@ -14,10 +14,10 @@
14
14
 
15
15
  <div align="left"><h1>Erubis Users' Guide</h1></div>
16
16
  <div align="left">
17
- last update: $Date: 2008-06-13 08:04:21 +0900 (Fri, 13 Jun 2008) $<br>
17
+ last update: $Date$<br>
18
18
  </div>
19
19
 
20
- <p>release: 2.6.4
20
+ <p>release: 2.6.5
21
21
  </p>
22
22
  <a name="preface"></a>
23
23
  <h2 class="section1">Preface</h2>
@@ -2986,8 +2986,8 @@ example of using NoCodeEnhancer with PHP file</div>
2986
2986
  <p>Thanks Andrew R Jackson, he developed 'erubis-run.rb' which enables you to use Erubis with mod_ruby.
2987
2987
  </p>
2988
2988
  <ol type="1">
2989
- <li>Copy 'erubis-2.6.4/contrib/erubis-run.rb' to the 'RUBYLIBDIR/apache' directory (for example '/usr/local/lib/ruby/1.8/apache') which contains 'ruby-run.rb', 'eruby-run.rb', and so on.
2990
- <pre class="terminal">$ cd erubis-2.6.4/
2989
+ <li>Copy 'erubis-2.6.5/contrib/erubis-run.rb' to the 'RUBYLIBDIR/apache' directory (for example '/usr/local/lib/ruby/1.8/apache') which contains 'ruby-run.rb', 'eruby-run.rb', and so on.
2990
+ <pre class="terminal">$ cd erubis-2.6.5/
2991
2991
  $ sudo copy contrib/erubis-run.rb /usr/local/lib/ruby/1.8/apache/
2992
2992
  </pre>
2993
2993
  </li>
@@ -3063,12 +3063,12 @@ p obj.render('world') #=&gt; "hello world"
3063
3063
 
3064
3064
  <a name="topics-benchmark"></a>
3065
3065
  <h3 class="section2">Benchmark</h3>
3066
- <p>A benchmark script is included in Erubis package at 'erubis-2.6.4/benchark/' directory.
3066
+ <p>A benchmark script is included in Erubis package at 'erubis-2.6.5/benchark/' directory.
3067
3067
  Here is an example result of benchmark.
3068
3068
  </p>
3069
3069
  <div class="terminal_caption">
3070
3070
  MacOS X 10.4 Tiger, Intel CoreDuo 1.83GHz, Ruby1.8.6, eruby1.0.5, gcc4.0.1</div>
3071
- <pre class="terminal">$ cd erubis-2.6.4/benchmark/
3071
+ <pre class="terminal">$ cd erubis-2.6.5/benchmark/
3072
3072
  $ ruby bench.rb -n 10000 -m execute
3073
3073
  *** ntimes=10000, testmode=execute
3074
3074
  user system total real
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 99 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -48,7 +47,7 @@
48
47
 
49
48
 
50
49
  module Erubis
51
- VERSION = ('$Release: 2.6.4 $' =~ /([.\d]+)/) && $1
50
+ VERSION = ('$Release: 2.6.5 $' =~ /([.\d]+)/) && $1
52
51
  end
53
52
 
54
53
  require 'erubis/engine'
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 115 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 104 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 95 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 115 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 115 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 89 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ###
2
- ### $Rev: 109 $
3
- ### $Release: 2.6.4 $
2
+ ### $Release: 2.6.5 $
4
3
  ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ###
6
5
 
@@ -1,6 +1,5 @@
1
1
  ###
2
- ### $Rev: 127 $
3
- ### $Release: 2.6.4 $
2
+ ### $Release: 2.6.5 $
4
3
  ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ###
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 77 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ###
2
- ### $Rev: 122 $
3
- ### $Release: 2.6.4 $
2
+ ### $Release: 2.6.5 $
4
3
  ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ###
6
5
 
@@ -90,7 +89,7 @@ module Erubis
90
89
  filenames = argv
91
90
  options['h'] = true if properties[:help]
92
91
  opts = Object.new
93
- arr = @option_names.collect { |ch, name| "def #{name}; @#{name}; end\n" }
92
+ arr = @option_names.collect {|ch, name| "def #{name}; @#{name}; end\n" }
94
93
  opts.instance_eval arr.join
95
94
  options.each do |ch, val|
96
95
  name = @option_names[ch]
@@ -166,7 +165,8 @@ module Erubis
166
165
  msg = "Syntax OK\n"
167
166
  if filenames && !filenames.empty?
168
167
  filenames.each do |filename|
169
- test(?f, filename) or raise CommandOptionError.new("#{filename}: file not found.")
168
+ File.file?(filename) or
169
+ raise CommandOptionError.new("#{filename}: file not found.")
170
170
  engine.filename = filename
171
171
  engine.convert!(File.read(filename))
172
172
  val = do_action(action, engine, context, filename, opts)
@@ -284,14 +284,13 @@ module Erubis
284
284
  end
285
285
 
286
286
  def show_enhancers
287
+ dict = {}
288
+ ObjectSpace.each_object(Module) do |mod|
289
+ dict[$1] = mod if mod.name =~ /\AErubis::(.*)Enhancer\z/
290
+ end
287
291
  s = "enhancers:\n"
288
- list = []
289
- ObjectSpace.each_object(Module) do |m| list << m end
290
- list.sort_by { |m| m.name.to_s }.each do |m|
291
- next unless m.name =~ /\AErubis::(.*)Enhancer\z/
292
- name = $1
293
- desc = m.desc
294
- s << (" %-13s : %s\n" % [name, desc])
292
+ dict.sort_by {|name, mod| name }.each do |name, mod|
293
+ s << (" %-13s : %s\n" % [name, mod.desc])
295
294
  end
296
295
  return s
297
296
  end
@@ -308,10 +307,9 @@ module Erubis
308
307
  optstr = optstr[1, optstr.length-1]
309
308
  #
310
309
  if optstr[0] == ?- # context
311
- unless optstr =~ /\A\-([-\w]+)(?:=(.*))?/
310
+ optstr =~ /\A\-([-\w]+)(?:=(.*))?/ or
312
311
  raise CommandOptionError.new("-#{optstr}: invalid context value.")
313
- end
314
- name = $1; value = $2
312
+ name, value = $1, $2
315
313
  name = name.gsub(/-/, '_').intern
316
314
  #value = value.nil? ? true : YAML.load(value) # error, why?
317
315
  value = value.nil? ? true : YAML.load("---\n#{value}\n")
@@ -320,15 +318,12 @@ module Erubis
320
318
  else # options
321
319
  while optstr && !optstr.empty?
322
320
  optchar = optstr[0].chr
323
- optstr[0,1] = ""
321
+ optstr = optstr[1..-1]
324
322
  if arg_none.include?(optchar)
325
323
  options[optchar] = true
326
324
  elsif arg_required.include?(optchar)
327
- arg = optstr.empty? ? argv.shift : optstr
328
- unless arg
329
- mesg = "-#{optchar}: #{@option_names[optchar]} required."
330
- raise CommandOptionError.new(mesg)
331
- end
325
+ arg = optstr.empty? ? argv.shift : optstr or
326
+ raise CommandOptionError.new("-#{optchar}: #{@option_names[optchar]} required.")
332
327
  options[optchar] = arg
333
328
  optstr = nil
334
329
  elsif arg_optional.include?(optchar)
@@ -473,7 +468,9 @@ module Erubis
473
468
 
474
469
  def check_syntax(filename, src)
475
470
  require 'open3'
476
- command = (ENV['_'] || 'ruby') + ' -wc' # ENV['_'] stores command name
471
+ #command = (ENV['_'] || 'ruby') + ' -wc' # ENV['_'] stores command name
472
+ bin = ENV['_'] && File.basename(ENV['_']) =~ /^ruby/ ? ENV['_'] : 'ruby'
473
+ command = bin + ' -wc'
477
474
  stdin, stdout, stderr = Open3.popen3(command)
478
475
  stdin.write(src)
479
476
  stdin.close
@@ -1,6 +1,5 @@
1
1
  ###
2
- ### $Rev: 102 $
3
- ### $Release: 2.6.4 $
2
+ ### $Release: 2.6.5 $
4
3
  ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ###
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 115 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -28,10 +27,9 @@ module Erubis
28
27
  src = "_buf = '';" # preamble
29
28
  pos = 0
30
29
  input.scan(EMBEDDED_PATTERN) do |indicator, code|
31
- match = Regexp.last_match
32
- len = match.begin(0) - pos
33
- text = input[pos, len]
34
- pos = match.end(0)
30
+ m = Regexp.last_match
31
+ text = input[pos...m.begin(0)]
32
+ pos = m.end(0)
35
33
  #src << " _buf << '" << escape_text(text) << "';"
36
34
  text.gsub!(/['\\]/, '\\\\\&')
37
35
  src << " _buf << '" << text << "';" unless text.empty?
@@ -1,6 +1,5 @@
1
1
  ###
2
- ### $Rev: 77 $
3
- ### $Release: 2.6.4 $
2
+ ### $Release: 2.6.5 $
4
3
  ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ###
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 115 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 115 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,6 +1,5 @@
1
1
  ##
2
- ## $Rev: 115 $
3
- ## $Release: 2.6.4 $
2
+ ## $Release: 2.6.5 $
4
3
  ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
4
  ##
6
5
 
@@ -1,7 +1,7 @@
1
1
  ##
2
- ## $Rev: 122 $
3
- ## $Release: 2.6.4 $
4
- ## $Date: 2009-02-07 18:10:01 +0900 (Sat, 07 Feb 2009) $
2
+ ## $Rev$
3
+ ## $Release: 2.6.5 $
4
+ ## $Date$
5
5
  ##
6
6
 
7
7
  require "#{File.dirname(__FILE__)}/test.rb"
@@ -141,16 +141,12 @@ END
141
141
  END
142
142
 
143
143
  def _test()
144
- if $target
145
- name = (caller()[0] =~ /in `test_(.*?)'/) && $1
146
- return unless name == $target
147
- end
148
144
  if @filename.nil?
149
145
  method = (caller[0] =~ /in `(.*)'/) && $1 #'
150
146
  method =~ /block in (.*)/ and method = $1 # for Ruby 1.9
151
147
  @filename = "tmp.#{method}"
152
148
  end
153
- File.open(@filename, 'w') { |f| f.write(@input) } if @filename
149
+ File.open(@filename, 'w') {|f| f.write(@input) } if @filename
154
150
  begin
155
151
  argv = @options.is_a?(Array) ? @options.dup : @options.split
156
152
  argv << @filename if @filename
@@ -179,7 +175,7 @@ END
179
175
 
180
176
  def test_version # -v
181
177
  @options = '-v'
182
- @expected = (("$Release: 2.6.4 $" =~ /[.\d]+/) && $&) + "\n"
178
+ @expected = (("$Release: 2.6.5 $" =~ /[.\d]+/) && $&) + "\n"
183
179
  @filename = false
184
180
  _test()
185
181
  end
@@ -201,11 +197,35 @@ END
201
197
  end
202
198
 
203
199
 
200
+ def _with_dummy_file
201
+ bindir = File.join(File.dirname(File.dirname(__FILE__)), 'bin')
202
+ env_path = ENV['PATH']
203
+ env__ = ENV['_']
204
+ begin
205
+ ENV['PATH'] = bindir + File::PATH_SEPARATOR + ENV['PATH']
206
+ ENV['_'] = 'erubis'
207
+ Tempfile.open(self.name.gsub(/[^\w]/,'_')) do |f|
208
+ f.write(INPUT)
209
+ f.flush
210
+ yield(f.path)
211
+ end
212
+ ensure
213
+ ENV['PATH'] = env_path
214
+ ENV['_'] = env__ if env__
215
+ end
216
+ end
217
+
218
+
204
219
  def test_syntax1 # -z (syntax ok)
205
220
  @input = INPUT
206
221
  @expected = "Syntax OK\n"
207
222
  @options = '-z'
208
223
  _test()
224
+ #
225
+ _with_dummy_file do |filepath|
226
+ actual = `erubis #{@options} #{filepath}`
227
+ assert_equal @expected, actual
228
+ end
209
229
  end
210
230
 
211
231
 
@@ -266,7 +286,7 @@ END
266
286
  #
267
287
  begin
268
288
  (0...max).each do |i|
269
- File.open(filenames[i], 'w') { |f| f.write(inputs[i]) }
289
+ File.open(filenames[i], 'w') {|f| f.write(inputs[i]) }
270
290
  end
271
291
  @input = '<ok/>'
272
292
  @expected = ''
@@ -365,7 +385,7 @@ END
365
385
  user: Hello
366
386
  password: world
367
387
  END
368
- File.open(datafile, 'w') { |f| f.write(str) }
388
+ File.open(datafile, 'w') {|f| f.write(str) }
369
389
  begin
370
390
  _test()
371
391
  ensure
@@ -384,7 +404,7 @@ END
384
404
  @user = 'Hello'
385
405
  @password = 'world'
386
406
  END
387
- File.open(datafile, 'w') { |f| f.write(str) }
407
+ File.open(datafile, 'w') {|f| f.write(str) }
388
408
  begin
389
409
  _test()
390
410
  ensure
@@ -403,7 +423,7 @@ END
403
423
  user: Hello
404
424
  password: world
405
425
  END
406
- File.open(yamlfile, 'w') { |f| f.write(yaml) }
426
+ File.open(yamlfile, 'w') {|f| f.write(yaml) }
407
427
  begin
408
428
  _test()
409
429
  ensure
@@ -425,11 +445,11 @@ END
425
445
  - bbb
426
446
  - ccc
427
447
  END
428
- File.open(yamlfile, 'w') { |f| f.write(yaml) }
448
+ File.open(yamlfile, 'w') {|f| f.write(yaml) }
429
449
  assert_raise(ArgumentError) do
430
450
  _test()
431
451
  end
432
- File.open(yamlfile, 'w') { |f| f.write(yaml.gsub(/\t/, ' '*8)) }
452
+ File.open(yamlfile, 'w') {|f| f.write(yaml.gsub(/\t/, ' '*8)) }
433
453
  _test()
434
454
  ensure
435
455
  File.unlink(yamlfile) if test(?f, yamlfile)
@@ -495,7 +515,7 @@ list:
495
515
  - bbb
496
516
  - ccc
497
517
  END
498
- File.open(yamlfile, 'w') { |f| f.write(yaml) }
518
+ File.open(yamlfile, 'w') {|f| f.write(yaml) }
499
519
  begin
500
520
  _test()
501
521
  ensure