mailfactory 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,7 +48,7 @@ end
48
48
  # An easy class for creating a mail message
49
49
  class MailFactory
50
50
 
51
- VERSION = '1.3.5'
51
+ VERSION = '1.4.0'
52
52
 
53
53
  def initialize()
54
54
  @headers = Array.new()
@@ -408,11 +408,15 @@ protected
408
408
  # Convert the given character to quoted printable format
409
409
  # see http://tools.ietf.org/html/rfc2047
410
410
 
411
+ require 'enumerator' unless ''.respond_to? :enum_for
412
+
411
413
  def quoted_printable_encode_header(text)
412
- text.scan(/./u).map do |char|
413
- (char[0] < 128 and char[0] != 61) ? # 61 is ascii '='
414
- char :
415
- '=%X' % char[0]
414
+ text.enum_for(:each_byte).map do |ord|
415
+ if ord < 128 and ord != 61 # 61 is ascii '='
416
+ ord.chr
417
+ else
418
+ '=%X' % ord
419
+ end
416
420
  end.join('').
417
421
  chomp.
418
422
  gsub(/=$/,'').
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # coding:utf-8
2
3
 
3
4
  require 'test/unit/ui/console/testrunner'
4
5
  require File.dirname(__FILE__) + '/../lib/mailfactory.rb'
@@ -98,7 +99,7 @@ class TC_MailFactory < Test::Unit::TestCase
98
99
  @mail.subject = "Test Subject"
99
100
  }
100
101
 
101
- assert_equal("=?utf-8?Q?Test_Subject?=", @mail.subject.to_s, "subject does not equal what it was set to")
102
+ assert_equal(["=?utf-8?Q?Test_Subject?="], @mail.subject, "subject does not equal what it was set to")
102
103
 
103
104
  assert_nothing_raised("exception raised while setting subject=") {
104
105
  @mail.subject = "A Different Subject"
@@ -190,15 +191,24 @@ class TC_MailFactory < Test::Unit::TestCase
190
191
  @mail.from="test@othertest.com"
191
192
  @mail.subject="My email subject has a ? in it and also an = and a _ too... Also some non-quoted junk ()!@\#\{\$\%\}"
192
193
  @mail.text = "This is a test message with\na few\n\nlines."
193
- assert_equal("=?utf-8?Q?My_email_subject_has_a_=3F_in_it_and_also_an_=3D_and_a_=5F_too..._Also_some_non-quoted_junk_()!@\#\{\$\%\}?=", @mail.subject.to_s)
194
+ assert_equal(["=?utf-8?Q?My_email_subject_has_a_=3F_in_it_and_also_an_=3D_and_a_=5F_too..._Also_some_non-quoted_junk_()!@\#\{\$\%\}?="], @mail.subject)
195
+ end
196
+
197
+ def test_scandinavian_subject_quoting
198
+ @mail.to="test@test.com"
199
+ @mail.from="test@othertest.com"
200
+ # Three a with dots and three o with dots.
201
+ @mail.subject="\303\244\303\244\303\244\303\266\303\266\303\266"
202
+ @mail.text = "This is a test message with\na few\n\nlines."
203
+ assert_equal(["=?utf-8?Q?=C3=A4=C3=A4=C3=A4=C3=B6=C3=B6=C3=B6?="], @mail.subject)
194
204
  end
195
205
 
196
206
  def test_utf8_quoted_printable_with_instruction
197
207
  @mail.to="test@test.com"
198
- @mail.from="test@othertest.com"
199
- @mail.subject="My email subject has a à which is utf8."
200
- @mail.text = "This is a test message with\na few\n\nlines."
201
- assert_equal("=?utf-8?Q?My_email_subject_has_a_=C3_which_is_utf8.?=", @mail.subject.to_s)
208
+ @mail.from="test@othertest.com"
209
+ @mail.subject="My email subject has a à which is utf8."
210
+ @mail.text = "This is a test message with\na few\n\nlines."
211
+ assert_equal(["=?utf-8?Q?My_email_subject_has_a_=C3=83_which_is_utf8.?="], @mail.subject)
202
212
  end
203
213
 
204
214
  def test_quoted_printable_html
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailfactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Powers
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-18 00:00:00 -07:00
12
+ date: 2008-08-06 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mime-types
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -53,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
54
  requirements: []
54
55
 
55
56
  rubyforge_project: mailfactory
56
- rubygems_version: 1.1.1
57
+ rubygems_version: 1.2.0
57
58
  signing_key:
58
59
  specification_version: 2
59
60
  summary: MailFactory is a pure-ruby MIME mail generator