erubis 2.6.2 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/CHANGES.txt +16 -5
  2. data/MIT-LICENSE +1 -1
  3. data/README.txt +2 -2
  4. data/benchmark/bench.rb +2 -2
  5. data/bin/erubis +4 -4
  6. data/contrib/erubis +3349 -5
  7. data/contrib/inline-require +2 -2
  8. data/doc-api/classes/Erubis.html +1 -1
  9. data/doc-api/classes/Erubis/ArrayEnhancer.html +12 -12
  10. data/doc-api/classes/Erubis/Basic/Converter.html +24 -24
  11. data/doc-api/classes/Erubis/BiPatternEnhancer.html +12 -12
  12. data/doc-api/classes/Erubis/CGenerator.html +60 -60
  13. data/doc-api/classes/Erubis/Converter.html +27 -27
  14. data/doc-api/classes/Erubis/DeleteIndentEnhancer.html +6 -6
  15. data/doc-api/classes/Erubis/ErboutEnhancer.html +12 -12
  16. data/doc-api/classes/Erubis/EscapeEnhancer.html +6 -6
  17. data/doc-api/classes/Erubis/Evaluator.html +19 -19
  18. data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +12 -12
  19. data/doc-api/classes/Erubis/Helpers/RailsFormHelper.html +150 -150
  20. data/doc-api/classes/Erubis/Helpers/RailsHelper.html +49 -49
  21. data/doc-api/classes/Erubis/Helpers/RailsHelper/TemplateConverter.html +12 -12
  22. data/doc-api/classes/Erubis/InterpolationEnhancer.html +30 -30
  23. data/doc-api/classes/Erubis/JavaGenerator.html +54 -54
  24. data/doc-api/classes/Erubis/JavascriptGenerator.html +60 -60
  25. data/doc-api/classes/Erubis/NoTextEnhancer.html +6 -6
  26. data/doc-api/classes/Erubis/OptimizedGenerator.html +72 -72
  27. data/doc-api/classes/Erubis/PI/Ec.html +6 -6
  28. data/doc-api/classes/Erubis/PI/Ejavascript.html +6 -6
  29. data/doc-api/classes/Erubis/PI/Eperl.html +6 -6
  30. data/doc-api/classes/Erubis/PI/Ephp.html +6 -6
  31. data/doc-api/classes/Erubis/PI/Eruby.html +6 -6
  32. data/doc-api/classes/Erubis/PI/Escheme.html +6 -6
  33. data/doc-api/classes/Erubis/PI/TinyEruby.html +24 -24
  34. data/doc-api/classes/Erubis/PercentLineEnhancer.html +6 -6
  35. data/doc-api/classes/Erubis/PerlGenerator.html +54 -54
  36. data/doc-api/classes/Erubis/PhpGenerator.html +54 -54
  37. data/doc-api/classes/Erubis/PreprocessingEruby.html +12 -12
  38. data/doc-api/classes/Erubis/PreprocessingHelper.html +22 -22
  39. data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +20 -20
  40. data/doc-api/classes/Erubis/PrintOutEnhancer.html +30 -30
  41. data/doc-api/classes/Erubis/RubyEvaluator.html +18 -18
  42. data/doc-api/classes/Erubis/RubyGenerator.html +48 -48
  43. data/doc-api/classes/Erubis/SchemeGenerator.html +60 -60
  44. data/doc-api/classes/Erubis/SimplifyEnhancer.html +7 -7
  45. data/doc-api/classes/Erubis/StdoutEnhancer.html +12 -12
  46. data/doc-api/classes/Erubis/StringBufferEnhancer.html +12 -12
  47. data/doc-api/classes/Erubis/TinyEruby.html +24 -24
  48. data/doc-api/classes/Erubis/XmlHelper.html +30 -30
  49. data/doc-api/created.rid +1 -1
  50. data/doc-api/files/README_txt.html +3 -3
  51. data/doc-api/files/erubis/context_rb.html +1 -1
  52. data/doc-api/files/erubis/converter_rb.html +1 -1
  53. data/doc-api/files/erubis/engine/ec_rb.html +1 -1
  54. data/doc-api/files/erubis/engine/ejava_rb.html +1 -1
  55. data/doc-api/files/erubis/engine/ejavascript_rb.html +1 -1
  56. data/doc-api/files/erubis/engine/enhanced_rb.html +1 -1
  57. data/doc-api/files/erubis/engine/eperl_rb.html +1 -1
  58. data/doc-api/files/erubis/engine/ephp_rb.html +1 -1
  59. data/doc-api/files/erubis/engine/eruby_rb.html +1 -1
  60. data/doc-api/files/erubis/engine/escheme_rb.html +1 -1
  61. data/doc-api/files/erubis/engine/optimized_rb.html +1 -1
  62. data/doc-api/files/erubis/engine_rb.html +1 -1
  63. data/doc-api/files/erubis/enhancer_rb.html +1 -1
  64. data/doc-api/files/erubis/error_rb.html +1 -1
  65. data/doc-api/files/erubis/evaluator_rb.html +1 -1
  66. data/doc-api/files/erubis/generator_rb.html +1 -1
  67. data/doc-api/files/erubis/helper_rb.html +1 -1
  68. data/doc-api/files/erubis/helpers/rails_form_helper_rb.html +1 -1
  69. data/doc-api/files/erubis/helpers/rails_helper_rb.html +1 -1
  70. data/doc-api/files/erubis/local-setting_rb.html +1 -1
  71. data/doc-api/files/erubis/main_rb.html +2 -2
  72. data/doc-api/files/erubis/preprocessing_rb.html +1 -1
  73. data/doc-api/files/erubis/tiny_rb.html +1 -1
  74. data/doc-api/files/erubis_rb.html +1 -1
  75. data/doc-api/fr_method_index.html +188 -188
  76. data/doc/users-guide.html +5 -5
  77. data/lib/erubis.rb +3 -3
  78. data/lib/erubis/context.rb +2 -2
  79. data/lib/erubis/converter.rb +2 -2
  80. data/lib/erubis/engine.rb +2 -2
  81. data/lib/erubis/engine/ec.rb +2 -2
  82. data/lib/erubis/engine/ejava.rb +2 -2
  83. data/lib/erubis/engine/ejavascript.rb +2 -2
  84. data/lib/erubis/engine/enhanced.rb +2 -2
  85. data/lib/erubis/engine/eperl.rb +2 -2
  86. data/lib/erubis/engine/ephp.rb +2 -2
  87. data/lib/erubis/engine/eruby.rb +2 -2
  88. data/lib/erubis/engine/escheme.rb +2 -2
  89. data/lib/erubis/engine/optimized.rb +2 -2
  90. data/lib/erubis/enhancer.rb +2 -2
  91. data/lib/erubis/error.rb +2 -2
  92. data/lib/erubis/evaluator.rb +2 -2
  93. data/lib/erubis/generator.rb +2 -2
  94. data/lib/erubis/helper.rb +2 -2
  95. data/lib/erubis/helpers/rails_form_helper.rb +2 -2
  96. data/lib/erubis/helpers/rails_helper.rb +2 -2
  97. data/lib/erubis/local-setting.rb +2 -2
  98. data/lib/erubis/main.rb +8 -7
  99. data/lib/erubis/preprocessing.rb +2 -2
  100. data/lib/erubis/tiny.rb +2 -2
  101. data/test/assert-text-equal.rb +2 -2
  102. data/test/data/users-guide/stderr.log +3 -0
  103. data/test/test-engines.rb +2 -2
  104. data/test/test-enhancers.rb +2 -2
  105. data/test/test-erubis.rb +2 -2
  106. data/test/test-main.rb +43 -16
  107. data/test/test-users-guide.rb +2 -2
  108. data/test/test.rb +2 -2
  109. data/test/testutil.rb +2 -2
  110. metadata +5 -10
  111. data/test/assert-text-equal.rbc +0 -0
  112. data/test/hoge.rb +0 -5
  113. data/test/test-engines.rbc +0 -0
  114. data/test/test-erubis.rbc +0 -0
  115. data/test/test-users-guide.rbc +0 -0
  116. data/test/test.rbc +0 -0
  117. data/test/testutil.rbc +0 -0
