mms2r 1.1.12 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/History.txt +32 -2
  2. data/Manifest.txt +41 -79
  3. data/README.txt +50 -51
  4. data/Rakefile +3 -2
  5. data/conf/aliases.yml +8 -0
  6. data/conf/message.alltel.com.yml +14 -0
  7. data/conf/messaging.nextel.com.yml +10 -0
  8. data/conf/mms.att.net.yml +9 -0
  9. data/conf/mms.dobson.net.yml +4 -0
  10. data/conf/mms.luxgsm.lu.yml +8 -0
  11. data/conf/mms.myhelio.com.yml +12 -0
  12. data/conf/mms.netcom.no.yml +4 -0
  13. data/conf/mms.o2online.de.yml +8 -0
  14. data/conf/mms.three.co.uk.yml +15 -0
  15. data/conf/mms2r_media.yml +6 -0
  16. data/conf/orangemms.net.yml +13 -0
  17. data/conf/pm.sprint.com.yml +10 -0
  18. data/conf/pxt.vodafone.net.nz.yml +5 -0
  19. data/conf/tmomail.net.yml +16 -0
  20. data/conf/vzwpix.com.yml +8 -0
  21. data/dev_tools/anonymizer.rb +20 -0
  22. data/lib/mms2r.rb +19 -45
  23. data/lib/mms2r/media.rb +288 -300
  24. data/lib/mms2r/media/sprint.rb +189 -0
  25. data/test/fixtures/att-text-01.mail +27 -0
  26. data/test/fixtures/helio-image-01.mail +8 -8
  27. data/test/fixtures/helio-message-01.mail +327 -0
  28. data/test/fixtures/luxgsm-image-01.mail +388 -0
  29. data/test/fixtures/netcom-image-01.mail +556 -0
  30. data/test/fixtures/o2-de-image-01.mail +314 -0
  31. data/test/fixtures/orange-uk-image-01.mail +71 -0
  32. data/test/fixtures/pxt-image-01.mail +118 -0
  33. data/test/fixtures/sprint-broken-image-01.mail +1 -1
  34. data/test/fixtures/sprint-image-01.mail +211 -195
  35. data/test/fixtures/sprint-purged-image-01.mail +1 -1
  36. data/test/fixtures/sprint-two-images-01.mail +231 -198
  37. data/test/fixtures/sprint-video-01.mail +210 -195
  38. data/test/fixtures/three-uk-image-01.mail +1202 -0
  39. data/test/test_helper.rb +39 -0
  40. data/test/{test_mms2r_alltel_media.rb → test_message_alltel_com.rb} +13 -17
  41. data/test/{test_mms2r_nextel_media.rb → test_messaging_nextel_com.rb} +12 -19
  42. data/test/{test_mms2r_sprint_pcs_media.rb → test_messaging_sprintpcs_com.rb} +9 -10
  43. data/test/test_mms2r_media.rb +474 -316
  44. data/test/test_mms_att_net.rb +92 -0
  45. data/test/test_mms_dobson_net.rb +41 -0
  46. data/test/test_mms_luxgsm_lu.rb +50 -0
  47. data/test/test_mms_myhelio_com.rb +60 -0
  48. data/test/test_mms_netcom_no.rb +52 -0
  49. data/test/test_mms_o2online_de.rb +53 -0
  50. data/test/test_mms_three_co_uk.rb +42 -0
  51. data/test/test_orangemms_net.rb +100 -0
  52. data/test/test_pm_sprint_com.rb +201 -0
  53. data/test/test_pxt_vodafone_net_nz.rb +37 -0
  54. data/test/{test_mms2r_t_mobile_media.rb → test_tmomail_net.rb} +8 -19
  55. data/test/{test_mms2r_verizon_media.rb → test_vzwpix_com.rb} +34 -27
  56. data/vendor/plugins/mms2r/lib/autotest/mms2r.rb +16 -11
  57. metadata +128 -157
  58. data/conf/mms2r_alltel_media_ignore.yml +0 -13
  59. data/conf/mms2r_att_media_subject.yml +0 -3
  60. data/conf/mms2r_cingular_me_media_subject.yml +0 -3
  61. data/conf/mms2r_cingular_me_media_transform.yml +0 -7
  62. data/conf/mms2r_dobson_media_ignore.yml +0 -4
  63. data/conf/mms2r_helio_media_ignore.yml +0 -6
  64. data/conf/mms2r_media_ignore.yml +0 -5
  65. data/conf/mms2r_media_subject.yml +0 -3
  66. data/conf/mms2r_my_cingular_media_subject.yml +0 -3
  67. data/conf/mms2r_nextel_media_ignore.yml +0 -11
  68. data/conf/mms2r_orange_france_media_ignore.yml +0 -6
  69. data/conf/mms2r_orange_poland_media_subject.yml +0 -3
  70. data/conf/mms2r_sprint_media_ignore.yml +0 -7
  71. data/conf/mms2r_sprint_media_subject.yml +0 -3
  72. data/conf/mms2r_t_mobile_media_ignore.yml +0 -16
  73. data/conf/mms2r_verizon_media_ignore.yml +0 -4
  74. data/conf/mms2r_verizon_media_transform.yml +0 -5
  75. data/lib/mms2r/alltel_media.rb +0 -10
  76. data/lib/mms2r/att_media.rb +0 -13
  77. data/lib/mms2r/cingular_me_media.rb +0 -23
  78. data/lib/mms2r/dobson_media.rb +0 -13
  79. data/lib/mms2r/helio_media.rb +0 -20
  80. data/lib/mms2r/m_mode_media.rb +0 -13
  81. data/lib/mms2r/my_cingular_media.rb +0 -15
  82. data/lib/mms2r/nextel_media.rb +0 -17
  83. data/lib/mms2r/orange_france_media.rb +0 -10
  84. data/lib/mms2r/orange_poland_media.rb +0 -10
  85. data/lib/mms2r/sprint_media.rb +0 -182
  86. data/lib/mms2r/sprint_pcs_media.rb +0 -16
  87. data/lib/mms2r/t_mobile_media.rb +0 -21
  88. data/lib/mms2r/verizon_media.rb +0 -19
  89. data/lib/mms2r/vtext_media.rb +0 -16
  90. data/lib/vendor/text/format.rb +0 -1466
  91. data/lib/vendor/tmail.rb +0 -3
  92. data/lib/vendor/tmail/address.rb +0 -242
  93. data/lib/vendor/tmail/attachments.rb +0 -39
  94. data/lib/vendor/tmail/base64.rb +0 -71
  95. data/lib/vendor/tmail/config.rb +0 -69
  96. data/lib/vendor/tmail/encode.rb +0 -467
  97. data/lib/vendor/tmail/facade.rb +0 -552
  98. data/lib/vendor/tmail/header.rb +0 -914
  99. data/lib/vendor/tmail/info.rb +0 -35
  100. data/lib/vendor/tmail/loader.rb +0 -1
  101. data/lib/vendor/tmail/mail.rb +0 -447
  102. data/lib/vendor/tmail/mailbox.rb +0 -433
  103. data/lib/vendor/tmail/mbox.rb +0 -1
  104. data/lib/vendor/tmail/net.rb +0 -280
  105. data/lib/vendor/tmail/obsolete.rb +0 -135
  106. data/lib/vendor/tmail/parser.rb +0 -1522
  107. data/lib/vendor/tmail/port.rb +0 -377
  108. data/lib/vendor/tmail/quoting.rb +0 -131
  109. data/lib/vendor/tmail/scanner.rb +0 -41
  110. data/lib/vendor/tmail/scanner_r.rb +0 -263
  111. data/lib/vendor/tmail/stringio.rb +0 -277
  112. data/lib/vendor/tmail/tmail.rb +0 -1
  113. data/lib/vendor/tmail/utils.rb +0 -238
  114. data/test/fixtures/broken_from_spam.mail +0 -80
  115. data/test/fixtures/hello_world_empty_text.mail +0 -7
  116. data/test/fixtures/hello_world_mail_multipart.mail +0 -24
  117. data/test/fixtures/hello_world_mail_plain_no_content_type.mail +0 -7
  118. data/test/fixtures/hello_world_mail_plain_with_content_type.mail +0 -8
  119. data/test/fixtures/simple-with-two-images-two-texts.mail +0 -49
  120. data/test/fixtures/simple_image.mail +0 -19
  121. data/test/fixtures/simple_multipart_alternative.mail +0 -42
  122. data/test/test_mms2r_att_media.rb +0 -54
  123. data/test/test_mms2r_cingular_me_media.rb +0 -51
  124. data/test/test_mms2r_dobson_media.rb +0 -46
  125. data/test/test_mms2r_helio_media.rb +0 -49
  126. data/test/test_mms2r_m_mode_media.rb +0 -36
  127. data/test/test_mms2r_my_cingular_media.rb +0 -31
  128. data/test/test_mms2r_orange_france_media.rb +0 -53
  129. data/test/test_mms2r_orange_poland_media.rb +0 -42
  130. data/test/test_mms2r_sprint_media.rb +0 -269
  131. data/test/test_mms2r_vtext_media.rb +0 -28
