mms2r 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
2
+ require File.join(File.dirname(__FILE__), "test_helper")
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'mocha'
6
+ gem 'tmail', '>= 1.2.1'
7
+ require 'tmail'
8
+
9
+ class TestBellsouthNet < Test::Unit::TestCase
10
+ include MMS2R::TestHelper
11
+
12
+ def test_image_from_blackberry
13
+ mail = TMail::Mail.parse(load_mail('suncom-blackberry.mail').join)
14
+ mms = MMS2R::Media.new(mail)
15
+
16
+ assert_nil mms.media['text/plain']
17
+
18
+ assert_not_nil mms.media['image/jpeg'].first
19
+ assert_match(/Windows-1252\?B\?SU1HMDAwNjUuanBn/, mms.media['image/jpeg'].first)
20
+ mms.purge
21
+ end
22
+ end
@@ -112,19 +112,20 @@ class TestMms2rMedia < Test::Unit::TestCase
112
112
 
113
113
  # test defaults shipped in mms2r_media.yml
114
114
  assert_not_nil config
115
- assert_not_nil config['ignore']
116
- assert_not_nil config['ignore']['text/plain']
117
- assert_not_nil config['ignore']['text/plain'].detect{|v| v == '/^\(no subject\)$/i'}
118
- assert_not_nil config['ignore']['multipart/mixed']
119
- assert_not_nil config['ignore']['multipart/mixed'].detect{|v| v == '/^Attachment: /i'}
120
- assert_nil config['ignore']['text/plain'].detect{|v| v == '/A TEST/'}
115
+ assert_equal true, config['ignore'].is_a?(Hash)
116
+ assert_equal true, config['transform'].is_a?(Hash)
117
+ assert_equal true, config['number'].is_a?(Array)
121
118
  end
122
119
 
123
120
  def test_initialize_config_contatenation
124
- c = {'ignore' => {'text/plain' => ['/A TEST/']} }
121
+ c = {'ignore' => {'text/plain' => ['/A TEST/']},
122
+ 'transform' => {'text/plain' => ['/FOO/', '']},
123
+ 'number' => ['from', '/^([^\s]+)\s.*/', '\1']
124
+ }
125
125
  config = MMS2R::Media.initialize_config(c)
126
- assert_not_nil config['ignore']['text/plain'].detect{|v| v == '/^\(no subject\)$/i'}
127
126
  assert_not_nil config['ignore']['text/plain'].detect{|v| v == '/A TEST/'}
127
+ assert_not_nil config['transform']['text/plain'].detect{|v| v == '/FOO/'}
128
+ assert_not_nil config['number'].first == 'from'
128
129
  end
129
130
 
130
131
  def test_create_with_default_processor
@@ -200,6 +201,14 @@ class TestMms2rMedia < Test::Unit::TestCase
200
201
  mms = MMS2R::Media.new(mail)
201
202
  assert_equal '2068675309', mms.number
202
203
  end
204
+
205
+ def test_mms_phone_number_from_config
206
+ mail = stub_mail()
207
+ mail.stubs(:header).returns({'from' => TMail::AddressHeader.new('from', '"+2068675309" <BCVOZH@mms.vodacom4me.co.za>')})
208
+ mms = MMS2R::Media.new(mail)
209
+ mms.expects(:config).once.returns({'number' => ['from', '/^([^\s]+)\s.*/', '\1']})
210
+ assert_equal '+2068675309', mms.number
211
+ end
203
212
 
204
213
  def test_mms_phone_number_with_errors
205
214
  mail = stub_mail(:from)
@@ -224,7 +233,7 @@ class TestMms2rMedia < Test::Unit::TestCase
224
233
 
225
234
  # testing the default config
226
235
  assert_equal ['text/plain', ''], mms.transform_text('text/plain', 'Sent from my iPhone')
227
- assert_equal ['text/plain', ''], mms.transform_text('text/plain', "image/jpeg\nSent via BlackBerry from T-Mobile")
236
+ assert_equal ['text/plain', ''], mms.transform_text('text/plain', "Sent via BlackBerry from T-Mobile")
228
237
 
229
238
  # has a bad regexp