@@ -17,7 +17,7 @@
17
17
  last update: $Date: 2008-06-13 08:04:21 +0900 (Fri, 13 Jun 2008) $<br>
18
18
  </div>
19
19
 
20
- <p>release: 2.6.2
20
+ <p>release: 2.6.3
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.2/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.2/
2989
+ <li>Copy 'erubis-2.6.3/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.3/
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.2/benchark/' directory.
3066
+ <p>A benchmark script is included in Erubis package at 'erubis-2.6.3/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.2/benchmark/
3071
+ <pre class="terminal">$ cd erubis-2.6.3/benchmark/
3072
3072
  $ ruby bench.rb -n 10000 -m execute
3073
3073
  *** ntimes=10000, testmode=execute
3074
3074
  user system total real
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 99 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  ##
@@ -48,7 +48,7 @@
48
48
 
49
49
 
50
50
  module Erubis
51
- VERSION = ('$Release: 2.6.2 $' =~ /([.\d]+)/) && $1
51
+ VERSION = ('$Release: 2.6.3 $' =~ /([.\d]+)/) && $1
52
52
  end
53
53
 
54
54
  require 'erubis/engine'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 115 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'abstract'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 104 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/engine'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/engine'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 95 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/engine'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/enhancer'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/engine'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/engine'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/engine'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/engine'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 115 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  module Erubis
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 115 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'erubis/error'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require 'abstract'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 89 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  ###
2
2
  ### $Rev: 109 $