@@ -0,0 +1,201 @@
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 TestPmSprintCom < Test::Unit::TestCase
10
+ include MMS2R::TestHelper
11
+
12
+ def mock_sprint_image(message_id)
13
+ uri = URI.parse('http://pictures.sprintpcs.com//mmps/RECIPIENT/001_2066c7013e7ca833_1/2?wm=1&ext=.jpg&iconifyVideo=true&inviteToken=PE5rJ5PdYzzwk7V7zoXU&outquality=90')
14
+ res = mock()
15
+ body = mock()
16
+ res.expects(:content_type).at_least_once.returns('image/jpeg')
17
+ res.expects(:body).once.returns(body)
18
+ res.expects(:code).never
19
+ Net::HTTP.expects(:get_response).once.with(uri).returns res
20
+ end
21
+
22
+ def mock_sprint_purged_image(message_id)
23
+ uri = URI.parse('http://pictures.sprintpcs.com//mmps/RECIPIENT/001_2066c7013e7ca833_1/2?wm=1&ext=.jpg&iconifyVideo=true&inviteToken=PE5rJ5PdYzzwk7V7zoXU&outquality=90')
24
+ res = mock()
25
+ body = mock()
26
+ res.expects(:content_type).once.returns('text/html')
27
+ res.expects(:code).once.returns('500')
28
+ res.expects(:body).never
29
+ Net::HTTP.expects(:get_response).once.with(uri).returns res
30
+ end
31
+
32
+ def test_mms_should_have_text
33
+ mail = TMail::Mail.parse(load_mail('sprint-text-01.mail').join)
34
+ mms = MMS2R::Media.new(mail)
35
+
36
+ assert_equal 1, mms.media.size
37
+ assert_equal 1, mms.media['text/plain'].size
38
+ file = mms.media['text/plain'].first
39
+ assert_equal true, File.exist?(file)
40
+ assert_match(/\.txt$/, File.basename(file))
41
+ assert_equal "Tea Pot", IO.read(file)
42
+ mms.purge
43
+ end
44
+
45
+ def test_mms_should_have_a_phone_number
46
+ mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
47
+ mms = MMS2R::Media.new(mail)
48
+
49
+ assert_equal '2068675309', mms.number
50
+ mms.purge
51
+ end
52
+
53
+ def test_should_have_simple_video
54
+ mail = TMail::Mail.parse(load_mail('sprint-video-01.mail').join)
55
+
56
+ uri = URI.parse(
57
+ 'http://pictures.sprintpcs.com//mmps/RECIPIENT/000_259e41e851be9b1d_1/2?inviteToken=lEvrJnPVY5UfOYmahQcx&amp;iconifyVideo=true&amp;wm=1&amp;limitsize=125,125&amp;outquality=90&amp;squareoutput=255,255,255&amp;ext=.jpg&amp;iconifyVideo=true&amp;wm=1')
58
+ res = mock()
59
+ body = mock()
60
+ res.expects(:content_type).at_least_once.returns('video/quicktime')
61
+ res.expects(:body).once.returns(body)
62
+ res.expects(:code).never
63
+ Net::HTTP.expects(:get_response).once.with(uri).returns res
64
+
65
+ mms = MMS2R::Media.new(mail)
66
+
67
+ assert_equal 1, mms.media.size
68
+ assert_nil mms.media['text/plain']
69
+ assert_nil mms.media['text/html']
70
+ assert_not_nil mms.media['video/quicktime']
71
+ assert_equal 1, mms.media['video/quicktime'].size
72
+ assert_equal "000_259e41e851be9b1d_1-0.mov", File.basename(mms.media['video/quicktime'][0])
73
+
74
+ mms.purge
75
+ end
76
+
77
+ def test_should_have_simple_image
78
+ mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
79
+ mock_sprint_image(mail.message_id)
80
+ mms = MMS2R::Media.new(mail)
81
+
82
+ assert_equal 1, mms.media.size
83
+ assert_nil mms.media['text/plain']
84
+ assert_nil mms.media['text/html']
85
+ assert_not_nil mms.media['image/jpeg'][0]
86
+ assert_match(/001_2066c7013e7ca833_1-0.jpg$/, mms.media['image/jpeg'][0])
87
+
88
+ mms.purge
89
+ end
90
+
91
+ def test_collect_image_using_block
92
+ mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
93
+ mock_sprint_image(mail.message_id)
94
+ mms = MMS2R::Media.new(mail)
95
+ assert_equal 1, mms.media.size
96
+ file_array = nil
97
+ mms.process do |k, v|
98
+ file_array = v if (k == 'image/jpeg')
99
+ assert_equal 1, file_array.size
100
+ file = file_array.first
101
+ assert_not_nil file = file_array.first
102
+ assert_equal "001_2066c7013e7ca833_1-0.jpg", File.basename(file)
103
+ end
104
+ mms.purge
105
+ end
106
+
107
+ def test_process_internals_should_only_be_executed_once
108
+ mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
109
+ mock_sprint_image(mail.message_id)
110
+ mms = MMS2R::Media.new(mail)
111
+ assert_equal 1, mms.media.size
112
+
113
+ # second time through shouldn't go into the was_processed block
114
+ mms.mail.expects(:parts).never
115
+
116
+ mms.process{|k, v| }
117
+
118
+ mms.purge
119
+ end
120
+
121
+ def test_should_have_two_images
122
+ mail = TMail::Mail.parse(load_mail('sprint-two-images-01.mail').join)
123
+
124
+ uri1 = URI.parse('http://pictures.sprintpcs.com/mmps/RECIPIENT/001_104058d23d79fb6a_1/2?wm=1&ext=.jpg&iconifyVideo=true&inviteToken=5E1rJSPk5hYDkUnY7op0&outquality=90')
125
+ res1 = mock()
126
+ body1 = mock()
127
+ res1.expects(:content_type).at_least_once.returns('image/jpeg')
128
+ res1.expects(:body).once.returns(body1)
129
+ res1.expects(:code).never
130
+ Net::HTTP.expects(:get_response).once.with(uri1).returns res1
131
+
132
+ uri2 = URI.parse('http://pictures.sprintpcs.com/mmps/RECIPIENT/001_104058d23d79fb6a_1/3?wm=1&ext=.jpg&iconifyVideo=true&inviteToken=5E1rJSPk5hYDkUnY7op0&outquality=90')
133
+
134
+ res2 = mock()
135
+ body2 = mock()
136
+ res2.expects(:content_type).at_least_once.returns('image/jpeg')
137
+ res2.expects(:body).once.returns(body2)
138
+ res2.expects(:code).never
139
+ Net::HTTP.expects(:get_response).once.with(uri2).returns res2
140
+ mms = MMS2R::Media.new(mail)
141
+
142
+ assert_equal 1, mms.media.size
143
+ assert_nil mms.media['text/plain']
144
+ assert_nil mms.media['text/html']
145
+ assert_equal 2, mms.media['image/jpeg'].size
146
+ assert_not_nil mms.media['image/jpeg'][0]
147
+ assert_not_nil mms.media['image/jpeg'][1]
148
+ assert_match(/001_104058d23d79fb6a_1-0.jpg$/, mms.media['image/jpeg'][0])
149
+ assert_match(/001_104058d23d79fb6a_1-1.jpg$/, mms.media['image/jpeg'][1])
150
+
151
+ mms.purge
152
+ end
153
+
154
+ def test_image_should_be_missing
155
+ # this test is questionable
156
+ mail = TMail::Mail.parse(load_mail('sprint-broken-image-01.mail').join)
157
+ mms = MMS2R::Media.new(mail)
158
+
159
+ assert_equal 0, mms.media.size
160
+
161
+ mms.purge
162
+ end
163
+
164
+ def test_image_should_be_purged_from_content_server
165
+ mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
166
+ mock_sprint_purged_image(mail.message_id)
167
+ mms = MMS2R::Media.new(mail)
168
+
169
+ assert_equal 0, mms.media.size
170
+
171
+ mms.purge
172
+ end
173
+
174
+ def test_body_should_return_empty_when_there_is_no_user_text
175
+ mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
176
+ mms = MMS2R::Media.new(mail)
177
+ assert_equal "", mms.body
178
+ end
179
+
180
+ def test_sprint_write_file
181
+ require 'tempfile'
182
+ mail = mock(:message_id => 'a')
183
+ mail.expects(:from).at_least_once.returns(['joe@pm.sprint.com'])
184
+ s = MMS2R::Media::Sprint.new(mail, :process => :lazy)
185
+ type = 'text/plain'
186
+ content = 'foo'
187
+ file = Tempfile.new('sprint')
188
+ file.close
189
+
190
+ type, file = s.send(:sprint_write_file, type, content, file.path)
191
+ assert_equal 'text/plain', type
192
+ assert_equal content, IO.read(file)
193
+ end
194
+
195
+ def test_subject
196
+ mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
197
+ mms = MMS2R::Media.new(mail)
198
+ assert_equal "", mms.subject
199
+ end
200
+
201
+ end
@@ -0,0 +1,37 @@
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 TestPxtVodafoneNetNz < Test::Unit::TestCase
10
+ include MMS2R::TestHelper
11
+
12
+ def setup
13
+ mail = TMail::Mail.parse(load_mail('pxt-image-01.mail').join)
14
+ @mms = MMS2R::Media.new(mail)
15
+ end
16
+
17
+ def teardown
18
+ @mms.purge
19
+ end
20
+
21
+ def test_pxt_text_returns_text_plain
22
+ assert_not_nil(@mms.media['text/plain'])
23
+
24
+ file = @mms.media['text/plain'][0]
25
+ assert_not_nil(file)
26
+ assert(File::exist?(file), "file #{file} does not exist")
27
+ text = IO.readlines("#{file}").join
28
+ assert_match(/Kia ora ano Luke/, text)
29
+
30
+ assert_match(/Kia ora ano Luke/, @mms.body)
31
+ end
32
+
33
+ def test_subject_should_clear_default_pxt_message
34
+ assert_equal "", @mms.subject
35
+ end
36
+
37
+ end
@@ -1,27 +1,17 @@
1
- $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
- require File.dirname(__FILE__) + "/test_helper"
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
2
+ require File.join(File.dirname(__FILE__), "test_helper")
3
3
  require 'test/unit'
4
4
  require 'rubygems'
5
- require 'mms2r'
6
- require 'mms2r/media'
7
- require 'tmail/mail'
8
- require 'logger'
5
+ require 'mocha'
6
+ gem 'tmail', '>= 1.2.1'
7
+ require 'tmail'
9
8
 
10
- class MMS2R::TMobileMediaTest < Test::Unit::TestCase
9
+ class TestTmobileNet < Test::Unit::TestCase
11
10
  include MMS2R::TestHelper
12
11
 
13
- def setup
14
- @log = Logger.new(STDOUT)
15
- @log.level = Logger::DEBUG
16
- @log.datetime_format = "%H:%M:%S"
17
- end
18
-
19
- def teardown; end
20
-
21
12
  def test_ignore_simple_image
22
13
  mail = TMail::Mail.parse(load_mail('tmobile-image-01.mail').join)
23
- mms = MMS2R::Media.create(mail)
24
- mms.process
14
+ mms = MMS2R::Media.new(mail)
25
15
 
26
16
  assert_equal 1, mms.media.size
27
17
  assert_nil mms.media['text/plain']
@@ -36,8 +26,7 @@ class MMS2R::TMobileMediaTest < Test::Unit::TestCase
36
26
 
37
27
  def test_message_with_body_text
38
28
  mail = TMail::Mail.parse(load_mail('tmobile-image-02.mail').join)
39
- mms = MMS2R::Media.create(mail)
40
- mms.process
29
+ mms = MMS2R::Media.new(mail)
41
30
 
42
31
  assert_equal 2, mms.media.size
43
32
  assert_not_nil mms.media['text/plain']
@@ -1,29 +1,23 @@
1
- $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
- require File.dirname(__FILE__) + "/test_helper"
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
2
+ require File.join(File.dirname(__FILE__), "test_helper")
3
3
  require 'test/unit'
4
4
  require 'rubygems'
5
- require 'mms2r'
6
- require 'mms2r/media'
7
- require 'tmail/mail'
8
- require 'logger'
5
+ require 'mocha'
6
+ gem 'tmail', '>= 1.2.1'
7
+ require 'tmail'
9
8
 
10
- class MMS2R::VerizonMediaTest < Test::Unit::TestCase
9
+ class TestVzwpixCom < Test::Unit::TestCase
11
10
  include MMS2R::TestHelper
12
11
 
13
12
  def setup
14
- @log = Logger.new(STDOUT)
15
- @log.level = Logger::DEBUG
16
- @log.datetime_format = "%H:%M:%S"
17
13
  @ad = "This message was sent using PIX-FLIX Messaging service from Verizon Wireless!\nTo learn how you can snap pictures with your wireless phone visit\nwww.verizonwireless.com/getitnow/getpix."
18
14
  @greet = "This message was sent using PIX-FLIX Messaging service from Verizon Wireless!"
19
15
  end
20
16
 
21
- def teardown; end
22
-
23
17
  def test_simple_video
18
+ # vzwpix.com service
24
19
  mail = TMail::Mail.parse(load_mail('verizon-video-01.mail').join)
25
- mms = MMS2R::Media.create(mail)
26
- mms.process
20
+ mms = MMS2R::Media.new(mail)
27
21
 
28
22
  assert_equal 1, mms.media.size
29
23
  assert_nil mms.media['text/plain']
@@ -37,10 +31,9 @@ class MMS2R::VerizonMediaTest < Test::Unit::TestCase
37
31
  end
38
32
 
39
33
  def test_simple_image
34
+ # vzwpix.com service
40
35
  mail = TMail::Mail.parse(load_mail('verizon-image-01.mail').join)
41
- mms = MMS2R::Media.create(mail)
42
- mms.process
43
- assert_equal MMS2R::VerizonMedia, mms.class, "expected a #{MMS2R::VerizonMedia} and received a #{mms.class}"
36
+ mms = MMS2R::Media.new(mail)
44
37
 
45
38
  assert_equal 1, mms.media.size
46
39
  assert_nil mms.media['text/plain']
@@ -54,24 +47,25 @@ class MMS2R::VerizonMediaTest < Test::Unit::TestCase
54
47
  end
55
48
 
56
49
  def test_simple_text
50
+ # vzwpix.com service
57
51
  mail = TMail::Mail.parse(load_mail('verizon-text-01.mail').join)
58
- mms = MMS2R::Media.create(mail)
59
- assert_equal MMS2R::VerizonMedia, mms.class, "expected a #{MMS2R::VerizonMedia} and received a #{mms.class}"
60
- mms.process
52
+ mms = MMS2R::Media.new(mail)
53
+
61
54
  assert_equal 1, mms.media.size
62
55
  assert_not_nil mms.media['text/plain']
63
56
  file = mms.media['text/plain'][0]
64
57
  assert_not_nil file
65
- assert File::exist?(file), "file #{file} does not exist"
58
+ assert_equal true, File::exist?(file)
59
+
66
60
  text = IO.readlines("#{file}").join
67
61
  assert_match(/hello world/, text)
68
62
  mms.purge
69
63
  end
70
64
 
71
65
  def test_image_with_body_text
66
+ # vzwpix.com service
72
67
  mail = TMail::Mail.parse(load_mail('verizon-image-02.mail').join)
73
- mms = MMS2R::Media.create(mail)
74
- mms.process
68
+ mms = MMS2R::Media.new(mail)
75
69
 
76
70
  assert_equal 2, mms.media.size
77
71
  assert_not_nil mms.media['text/plain']
@@ -83,14 +77,27 @@ class MMS2R::VerizonMediaTest < Test::Unit::TestCase
83
77
 
84
78
  file = mms.media['text/plain'][0]
85
79
  assert_not_nil file
86
- assert File::exist?(file), "file #{file} does not exist"
80
+ assert_equal true, File::exist?(file)
87
81
  text = IO.readlines("#{file}").join
88
- assert !text.match(@ad), "found ad in text"
89
- assert !text.match(@greet), "found ad in text"
82
+ assert_no_match(/Regexp.escape(@ad)/, text)
83
+ assert_no_match(/Regexp.escape@greet/, text)
90
84
  assert_equal "? Weird", text
91
85
 
92
86
  mms.purge
93
87
  end
94
88
 
95
-
89
+ def test_simple_text_vtext
90
+ # vtext.com service
91
+ mail = TMail::Mail.parse(load_mail('vtext-text-01.mail').join)
92
+ mms = MMS2R::Media.new(mail)
93
+
94
+ assert_not_nil mms.media['text/plain']
95
+ file = mms.media['text/plain'][0]
96
+ assert_not_nil file
97
+ assert_equal true, File::exist?(file)
98
+ text = IO.readlines("#{file}").join
99
+ assert_match(/hello world/, text)
100
+ mms.purge
101
+ end
102
+
96
103
  end
@@ -4,30 +4,35 @@ class Autotest::Mms2r < Autotest
4
4
 
5
5
  def initialize # :nodoc:
6
6
  super
7
- @exceptions = /\.svn|test\/files|test\/test_helper|doc\/|lib\/vendor|coverage\//
7
+ @exceptions = /\.svn/
8
8
  @test_mappings = {
9
- %r%^conf/(mms2r_.*media)_(subject|transform|ignore)\.yml% => proc { |_, m|
10
- ["test/test_#{m[1]}.rb"]
9
+ %r%^conf/aliases.yml$% => proc { |_, m|
10
+ ["test/test_mms2r_media.rb"]
11
11
  },
12
- %r%^lib/mms2r/(.+)\.rb$% => proc { |_, m|
13
- ["test/test_mms2r_#{m[1]}.rb"]
12
+ %r%^conf/(.*)\.yml% => proc { |_, m|
13
+ ["test/test_#{m[1].gsub(/\./,'_')}.rb"]
14
14
  },
15
15
  %r%^lib/mms2r.rb$% => proc { |_, m|
16
16
  ["test/test_mms2r_media.rb"]
17
17
  },
18
- %r%^test/test_mms2r_.*media\.rb$% => proc { |filename, _|
18
+ %r%^lib/mms2r/media.rb$% => proc { |_, m|
19
+ ["test/test_mms2r_media.rb"]
20
+ },
21
+ %r%^lib/mms2r/media/sprint.rb$% => proc { |_, m|
22
+ ["test/test_pm_sprint_com.rb"]
23
+ },
24
+ %r%^test/test_.*\.rb$% => proc { |filename, _|
19
25
  filename
20
26
  }
21
27
  }
22
28
  end
23
29
 
24
30
  def path_to_classname(s)
25
- f = s.sub(/.*test_mms2r_(.+).rb$/, '\1')
31
+ sep = File::SEPARATOR
32
+ f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
26
33
  f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
27
- f.unshift("MMS2R")
28
- l = f.pop
29
- f.push( l =~ /Test$/ ? l : "#{l}Test" )
30
- f.join('::')
34
+ f = f.map { |path| path =~ /^Test/ ? path : "Test#{path}" }
35
+ f.join
31
36
  end
32
37
 
33
38
  end
metadata CHANGED
@@ -1,122 +1,104 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: mms2r
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.1.12
7
- date: 2007-10-21 00:00:00 -07:00
8
- summary: Extract user media from MMS (and not carrier cruft)
9
- require_paths:
10
- - lib
11
- email: mikemondragon@gmail.com
12
- homepage: http://mms2r.rubyforge.org/
13
- rubyforge_project: mms2r
14
- description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the cellphone 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 => mms.att.net * AT&T/Cingular => mmode.com * Cingular => mms.mycingular.com * Cingular => cingularme.com * Dobson/Cellular One => mms.dobson.net * Helio => mms.myhelio.com * Nextel => messaging.nextel.com * Orange (Poland) => mmsemail.orange.pl * Orange (France) => orange.fr * Sprint => pm.sprint.com * Sprint => messaging.sprintpcs.com * T-Mobile => tmomail.net * Verizon => vzwpix.com * Verizon => vtext.com"
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 2.0.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Mike Mondragon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-01-23 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hpricot
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.6.0
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: tmail
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.2.1
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: hoe
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.4.0
41
+ version:
42
+ 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"
43
+ email: mikemondragon@gmail.com
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ extra_rdoc_files:
49
+ - History.txt
50
+ - Manifest.txt
51
+ - README.txt
31
52
  files:
32
53
  - History.txt
33
54
  - Manifest.txt
34
55
  - README.txt
35
56
  - Rakefile
36
- - conf/mms2r_alltel_media_ignore.yml
37
- - conf/mms2r_att_media_subject.yml
38
- - conf/mms2r_cingular_me_media_subject.yml
39
- - conf/mms2r_cingular_me_media_transform.yml
40
- - conf/mms2r_dobson_media_ignore.yml
41
- - conf/mms2r_helio_media_ignore.yml
42
- - conf/mms2r_media_ignore.yml
43
- - conf/mms2r_media_subject.yml
44
- - conf/mms2r_my_cingular_media_subject.yml
45
- - conf/mms2r_nextel_media_ignore.yml
46
- - conf/mms2r_orange_france_media_ignore.yml
47
- - conf/mms2r_orange_poland_media_subject.yml
48
- - conf/mms2r_sprint_media_ignore.yml
49
- - conf/mms2r_sprint_media_subject.yml
50
- - conf/mms2r_t_mobile_media_ignore.yml
51
- - conf/mms2r_verizon_media_ignore.yml
52
- - conf/mms2r_verizon_media_transform.yml
57
+ - conf/aliases.yml
58
+ - conf/message.alltel.com.yml
59
+ - conf/messaging.nextel.com.yml
60
+ - conf/mms.att.net.yml
61
+ - conf/mms.dobson.net.yml
62
+ - conf/mms.luxgsm.lu.yml
63
+ - conf/mms.myhelio.com.yml
64
+ - conf/mms.netcom.no.yml
65
+ - conf/mms.o2online.de.yml
66
+ - conf/mms.three.co.uk.yml
67
+ - conf/mms2r_media.yml
68
+ - conf/orangemms.net.yml
69
+ - conf/pm.sprint.com.yml
70
+ - conf/pxt.vodafone.net.nz.yml
71
+ - conf/tmomail.net.yml
72
+ - conf/vzwpix.com.yml
73
+ - dev_tools/anonymizer.rb
53
74
  - dev_tools/debug_sprint_hpricot_parsing.rb
54
75
  - lib/mms2r.rb
55
- - lib/mms2r/alltel_media.rb
56
- - lib/mms2r/att_media.rb
57
- - lib/mms2r/cingular_me_media.rb
58
- - lib/mms2r/dobson_media.rb
59
- - lib/mms2r/helio_media.rb
60
- - lib/mms2r/m_mode_media.rb
61
76
  - lib/mms2r/media.rb
62
- - lib/mms2r/my_cingular_media.rb
63
- - lib/mms2r/nextel_media.rb
64
- - lib/mms2r/orange_france_media.rb
65
- - lib/mms2r/orange_poland_media.rb
66
- - lib/mms2r/sprint_media.rb
67
- - lib/mms2r/sprint_pcs_media.rb
68
- - lib/mms2r/t_mobile_media.rb
69
- - lib/mms2r/verizon_media.rb
70
- - lib/mms2r/vtext_media.rb
71
- - lib/vendor/text/format.rb
72
- - lib/vendor/tmail.rb
73
- - lib/vendor/tmail/address.rb
74
- - lib/vendor/tmail/attachments.rb
75
- - lib/vendor/tmail/base64.rb
76
- - lib/vendor/tmail/config.rb
77
- - lib/vendor/tmail/encode.rb
78
- - lib/vendor/tmail/facade.rb
79
- - lib/vendor/tmail/header.rb
80
- - lib/vendor/tmail/info.rb
81
- - lib/vendor/tmail/loader.rb
82
- - lib/vendor/tmail/mail.rb
83
- - lib/vendor/tmail/mailbox.rb
84
- - lib/vendor/tmail/mbox.rb
85
- - lib/vendor/tmail/net.rb
86
- - lib/vendor/tmail/obsolete.rb
87
- - lib/vendor/tmail/parser.rb
88
- - lib/vendor/tmail/port.rb
89
- - lib/vendor/tmail/quoting.rb
90
- - lib/vendor/tmail/scanner.rb
91
- - lib/vendor/tmail/scanner_r.rb
92
- - lib/vendor/tmail/stringio.rb
93
- - lib/vendor/tmail/tmail.rb
94
- - lib/vendor/tmail/utils.rb
77
+ - lib/mms2r/media/sprint.rb
95
78
  - test/fixtures/alltel-image-01.mail
96
79
  - test/fixtures/att-image-01.mail
97
80
  - test/fixtures/att-image-02.mail
98
- - test/fixtures/broken_from_spam.mail
81
+ - test/fixtures/att-text-01.mail
99
82
  - test/fixtures/cingularme-text-01.mail
100
83
  - test/fixtures/cingularme-text-02.mail
101
84
  - test/fixtures/dobson-image-01.mail
102
85
  - test/fixtures/dot.jpg
103
86
  - test/fixtures/helio-image-01.mail
104
- - test/fixtures/hello_world_empty_text.mail
105
- - test/fixtures/hello_world_mail_multipart.mail
106
- - test/fixtures/hello_world_mail_plain_no_content_type.mail
107
- - test/fixtures/hello_world_mail_plain_with_content_type.mail
87
+ - test/fixtures/helio-message-01.mail
88
+ - test/fixtures/luxgsm-image-01.mail
108
89
  - test/fixtures/mmode-image-01.mail
109
90
  - test/fixtures/mycingular-image-01.mail
91
+ - test/fixtures/netcom-image-01.mail
110
92
  - test/fixtures/nextel-image-01.mail
111
93
  - test/fixtures/nextel-image-02.mail
112
94
  - test/fixtures/nextel-image-03.mail
113
95
  - test/fixtures/nextel-image-04.mail
96
+ - test/fixtures/o2-de-image-01.mail
97
+ - test/fixtures/orange-uk-image-01.mail
114
98
  - test/fixtures/orangefrance-text-and-image.mail
115
99
  - test/fixtures/orangepoland-text-01.mail
116
100
  - test/fixtures/orangepoland-text-02.mail
117
- - test/fixtures/simple-with-two-images-two-texts.mail
118
- - test/fixtures/simple_image.mail
119
- - test/fixtures/simple_multipart_alternative.mail
101
+ - test/fixtures/pxt-image-01.mail
120
102
  - test/fixtures/sprint-broken-image-01.mail
121
103
  - test/fixtures/sprint-image-01.mail
122
104
  - test/fixtures/sprint-pcs-text-01.mail
@@ -125,6 +107,7 @@ files:
125
107
  - test/fixtures/sprint-two-images-01.mail
126
108
  - test/fixtures/sprint-video-01.mail
127
109
  - test/fixtures/sprint.mov
110
+ - test/fixtures/three-uk-image-01.mail
128
111
  - test/fixtures/tmobile-image-01.mail
129
112
  - test/fixtures/tmobile-image-02.mail
130
113
  - test/fixtures/verizon-image-01.mail
@@ -133,80 +116,68 @@ files:
133
116
  - test/fixtures/verizon-video-01.mail
134
117
  - test/fixtures/vtext-text-01.mail
135
118
  - test/test_helper.rb
136
- - test/test_mms2r_alltel_media.rb
137
- - test/test_mms2r_att_media.rb
138
- - test/test_mms2r_cingular_me_media.rb
139
- - test/test_mms2r_dobson_media.rb
140
- - test/test_mms2r_helio_media.rb
141
- - test/test_mms2r_m_mode_media.rb
119
+ - test/test_message_alltel_com.rb
120
+ - test/test_messaging_nextel_com.rb
121
+ - test/test_messaging_sprintpcs_com.rb
142
122
  - test/test_mms2r_media.rb
143
- - test/test_mms2r_my_cingular_media.rb
144
- - test/test_mms2r_nextel_media.rb
145
- - test/test_mms2r_orange_france_media.rb
146
- - test/test_mms2r_orange_poland_media.rb
147
- - test/test_mms2r_sprint_media.rb
148
- - test/test_mms2r_sprint_pcs_media.rb
149
- - test/test_mms2r_t_mobile_media.rb
150
- - test/test_mms2r_verizon_media.rb
151
- - test/test_mms2r_vtext_media.rb
123
+ - test/test_mms_att_net.rb
124
+ - test/test_mms_dobson_net.rb
125
+ - test/test_mms_luxgsm_lu.rb
126
+ - test/test_mms_myhelio_com.rb
127
+ - test/test_mms_netcom_no.rb
128
+ - test/test_mms_o2online_de.rb
129
+ - test/test_mms_three_co_uk.rb
130
+ - test/test_orangemms_net.rb
131
+ - test/test_pm_sprint_com.rb
132
+ - test/test_pxt_vodafone_net_nz.rb
133
+ - test/test_tmomail_net.rb
134
+ - test/test_vzwpix_com.rb
152
135
  - vendor/plugins/mms2r/lib/autotest/discover.rb
153
136
  - vendor/plugins/mms2r/lib/autotest/mms2r.rb
154
- test_files:
155
- - test/test_mms2r_cingular_me_media.rb
156
- - test/test_mms2r_orange_poland_media.rb
157
- - test/test_mms2r_helio_media.rb
158
- - test/test_mms2r_sprint_pcs_media.rb
159
- - test/test_mms2r_att_media.rb
160
- - test/test_mms2r_media.rb
161
- - test/test_mms2r_my_cingular_media.rb
162
- - test/test_mms2r_nextel_media.rb
163
- - test/test_mms2r_sprint_media.rb
164
- - test/test_mms2r_vtext_media.rb
165
- - test/test_mms2r_dobson_media.rb
166
- - test/test_mms2r_alltel_media.rb
167
- - test/test_mms2r_orange_france_media.rb
168
- - test/test_mms2r_m_mode_media.rb
169
- - test/test_mms2r_verizon_media.rb
170
- - test/test_helper.rb
171
- - test/test_mms2r_t_mobile_media.rb
137
+ has_rdoc: true
138
+ homepage: |
139
+ http://mms2r.rubyforge.org/
140
+
141
+ post_install_message:
172
142
  rdoc_options:
173
143
  - --main
174
144
  - README.txt
175
- extra_rdoc_files:
176
- - History.txt
177
- - Manifest.txt
178
- - README.txt
179
- executables: []
180
-
181
- extensions: []
182
-
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: "0"
152
+ version:
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: "0"
158
+ version:
183
159
  requirements: []
184
160
 
185
- dependencies:
186
- - !ruby/object:Gem::Dependency
187
- name: hpricot
188
- version_requirement:
189
- version_requirements: !ruby/object:Gem::Version::Requirement
190
- requirements:
191
- - - ">="
192
- - !ruby/object:Gem::Version
193
- version: 0.6.0
194
- version:
195
- - !ruby/object:Gem::Dependency
196
- name: mechanize
197
- version_requirement:
198
- version_requirements: !ruby/object:Gem::Version::Requirement
199
- requirements:
200
- - - ">="
201
- - !ruby/object:Gem::Version
202
- version: 0.6.9
203
- version:
204
- - !ruby/object:Gem::Dependency
205
- name: hoe
206
- version_requirement:
207
- version_requirements: !ruby/object:Gem::Version::Requirement
208
- requirements:
209
- - - ">="
210
- - !ruby/object:Gem::Version
211
- version: 1.3.0
212
- version:
161
+ rubyforge_project: mms2r
162
+ rubygems_version: 1.0.1
163
+ signing_key:
164
+ specification_version: 2
165
+ summary: Extract user media from MMS (and not carrier cruft)
166
+ test_files:
167
+ - test/test_pxt_vodafone_net_nz.rb
168
+ - test/test_pm_sprint_com.rb
169
+ - test/test_messaging_sprintpcs_com.rb
170
+ - test/test_vzwpix_com.rb
171
+ - test/test_mms2r_media.rb
172
+ - test/test_mms_o2online_de.rb
173
+ - test/test_message_alltel_com.rb
174
+ - test/test_mms_att_net.rb
175
+ - test/test_mms_netcom_no.rb
176
+ - test/test_tmomail_net.rb
177
+ - test/test_mms_myhelio_com.rb
178
+ - test/test_mms_three_co_uk.rb
179
+ - test/test_mms_dobson_net.rb
180
+ - test/test_mms_luxgsm_lu.rb
181
+ - test/test_orangemms_net.rb
182
+ - test/test_helper.rb
183
+ - test/test_messaging_nextel_com.rb