From 694d19941e8e52f290f3cb5e6c2afbffba796d5c Mon Sep 17 00:00:00 2001 From: makoto kuwata Date: Sat, 7 Feb 2009 08:24:36 +0000 Subject: - [change] change '#!/usr/bin/ruby' to '#!/usr/bin/env ruby' in 'bin/erubis' - [bugfix] change 'optchar.chr' to 'optchar' in 'main.rb'. --- ChangeLog.txt | 7 +++++-- bin/erubis | 2 +- lib/erubis/main.rb | 6 +++--- test/test-main.rb | 24 ++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b775cb1..b70e4ec 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,8 +1,11 @@ - l.=document: ChangeLog -.# -*- coding: utf-8 -*- +.=document: ChangeLog .?lastupdate: $Date$ .?version: $Rev$ +: Rev.121 (2009-02-07) + .- [change] change '#!/usr/bin/ruby' to '#!/usr/bin/env ruby' in 'bin/erubis' + .- [bugfix] change 'optchar.chr' to 'optchar' in 'main.rb'. + : Rev.120 (2008-06-13) .- [update] ReleasNote, CHANGES diff --git a/bin/erubis b/bin/erubis index 8d5f3ab..0d0b42d 100755 --- a/bin/erubis +++ b/bin/erubis @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby ### ### $Rev$ diff --git a/lib/erubis/main.rb b/lib/erubis/main.rb index 22cdfbd..58084d8 100644 --- a/lib/erubis/main.rb +++ b/lib/erubis/main.rb @@ -326,7 +326,7 @@ module Erubis elsif arg_required.include?(optchar) arg = optstr.empty? ? argv.shift : optstr unless arg - mesg = "-#{optchar.chr}: #{@option_args[optchar]} required." + mesg = "-#{optchar}: #{@option_args[optchar]} required." raise CommandOptionError.new(mesg) end options[optchar] = arg @@ -336,7 +336,7 @@ module Erubis options[optchar] = arg optstr = nil else - raise CommandOptionError.new("-#{optchar.chr}: unknown option.") + raise CommandOptionError.new("-#{optchar}: unknown option.") end end end @@ -399,7 +399,7 @@ module Erubis enhancers << Erubis.const_get("#{shortname}Enhancer") end rescue NameError - raise CommandOptionError.new("#{shortname}: no such Enhancer (try '-E' to show all enhancers).") + raise CommandOptionError.new("#{shortname}: no such Enhancer (try '-h' to show all enhancers).") end return enhancers end diff --git a/test/test-main.rb b/test/test-main.rb index 50cf3ad..dab8006 100644 --- a/test/test-main.rb +++ b/test/test-main.rb @@ -617,6 +617,30 @@ END end + def test_invalid_option # -1 (invalid option) + @input = INPUT + @options = '-1' + ex = assert_raise(Erubis::CommandOptionError) { _test() } + assert_equal("-1: unknown option.", ex.message) + end + + + def test_invalid_enhancer # -E hoge + @options = '-E hoge' + errmsg = "hoge: no such Enhancer (try '-h' to show all enhancers)." + ex = assert_raise(Erubis::CommandOptionError) { _test() } + assert_equal(errmsg, ex.message) + end + + + def test_invalid_lang # -l hoge + @options = '-l hoge' + errmsg = "-l hoge: invalid language name (class Erubis::Ehoge not found)." + ex = assert_raise(Erubis::CommandOptionError) { _test() } + assert_equal(errmsg, ex.message) + end + + def test_pi1 # --pi -x @input = PI_INPUT @expected = PI_SRC -- cgit v1.2.1