mms2r 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Manifest.txt +4 -0
- data/README.txt +17 -5
- data/lib/mms2r.rb +1 -1
- data/lib/mms2r/dobson_media.rb +14 -0
- data/lib/mms2r/media.rb +68 -1
- data/lib/mms2r/version.rb +1 -1
- data/test/files/dobson-image-01.mail +64 -0
- data/test/test_helper.rb +14 -0
- data/test/test_mms2r_cingular.rb +2 -5
- data/test/test_mms2r_dobson.rb +36 -0
- data/test/test_mms2r_media.rb +4 -6
- data/test/test_mms2r_mmode.rb +3 -10
- data/test/test_mms2r_nextel.rb +54 -22
- data/test/test_mms2r_sprint.rb +4 -14
- data/test/test_mms2r_tmobile.rb +4 -12
- data/test/test_mms2r_verizon.rb +7 -18
- metadata +9 -3
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 1.0.6 / 2007-04-24 (Pickles the Drummer)
|
2
|
+
|
3
|
+
* patch submitted by Luke Francl
|
4
|
+
* added support for mms.dobson.net (Dobson aka Cellular One) (Luke)
|
5
|
+
* DRY'd up unit tests (Luke)
|
6
|
+
* added get_media instance method that returns first video or image as File (Luke)
|
7
|
+
* File from get_media can be used by/with attachment_fu (Luke)
|
8
|
+
* added get_text instance method that returns first non advertising text
|
9
|
+
* File from get_text can be used by/with attachment_fu
|
10
|
+
|
1
11
|
== 1.0.5 / 2007-04-10 (William Murderface)
|
2
12
|
|
3
13
|
* patch submitted by Luke Francl
|
data/Manifest.txt
CHANGED
@@ -10,6 +10,7 @@ conf/mms2r_verizonmedia_ignore.yml
|
|
10
10
|
conf/mms2r_verizonmedia_transform.yml
|
11
11
|
lib/mms2r.rb
|
12
12
|
lib/mms2r/cingular_media.rb
|
13
|
+
lib/mms2r/dobson_media.rb
|
13
14
|
lib/mms2r/media.rb
|
14
15
|
lib/mms2r/mmode_media.rb
|
15
16
|
lib/mms2r/nextel_media.rb
|
@@ -42,6 +43,7 @@ lib/vendor/tmail/stringio.rb
|
|
42
43
|
lib/vendor/tmail/tmail.rb
|
43
44
|
lib/vendor/tmail/utils.rb
|
44
45
|
test/files/cingularme-text-01.mail
|
46
|
+
test/files/dobson-image-01.mail
|
45
47
|
test/files/dot.jpg
|
46
48
|
test/files/hello_world_mail_multipart.mail
|
47
49
|
test/files/hello_world_mail_plain_no_content_type.mail
|
@@ -65,7 +67,9 @@ test/files/verizon-image-02.mail
|
|
65
67
|
test/files/verizon-text-01.mail
|
66
68
|
test/files/verizon-video-01.mail
|
67
69
|
test/files/vtext-text-01.mail
|
70
|
+
test/test_helper.rb
|
68
71
|
test/test_mms2r_cingular.rb
|
72
|
+
test/test_mms2r_dobson.rb
|
69
73
|
test/test_mms2r_media.rb
|
70
74
|
test/test_mms2r_mmode.rb
|
71
75
|
test/test_mms2r_nextel.rb
|
data/README.txt
CHANGED
@@ -21,6 +21,7 @@ Corpus of carriers currently processed by MMS2R:
|
|
21
21
|
* AT&T/Cingular => mmode.com
|
22
22
|
* Cingular => mms.mycingular.com
|
23
23
|
* Cingular => cingularme.com
|
24
|
+
* Dobson/Cellular One => mms.dobson.net
|
24
25
|
* Nextel => messaging.nextel.com
|
25
26
|
* Sprint => pm.sprint.com
|
26
27
|
* Sprint => messaging.sprintpcs.com
|
@@ -28,10 +29,10 @@ Corpus of carriers currently processed by MMS2R:
|
|
28
29
|
* Verizon => vzwpix.com
|
29
30
|
* Verizon => vtext.com
|
30
31
|
|
31
|
-
== FEATURES
|
32
|
+
== FEATURES
|
32
33
|
|
33
|
-
TMail from 1.3.1 of ActionMailer is shipped as a vendor library with MMS2R
|
34
|
-
|
34
|
+
* TMail from 1.3.1 of ActionMailer is shipped as a vendor library with MMS2R
|
35
|
+
* get_media and get_text methods return a File that can be used in attachment_fu
|
35
36
|
== SYNOPSIS:
|
36
37
|
|
37
38
|
require 'rubygems'
|
@@ -40,13 +41,24 @@ TMail from 1.3.1 of ActionMailer is shipped as a vendor library with MMS2R
|
|
40
41
|
require 'tmail'
|
41
42
|
require 'fileutils'
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
# TMail::Mail.parse is what ActionMailer::Base.receive(email) does, see:
|
45
|
+
# http://wiki.rubyonrails.com/rails/pages/HowToReceiveEmailsWithActionMailer
|
46
|
+
email = TMail::Mail.parse(IO.readlines("sample-MMS.file").join)
|
47
|
+
mms = MMS2R::Media.create(email,Logger.new(STDOUT))
|
45
48
|
|
46
49
|
# process finds all the media in a MMS, strips advertsing, then
|
47
50
|
# writes the user generated media to disk in a temporary subdirectory
|
48
51
|
mms.process
|
49
52
|
|
53
|
+
# most MMS are either image or video, get_media will blindly return
|
54
|
+
# the first video or image found
|
55
|
+
file = mms.get_media
|
56
|
+
puts "MMS had a media: #{file.inspect}" unless file.nil?
|
57
|
+
|
58
|
+
# get_text will blindly return the first (non-advertising) text found
|
59
|
+
file = mms.get_text
|
60
|
+
puts "MMS had some text: #{file.inspect}" unless file.nil?
|
61
|
+
|
50
62
|
# mms.media is a hash that is indexed by mime-type.
|
51
63
|
# The mime-type key returns an array of filepaths
|
52
64
|
# to media that were extract from the MMS and
|
data/lib/mms2r.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mms2r'
|
2
|
+
require 'mms2r/media'
|
3
|
+
|
4
|
+
module MMS2R
|
5
|
+
|
6
|
+
##
|
7
|
+
# Dobson/Cellular One version version of MMS2R::Media
|
8
|
+
# So far, Dobson MMS messages do not contain advertising
|
9
|
+
# They do, however, have a weird SMIL file attachment. It
|
10
|
+
# can be safely ignored.
|
11
|
+
|
12
|
+
class MMS2R::DobsonMedia < MMS2R::Media
|
13
|
+
end
|
14
|
+
end
|
data/lib/mms2r/media.rb
CHANGED
@@ -14,6 +14,7 @@ require 'mms2r/nextel_media'
|
|
14
14
|
require 'mms2r/sprint_media'
|
15
15
|
require 'mms2r/tmobile_media'
|
16
16
|
require 'mms2r/verizon_media'
|
17
|
+
require 'mms2r/dobson_media'
|
17
18
|
|
18
19
|
##
|
19
20
|
# MMS2R is a library to collect media files from MMS messages. MMS messages
|
@@ -64,7 +65,8 @@ module MMS2R
|
|
64
65
|
'messaging.sprintpcs.com' => MMS2R::SprintMedia,
|
65
66
|
'tmomail.net' => MMS2R::TMobileMedia,
|
66
67
|
'vtext.com' => MMS2R::VerizonMedia,
|
67
|
-
'vzwpix.com' => MMS2R::VerizonMedia
|
68
|
+
'vzwpix.com' => MMS2R::VerizonMedia,
|
69
|
+
'mms.dobson.net' => MMS2R::DobsonMedia
|
68
70
|
}
|
69
71
|
|
70
72
|
class MMS2R::Media
|
@@ -107,6 +109,28 @@ module MMS2R
|
|
107
109
|
self.class.safe_message_id(@mail.message_id))
|
108
110
|
end
|
109
111
|
|
112
|
+
# Returns a File with the most likely candidate for the user-submitted
|
113
|
+
# media. Given that most MMS messages only have one file attached,
|
114
|
+
# this will try to give you that file. First it looks for videos, then
|
115
|
+
# images. It also adds singleton methods to the File object so it can
|
116
|
+
# be used in place of a CGI upload (local_path, original_filename, size,
|
117
|
+
# and content_type)
|
118
|
+
#
|
119
|
+
# Returns nil if no video or image is found.
|
120
|
+
|
121
|
+
def get_media
|
122
|
+
get_attachement(['video', 'image'])
|
123
|
+
end
|
124
|
+
|
125
|
+
# Returns a File with the most likely candidate that is text, or nil
|
126
|
+
# otherwise. It also adds singleton methods to the File object so it can
|
127
|
+
# be used in place of a CGI upload (local_path, original_filename, size,
|
128
|
+
# and content_type)
|
129
|
+
|
130
|
+
def get_text
|
131
|
+
get_attachement(['text'])
|
132
|
+
end
|
133
|
+
|
110
134
|
##
|
111
135
|
# Helper for process template method to decode the part based
|
112
136
|
# on its type and write its content to a temporary file. Returns
|
@@ -362,6 +386,49 @@ module MMS2R
|
|
362
386
|
/\/([^\/]+)$/.match(self.part_type?(part))[1]
|
363
387
|
end
|
364
388
|
|
389
|
+
private
|
390
|
+
|
391
|
+
##
|
392
|
+
# used by get_media and get_text to return the first attachment type
|
393
|
+
# listed in the types array
|
394
|
+
|
395
|
+
def get_attachement(types)
|
396
|
+
|
397
|
+
mime_type = nil
|
398
|
+
types.each{|t|
|
399
|
+
mime_type = media.keys.find { |key| 0 == (key =~ /#{t}/) } if mime_type.nil?
|
400
|
+
}
|
401
|
+
|
402
|
+
if mime_type.nil?
|
403
|
+
return nil
|
404
|
+
end
|
405
|
+
|
406
|
+
file = File.new(media[mime_type][0])
|
407
|
+
|
408
|
+
# These singleton methods implement the interface necessary to be used
|
409
|
+
# as a drop-in replacement for files uploaded with CGI.rb.
|
410
|
+
# This helps if you want to use the files with, for example,
|
411
|
+
# attachment_fu.
|
412
|
+
def file.local_path
|
413
|
+
self.path
|
414
|
+
end
|
415
|
+
|
416
|
+
def file.original_filename
|
417
|
+
File.basename(self.path)
|
418
|
+
end
|
419
|
+
|
420
|
+
def file.size
|
421
|
+
File.size(self.path)
|
422
|
+
end
|
423
|
+
|
424
|
+
# this one is kind of confusing because it needs a closure.
|
425
|
+
class << file
|
426
|
+
self
|
427
|
+
end.send(:define_method, :content_type) { mime_type }
|
428
|
+
|
429
|
+
return file
|
430
|
+
end
|
431
|
+
|
365
432
|
end
|
366
433
|
|
367
434
|
end
|
data/lib/mms2r/version.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
Delivered-To: luke@example.com
|
2
|
+
Received: by 10.114.126.6 with SMTP id y6cs662518wac;
|
3
|
+
Wed, 18 Apr 2007 17:30:16 -0700 (PDT)
|
4
|
+
Received: by 10.70.37.12 with SMTP id k12mr2098583wxk.1176942615765;
|
5
|
+
Wed, 18 Apr 2007 17:30:15 -0700 (PDT)
|
6
|
+
Return-Path: <19075551234@mms.dobson.net>
|
7
|
+
Received: from mms.dobson.net ([12.168.76.27])
|
8
|
+
by mx.google.com with SMTP id h13si2340383wxd.2007.04.18.17.30.14;
|
9
|
+
Wed, 18 Apr 2007 17:30:15 -0700 (PDT)
|
10
|
+
Received-SPF: neutral (google.com: 12.168.76.27 is neither permitted nor denied by best guess record for domain of 19075551234@mms.dobson.net)
|
11
|
+
Received: (qmail 4243 invoked from network); 19 Apr 2007 00:30:14 -0000
|
12
|
+
Received: from unknown (HELO mmsc1be1.dobson.net) (172.23.1.158)
|
13
|
+
by 0 with SMTP; 19 Apr 2007 00:30:14 -0000
|
14
|
+
Resent-To: luke@example.com
|
15
|
+
Received: by mms.dobson.net ; Thu, 19 Apr 2007 00:30:14 GMT
|
16
|
+
Content-Type: multipart/related;boundary=1_4626B816_9F1690;Type="application/smil";Start="<mms.smil.txt>"
|
17
|
+
Subject: Subject
|
18
|
+
Date: Thu, 19 Apr 2007 00:30:14 GMT
|
19
|
+
To: luke@example.com
|
20
|
+
From: 19075551234@mms.dobson.net
|
21
|
+
Message-ID: <AVTD2MlE05dRftqAJ@mmsc1be1.dobson.net>
|
22
|
+
Mime-Version: 1.0
|
23
|
+
X-Mms-Message-Type: m-send-req
|
24
|
+
X-Mms-Transaction-ID: AVTD2MlE05dRftqAJ
|
25
|
+
X-Mms-MMS-Version: 1.0
|
26
|
+
X-Mms-Message-Class: Personal
|
27
|
+
X-Mms-Expiry: 1176949814
|
28
|
+
X-Mms-Delivery-Time: 1176942614
|
29
|
+
X-Mms-Priority: Normal
|
30
|
+
X-Mms-Sender-Visibility: Show
|
31
|
+
X-Mms-Delivery-Report: No
|
32
|
+
X-Mms-Read-Reply: No
|
33
|
+
X-Mms-Message-Size: 73237
|
34
|
+
X-Mms-Mmsc-Originated: Yes
|
35
|
+
|
36
|
+
--1_4626B816_9F1690
|
37
|
+
Content-Type: application/smil;Charset=UTF-8;Name=mms.smil.txt
|
38
|
+
content-location: mms.smil.txt
|
39
|
+
content-id: <mms.smil.txt>
|
40
|
+
Content-Transfer-Encoding: 7bit
|
41
|
+
|
42
|
+
<smil><head><layout><root-layout width="176px" height="161px"/><region id="Image" left="0%" top="0%" height="67%" width="100%"/><region id="Text" left="0%" top="67%" height="33%" width="100%"/></layout></head><body><par dur="20s"><img src="media1.jpeg" type="image/jpeg" region="Image" alt="media1.jpeg" /><text src="media2.txt" type="text/plain" region="Text" alt="media2.txt" /></par></body></smil>
|
43
|
+
--1_4626B816_9F1690
|
44
|
+
Content-Type: image/jpeg;Name=04-18-07_1723.jpg
|
45
|
+
content-location: media1.jpeg
|
46
|
+
content-id: <media1.jpeg>
|
47
|
+
Content-Transfer-Encoding: base64
|
48
|
+
|
49
|
+
/9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
|
50
|
+
ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
|
51
|
+
ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
|
52
|
+
Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
|
53
|
+
AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
|
54
|
+
AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
|
55
|
+
EQMRAD8AlgA6WW//2Q==
|
56
|
+
--1_4626B816_9F1690
|
57
|
+
Content-Type: text/plain;Charset=UTF-8;Name=media2.txt
|
58
|
+
content-id: <media2.txt>
|
59
|
+
content-location: media2.txt
|
60
|
+
Content-Transfer-Encoding: 7bit
|
61
|
+
|
62
|
+
Body
|
63
|
+
--1_4626B816_9F1690--
|
64
|
+
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module MMS2R
|
2
|
+
module TestHelper
|
3
|
+
|
4
|
+
def assert_file_size(file, size)
|
5
|
+
assert_not_nil(file, "file was nil")
|
6
|
+
assert(File::exist?(file), "file #{file} does not exist")
|
7
|
+
assert(File::size(file) == size, "file #{file} is #{File::size(file)} bytes, not #{size} bytes")
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_mail(file)
|
11
|
+
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/test_mms2r_cingular.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
3
|
require 'test/unit'
|
3
4
|
require 'rubygems'
|
4
5
|
require 'mms2r'
|
@@ -8,6 +9,7 @@ require 'logger'
|
|
8
9
|
|
9
10
|
|
10
11
|
class MMS2RCingularTest < Test::Unit::TestCase
|
12
|
+
include MMS2R::TestHelper
|
11
13
|
|
12
14
|
def setup
|
13
15
|
@log = Logger.new(STDOUT)
|
@@ -34,9 +36,4 @@ class MMS2RCingularTest < Test::Unit::TestCase
|
|
34
36
|
assert_match(/#{good_text}/m, text)
|
35
37
|
mms.purge
|
36
38
|
end
|
37
|
-
|
38
|
-
private
|
39
|
-
def load_mail(file)
|
40
|
-
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
41
|
-
end
|
42
39
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require File.dirname(__FILE__) + "/test_helper"
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mms2r'
|
6
|
+
require 'mms2r/media'
|
7
|
+
require 'tmail/mail'
|
8
|
+
require 'logger'
|
9
|
+
|
10
|
+
|
11
|
+
class MMS2RDobson < Test::Unit::TestCase
|
12
|
+
include MMS2R::TestHelper
|
13
|
+
|
14
|
+
def test_dobson_image
|
15
|
+
mail = TMail::Mail.parse(load_mail('dobson-image-01.mail').join)
|
16
|
+
mms = MMS2R::Media.create(mail)
|
17
|
+
assert_equal(mms.class, MMS2R::DobsonMedia)
|
18
|
+
|
19
|
+
mms.process
|
20
|
+
|
21
|
+
assert(mms.media.size == 3, "Size is #{mms.media.size}")
|
22
|
+
assert_not_nil(mms.media['text/plain'])
|
23
|
+
assert_not_nil(mms.media['application/smil']) # dobson phones have weird SMIL that can be ignored.
|
24
|
+
assert_not_nil(mms.media['image/jpeg'][0])
|
25
|
+
assert_match(/04-18-07_1723.jpg$/, mms.media['image/jpeg'][0])
|
26
|
+
|
27
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
28
|
+
|
29
|
+
file = mms.media['text/plain'][0]
|
30
|
+
assert_not_nil(file)
|
31
|
+
assert(File::exist?(file), "file #{file} does not exist")
|
32
|
+
text = IO.readlines("#{file}").join
|
33
|
+
assert_equal "Body", text.strip
|
34
|
+
mms.purge
|
35
|
+
end
|
36
|
+
end
|
data/test/test_mms2r_media.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
3
|
require 'test/unit'
|
3
4
|
require 'rubygems'
|
4
5
|
require 'yaml'
|
@@ -9,6 +10,7 @@ require 'tmail/mail'
|
|
9
10
|
require 'logger'
|
10
11
|
|
11
12
|
class MMS2RMediaTest < Test::Unit::TestCase
|
13
|
+
include MMS2R::TestHelper
|
12
14
|
|
13
15
|
class MMS2R::FakeCarrier < MMS2R::Media; end
|
14
16
|
|
@@ -25,7 +27,8 @@ class MMS2RMediaTest < Test::Unit::TestCase
|
|
25
27
|
'messaging.sprintpcs.com' => MMS2R::SprintMedia,
|
26
28
|
'tmomail.net' => MMS2R::TMobileMedia,
|
27
29
|
'vtext.com' => MMS2R::VerizonMedia,
|
28
|
-
'vzwpix.com' => MMS2R::VerizonMedia
|
30
|
+
'vzwpix.com' => MMS2R::VerizonMedia,
|
31
|
+
'mms.dobson.net' => MMS2R::DobsonMedia
|
29
32
|
}
|
30
33
|
|
31
34
|
def use_temp_dirs
|
@@ -285,9 +288,4 @@ class MMS2RMediaTest < Test::Unit::TestCase
|
|
285
288
|
mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
|
286
289
|
assert(MMS2R::Media.sub_type?(mail.parts[0]).eql?('gif'))
|
287
290
|
end
|
288
|
-
|
289
|
-
private
|
290
|
-
def load_mail(file)
|
291
|
-
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
292
|
-
end
|
293
291
|
end
|
data/test/test_mms2r_mmode.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
3
|
require 'test/unit'
|
3
4
|
require 'rubygems'
|
4
5
|
require 'mms2r'
|
@@ -7,6 +8,7 @@ require 'tmail/mail'
|
|
7
8
|
require 'logger'
|
8
9
|
|
9
10
|
class MMS2RMModeTest < Test::Unit::TestCase
|
11
|
+
include MMS2R::TestHelper
|
10
12
|
|
11
13
|
def setup
|
12
14
|
@log = Logger.new(STDOUT)
|
@@ -28,16 +30,7 @@ class MMS2RMModeTest < Test::Unit::TestCase
|
|
28
30
|
assert_not_nil(mms.media['image/jpeg'][0])
|
29
31
|
assert_match(/picture\(3\).jpg$/, mms.media['image/jpeg'][0])
|
30
32
|
|
31
|
-
|
32
|
-
assert_not_nil(file)
|
33
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
34
|
-
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
35
|
-
|
33
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
36
34
|
mms.purge
|
37
35
|
end
|
38
|
-
|
39
|
-
private
|
40
|
-
def load_mail(file)
|
41
|
-
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
42
|
-
end
|
43
36
|
end
|
data/test/test_mms2r_nextel.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
-
|
2
|
+
require File.dirname(__FILE__) + "/test_helper"
|
3
3
|
require 'test/unit'
|
4
4
|
require 'rubygems'
|
5
5
|
require 'mms2r'
|
@@ -8,6 +8,7 @@ require 'tmail/mail'
|
|
8
8
|
require 'logger'
|
9
9
|
|
10
10
|
class MMS2RNextelTest < Test::Unit::TestCase
|
11
|
+
include MMS2R::TestHelper
|
11
12
|
|
12
13
|
def setup
|
13
14
|
@log = Logger.new(STDOUT)
|
@@ -17,6 +18,54 @@ class MMS2RNextelTest < Test::Unit::TestCase
|
|
17
18
|
|
18
19
|
def teardown; end
|
19
20
|
|
21
|
+
def test_simple_get_text_is_nil
|
22
|
+
mail = TMail::Mail.parse(load_mail('nextel-image-01.mail').join)
|
23
|
+
mms = MMS2R::Media.create(mail)
|
24
|
+
mms.process
|
25
|
+
|
26
|
+
assert_nil(mms.get_text)
|
27
|
+
|
28
|
+
mms.purge
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_simple_get_text
|
32
|
+
mail = TMail::Mail.parse(load_mail('cingularme-text-01.mail').join)
|
33
|
+
mms = MMS2R::Media.create(mail)
|
34
|
+
mms.process
|
35
|
+
|
36
|
+
file = mms.get_text
|
37
|
+
assert_file_size(file, 13)
|
38
|
+
assert_match(/\.txt$/, file.original_filename)
|
39
|
+
assert_equal(13, file.size)
|
40
|
+
assert_match(/\.txt$/, file.local_path)
|
41
|
+
|
42
|
+
mms.purge
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_simple_get_media_is_nil
|
46
|
+
mail = TMail::Mail.parse(load_mail('cingularme-text-01.mail').join)
|
47
|
+
mms = MMS2R::Media.create(mail)
|
48
|
+
mms.process
|
49
|
+
|
50
|
+
assert_nil(mms.get_media)
|
51
|
+
|
52
|
+
mms.purge
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_simple_get_media
|
56
|
+
mail = TMail::Mail.parse(load_mail('nextel-image-01.mail').join)
|
57
|
+
mms = MMS2R::Media.create(mail)
|
58
|
+
mms.process
|
59
|
+
|
60
|
+
file = mms.get_media
|
61
|
+
assert_file_size(file, 337)
|
62
|
+
assert_equal('Jan15_0001.jpg', file.original_filename)
|
63
|
+
assert_equal(337, file.size)
|
64
|
+
assert_match(/Jan15_0001.jpg$/, file.local_path)
|
65
|
+
|
66
|
+
mms.purge
|
67
|
+
end
|
68
|
+
|
20
69
|
def test_simple_image1
|
21
70
|
mail = TMail::Mail.parse(load_mail('nextel-image-01.mail').join)
|
22
71
|
mms = MMS2R::Media.create(mail)
|
@@ -28,10 +77,7 @@ class MMS2RNextelTest < Test::Unit::TestCase
|
|
28
77
|
assert_not_nil(mms.media['image/jpeg'][0])
|
29
78
|
assert_match(/Jan15_0001.jpg$/, mms.media['image/jpeg'][0])
|
30
79
|
|
31
|
-
|
32
|
-
assert_not_nil(file)
|
33
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
34
|
-
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
80
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
35
81
|
|
36
82
|
mms.purge
|
37
83
|
end
|
@@ -47,10 +93,7 @@ class MMS2RNextelTest < Test::Unit::TestCase
|
|
47
93
|
assert_not_nil(mms.media['image/jpeg'][0])
|
48
94
|
assert_match(/Mar12_0001.jpg$/, mms.media['image/jpeg'][0])
|
49
95
|
|
50
|
-
|
51
|
-
assert_not_nil(file)
|
52
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
53
|
-
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
96
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
54
97
|
|
55
98
|
mms.purge
|
56
99
|
end
|
@@ -66,10 +109,7 @@ class MMS2RNextelTest < Test::Unit::TestCase
|
|
66
109
|
assert_not_nil(mms.media['image/jpeg'][0])
|
67
110
|
assert_match(/Apr01_0001.jpg$/, mms.media['image/jpeg'][0])
|
68
111
|
|
69
|
-
|
70
|
-
assert_not_nil(file)
|
71
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
72
|
-
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
112
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
73
113
|
|
74
114
|
mms.purge
|
75
115
|
end
|
@@ -85,16 +125,8 @@ class MMS2RNextelTest < Test::Unit::TestCase
|
|
85
125
|
assert_not_nil(mms.media['image/jpeg'][0])
|
86
126
|
assert_match(/Mar20_0001.jpg$/, mms.media['image/jpeg'][0])
|
87
127
|
|
88
|
-
|
89
|
-
assert_not_nil(file)
|
90
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
91
|
-
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
128
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
92
129
|
|
93
130
|
mms.purge
|
94
131
|
end
|
95
|
-
|
96
|
-
private
|
97
|
-
def load_mail(file)
|
98
|
-
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
99
|
-
end
|
100
132
|
end
|
data/test/test_mms2r_sprint.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
-
|
2
|
+
require File.dirname(__FILE__) + "/test_helper"
|
3
3
|
require 'test/unit'
|
4
4
|
require 'webrick'
|
5
5
|
require 'net/http'
|
@@ -102,6 +102,7 @@ class Response
|
|
102
102
|
end
|
103
103
|
|
104
104
|
class MMS2RSprintTest < Test::Unit::TestCase
|
105
|
+
include MMS2R::TestHelper
|
105
106
|
|
106
107
|
def setup
|
107
108
|
@log = Logger.new(STDOUT)
|
@@ -122,10 +123,7 @@ class MMS2RSprintTest < Test::Unit::TestCase
|
|
122
123
|
assert_not_nil(mms.media['video/quicktime'][0])
|
123
124
|
assert_match(/000_0123a01234567895_1.mov$/, mms.media['video/quicktime'][0])
|
124
125
|
|
125
|
-
|
126
|
-
assert_not_nil(file)
|
127
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
128
|
-
assert(File::size(file) == 49063, "file #{file} not 49063 byts")
|
126
|
+
assert_file_size(mms.media['video/quicktime'][0], 49063)
|
129
127
|
mms.purge
|
130
128
|
end
|
131
129
|
|
@@ -140,10 +138,7 @@ class MMS2RSprintTest < Test::Unit::TestCase
|
|
140
138
|
assert_not_nil(mms.media['image/jpeg'][0])
|
141
139
|
assert_match(/000_0123a01234567890_1.jpg$/, mms.media['image/jpeg'][0])
|
142
140
|
|
143
|
-
|
144
|
-
assert_not_nil(file)
|
145
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
146
|
-
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
141
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
147
142
|
mms.purge
|
148
143
|
end
|
149
144
|
|
@@ -170,9 +165,4 @@ class MMS2RSprintTest < Test::Unit::TestCase
|
|
170
165
|
assert_match(/hello world/, text)
|
171
166
|
mms.purge
|
172
167
|
end
|
173
|
-
|
174
|
-
private
|
175
|
-
def load_mail(file)
|
176
|
-
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
177
|
-
end
|
178
168
|
end
|
data/test/test_mms2r_tmobile.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
3
|
require 'test/unit'
|
3
4
|
require 'rubygems'
|
4
5
|
require 'mms2r'
|
@@ -7,6 +8,7 @@ require 'tmail/mail'
|
|
7
8
|
require 'logger'
|
8
9
|
|
9
10
|
class MMS2RTMobileTest < Test::Unit::TestCase
|
11
|
+
include MMS2R::TestHelper
|
10
12
|
|
11
13
|
def setup
|
12
14
|
@log = Logger.new(STDOUT)
|
@@ -27,10 +29,7 @@ class MMS2RTMobileTest < Test::Unit::TestCase
|
|
27
29
|
assert_not_nil(mms.media['image/jpeg'][0])
|
28
30
|
assert_match(/12-01-06_1234.jpg$/, mms.media['image/jpeg'][0])
|
29
31
|
|
30
|
-
|
31
|
-
assert_not_nil(file)
|
32
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
33
|
-
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
32
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
34
33
|
|
35
34
|
mms.purge
|
36
35
|
end
|
@@ -46,9 +45,7 @@ class MMS2RTMobileTest < Test::Unit::TestCase
|
|
46
45
|
assert_not_nil(mms.media['image/jpeg'][0])
|
47
46
|
assert_match(/07-25-05_0935.jpg$/, mms.media['image/jpeg'][0])
|
48
47
|
|
49
|
-
|
50
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
51
|
-
assert(File::size(file) == 337, "file #{file} is not 337 bytes")
|
48
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
52
49
|
|
53
50
|
file = mms.media['text/plain'][0]
|
54
51
|
assert_not_nil(file)
|
@@ -58,9 +55,4 @@ class MMS2RTMobileTest < Test::Unit::TestCase
|
|
58
55
|
|
59
56
|
mms.purge
|
60
57
|
end
|
61
|
-
|
62
|
-
private
|
63
|
-
def load_mail(file)
|
64
|
-
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
65
|
-
end
|
66
58
|
end
|
data/test/test_mms2r_verizon.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
-
|
2
|
+
require File.dirname(__FILE__) + "/test_helper"
|
3
3
|
require 'test/unit'
|
4
4
|
require 'rubygems'
|
5
5
|
require 'mms2r'
|
@@ -8,6 +8,7 @@ require 'tmail/mail'
|
|
8
8
|
require 'logger'
|
9
9
|
|
10
10
|
class MMS2RVerizonTest < Test::Unit::TestCase
|
11
|
+
include MMS2R::TestHelper
|
11
12
|
|
12
13
|
def setup
|
13
14
|
@log = Logger.new(STDOUT)
|
@@ -28,10 +29,8 @@ class MMS2RVerizonTest < Test::Unit::TestCase
|
|
28
29
|
assert_not_nil(mms.media['video/3gpp2'][0])
|
29
30
|
assert_match(/012345_67890.3g2$/, mms.media['video/3gpp2'][0])
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
34
|
-
assert(File::size(file) == 16553, "file #{file} not 16553 byts")
|
32
|
+
assert_file_size(mms.media['video/3gpp2'][0], 16553)
|
33
|
+
|
35
34
|
mms.purge
|
36
35
|
end
|
37
36
|
|
@@ -46,10 +45,8 @@ class MMS2RVerizonTest < Test::Unit::TestCase
|
|
46
45
|
assert_not_nil(mms.media['image/jpeg'][0])
|
47
46
|
assert_match(/IMAGE_00004.jpg$/, mms.media['image/jpeg'][0])
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
52
|
-
assert(File::size(file) == 337, "file #{file} not 41983 byts")
|
48
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
49
|
+
|
53
50
|
mms.purge
|
54
51
|
end
|
55
52
|
|
@@ -92,10 +89,7 @@ class MMS2RVerizonTest < Test::Unit::TestCase
|
|
92
89
|
assert_not_nil(mms.media['image/jpeg'][0])
|
93
90
|
assert_match(/04-09-07_1114.jpg$/, mms.media['image/jpeg'][0])
|
94
91
|
|
95
|
-
|
96
|
-
assert_not_nil(file)
|
97
|
-
assert(File::exist?(file), "file #{file} does not exist")
|
98
|
-
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
92
|
+
assert_file_size(mms.media['image/jpeg'][0], 337)
|
99
93
|
|
100
94
|
file = mms.media['text/plain'][0]
|
101
95
|
assert_not_nil(file)
|
@@ -105,9 +99,4 @@ class MMS2RVerizonTest < Test::Unit::TestCase
|
|
105
99
|
|
106
100
|
mms.purge
|
107
101
|
end
|
108
|
-
|
109
|
-
private
|
110
|
-
def load_mail(file)
|
111
|
-
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
112
|
-
end
|
113
102
|
end
|
metadata
CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mms2r
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2007-04-
|
6
|
+
version: 1.0.6
|
7
|
+
date: 2007-04-25 00:00:00 -07:00
|
8
8
|
summary: Extract media from MMS
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: mike@mondragon.cc
|
12
12
|
homepage: http://mms2r.rubyforge.org/
|
13
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 garbage 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: * AT&T/Cingular => mmode.com * Cingular => mms.mycingular.com * Cingular => cingularme.com * Nextel => messaging.nextel.com * Sprint => pm.sprint.com * Sprint => messaging.sprintpcs.com * T-Mobile => tmomail.net * Verizon => vzwpix.com * Verizon => vtext.com"
|
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 garbage 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: * AT&T/Cingular => mmode.com * Cingular => mms.mycingular.com * Cingular => cingularme.com * Dobson/Cellular One => mms.dobson.net * Nextel => messaging.nextel.com * Sprint => pm.sprint.com * Sprint => messaging.sprintpcs.com * T-Mobile => tmomail.net * Verizon => vzwpix.com * Verizon => vtext.com"
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- conf/mms2r_verizonmedia_transform.yml
|
42
42
|
- lib/mms2r.rb
|
43
43
|
- lib/mms2r/cingular_media.rb
|
44
|
+
- lib/mms2r/dobson_media.rb
|
44
45
|
- lib/mms2r/media.rb
|
45
46
|
- lib/mms2r/mmode_media.rb
|
46
47
|
- lib/mms2r/nextel_media.rb
|
@@ -73,6 +74,7 @@ files:
|
|
73
74
|
- lib/vendor/tmail/tmail.rb
|
74
75
|
- lib/vendor/tmail/utils.rb
|
75
76
|
- test/files/cingularme-text-01.mail
|
77
|
+
- test/files/dobson-image-01.mail
|
76
78
|
- test/files/dot.jpg
|
77
79
|
- test/files/hello_world_mail_multipart.mail
|
78
80
|
- test/files/hello_world_mail_plain_no_content_type.mail
|
@@ -96,7 +98,9 @@ files:
|
|
96
98
|
- test/files/verizon-text-01.mail
|
97
99
|
- test/files/verizon-video-01.mail
|
98
100
|
- test/files/vtext-text-01.mail
|
101
|
+
- test/test_helper.rb
|
99
102
|
- test/test_mms2r_cingular.rb
|
103
|
+
- test/test_mms2r_dobson.rb
|
100
104
|
- test/test_mms2r_media.rb
|
101
105
|
- test/test_mms2r_mmode.rb
|
102
106
|
- test/test_mms2r_nextel.rb
|
@@ -111,6 +115,8 @@ test_files:
|
|
111
115
|
- test/test_mms2r_sprint.rb
|
112
116
|
- test/test_mms2r_mmode.rb
|
113
117
|
- test/test_mms2r_nextel.rb
|
118
|
+
- test/test_helper.rb
|
119
|
+
- test/test_mms2r_dobson.rb
|
114
120
|
rdoc_options: []
|
115
121
|
|
116
122
|
extra_rdoc_files: []
|