Package: ruby-tmail
Version: 1.2.7.1-2
Followup-For: Bug #688798

Hi,


It seems to be a known fact [1,2,3] that ruby-tmail is not suited for
the latest versions of Ruby 1.9.

        1: http://isitruby19.com/tmail
        2: https://github.com/mikel/tmail/issues/11
        3: https://github.com/mikel/tmail/blob/master/README.rdoc

There are three main reasons for that:
- the one you mentioned: the C extension for Ruby 1.9 will not work
  because some functions have been removed from ruby1.9 code.
- String#is_binary_data? method used in lib/tmail/quoting.rb has been
  removed from ruby1.9 code
- encoding issues (at least in test files)

It turns out that the is_binary_data? is not properly defined for
Ruby1.8 either, because it is defined in "yaml/rubytypes", but there is
no require statement on "yaml". Moreover, there is also a pure Ruby
implementation of the scanner in scanner_r.rb which should replace the
native C extension when this one is not present.

Here is a proposition to work around this problem:
- do not build the C extension for Ruby 1.9, by setting
  the variable XS-Ruby-Versions to Ruby1.8 in debian/control.so that
  the pure Ruby library scanner_r can play its role 
- add the definition of String#is_binary_data? in lib/tmail/quoting.rb,
  so that it is properly defined for Ruby 1.8 and 1.9.1
- indicate in the description that ruby-tmail should work only with
  Ruby1.8
- run the tests at build time, to track possible regressions

With these modifications, all the tests pass with Ruby1.8 (except one,
which wrongly relies on an order for hashes), and "only" 4 errors and 3
failures due to encoding issues (when proper #encoding: utf-8 headers
are put in the test files). Trying to solve these would probably
imply invasive changes in the code.

With the modifications proposed, the package will work properly with
Ruby 1.8 and some functionalities may work with Ruby 1.9.1.

Attached is the debdiff reflecting the changes described above, already
pushed in the team repository.

