attachments 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -66,11 +66,23 @@ module Attachments
66
66
  end
67
67
 
68
68
  def text_body
69
- (@mail && @mail.text_part.body.decoded) || nil
69
+ if(@mail && @mail.text_part && @mail.text_part.body)
70
+ m = @mail.text_part.body.decoded
71
+ charset = @mail.text_part.charset
72
+ charset ? Iconv.conv("utf-8", charset, m) : m
73
+ else
74
+ nil
75
+ end
70
76
  end
71
77
 
72
78
  def html_body
73
- (@mail && @mail.html_part.body.decoded) || nil
79
+ if(@mail && @mail.text_part && @mail.text_part.body)
80
+ m = @mail.text_part.body.decoded
81
+ charset = @mail.text_part.charset
82
+ charset ? Iconv.conv("utf-8", charset, m) : m
83
+ else
84
+ nil
85
+ end
74
86
  end
75
87
 
76
88
  def mail
@@ -87,5 +87,37 @@ class TestAttachments < Test::Unit::TestCase
87
87
  assert(isIdentical)
88
88
  end
89
89
  end
90
+
91
+ context "convenience accessors" do
92
+ setup do
93
+ @extract = Attachments::Extract.new [ "text/plain", "image/jpeg" ]
94
+ @extract.parse "./test/data/mail_0001.eml"
95
+ end
96
+
97
+ teardown do
98
+ @extract.close
99
+ end
100
+
101
+ should "not raise exceptions" do
102
+ assert_nothing_raised do
103
+ @extract.text_body
104
+ end
105
+ assert_nothing_raised do
106
+ @extract.html_body
107
+ end
108
+ assert_nothing_raised do
109
+ @extract.subject
110
+ end
111
+ assert_nothing_raised do
112
+ @extract.to
113
+ end
114
+ assert_nothing_raised do
115
+ @extract.from
116
+ end
117
+ assert_nothing_raised do
118
+ @extract.mail
119
+ end
120
+ end
121
+ end
90
122
  end
91
123
 
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rune Myrland