mms2r 1.1.10 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +16 -1
- data/Manifest.txt +2 -2
- data/README.txt +8 -7
- data/conf/mms2r_t_mobile_media_ignore.yml +2 -1
- data/lib/mms2r.rb +3 -3
- data/lib/mms2r/{a_t_t_media.rb → att_media.rb} +1 -1
- data/lib/mms2r/helio_media.rb +2 -3
- data/lib/mms2r/media.rb +50 -10
- data/lib/mms2r/sprint_media.rb +8 -1
- data/test/test_mms2r_alltel_media.rb +2 -2
- data/test/{test_mms2r_a_t_t_media.rb → test_mms2r_att_media.rb} +4 -4
- data/test/test_mms2r_dobson_media.rb +2 -2
- data/test/test_mms2r_helio_media.rb +8 -8
- data/test/test_mms2r_media.rb +14 -14
- data/test/test_mms2r_my_cingular_media.rb +2 -2
- data/test/test_mms2r_nextel_media.rb +4 -4
- data/test/test_mms2r_orange_france_media.rb +3 -3
- data/test/test_mms2r_orange_poland_media.rb +2 -2
- data/test/test_mms2r_sprint_media.rb +22 -8
- metadata +6 -6
data/History.txt
CHANGED
@@ -1,9 +1,24 @@
|
|
1
|
+
== 1.1.11 / 2007-10-20 (Dr. Armand Skagerakk Frederickshaven)
|
2
|
+
|
3
|
+
* minor fix for attachment_fu where it might call #path on the cgi temp file
|
4
|
+
that is returned by get_attachment
|
5
|
+
* renamed a_t_t_media.rb to att_media.rb to make it autotest happy
|
6
|
+
* masthead.jpg misplaced in mms2r_t_mobile_media_ignore.yml (Layton Wedgeworth)
|
7
|
+
* overridden SprintMedia#process failed to accept block (Layton Wedgeworth)
|
8
|
+
* added method_deprecated to help mark methods that are going to be deprecated
|
9
|
+
in preparation of 1.2.x release
|
10
|
+
* #get_number marked deprecated, use #number instead
|
11
|
+
* #get_subject marked deprecated, use #subject instead
|
12
|
+
* #get_body marked deprecated, use #body instead
|
13
|
+
* #get_text marked deprecated, use #default_text instead
|
14
|
+
* #get_attachment marked deprecated, use #attachment instead
|
15
|
+
* #get_media marked deprecated, use #default_media instead
|
16
|
+
|
1
17
|
== 1.1.10 / 2007-09-30 (Face Bones)
|
2
18
|
|
3
19
|
* fixed a case for a nil match on From in the create method (Luke Francl)
|
4
20
|
* added support for Alltel message.alltel.com (Ben Wood)
|
5
21
|
|
6
|
-
|
7
22
|
== 1.1.9 / 2007-09-08 (Rebecca Nightrod - controlling girlfriend of Nathan
|
8
23
|
Explosion)
|
9
24
|
|
data/Manifest.txt
CHANGED
@@ -21,8 +21,8 @@ conf/mms2r_verizon_media_ignore.yml
|
|
21
21
|
conf/mms2r_verizon_media_transform.yml
|
22
22
|
dev_tools/debug_sprint_hpricot_parsing.rb
|
23
23
|
lib/mms2r.rb
|
24
|
-
lib/mms2r/a_t_t_media.rb
|
25
24
|
lib/mms2r/alltel_media.rb
|
25
|
+
lib/mms2r/att_media.rb
|
26
26
|
lib/mms2r/cingular_me_media.rb
|
27
27
|
lib/mms2r/dobson_media.rb
|
28
28
|
lib/mms2r/helio_media.rb
|
@@ -101,8 +101,8 @@ test/fixtures/verizon-text-01.mail
|
|
101
101
|
test/fixtures/verizon-video-01.mail
|
102
102
|
test/fixtures/vtext-text-01.mail
|
103
103
|
test/test_helper.rb
|
104
|
-
test/test_mms2r_a_t_t_media.rb
|
105
104
|
test/test_mms2r_alltel_media.rb
|
105
|
+
test/test_mms2r_att_media.rb
|
106
106
|
test/test_mms2r_cingular_me_media.rb
|
107
107
|
test/test_mms2r_dobson_media.rb
|
108
108
|
test/test_mms2r_helio_media.rb
|
data/README.txt
CHANGED
@@ -36,7 +36,8 @@ Corpus of carriers currently processed by MMS2R:
|
|
36
36
|
|
37
37
|
== FEATURES
|
38
38
|
|
39
|
-
*
|
39
|
+
* #default_media and #default_text methods return a File that can be used in
|
40
|
+
attachment_fu
|
40
41
|
|
41
42
|
== SYNOPSIS:
|
42
43
|
|
@@ -58,18 +59,18 @@ Corpus of carriers currently processed by MMS2R:
|
|
58
59
|
# writes the user generated media to disk in a temporary subdirectory
|
59
60
|
mms.process
|
60
61
|
|
61
|
-
puts "MMS has default carrier subject!" unless mms.
|
62
|
+
puts "MMS has default carrier subject!" unless mms.subject
|
62
63
|
|
63
64
|
# access the senders phone number
|
64
|
-
puts "MMS was from phone #{mms.
|
65
|
+
puts "MMS was from phone #{mms.number}"
|
65
66
|
|
66
|
-
# most MMS are either image or video,
|
67
|
+
# most MMS are either image or video, default_media will return the largest
|
67
68
|
# (non-advertising) video or image found
|
68
|
-
file = mms.
|
69
|
+
file = mms.default_media
|
69
70
|
puts "MMS had a media: #{file.inspect}" unless file.nil?
|
70
71
|
|
71
|
-
#
|
72
|
-
file = mms.
|
72
|
+
# text return the largest (non-advertising) text found
|
73
|
+
file = mms.default_text
|
73
74
|
puts "MMS had some text: #{file.inspect}" unless file.nil?
|
74
75
|
|
75
76
|
# mms.media is a hash that is indexed by mime-type.
|
@@ -1,12 +1,13 @@
|
|
1
1
|
---
|
2
2
|
text/html:
|
3
3
|
- !ruby/regexp /^<html> <head> <title>T-Mobile</title>/
|
4
|
+
image/jpeg:
|
5
|
+
- masthead.jpg
|
4
6
|
image/gif:
|
5
7
|
- dottedline350.gif
|
6
8
|
- dottedline600.gif
|
7
9
|
- dottedLine_350.gif
|
8
10
|
- dottedLine_600.gif
|
9
|
-
- masthead.jpg
|
10
11
|
- spacer.gif
|
11
12
|
- video.gif
|
12
13
|
- audio.gif
|
data/lib/mms2r.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
$:.unshift(File.dirname(__FILE__) + "/vendor/")
|
8
8
|
require 'mms2r/media'
|
9
9
|
require 'mms2r/alltel_media'
|
10
|
-
require 'mms2r/
|
10
|
+
require 'mms2r/att_media'
|
11
11
|
require 'mms2r/cingular_me_media'
|
12
12
|
require 'mms2r/dobson_media'
|
13
13
|
require 'mms2r/helio_media'
|
@@ -33,7 +33,7 @@ module MMS2R
|
|
33
33
|
|
34
34
|
CARRIER_CLASSES = {
|
35
35
|
'message.alltel.com' => MMS2R::AlltelMedia,
|
36
|
-
'mms.att.net' => MMS2R::
|
36
|
+
'mms.att.net' => MMS2R::AttMedia,
|
37
37
|
'cingularme.com' => MMS2R::CingularMeMedia,
|
38
38
|
'mms.dobson.net' => MMS2R::DobsonMedia,
|
39
39
|
'mms.myhelio.com' => MMS2R::HelioMedia,
|
@@ -67,7 +67,7 @@ module MMS2R
|
|
67
67
|
##
|
68
68
|
# MMS2R Library version
|
69
69
|
|
70
|
-
VERSION = '1.1.
|
70
|
+
VERSION = '1.1.11'
|
71
71
|
|
72
72
|
end
|
73
73
|
|
data/lib/mms2r/helio_media.rb
CHANGED
@@ -11,9 +11,8 @@ module MMS2R
|
|
11
11
|
# in the markup.
|
12
12
|
|
13
13
|
class MMS2R::HelioMedia < MMS2R::Media
|
14
|
-
def
|
15
|
-
|
16
|
-
d = Hpricot(text)
|
14
|
+
def body
|
15
|
+
d = Hpricot(default_text())
|
17
16
|
body = d.search("//table/tr[2]/td/table/tr/td/table/tr[6]/td").inner_html
|
18
17
|
body
|
19
18
|
end
|
data/lib/mms2r/media.rb
CHANGED
@@ -111,17 +111,22 @@ module MMS2R
|
|
111
111
|
# your application on your own. Most carriers are using the real
|
112
112
|
# phone number as the username.
|
113
113
|
|
114
|
-
def
|
114
|
+
def number
|
115
115
|
# override this method in a child if the number exists elsewhere (like Sprint)
|
116
116
|
@number ||= /^([^@]+)@/.match(mail.from[0])[1]
|
117
117
|
end
|
118
118
|
|
119
|
+
def get_number # :nodoc:
|
120
|
+
sclz.method_deprecated(:get_number, :number)
|
121
|
+
self.number
|
122
|
+
end
|
123
|
+
|
119
124
|
##
|
120
125
|
# Filter some common place holder subjects from MMS messages and
|
121
126
|
# return nil such that default carrier subjects can be pragmatically
|
122
127
|
# ignored.
|
123
128
|
|
124
|
-
def
|
129
|
+
def subject
|
125
130
|
|
126
131
|
return @subject if @subject # we've already done the work
|
127
132
|
|
@@ -142,14 +147,19 @@ module MMS2R
|
|
142
147
|
return @subject ||= nil if a.detect{|r| r.match(subject.strip)}
|
143
148
|
return @subject ||= subject
|
144
149
|
end
|
150
|
+
|
151
|
+
def get_subject # :nodoc:
|
152
|
+
sclz.method_deprecated(:get_subject, :subject)
|
153
|
+
self.subject
|
154
|
+
end
|
145
155
|
|
146
156
|
# Convenience method that returns a string including all the text of the
|
147
157
|
# first text/plain file found. Returns empty string if no body text
|
148
158
|
# is found.
|
149
|
-
def
|
159
|
+
def body
|
150
160
|
return @body if @body
|
151
161
|
|
152
|
-
text_file =
|
162
|
+
text_file = default_text
|
153
163
|
if text_file.nil?
|
154
164
|
return @body ||= nil
|
155
165
|
end
|
@@ -157,6 +167,11 @@ module MMS2R
|
|
157
167
|
return @body ||= IO.readlines(text_file.path).join.strip
|
158
168
|
end
|
159
169
|
|
170
|
+
def get_body # :nodoc:
|
171
|
+
sclz.method_deprecated(:get_body, :body)
|
172
|
+
self.body
|
173
|
+
end
|
174
|
+
|
160
175
|
# Returns a File with the most likely candidate for the user-submitted
|
161
176
|
# media. Given that most MMS messages only have one file attached,
|
162
177
|
# this will try to give you that file. First it looks for videos, then
|
@@ -166,8 +181,13 @@ module MMS2R
|
|
166
181
|
#
|
167
182
|
# Returns nil if there are not any video or image Files found.
|
168
183
|
|
169
|
-
def
|
170
|
-
return @default_media ||=
|
184
|
+
def default_media
|
185
|
+
return @default_media ||= attachement(['video', 'image'])
|
186
|
+
end
|
187
|
+
|
188
|
+
def get_media # :nodoc:
|
189
|
+
sclz.method_deprecated(:get_media, :default_media)
|
190
|
+
self.default_media
|
171
191
|
end
|
172
192
|
|
173
193
|
# Returns a File with the most likely candidate that is text, or nil
|
@@ -177,8 +197,13 @@ module MMS2R
|
|
177
197
|
#
|
178
198
|
# Returns nil if there are not any text Files found
|
179
199
|
|
180
|
-
def
|
181
|
-
return @default_text ||=
|
200
|
+
def default_text
|
201
|
+
return @default_text ||= attachement(['text'])
|
202
|
+
end
|
203
|
+
|
204
|
+
def get_text # :nodoc:
|
205
|
+
sclz.method_deprecated(:get_text, :default_text)
|
206
|
+
self.default_text
|
182
207
|
end
|
183
208
|
|
184
209
|
##
|
@@ -535,10 +560,10 @@ module MMS2R
|
|
535
560
|
private
|
536
561
|
|
537
562
|
##
|
538
|
-
# used by
|
563
|
+
# used by #default_media and #text to return the biggest attachment type
|
539
564
|
# listed in the types array
|
540
565
|
|
541
|
-
def
|
566
|
+
def attachement(types)
|
542
567
|
|
543
568
|
# get all the files that are of the major types passed in
|
544
569
|
files = Array.new
|
@@ -568,10 +593,13 @@ module MMS2R
|
|
568
593
|
end
|
569
594
|
end
|
570
595
|
|
596
|
+
return nil if file.nil?
|
597
|
+
|
571
598
|
# These singleton methods implement the interface necessary to be used
|
572
599
|
# as a drop-in replacement for files uploaded with CGI.rb.
|
573
600
|
# This helps if you want to use the files with, for example,
|
574
601
|
# attachment_fu.
|
602
|
+
|
575
603
|
def file.local_path
|
576
604
|
self.path
|
577
605
|
end
|
@@ -592,6 +620,18 @@ module MMS2R
|
|
592
620
|
file
|
593
621
|
end
|
594
622
|
|
623
|
+
def get_attachement(types) # :nodoc:
|
624
|
+
sclz.method_deprecated(:get_attachment, :attachment)
|
625
|
+
self.attachement(types)
|
626
|
+
end
|
627
|
+
|
628
|
+
def self.method_deprecated(from, to) # :nodoc:
|
629
|
+
msg = "Method '#{from}' has been deprecated use method '#{to}'." +
|
630
|
+
"\nMethod '#{from}' will be removed in a future release"
|
631
|
+
@logger.error(msg) if @logger
|
632
|
+
$stderr.puts msg
|
633
|
+
end
|
634
|
+
|
595
635
|
end
|
596
636
|
|
597
637
|
end
|
data/lib/mms2r/sprint_media.rb
CHANGED
@@ -52,6 +52,13 @@ module MMS2R
|
|
52
52
|
sprint_process_text(doc)
|
53
53
|
sprint_process_media(doc)
|
54
54
|
|
55
|
+
# when process acts upon a block
|
56
|
+
if block_given?
|
57
|
+
media.each do |k, v|
|
58
|
+
yield(k, v)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
55
62
|
end
|
56
63
|
|
57
64
|
private
|
@@ -62,7 +69,7 @@ module MMS2R
|
|
62
69
|
def sprint_phone_number(doc)
|
63
70
|
c = doc.search("/html/head/comment()").last
|
64
71
|
t = c.content.gsub(/\s+/m," ").strip
|
65
|
-
#@number returned in parent's
|
72
|
+
#@number returned in parent's #number
|
66
73
|
@number = / name="MDN">(\d+)</.match(t)[1]
|
67
74
|
end
|
68
75
|
|
@@ -27,11 +27,11 @@ class MMS2R::AlltelMediaTest < Test::Unit::TestCase
|
|
27
27
|
mms.purge
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def test_default_media_should_return_user_generated_content
|
31
31
|
mail = TMail::Mail.parse(load_mail('alltel-image-01.mail').join)
|
32
32
|
mms = MMS2R::Media.create(mail)
|
33
33
|
mms.process
|
34
|
-
file = mms.
|
34
|
+
file = mms.default_media
|
35
35
|
assert_equal 'eastern sky.jpg', file.original_filename
|
36
36
|
mms.purge
|
37
37
|
end
|
@@ -7,7 +7,7 @@ require 'mms2r/media'
|
|
7
7
|
require 'tmail/mail'
|
8
8
|
require 'logger'
|
9
9
|
|
10
|
-
class MMS2R::
|
10
|
+
class MMS2R::AttMediaTest < Test::Unit::TestCase
|
11
11
|
include MMS2R::TestHelper
|
12
12
|
|
13
13
|
def setup
|
@@ -21,7 +21,7 @@ class MMS2R::ATTMediaTest < Test::Unit::TestCase
|
|
21
21
|
def test_simple
|
22
22
|
mail = TMail::Mail.parse(load_mail('att-image-01.mail').join)
|
23
23
|
mms = MMS2R::Media.create(mail)
|
24
|
-
assert_equal(MMS2R::
|
24
|
+
assert_equal(MMS2R::AttMedia, mms.class, "expected a #{MMS2R::AttMedia} and received a #{mms.class}")
|
25
25
|
mms.process
|
26
26
|
|
27
27
|
assert(mms.media.size == 1)
|
@@ -37,7 +37,7 @@ class MMS2R::ATTMediaTest < Test::Unit::TestCase
|
|
37
37
|
def test_subject
|
38
38
|
mail = TMail::Mail.parse(load_mail('att-image-02.mail').join)
|
39
39
|
mms = MMS2R::Media.create(mail)
|
40
|
-
assert_equal(MMS2R::
|
40
|
+
assert_equal(MMS2R::AttMedia, mms.class, "expected a #{MMS2R::AttMedia} and received a #{mms.class}")
|
41
41
|
mms.process
|
42
42
|
|
43
43
|
assert(mms.media.size == 1)
|
@@ -48,7 +48,7 @@ class MMS2R::ATTMediaTest < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
assert_file_size(mms.media['image/jpeg'][0], 337)
|
50
50
|
|
51
|
-
assert_nil mms.
|
51
|
+
assert_nil mms.subject
|
52
52
|
mms.purge
|
53
53
|
end
|
54
54
|
end
|
@@ -34,12 +34,12 @@ class MMS2R::DobsonMediaTest < Test::Unit::TestCase
|
|
34
34
|
mms.purge
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def test_body_should_return_user_text
|
38
38
|
mail = TMail::Mail.parse(load_mail('dobson-image-01.mail').join)
|
39
39
|
mms = MMS2R::Media.create(mail)
|
40
40
|
mms.process
|
41
41
|
|
42
|
-
assert_equal 'Body', mms.
|
42
|
+
assert_equal 'Body', mms.body
|
43
43
|
|
44
44
|
mms.purge
|
45
45
|
end
|
@@ -21,23 +21,23 @@ class MMS2R::HelioMediaTest < Test::Unit::TestCase
|
|
21
21
|
assert_equal @mms.class, MMS2R::HelioMedia
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
number = @mms.
|
24
|
+
def test_number_should_return_correct_number
|
25
|
+
number = @mms.number()
|
26
26
|
assert_equal number, 7608070850.to_s
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
title = @mms.
|
29
|
+
def test_subject_should_return_correct_subject
|
30
|
+
title = @mms.subject()
|
31
31
|
assert_equal title, "Test image"
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
body = @mms.
|
34
|
+
def test_body_should_return_correct_body
|
35
|
+
body = @mms.body()
|
36
36
|
assert_equal body, "Test image"
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
image = @mms.
|
39
|
+
def test_attachment_should_return_jpeg
|
40
|
+
image = @mms.default_media()
|
41
41
|
assert_not_nil @mms.media['image/jpeg'][0]
|
42
42
|
assert_match(/0628070005.jpg$/, @mms.media['image/jpeg'][0])
|
43
43
|
end
|
data/test/test_mms2r_media.rb
CHANGED
@@ -216,20 +216,20 @@ class MMS2R::MediaTest < Test::Unit::TestCase
|
|
216
216
|
mms.purge
|
217
217
|
end
|
218
218
|
|
219
|
-
def
|
219
|
+
def test_mms_with_two_images_should_default_media_to_largest_file
|
220
220
|
mail = TMail::Mail.parse(load_mail('simple-with-two-images-two-texts.mail').join)
|
221
221
|
mms = MMS2R::Media.create(mail)
|
222
222
|
mms.process
|
223
|
-
file = mms.
|
223
|
+
file = mms.default_media
|
224
224
|
assert_equal 'big.jpg', file.original_filename
|
225
225
|
mms.purge
|
226
226
|
end
|
227
227
|
|
228
|
-
def
|
228
|
+
def test_mms_with_two_texts_should_text_to_largest_file
|
229
229
|
mail = TMail::Mail.parse(load_mail('simple-with-two-images-two-texts.mail').join)
|
230
230
|
mms = MMS2R::Media.create(mail)
|
231
231
|
mms.process
|
232
|
-
file = mms.
|
232
|
+
file = mms.default_text
|
233
233
|
assert_equal 'big.txt', file.original_filename
|
234
234
|
mms.purge
|
235
235
|
end
|
@@ -238,7 +238,7 @@ class MMS2R::MediaTest < Test::Unit::TestCase
|
|
238
238
|
mail = TMail::Mail.parse(load_mail('hello_world_empty_text.mail').join)
|
239
239
|
mms = MMS2R::Media.create(mail)
|
240
240
|
mms.process
|
241
|
-
assert_equal '2068675309', mms.
|
241
|
+
assert_equal '2068675309', mms.number
|
242
242
|
mms.purge
|
243
243
|
end
|
244
244
|
|
@@ -339,7 +339,7 @@ class MMS2R::MediaTest < Test::Unit::TestCase
|
|
339
339
|
assert MMS2R::Media.sub_type?(mail.parts[0]).eql?('gif')
|
340
340
|
end
|
341
341
|
|
342
|
-
def
|
342
|
+
def test_subject
|
343
343
|
subjects = [nil, '', '(no subject)']
|
344
344
|
|
345
345
|
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
@@ -347,26 +347,26 @@ class MMS2R::MediaTest < Test::Unit::TestCase
|
|
347
347
|
mail.subject = s
|
348
348
|
mms = MMS2R::Media.create(mail)
|
349
349
|
mms.process
|
350
|
-
assert_equal nil, mms.
|
350
|
+
assert_equal nil, mms.subject, "Default subject not scrubbed."
|
351
351
|
mms.purge
|
352
352
|
end
|
353
353
|
|
354
354
|
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
355
355
|
mms = MMS2R::Media.create(mail)
|
356
356
|
mms.process
|
357
|
-
assert_equal 'text only', mms.
|
357
|
+
assert_equal 'text only', mms.subject
|
358
358
|
mms.purge
|
359
359
|
end
|
360
360
|
|
361
|
-
def
|
361
|
+
def test_body
|
362
362
|
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
363
363
|
mms = MMS2R::Media.create(mail)
|
364
364
|
mms.process
|
365
|
-
assert_equal 'hello world', mms.
|
365
|
+
assert_equal 'hello world', mms.body
|
366
366
|
mms.purge
|
367
367
|
end
|
368
368
|
|
369
|
-
def
|
369
|
+
def test_attachment_should_return_duck_typed_file
|
370
370
|
|
371
371
|
mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
|
372
372
|
mms = MMS2R::Media.create(mail)
|
@@ -382,10 +382,10 @@ class MMS2R::MediaTest < Test::Unit::TestCase
|
|
382
382
|
assert File::exist?(test), "file #{test} does not exist"
|
383
383
|
assert_equal base_name, File.basename(test), "file #{test} does not exist as #{base_name}"
|
384
384
|
|
385
|
-
#
|
386
|
-
#
|
385
|
+
# default_media calls attachment and
|
386
|
+
# attachment should return a file that has some duck sauce for
|
387
387
|
# act_as_attachment and attachment_fu
|
388
|
-
file = mms.
|
388
|
+
file = mms.default_media
|
389
389
|
assert_not_nil file, "file #{file} does not exist"
|
390
390
|
assert_equal test, file.local_path
|
391
391
|
assert_equal base_name, file.original_filename
|
@@ -21,10 +21,10 @@ class MMS2R::MyCingularMediaTest < Test::Unit::TestCase
|
|
21
21
|
assert_not_nil mms.media['image/jpeg'][0]
|
22
22
|
assert_match(/04-18-07_1723.jpg$/, mms.media['image/jpeg'][0])
|
23
23
|
|
24
|
-
assert_equal nil, mms.
|
24
|
+
assert_equal nil, mms.subject, "Default Cingular subject not stripped"
|
25
25
|
assert_file_size mms.media['image/jpeg'][0], 337
|
26
26
|
|
27
|
-
assert_equal "Water", IO.readlines(mms.
|
27
|
+
assert_equal "Water", IO.readlines(mms.default_text.path).join
|
28
28
|
|
29
29
|
mms.purge
|
30
30
|
end
|
@@ -10,22 +10,22 @@ require 'logger'
|
|
10
10
|
class MMS2R::NextelMediaTest < Test::Unit::TestCase
|
11
11
|
include MMS2R::TestHelper
|
12
12
|
|
13
|
-
def
|
13
|
+
def test_simple_text_is_nil
|
14
14
|
mail = TMail::Mail.parse(load_mail('nextel-image-01.mail').join)
|
15
15
|
mms = MMS2R::Media.create(mail)
|
16
16
|
mms.process
|
17
17
|
|
18
|
-
assert_nil mms.
|
18
|
+
assert_nil mms.default_text
|
19
19
|
|
20
20
|
mms.purge
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def test_simple_default_media
|
24
24
|
mail = TMail::Mail.parse(load_mail('nextel-image-01.mail').join)
|
25
25
|
mms = MMS2R::Media.create(mail)
|
26
26
|
mms.process
|
27
27
|
|
28
|
-
file = mms.
|
28
|
+
file = mms.default_media
|
29
29
|
assert_file_size file, 337
|
30
30
|
assert_equal 'Jan15_0001.jpg', file.original_filename
|
31
31
|
assert_equal 337, file.size
|
@@ -20,7 +20,7 @@ class MMS2R::OrangeFranceMediaTest < Test::Unit::TestCase
|
|
20
20
|
mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
|
21
21
|
mms = MMS2R::Media.create(mail)
|
22
22
|
mms.process
|
23
|
-
assert_nil mms.
|
23
|
+
assert_nil mms.subject
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_processed_content
|
@@ -39,12 +39,12 @@ class MMS2R::OrangeFranceMediaTest < Test::Unit::TestCase
|
|
39
39
|
file = mms.media['text/plain'].first
|
40
40
|
assert File::exist?(file), "file #{file} does not exist"
|
41
41
|
text = IO.readlines("#{file}").join
|
42
|
-
assert_match
|
42
|
+
assert_match(/Test ma poule/, text)
|
43
43
|
|
44
44
|
# image
|
45
45
|
assert_not_nil mms.media['image/jpeg']
|
46
46
|
assert_equal 1, mms.media['image/jpeg'].size
|
47
|
-
assert_match
|
47
|
+
assert_match(/IMAGE.jpeg$/, mms.media['image/jpeg'].first)
|
48
48
|
assert_file_size mms.media['image/jpeg'].first, 337
|
49
49
|
|
50
50
|
mms.purge
|
@@ -15,7 +15,7 @@ class MMS2R::OrangePolandMediaTest < Test::Unit::TestCase
|
|
15
15
|
mms = MMS2R::Media.create(mail)
|
16
16
|
assert_equal MMS2R::OrangePolandMedia, mms.class, "expected a #{MMS2R::OrangePolandMedia} and received a #{mms.class}"
|
17
17
|
mms.process
|
18
|
-
assert_nil mms.
|
18
|
+
assert_nil mms.subject
|
19
19
|
assert_not_nil mms.media['text/plain']
|
20
20
|
file = mms.media['text/plain'][0]
|
21
21
|
assert_not_nil file
|
@@ -30,7 +30,7 @@ class MMS2R::OrangePolandMediaTest < Test::Unit::TestCase
|
|
30
30
|
mms = MMS2R::Media.create(mail)
|
31
31
|
assert_equal MMS2R::OrangePolandMedia, mms.class, "expected a #{MMS2R::OrangePolandMedia} and received a #{mms.class}"
|
32
32
|
mms.process
|
33
|
-
assert mms.
|
33
|
+
assert mms.subject, "whazzup"
|
34
34
|
assert_not_nil mms.media['text/plain']
|
35
35
|
file = mms.media['text/plain'][0]
|
36
36
|
assert_not_nil file
|
@@ -130,8 +130,8 @@ class MMS2R::SprintMediaTest < Test::Unit::TestCase
|
|
130
130
|
mms.process
|
131
131
|
assert_equal 1, mms.media.size
|
132
132
|
assert_equal 1, mms.media['text/plain'].size
|
133
|
-
assert_equal 7, mms.
|
134
|
-
text = IO.readlines("#{mms.
|
133
|
+
assert_equal 7, mms.default_text.size
|
134
|
+
text = IO.readlines("#{mms.default_text.path}").join
|
135
135
|
assert_match(/Tea Pot/, text)
|
136
136
|
mms.purge
|
137
137
|
end
|
@@ -140,7 +140,7 @@ class MMS2R::SprintMediaTest < Test::Unit::TestCase
|
|
140
140
|
mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
|
141
141
|
mms = MMS2R::Media.create(mail)
|
142
142
|
mms.process
|
143
|
-
assert_equal '2068509247', mms.
|
143
|
+
assert_equal '2068509247', mms.number
|
144
144
|
mms.purge
|
145
145
|
end
|
146
146
|
|
@@ -157,7 +157,7 @@ class MMS2R::SprintMediaTest < Test::Unit::TestCase
|
|
157
157
|
|
158
158
|
assert_file_size mms.media['video/quicktime'][0], 49063
|
159
159
|
|
160
|
-
assert_equal nil, mms.
|
160
|
+
assert_equal nil, mms.subject, "Default Sprint subject not scrubbed."
|
161
161
|
|
162
162
|
mms.purge
|
163
163
|
end
|
@@ -175,11 +175,25 @@ class MMS2R::SprintMediaTest < Test::Unit::TestCase
|
|
175
175
|
|
176
176
|
assert_file_size mms.media['image/jpeg'][0], 337
|
177
177
|
|
178
|
-
assert_equal nil, mms.
|
178
|
+
assert_equal nil, mms.subject, "Default Sprint subject not scrubbed"
|
179
179
|
|
180
180
|
mms.purge
|
181
181
|
end
|
182
182
|
|
183
|
+
def test_collect_image_using_block
|
184
|
+
mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
|
185
|
+
mms = MMS2R::Media.create(mail)
|
186
|
+
file_array = nil
|
187
|
+
mms.process do |k, v|
|
188
|
+
file_array = v if (k == 'image/jpeg')
|
189
|
+
assert_not_nil(file = file_array.first)
|
190
|
+
assert(File::exist?(file), "file #{file} does not exist")
|
191
|
+
assert(File.basename(file) =~ /000_0123a01234567890_1-0\.jpg/, "file #{file} does not exist")
|
192
|
+
end
|
193
|
+
# mms.purge has to be called manually
|
194
|
+
assert File.exist?(file_array.first)
|
195
|
+
end
|
196
|
+
|
183
197
|
def test_should_have_two_images
|
184
198
|
mail = TMail::Mail.parse(load_mail('sprint-two-images-01.mail').join)
|
185
199
|
mms = MMS2R::Media.create(mail)
|
@@ -197,7 +211,7 @@ class MMS2R::SprintMediaTest < Test::Unit::TestCase
|
|
197
211
|
assert_file_size mms.media['image/jpeg'][0], 337
|
198
212
|
assert_file_size mms.media['image/jpeg'][1], 337
|
199
213
|
|
200
|
-
assert_equal nil, mms.
|
214
|
+
assert_equal nil, mms.subject, "Default Sprint subject not scrubbed"
|
201
215
|
|
202
216
|
mms.purge
|
203
217
|
end
|
@@ -212,10 +226,10 @@ class MMS2R::SprintMediaTest < Test::Unit::TestCase
|
|
212
226
|
mms.purge
|
213
227
|
end
|
214
228
|
|
215
|
-
def
|
229
|
+
def test_body_should_return_nil_when_there_is_no_user_text
|
216
230
|
mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
|
217
231
|
mms = MMS2R::Media.create(mail)
|
218
232
|
mms.process
|
219
|
-
assert_equal nil, mms.
|
233
|
+
assert_equal nil, mms.body
|
220
234
|
end
|
221
235
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mms2r
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.1.11
|
7
|
+
date: 2007-10-20 00:00:00 -07:00
|
8
8
|
summary: Extract user media from MMS (and not carrier cruft)
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -52,8 +52,8 @@ files:
|
|
52
52
|
- conf/mms2r_verizon_media_transform.yml
|
53
53
|
- dev_tools/debug_sprint_hpricot_parsing.rb
|
54
54
|
- lib/mms2r.rb
|
55
|
-
- lib/mms2r/a_t_t_media.rb
|
56
55
|
- lib/mms2r/alltel_media.rb
|
56
|
+
- lib/mms2r/att_media.rb
|
57
57
|
- lib/mms2r/cingular_me_media.rb
|
58
58
|
- lib/mms2r/dobson_media.rb
|
59
59
|
- lib/mms2r/helio_media.rb
|
@@ -132,8 +132,8 @@ files:
|
|
132
132
|
- test/fixtures/verizon-video-01.mail
|
133
133
|
- test/fixtures/vtext-text-01.mail
|
134
134
|
- test/test_helper.rb
|
135
|
-
- test/test_mms2r_a_t_t_media.rb
|
136
135
|
- test/test_mms2r_alltel_media.rb
|
136
|
+
- test/test_mms2r_att_media.rb
|
137
137
|
- test/test_mms2r_cingular_me_media.rb
|
138
138
|
- test/test_mms2r_dobson_media.rb
|
139
139
|
- test/test_mms2r_helio_media.rb
|
@@ -155,6 +155,7 @@ test_files:
|
|
155
155
|
- test/test_mms2r_orange_poland_media.rb
|
156
156
|
- test/test_mms2r_helio_media.rb
|
157
157
|
- test/test_mms2r_sprint_pcs_media.rb
|
158
|
+
- test/test_mms2r_att_media.rb
|
158
159
|
- test/test_mms2r_media.rb
|
159
160
|
- test/test_mms2r_my_cingular_media.rb
|
160
161
|
- test/test_mms2r_nextel_media.rb
|
@@ -167,7 +168,6 @@ test_files:
|
|
167
168
|
- test/test_mms2r_verizon_media.rb
|
168
169
|
- test/test_helper.rb
|
169
170
|
- test/test_mms2r_t_mobile_media.rb
|
170
|
-
- test/test_mms2r_a_t_t_media.rb
|
171
171
|
rdoc_options:
|
172
172
|
- --main
|
173
173
|
- README.txt
|
@@ -207,5 +207,5 @@ dependencies:
|
|
207
207
|
requirements:
|
208
208
|
- - ">="
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version: 1.
|
210
|
+
version: 1.3.0
|
211
211
|
version:
|