Cédric
diff -Nru ruby-tmail-1.2.7.1/debian/changelog 
ruby-tmail-1.2.7.1/debian/changelog
--- ruby-tmail-1.2.7.1/debian/changelog 2012-06-26 22:35:13.000000000 +0200
+++ ruby-tmail-1.2.7.1/debian/changelog 2012-10-07 22:34:36.000000000 +0200
@@ -1,3 +1,20 @@
+ruby-tmail (1.2.7.1-3) UNRELEASED; urgency=medium
+
+  * Team upload
+  * Set urgency to medium, as a RC bug is fixed
+  * Build only for Ruby 1.8 (Closes: #688798)
+    - debian/control: change XS-Ruby-Versions from all to ruby1.8;
+           mention in the description it works only with Ruby 1.8.
+  * Add debian/patches/0002-include_is_binary_data_definition.patch: include
+    the definition of isString#_binary_data? method needed in tmail/quoting.rb.
+  * Add debian/patches/0003-deactivate_faulty_test.patch: deactivate test
+    relying on ordered hashes, which is a wrong asumption with Ruby 1.8.7.
+  * Enable test suite to track possible regressions
+    - debian/rules: do not ignore test results anymore
+    - debian/ruby-test-files.yaml: restore the list of test files
+    
+ -- Cédric Boutillier <bou...@debian.org>  Sun, 07 Oct 2012 15:42:38 +0200
+
 ruby-tmail (1.2.7.1-2) unstable; urgency=low
 
   * debian/control:
diff -Nru ruby-tmail-1.2.7.1/debian/control ruby-tmail-1.2.7.1/debian/control
--- ruby-tmail-1.2.7.1/debian/control   2012-06-26 22:08:48.000000000 +0200
+++ ruby-tmail-1.2.7.1/debian/control   2012-10-07 22:24:40.000000000 +0200
@@ -9,7 +9,7 @@
 Vcs-Git: git://git.debian.org/pkg-ruby-extras/ruby-tmail.git
 Vcs-Browser: http://git.debian.org/?p=pkg-ruby-extras/ruby-tmail.git;a=summary
 Homepage: http://tmail.rubyforge.org
-XS-Ruby-Versions: all
+XS-Ruby-Versions: ruby1.8
 
 Package: ruby-tmail
 Architecture: any
@@ -22,6 +22,8 @@
  TMail is a Ruby-based mail handler.  It allows you to handle mail
  headers or compose MIME multipart standards compliant emails in a
  very Ruby-way.
+ .
+ This package works with Ruby 1.8, but may not work properly with Ruby 1.9.
 
 Package: libtmail-ruby-doc
 Section: oldlibs
diff -Nru 
ruby-tmail-1.2.7.1/debian/patches/0002-include_is_binary_data_definition.patch 
ruby-tmail-1.2.7.1/debian/patches/0002-include_is_binary_data_definition.patch
--- 
ruby-tmail-1.2.7.1/debian/patches/0002-include_is_binary_data_definition.patch  
    1970-01-01 01:00:00.000000000 +0100
+++ 
ruby-tmail-1.2.7.1/debian/patches/0002-include_is_binary_data_definition.patch  
    2012-10-07 21:49:50.000000000 +0200
@@ -0,0 +1,23 @@
+Description: include definition of String#is_binary_data?
+ String#is_binary_data? method used in tmail/quoting.rb is defined in
+ yaml/rubytypes.rb for Ruby1.8, but has been removed from Ruby1.9 code.
+ Including it here ensures that it is properly defined in both cases.
+Author: Cédric Boutillier <bou...@debian.org>
+Last-Update: 2012-10-07
+
+--- a/lib/tmail/quoting.rb
++++ b/lib/tmail/quoting.rb
+@@ -3,6 +3,13 @@
+ = Quoting methods
+ 
+ =end
++
++class String
++  def is_binary_data?
++    ( self.count( "^ -~", "^\r\n" ).fdiv(self.size) > 0.3 || self.index( 
"\x00" ) ) unless empty?
++  end
++end
++
+ module TMail
+   class Mail
+     def subject(to_charset = 'utf-8')
diff -Nru ruby-tmail-1.2.7.1/debian/patches/0003-deactivate_faulty_test.patch 
ruby-tmail-1.2.7.1/debian/patches/0003-deactivate_faulty_test.patch
--- ruby-tmail-1.2.7.1/debian/patches/0003-deactivate_faulty_test.patch 
1970-01-01 01:00:00.000000000 +0100
+++ ruby-tmail-1.2.7.1/debian/patches/0003-deactivate_faulty_test.patch 
2012-10-07 21:50:15.000000000 +0200
@@ -0,0 +1,18 @@
+Description: Disable a faulty test
+ This test relies on the fact that a hash is ordered, which is not true with
+ Ruby 1.8.7.
+Author: Cédric Boutillier <bou...@debian.org>
+Last-Update: 2012-10-07
+
+
+--- a/test/test_mail.rb
++++ b/test/test_mail.rb
+@@ -502,7 +502,7 @@
+     assert_equal(3, mail.parts.length)
+   end
+ 
+-  def test_mail_to_s_with_illegal_content_type_boundary_preserves_quotes
++  def 
disabled_test_mail_to_s_with_illegal_content_type_boundary_preserves_quotes
+     msg = <<EOF
+ From: mi...@example.com
+ Subject: Hello
diff -Nru ruby-tmail-1.2.7.1/debian/patches/series 
ruby-tmail-1.2.7.1/debian/patches/series
--- ruby-tmail-1.2.7.1/debian/patches/series    2012-02-03 00:00:16.000000000 
+0100
+++ ruby-tmail-1.2.7.1/debian/patches/series    2012-10-07 21:49:50.000000000 
+0200
@@ -1 +1,3 @@
 0001-use_system_rchardet_library.patch
+0002-include_is_binary_data_definition.patch
+0003-deactivate_faulty_test.patch
diff -Nru ruby-tmail-1.2.7.1/debian/ruby-test-files.yaml 
ruby-tmail-1.2.7.1/debian/ruby-test-files.yaml
--- ruby-tmail-1.2.7.1/debian/ruby-test-files.yaml      1970-01-01 
01:00:00.000000000 +0100
+++ ruby-tmail-1.2.7.1/debian/ruby-test-files.yaml      2012-10-07 
21:52:07.000000000 +0200
@@ -0,0 +1,13 @@
+--- 
+- test/test_address.rb
+- test/test_attachments.rb
+- test/test_base64.rb
+- test/test_encode.rb
+- test/test_header.rb
+- test/test_helper.rb
+- test/test_mail.rb
+- test/test_mbox.rb
+- test/test_port.rb
+- test/test_quote.rb
+- test/test_scanner.rb
+- test/test_utils.rb

Reply via email to