3
- ### $Release: 2.6.2 $
4
- ### copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ### $Release: 2.6.3 $
4
+ ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ###
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  ###
2
2
  ### $Rev: 112 $
3
- ### $Release: 2.6.2 $
4
- ### copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ### $Release: 2.6.3 $
4
+ ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ###
6
6
 
7
7
 
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 77 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  ##
@@ -1,7 +1,7 @@
1
1
  ###
2
- ### $Rev: 116 $
3
- ### $Release: 2.6.2 $
4
- ### copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
2
+ ### $Rev: 122 $
3
+ ### $Release: 2.6.3 $
4
+ ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'yaml'
@@ -326,7 +326,7 @@ module Erubis
326
326
  elsif arg_required.include?(optchar)
327
327
  arg = optstr.empty? ? argv.shift : optstr
328
328
  unless arg
329
- mesg = "-#{optchar.chr}: #{@option_args[optchar]} required."
329
+ mesg = "-#{optchar}: #{@option_names[optchar]} required."
330
330
  raise CommandOptionError.new(mesg)
331
331
  end
332
332
  options[optchar] = arg
@@ -336,7 +336,7 @@ module Erubis
336
336
  options[optchar] = arg
337
337
  optstr = nil
338
338
  else
339
- raise CommandOptionError.new("-#{optchar.chr}: unknown option.")
339
+ raise CommandOptionError.new("-#{optchar}: unknown option.")
340
340
  end
341
341
  end
342
342
  end
@@ -395,11 +395,12 @@ module Erubis
395
395
  enhancers = []
396
396
  shortname = nil
397
397
  begin
398
- enhancer_names.split(/,/).each do |shortname|
398
+ enhancer_names.split(/,/).each do |name|
399
+ shortname = name
399
400
  enhancers << Erubis.const_get("#{shortname}Enhancer")
400
401
  end
401
402
  rescue NameError
402
- raise CommandOptionError.new("#{shortname}: no such Enhancer (try '-E' to show all enhancers).")
403
+ raise CommandOptionError.new("#{shortname}: no such Enhancer (try '-h' to show all enhancers).")
403
404
  end
404
405
  return enhancers
405
406
  end
@@ -1,7 +1,7 @@
1
1
  ###
2
2
  ### $Rev: 102 $
3
- ### $Release: 2.6.2 $
4
- ### copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ### $Release: 2.6.3 $
4
+ ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'cgi'
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 115 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  module Erubis
@@ -1,7 +1,7 @@
1
1
  ###
2
2
  ### $Rev: 77 $
3
- ### $Release: 2.6.2 $
4
- ### copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ### $Release: 2.6.3 $
4
+ ### copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ###
6
6
 
7
7
  require 'test/unit'
@@ -0,0 +1,3 @@
1
+ *** debug: item="<aaa>"
2
+ *** debug: item="b&b"
3
+ *** debug: item="\"ccc\""
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 115 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require "#{File.dirname(__FILE__)}/test.rb"
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 115 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require "#{File.dirname(__FILE__)}/test.rb"
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## $Rev: 115 $
3
- ## $Release: 2.6.2 $
4
- ## copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
3
+ ## $Release: 2.6.3 $
4
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
5
5
  ##
6
6
 
7
7
  require "#{File.dirname(__FILE__)}/test.rb"
@@ -1,7 +1,7 @@
1
1
  ##
2
- ## $Rev: 116 $
3
- ## $Release: 2.6.2 $
4
- ## $Date: 2008-06-12 21:08:47 +0900 (Thu, 12 Jun 2008) $
2
+ ## $Rev: 122 $
3
+ ## $Release: 2.6.3 $
4
+ ## $Date: 2009-02-07 18:10:01 +0900 (Sat, 07 Feb 2009) $
5
5
  ##
6
6
 
7
7
  require "#{File.dirname(__FILE__)}/test.rb"
@@ -152,17 +152,8 @@ END
152
152
  end
153
153
  File.open(@filename, 'w') { |f| f.write(@input) } if @filename
154
154
  begin
155
- #if @options.is_a?(Array)
156
- # command = "ruby #{$script} #{@options.join(' ')} #{@filename}"
157
- #else
158
- # command = "ruby #{$script} #{@options} #{@filename}"
159
- #end
160
- #output = `#{command}`
161
- if @options.is_a?(Array)
162
- argv = @options + [ @filename ]
163
- else
164
- argv = "#{@options} #{@filename}".split
165
- end
155
+ argv = @options.is_a?(Array) ? @options.dup : @options.split
156
+ argv << @filename if @filename
166
157
  $stdout = output = StringWriter.new
167
158
  Erubis::Main.new.execute(argv)
168
159
  ensure
@@ -172,6 +163,12 @@ END
172
163
  assert_text_equal(@expected, output)
173
164
  end
174
165
 
166
+ def _error_test(errclass, errmsg)
167
+ ex = assert_raise(errclass) { _test() }
168
+ assert_equal(errmsg, ex.message)
169
+ end
170
+
171
+
175
172
  def test_help # -h
176
173
  @options = '-h'
177
174
  m = Erubis::Main.new
@@ -182,7 +179,7 @@ END
182
179
 
183
180
  def test_version # -v
184
181
  @options = '-v'
185
- @expected = (("$Release: 2.6.2 $" =~ /[.\d]+/) && $&) + "\n"
182
+ @expected = (("$Release: 2.6.3 $" =~ /[.\d]+/) && $&) + "\n"
186
183
  @filename = false
187
184
  _test()
188
185
  end
@@ -242,7 +239,7 @@ END
242
239
  -:7: syntax error, unexpected $end, expecting ')'
243
240
  END
244
241
  errmsgs << <<'END'
245
- 7: syntax error, unexpected $end, expecting keyword_end or keyword_endfor
242
+ 7: syntax error, unexpected $end, expecting keyword_end
246
243
  END
247
244
  else
248
245
  errmsgs << <<'END'
@@ -617,6 +614,36 @@ END
617
614
  end
618
615
 
619
616
 
617
+ def test_invalid_option # -1 (invalid option)
618
+ @input = INPUT
619
+ @options = '-1'
620
+ _error_test(Erubis::CommandOptionError, "-1: unknown option.")
621
+ end
622
+
623
+
624
+ def test_invalid_enhancer # -E hoge
625
+ @options = '-E hoge'
626
+ errmsg = "hoge: no such Enhancer (try '-h' to show all enhancers)."
627
+ _error_test(Erubis::CommandOptionError, errmsg)
628
+ end
629
+
630
+
631
+ def test_invalid_lang # -l hoge
632
+ @options = '-l hoge'
633
+ errmsg = "-l hoge: invalid language name (class Erubis::Ehoge not found)."
634
+ _error_test(Erubis::CommandOptionError, errmsg)
635
+ end
636
+
637
+
638
+ def test_missing_argument # -E
639
+ @filename = false
640
+ @options = '-E'
641
+ _error_test(Erubis::CommandOptionError, "-E: enhancers required.")
642
+ @options = '-l'
643
+ _error_test(Erubis::CommandOptionError, "-l: lang required.")
644
+ end
645
+
646
+
620
647
  def test_pi1 # --pi -x
621
648
  @input = PI_INPUT
622
649
  @expected = PI_SRC