230
239
  mms.expects(:config).once.returns({'transform' => {type => [['(hello)', 'world']]}})
@@ -89,4 +89,15 @@ class TestMmsAttNet < Test::Unit::TestCase
89
89
  assert_equal "Water", IO.read(mms.media['text/plain'][0])
90
90
  mms.purge
91
91
  end
92
+
93
+ def test_image_from_blackberry
94
+ mail = TMail::Mail.parse(load_mail('att-blackberry.mail').join)
95
+ mms = MMS2R::Media.new(mail)
96
+
97
+ assert_not_nil mms.media['text/plain']
98
+ assert_equal "Hello world", IO.readlines(mms.media['text/plain'].first).join.strip
99
+
100
+ assert_not_nil mms.media['image/jpeg'].first
101
+ assert_match(/Windows-1252\?B\?QkMtV0FLRS5qcGc/, mms.media['image/jpeg'].first)
102
+ end
92
103
  end
@@ -17,6 +17,14 @@ class TestMmsLuxgsmLu < Test::Unit::TestCase
17
17
  mms.purge
18
18
  end
19
19
 
20
+ def test_number
21
+ mail = TMail::Mail.parse(load_mail('luxgsm-image-01.mail').join)
22
+ mms = MMS2R::Media.new(mail)
23
+ assert_equal "+5551234", mms.number
24
+
25
+ mms.purge
26
+ end
27
+
20
28
  def test_image
21
29
  mail = TMail::Mail.parse(load_mail('luxgsm-image-01.mail').join)
22
30
  mms = MMS2R::Media.new(mail)
@@ -0,0 +1,60 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
2
+ require File.join(File.dirname(__FILE__), "test_helper")
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'mocha'
6
+ gem 'tmail', '>= 1.2.1'
7
+ require 'tmail'
8
+
9
+ class TestMmsMycricketCom < Test::Unit::TestCase
10
+ include MMS2R::TestHelper
11
+
12
+ def test_subject
13
+ # mms.mycricket.com service
14
+ mail = TMail::Mail.parse(load_mail('mms.mycricket.com-pic.mail').join)
15
+ mms = MMS2R::Media.new(mail)
16
+ assert_equal "", mms.subject
17
+ mms.purge
18
+ end
19
+
20
+ def test_image
21
+ # mms.mycricket.com service
22
+ mail = TMail::Mail.parse(load_mail('mms.mycricket.com-pic.mail').join)
23
+ mms = MMS2R::Media.new(mail)
24
+
25
+ assert_equal 1, mms.media.size
26
+ assert_nil mms.media['text/plain']
27
+ assert_nil mms.media['text/html']
28
+ assert_equal 1, mms.media['image/jpeg'].size
29
+ assert_not_nil mms.media['image/jpeg'].first
30
+ assert_match(/10-26-07_1739.jpg$/, mms.media['image/jpeg'].first)
31
+
32
+ assert_file_size mms.media['image/jpeg'].first, 7249
33
+
34
+ mms.purge
35
+ end
36
+
37
+ def test_image_and_text
38
+ # mms.mycricket.com service
39
+ mail = TMail::Mail.parse(load_mail('mms.mycricket.com-pic-and-text.mail').join)
40
+ mms = MMS2R::Media.new(mail)
41
+
42
+ assert_equal 2, mms.media.size
43
+ assert_nil mms.media['text/html']
44
+ assert_equal 1, mms.media['text/plain'].size
45
+ assert_equal 1, mms.media['image/jpeg'].size
46
+ assert_not_nil mms.media['text/plain'].first
47
+ assert_not_nil mms.media['image/jpeg'].first
48
+
49
+ file = mms.media['text/plain'].first
50
+ assert_equal true, File::exist?(file), "file #{file} does not exist"
51
+ text = IO.readlines("#{file}").join
52
+ assert_match(/Hello World/, text)
53
+
54
+ assert_match(/02-14-08_2114.jpg$/, mms.media['image/jpeg'].first)
55
+ assert_file_size mms.media['image/jpeg'].first, 16770
56
+
57
+ mms.purge
58
+ end
59
+
60
+ end
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
2
+ require File.join(File.dirname(__FILE__), "test_helper")
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'mocha'
6
+ gem 'tmail', '>= 1.2.1'
7
+ require 'tmail'
8
+
9
+ class TestMmsVodacom4meCoZa < Test::Unit::TestCase
10
+ include MMS2R::TestHelper
11
+
12
+ def test_image_only
13
+ mail = TMail::Mail.parse(load_mail('vodacom4me-co-za-01.mail').join)
14
+ mms = MMS2R::Media.new(mail)
15
+
16
+ assert_nil mms.media['text/plain']
17
+ assert_nil mms.media['text/html']
18
+
19
+ assert_not_nil mms.media['image/jpeg'].first
20
+ assert_match(/Ugly\.jpg$/, mms.media['image/jpeg'].first)
21
+ mms.purge
22
+ end
23
+
24
+ def test_should_have_phone_number
25
+ mail = TMail::Mail.parse(load_mail('vodacom4me-co-za-01.mail').join)
26
+ mms = MMS2R::Media.new(mail)
27
+
28
+ assert_equal '+2068675309', mms.number
29
+
30
+ mms.purge
31
+ end
32
+
33
+ def test_image_and_text
34
+ mail = TMail::Mail.parse(load_mail('vodacom4me-co-za-02.mail').join)
35
+ mms = MMS2R::Media.new(mail)
36
+
37
+ assert_not_nil mms.media['text/plain']
38
+ assert_equal "Hello World", open(mms.media['text/plain'].first).read
39
+
40
+ assert_nil mms.media['text/html']
41
+
42
+ assert_not_nil mms.media['image/jpeg'].first
43
+ assert_match(/DSC00184\.JPG$/, mms.media['image/jpeg'].first)
44
+ mms.purge
45
+ end
46
+ end
@@ -26,6 +26,14 @@ class TestMobileIndosatNetId < Test::Unit::TestCase
26
26
  mms.purge
