attachments 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -69,7 +69,8 @@ module Attachments
69
69
  if(@mail && @mail.text_part && @mail.text_part.body)
70
70
  m = @mail.text_part.body.decoded
71
71
  charset = @mail.text_part.charset
72
- charset ? Iconv.conv("utf-8", charset, m) : m
72
+ text = charset ? Iconv.conv("utf-8", charset, m) : m
73
+ (text.respond_to? :force_encoding) ? text.force_encoding("utf-8") : text
73
74
  else
74
75
  nil
75
76
  end
@@ -13,15 +13,22 @@ class TestAttachments < Test::Unit::TestCase
13
13
  @extract.close
14
14
  end
15
15
 
16
- should "parse text/plain + text/html" do
17
- assert_nothing_raised do
18
- @extract.parse "./test/data/mail_0001.eml"
16
+ should "parse test mails without raising exceptions" do
17
+ Dir.glob("./test/data/mail_*.eml") do |filename|
18
+ assert_nothing_raised do
19
+ @extract.parse_file filename
20
+ end
19
21
  end
20
22
  end
21
23
 
22
- should "parse text/plain with UTF-8 and image/jpeg" do
23
- assert_nothing_raised do
24
- @extract.parse "./test/data/mail_0002.eml"
24
+ should "return valid encoding in all text bodies" do
25
+ return unless "".respond_to?(:valid_encoding?)
26
+
27
+ Dir.glob("./test/data/mail_*.eml") do |filename|
28
+ assert_nothing_raised do
29
+ @extract.parse_file filename
30
+ assert @extract.text_body.valid_encoding?
31
+ end
25
32
  end
26
33
  end
27
34
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachments
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rune Myrland
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-16 00:00:00 +02:00
18
+ date: 2010-08-17 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency