[Apt-listbugs-commits] [apt-listbugs] 03/04: avoid NameError with Ruby 1.8
Francesco Poli
frx-guest at alioth.debian.org
Sat Sep 14 16:36:12 UTC 2013
This is an automated email from the git hooks/post-receive script.
frx-guest pushed a commit to branch master
in repository apt-listbugs.
commit 49107a2b019c7d09a97c76b0af38fdfeac145bfc
Author: Francesco Poli (wintermute) <invernomuto at paranoici.org>
Date: Thu Sep 12 23:27:59 2013 +0200
avoid NameError with Ruby 1.8
The exception GetoptLong::AmbigousOption was renamed as
GetoptLong::AmbiguousOption in Ruby 1.9, in order to fix the misspelling.
See
http://www.ruby-doc.org/stdlib-1.8.7/libdoc/getoptlong/rdoc/GetoptLong/AmbigousOption.html
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/getoptlong/rdoc/GetoptLong/AmbiguousOption.html
http://www.ruby-doc.org/stdlib-2.0.0/libdoc/getoptlong/rdoc/GetoptLong/AmbiguousOption.html
Using the new (correctly spelled) name generates an uninitialized constant
NameError with Ruby 1.8; using the misspelled name generates the same
NameError with Ruby 1.9 and later...
This temporary hack helps supporting both Ruby 1.8 and Ruby 1.9 (and later).
---
lib/apt-listbugs/logic.rb | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/apt-listbugs/logic.rb b/lib/apt-listbugs/logic.rb
index 325bd65..5fb45f2 100644
--- a/lib/apt-listbugs/logic.rb
+++ b/lib/apt-listbugs/logic.rb
@@ -121,6 +121,14 @@ class AppConfig
end
end
+ # this hack is not nice: it should be dropped, once
+ # Debian support for Ruby 1.8 is long gone
+ getoptlong_ambiguousoption = if RUBY_VERSION >= "1.9"
+ GetoptLong::AmbiguousOption
+ else
+ GetoptLong::AmbigousOption
+ end
+
opt_parser = GetoptLong.new
opt_parser.set_options(['--help', '-h', GetoptLong::NO_ARGUMENT],
['--severity', '-s', GetoptLong::REQUIRED_ARGUMENT],
@@ -184,7 +192,7 @@ class AppConfig
@yes = false
end
}
- rescue GetoptLong::AmbiguousOption, GetoptLong::NeedlessArgument,
+ rescue getoptlong_ambiguousoption, GetoptLong::NeedlessArgument,
GetoptLong::MissingArgument, GetoptLong::InvalidOption
usage
exit 1
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/apt-listbugs/apt-listbugs.git
More information about the Apt-listbugs-commits
mailing list