27
27
  end
28
28
 
29
+ def test_mms_indosat_phone_number_with_yahoo_service
30
+ # mobile.indosat.net.id service
31
+ mail = TMail::Mail.parse(load_mail('indosat-image-01.mail').join)
32
+ mms = MMS2R::Media.new(mail)
33
+ assert_equal "2068675309", mms.number
34
+ mms.purge
35
+ end
36
+
29
37
  def test_mms_indosat
30
38
  # mobile.indosat.net.id service
31
39
  mail = TMail::Mail.parse(load_mail('indosat-image-02.mail').join)
@@ -44,4 +44,15 @@ class TestTmobileNet < Test::Unit::TestCase
44
44
 
45
45
  mms.purge
46
46
  end
47
+
48
+ def test_image_from_blackberry
49
+ mail = TMail::Mail.parse(load_mail('tmobile-blackberry.mail').join)
50
+ mms = MMS2R::Media.new(mail)
51
+
52
+ assert_nil mms.media['text/plain']
53
+
54
+ assert_not_nil mms.media['image/jpeg'].first
55
+ assert_match(/Windows-1252\?B\?SU1HMDAyMzkuanBn/, mms.media['image/jpeg'].first)
56
+ mms.purge
57
+ end
47
58
  end
@@ -99,5 +99,17 @@ class TestVzwpixCom < Test::Unit::TestCase
99
99
  assert_match(/hello world/, text)
100
100
  mms.purge
101
101
  end
102
+
103
+ def test_image_from_blackberry
104
+ mail = TMail::Mail.parse(load_mail('verizon-blackberry.mail').join)
105
+ mms = MMS2R::Media.new(mail)
106
+
107
+ assert_not_nil mms.media['text/plain']
108
+ assert_equal "Wonderful picture!", IO.readlines(mms.media['text/plain'].first).join.strip
109
+
110
+ assert_not_nil mms.media['image/jpeg'].first
111
+ assert_match(/Windows-1252\?B\?SU1HMDAwMTYuanBn/, mms.media['image/jpeg'].first)
112
+ mms.purge
113
+ end
102
114
 
103
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mms2r
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Mondragon
@@ -30,7 +30,7 @@ cert_chain:
30
30
  q8SfeAt4oNk4pWm9Ocmiww==
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2008-02-08 00:00:00 -08:00
33
+ date: 2008-02-22 00:00:00 -08:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -60,7 +60,7 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.5.0
62
62
  version:
