[DRE-commits] [ruby-soap4r] 01/04: Remove iconv usage under Ruby 1.9
Antonio Terceiro
terceiro at alioth.debian.org
Wed Aug 14 23:06:35 UTC 2013
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to branch master
in repository ruby-soap4r.
commit c11e2c614ec26f8bf0aed038adbbffa42c278fc9
Author: Antonio Terceiro <terceiro at debian.org>
Date: Thu Aug 15 00:39:30 2013 +0200
Remove iconv usage under Ruby 1.9
---
debian/ruby-tests.rake | 7 +++++++
debian/source/options | 1 +
lib/xsd/iconvcharset.rb | 17 ++++++++++++-----
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/debian/ruby-tests.rake b/debian/ruby-tests.rake
new file mode 100644
index 0000000..855c8d6
--- /dev/null
+++ b/debian/ruby-tests.rake
@@ -0,0 +1,7 @@
+require 'rake/testtask'
+Gem2Deb::Rake::TestTask.new do |test|
+ # FIXME enable more of the upstream test suite
+ test.pattern = 'test/xsd/test_*.rb'
+ test.verbose = true
+end
+task :default => :test
diff --git a/debian/source/options b/debian/source/options
new file mode 100644
index 0000000..7423a2d
--- /dev/null
+++ b/debian/source/options
@@ -0,0 +1 @@
+single-debian-patch
diff --git a/lib/xsd/iconvcharset.rb b/lib/xsd/iconvcharset.rb
index 57733a8..ad078fb 100644
--- a/lib/xsd/iconvcharset.rb
+++ b/lib/xsd/iconvcharset.rb
@@ -5,14 +5,11 @@
# redistribute it and/or modify it under the same terms of Ruby's license;
# either the dual license version in 2003, or any later version.
-
-require 'iconv'
-
-
module XSD
class IconvCharset
+ require 'iconv'
def self.safe_iconv(to, from, str)
iconv = Iconv.new(to, from)
out = ""
@@ -27,7 +24,17 @@ class IconvCharset
end
return out
end
-end
+end if RUBY_VERSION < '1.9'
+
+class IconvCharset
+ def self.safe_iconv(to, from, str)
+ begin
+ out << str.force_encoding(from).encode(to)
+ rescue Encoding::UndefinedConversionError, Encoding::ConverterNotFoundError
+ out << str.force_encoding(to).chars.map { |c| c.valid_encoding? && c || '?' }.join
+ end
+ end
+end if RUBY_VERSION > '1.9'
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-soap4r.git
More information about the Pkg-ruby-extras-commits
mailing list