63
- description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the mobile carriers. MMS messages are multipart email and the carriers often inject branding into these messages. Use MMS2R if you want to get at the real user generated content from a MMS without having to deal with the cruft from the carriers. If MMS2R is not aware of a particular carrier no extra processing is done to the MMS other than decoding and consolidating its media. Contact the author to add additional carriers to be processed by the library. Suggestions and patches appreciated and welcomed! Corpus of carriers currently processed by MMS2R: * Alltel: message.alltel.com * AT&T/Cingular/Legacy: mms.att.net, txt.att.net, mmode.com, mms.mycingular.com, cingularme.com * Dobson/Cellular One: mms.dobson.net * Helio: mms.myhelio.com * Hutchison 3G UK Ltd: mms.three.co.uk * LUXGSM S.A.: mms.luxgsm.lu * NetCom (Norway): mms.netcom.no * Nextel: messaging.nextel.com * O2 Germany: mms.o2online.de * Orange & Regional Oranges: orangemms.net, mmsemail.orange.pl, orange.fr * PXT New Zealand: pxt.vodafone.net.nz * Sprint: pm.sprint.com, messaging.sprintpcs.com * T-Mobile: tmomail.net * Verizon: vzwpix.com, vtext.com"
63
+ description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the mobile carriers. MMS messages are multipart email and the carriers often inject branding into these messages. Use MMS2R if you want to get at the real user generated content from a MMS without having to deal with the cruft from the carriers. If MMS2R is not aware of a particular carrier no extra processing is done to the MMS other than decoding and consolidating its media. Contact the author to add additional carriers to be processed by the library. Suggestions and patches appreciated and welcomed! Corpus of carriers currently processed by MMS2R: * Alltel: message.alltel.com * AT&T/Cingular/Legacy: mms.att.net, txt.att.net, mmode.com, mms.mycingular.com, cingularme.com * Bell South / Suncom: bellsouth.net * Cricket Wireless: mms.mycricket.com * Dobson/Cellular One: mms.dobson.net * Helio: mms.myhelio.com * Hutchison 3G UK Ltd: mms.three.co.uk * INDOSAT M2: mobile.indosat.net.id * LUXGSM S.A.: mms.luxgsm.lu * NetCom (Norway): mms.netcom.no * Nextel: messaging.nextel.com * O2 Germany: mms.o2online.de * Orange & Regional Oranges: orangemms.net, mmsemail.orange.pl, orange.fr * PXT New Zealand: pxt.vodafone.net.nz * SaskTel: sms.sasktel.com * Sprint: pm.sprint.com, messaging.sprintpcs.com * T-Mobile: tmomail.net * Vodacom: mms.vodacom4me.co.za * Verizon: vzwpix.com, vtext.com"
64
64
  email: mikemondragon@gmail.com
65
65
  executables: []
66
66
 
@@ -76,15 +76,18 @@ files:
76
76
  - README.txt
77
77
  - Rakefile
78
78
  - conf/aliases.yml
79
+ - conf/bellsouth.net.yml
79
80
  - conf/message.alltel.com.yml
80
81
  - conf/messaging.nextel.com.yml
81
82
  - conf/mms.att.net.yml
82
83
  - conf/mms.dobson.net.yml
83
84
  - conf/mms.luxgsm.lu.yml
85
+ - conf/mms.mycricket.com.yml
84
86
  - conf/mms.myhelio.com.yml
85
87
  - conf/mms.netcom.no.yml
86
88
  - conf/mms.o2online.de.yml
87
89
  - conf/mms.three.co.uk.yml
90
+ - conf/mms.vodacom4me.co.za.yml
88
91
  - conf/mms2r_media.yml
89
92
  - conf/mobile.indosat.net.id.yml
90
93
  - conf/orangemms.net.yml
@@ -99,6 +102,7 @@ files:
99
102
  - lib/mms2r/media.rb
100
103
  - lib/mms2r/media/sprint.rb
101
104
  - test/fixtures/alltel-image-01.mail
105
+ - test/fixtures/att-blackberry.mail
102
106
  - test/fixtures/att-image-01.mail
103
107
  - test/fixtures/att-image-02.mail
104
108
  - test/fixtures/att-text-01.mail
@@ -112,6 +116,8 @@ files:
112
116
  - test/fixtures/indosat-image-02.mail
113
117
  - test/fixtures/luxgsm-image-01.mail
114
118
  - test/fixtures/mmode-image-01.mail
119
+ - test/fixtures/mms.mycricket.com-pic-and-text.mail
120
+ - test/fixtures/mms.mycricket.com-pic.mail
115
121
  - test/fixtures/mycingular-image-01.mail
116
122
  - test/fixtures/netcom-image-01.mail
117
123
  - test/fixtures/nextel-image-01.mail
@@ -133,14 +139,20 @@ files:
133
139
  - test/fixtures/sprint-two-images-01.mail
134
140
  - test/fixtures/sprint-video-01.mail
135
141
  - test/fixtures/sprint.mov
142
+ - test/fixtures/suncom-blackberry.mail
136
143
  - test/fixtures/three-uk-image-01.mail
144
+ - test/fixtures/tmobile-blackberry.mail
137
145
  - test/fixtures/tmobile-image-01.mail
138
146
  - test/fixtures/tmobile-image-02.mail
147
+ - test/fixtures/verizon-blackberry.mail
139
148
  - test/fixtures/verizon-image-01.mail
140
149
  - test/fixtures/verizon-image-02.mail
141
150
  - test/fixtures/verizon-text-01.mail
142
151
  - test/fixtures/verizon-video-01.mail
152
+ - test/fixtures/vodacom4me-co-za-01.mail
153
+ - test/fixtures/vodacom4me-co-za-02.mail
143
154
  - test/fixtures/vtext-text-01.mail
155
+ - test/test_bellsouth_net.rb
144
156
  - test/test_helper.rb
145
157
  - test/test_message_alltel_com.rb
146
158
  - test/test_messaging_nextel_com.rb
@@ -149,10 +161,12 @@ files:
149
161
  - test/test_mms_att_net.rb
150
162
  - test/test_mms_dobson_net.rb
151
163
  - test/test_mms_luxgsm_lu.rb
164
+ - test/test_mms_mycricket_com.rb
152
165
  - test/test_mms_myhelio_com.rb
153
166
  - test/test_mms_netcom_no.rb
154
167
  - test/test_mms_o2online_de.rb
155
168
  - test/test_mms_three_co_uk.rb
169
+ - test/test_mms_vodacom4me_co_za.rb
156
170
  - test/test_mobile_indosat_net_id.rb
157
171
  - test/test_orangemms_net.rb
158
172
  - test/test_pm_sprint_com.rb
@@ -164,7 +178,7 @@ files:
164
178
  - vendor/plugins/mms2r/lib/autotest/mms2r.rb
165
179
  has_rdoc: true
166
180
  homepage: |
167
- http://mms2r.rubyforge.org/
181
+ by Mike Mondragon
168
182
 
169
183
  post_install_message:
170
184
  rdoc_options:
@@ -194,11 +208,13 @@ summary: Extract user media from MMS (and not carrier cruft)
194
208
  test_files:
195
209
  - test/test_sms_sasktel_com.rb
196
210
  - test/test_pxt_vodafone_net_nz.rb
211
+ - test/test_mms_mycricket_com.rb
197
212
  - test/test_mobile_indosat_net_id.rb
198
213
  - test/test_pm_sprint_com.rb
199
214
  - test/test_messaging_sprintpcs_com.rb
200
215
  - test/test_vzwpix_com.rb
201
216
  - test/test_mms2r_media.rb
217
+ - test/test_bellsouth_net.rb
202
218
  - test/test_mms_o2online_de.rb
203
219
  - test/test_message_alltel_com.rb
204
220
  - test/test_mms_att_net.rb
@@ -211,3 +227,4 @@ test_files:
211
227
  - test/test_orangemms_net.rb
212
228
  - test/test_helper.rb
213
229
  - test/test_messaging_nextel_com.rb
230
+ - test/test_mms_vodacom4me_co_za.rb
metadata.gz.sig CHANGED
Binary file