mms2r 3.8.2 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +5 -0
- data/lib/mms2r.rb +1 -1
- data/lib/mms2r/media.rb +18 -18
- data/lib/mms2r/version.rb +2 -2
- data/test/fixtures/sprint-ajax-response-success.json +1 -1
- data/test/test_invalid_byte_seq_outlook.rb +2 -14
- data/test/test_messaging_sprintpcs_com.rb +1 -1
- data/test/test_mms2r_media.rb +6 -10
- data/test/test_mms_att_net.rb +2 -2
- data/test/test_mms_mycricket_com.rb +1 -1
- data/test/test_mms_uscc_net.rb +1 -1
- data/test/test_orangemms_net.rb +2 -2
- data/test/test_pm_sprint_com.rb +1 -1
- data/test/test_pxt_vodafone_net_nz.rb +1 -1
- data/test/test_tmomail_net.rb +1 -1
- data/test/test_unicel_com.rb +1 -1
- data/test/test_vzwpix_com.rb +4 -4
- metadata +2 -8
data/History.txt
CHANGED
data/lib/mms2r.rb
CHANGED
data/lib/mms2r/media.rb
CHANGED
@@ -265,18 +265,21 @@ module MMS2R
|
|
265
265
|
|
266
266
|
def body
|
267
267
|
text_file = default_text
|
268
|
-
@body = text_file ? IO.readlines(text_file.path).join.strip : ""
|
269
|
-
@body.force_encoding("ISO-8859-1") if RUBY_VERSION >= "1.9" && @body.encoding == "ASCII-8BIT"
|
270
268
|
|
271
|
-
|
272
|
-
|
269
|
+
if RUBY_VERSION < "1.9"
|
270
|
+
@body = text_file ? IO.read(text_file.path).strip : ""
|
271
|
+
require 'iconv'
|
272
|
+
ic = Iconv.new('UTF-8', 'ISO-8859-1')
|
273
273
|
@body = ic.iconv(@body)
|
274
274
|
@body << ic.iconv(nil)
|
275
275
|
ic.close
|
276
|
-
|
276
|
+
else
|
277
|
+
@body = text_file ? IO.read(text_file.path, :mode => "rb").strip : ""
|
278
|
+
@body = @body.chars.select{|i| i.valid_encoding?}.join
|
277
279
|
end
|
278
280
|
|
279
|
-
if @body.blank? &&
|
281
|
+
if @body.blank? &&
|
282
|
+
html_file = default_html
|
280
283
|
html = Nokogiri::HTML(IO.read(html_file.path))
|
281
284
|
@body = (html.xpath("//head/title").map(&:text) + html.xpath("//body/*").map(&:text)).join(" ")
|
282
285
|
end
|
@@ -402,7 +405,6 @@ module MMS2R
|
|
402
405
|
if part.part_type? =~ /^text\// ||
|
403
406
|
part.part_type? == 'application/smil'
|
404
407
|
type, content = transform_text_part(part)
|
405
|
-
mode = 'wb'
|
406
408
|
else
|
407
409
|
if part.part_type? == 'application/octet-stream'
|
408
410
|
type = type_from_filename(filename?(part))
|
@@ -410,12 +412,11 @@ module MMS2R
|
|
410
412
|
type = part.part_type?
|
411
413
|
end
|
412
414
|
content = part.body.decoded
|
413
|
-
mode = 'wb' # open with binary bit for Windows for non text
|
414
415
|
end
|
415
416
|
return type, nil if content.nil? || content.empty?
|
416
417
|
|
417
418
|
log("#{self.class} writing file #{file}", :info)
|
418
|
-
File.open(file,
|
419
|
+
File.open(file, 'wb'){ |f| f.write(content) }
|
419
420
|
return type, file
|
420
421
|
end
|
421
422
|
|
@@ -443,26 +444,25 @@ module MMS2R
|
|
443
444
|
# See the transform section in the discussion of the built-in
|
444
445
|
# configuration.
|
445
446
|
|
446
|
-
def transform_text(type, text
|
447
|
+
def transform_text(type, text)
|
447
448
|
return type, text if !config['transform'] || !(transforms = config['transform'][type])
|
448
449
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
450
|
+
if RUBY_VERSION < "1.9"
|
451
|
+
require 'iconv'
|
452
|
+
ic = Iconv.new('UTF-8', 'ISO-8859-1')
|
453
|
+
text = ic.iconv(text)
|
454
|
+
text << ic.iconv(nil)
|
453
455
|
ic.close
|
454
|
-
rescue Exception => e
|
455
|
-
utf_t = text
|
456
456
|
end
|
457
457
|
|
458
458
|
transforms.each do |transform|
|
459
459
|
next unless transform.size == 2
|
460
460
|
p = transform.first
|
461
461
|
r = transform.last
|
462
|
-
|
462
|
+
text = text.gsub(p, r) rescue text
|
463
463
|
end
|
464
464
|
|
465
|
-
return type,
|
465
|
+
return type, text
|
466
466
|
end
|
467
467
|
|
468
468
|
##
|
data/lib/mms2r/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"totalMediaItems":2,"shareType":"normal","nomediaItem":"false","isOnlyVideo":null,"creationDate":"May 31, 2012","from":"(513)545-0000","offset":null,"externalMessageId":"XXXXXXXXXXXXXXXXXX","Results":[{"elementID":"0","hasVoiceCaption":false,"URL":{"elementID":"0","indexCount":0,"audio":null,"thumb":"\/retailers\/PCSNEXTEL\/ui-refresh\/images\/background\/slide_no_media_90x90.gif","annotationVoiceID":null,"image":"\/retailers\/PCSNEXTEL\/ui-refresh\/images\/background\/slide_no_media_90x90.gif","video":null},"description":"First text content.
|
1
|
+
{"totalMediaItems":2,"shareType":"normal","nomediaItem":"false","isOnlyVideo":null,"creationDate":"May 31, 2012","from":"(513)545-0000","offset":null,"externalMessageId":"XXXXXXXXXXXXXXXXXX","Results":[{"elementID":"0","hasVoiceCaption":false,"URL":{"elementID":"0","indexCount":0,"audio":null,"thumb":"\/retailers\/PCSNEXTEL\/ui-refresh\/images\/background\/slide_no_media_90x90.gif","annotationVoiceID":null,"image":"\/retailers\/PCSNEXTEL\/ui-refresh\/images\/background\/slide_no_media_90x90.gif","video":null},"description":"First text content.","mediaItemNum":0,"isDRMProtected":false,"externalMessageId":"XXXXXXXXXXXXXXXXXX","mediaType":"TEXT","restOperation":"false","folderFullName":"\/RECIPIENT"},{"elementID":"3","hasVoiceCaption":false,"URL":{"elementID":"3","indexCount":1,"audio":"","thumb":"http:\/\/pictures.sprintpcs.com:80\/mmps\/048_0736849c3f1a9d27_1\/3.jpg?partExt=.jpg&&&outquality=90&ext=.jpg&&size=40,40&squareoutput=255,255,255&aspectcrop=0.5,0.5,1.0,1.0,1.0","annotationVoiceID":null,"image":"http:\/\/pictures.sprintpcs.com:80\/mmps\/048_0736849c3f1a9d27_1\/3.jpg?partExt=.jpg&&&outquality=90&ext=.jpg","video":""},"description":"Second text content. ","mediaItemNum":1,"isDRMProtected":false,"externalMessageId":"XXXXXXXXXXXXXXXXXX","mediaType":"IMAGE","restOperation":"false","folderFullName":"\/RECIPIENT"}],"invite":null,"tmemo":null,"toAddress":"textinsubmit@gmail.com","mediaIndex":0,"subject":"New Message","isDRMProtected":false,"expirationDate":"Expires in 57 Days","voiceURL":null,"guest":"true","folderFullName":"\/RECIPIENT"}
|
@@ -6,21 +6,9 @@ class TestInvalidByteSeqOutlook < Test::Unit::TestCase
|
|
6
6
|
def test_bad_outlook
|
7
7
|
mail = mail('invalid-byte-seq-outlook.mail')
|
8
8
|
mms = MMS2R::Media.new(mail)
|
9
|
-
body = mms.body
|
10
|
-
=begin
|
11
9
|
|
12
|
-
assert_equal "
|
13
|
-
|
14
|
-
assert_equal 2, mms.media.size
|
15
|
-
|
16
|
-
assert_not_nil mms.media['text/plain']
|
17
|
-
assert_equal 1, mms.media['text/plain'].size
|
18
|
-
assert_equal "testing123456789012", open(mms.media['text/plain'].first).read
|
19
|
-
|
20
|
-
assert_not_nil mms.media['image/jpeg']
|
21
|
-
assert_equal 1, mms.media['text/plain'].size
|
22
|
-
assert_match(/@003\.jpg$/, mms.media['image/jpeg'].first)
|
23
|
-
=end
|
10
|
+
assert_equal "RE: Issue 14794:Don M. says.. Aaron - I completed RNS Test Question 3, which was done as a 'Cargo Control Number' query. H", mms.subject
|
11
|
+
assert_match /Don Doe said less than a minute ago/im, mms.body
|
24
12
|
|
25
13
|
mms.purge
|
26
14
|
end
|
@@ -14,7 +14,7 @@ class TestMessagingSprintpcsCom < Test::Unit::TestCase
|
|
14
14
|
file = mms.media['text/plain'][0]
|
15
15
|
assert_not_nil file
|
16
16
|
assert File::exist?(file), "file #{file} does not exist"
|
17
|
-
text = IO.
|
17
|
+
text = IO.read("#{file}")
|
18
18
|
assert_match(/hello world/, text)
|
19
19
|
mms.purge
|
20
20
|
end
|
data/test/test_mms2r_media.rb
CHANGED
@@ -233,20 +233,16 @@ class TestMms2rMedia < Test::Unit::TestCase
|
|
233
233
|
file = mms.media['text/plain'][0]
|
234
234
|
assert_not_nil file
|
235
235
|
assert_equal true, File::exist?(file)
|
236
|
-
text_lines = IO.readlines("#{file}")
|
237
|
-
text = text_lines.join
|
238
|
-
|
239
|
-
# ASCII-8BIT -> D'ici un mois G\xE9orgie
|
240
|
-
# UTF-8 -> D'ici un mois Géorgie
|
241
|
-
|
242
236
|
if RUBY_VERSION < "1.9"
|
243
|
-
|
244
|
-
assert_equal("D'ici un mois Géorgie body", text_lines.first.strip)
|
237
|
+
text = IO.read("#{file}")
|
245
238
|
else
|
246
|
-
|
247
|
-
assert_equal(Iconv.new('UTF-8', 'ISO-8859-1').iconv("D'ici un mois G\xE9orgie body"), text_lines.first.strip)
|
239
|
+
text = IO.read("#{file}", :mode => "rb")
|
248
240
|
end
|
249
241
|
|
242
|
+
# ASCII-8BIT -> D'ici un mois G\xE9orgie
|
243
|
+
# UTF-8 -> D'ici un mois Géorgie
|
244
|
+
|
245
|
+
assert_equal("sample email message Fwd: sub D'ici un mois Géorgie", mms.subject)
|
250
246
|
end
|
251
247
|
|
252
248
|
def test_subject
|
data/test/test_mms_att_net.rb
CHANGED
@@ -103,7 +103,7 @@ class TestMmsAttNet < Test::Unit::TestCase
|
|
103
103
|
assert_equal "example.com", mms.carrier
|
104
104
|
|
105
105
|
assert_not_nil mms.media['text/plain']
|
106
|
-
assert_equal "Hello world", IO.
|
106
|
+
assert_equal "Hello world", IO.read(mms.media['text/plain'].first).strip
|
107
107
|
|
108
108
|
assert_not_nil mms.media['image/jpeg'].first
|
109
109
|
assert_match(/\/BC-WAKE\.jpg$/, mms.media['image/jpeg'].first)
|
@@ -118,7 +118,7 @@ class TestMmsAttNet < Test::Unit::TestCase
|
|
118
118
|
assert_equal 2, mms.media.size
|
119
119
|
|
120
120
|
assert_not_nil mms.media['text/plain']
|
121
|
-
assert_match(/^Testing memorymail from my blackberry and at&t.$/, IO.
|
121
|
+
assert_match(/^Testing memorymail from my blackberry and at&t.$/, IO.read(mms.media['text/plain'].first).strip)
|
122
122
|
|
123
123
|
assert_not_nil mms.media['image/jpeg'].first
|
124
124
|
assert_match(/IMG00367.jpg/, mms.media['image/jpeg'].first)
|
@@ -48,7 +48,7 @@ class TestMmsMycricketCom < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
file = mms.media['text/plain'].first
|
50
50
|
assert_equal true, File::exist?(file), "file #{file} does not exist"
|
51
|
-
text = IO.
|
51
|
+
text = IO.read("#{file}")
|
52
52
|
assert_match(/Hello World/, text)
|
53
53
|
|
54
54
|
assert_match(/02-14-08_2114.jpg$/, mms.media['image/jpeg'].first)
|
data/test/test_mms_uscc_net.rb
CHANGED
@@ -24,7 +24,7 @@ class TestMmsUsccNet < Test::Unit::TestCase
|
|
24
24
|
file = mms.media['text/plain'][0]
|
25
25
|
assert_not_nil file
|
26
26
|
assert_equal true, File::exist?(file)
|
27
|
-
text = IO.
|
27
|
+
text = IO.read("#{file}")
|
28
28
|
assert_match(/This is what i do at work most the day/, text)
|
29
29
|
|
30
30
|
mms.purge
|
data/test/test_orangemms_net.rb
CHANGED
@@ -58,7 +58,7 @@ class TestOrangemmsNet < Test::Unit::TestCase
|
|
58
58
|
assert_equal 1, mms.media['text/plain'].size
|
59
59
|
file = mms.media['text/plain'].first
|
60
60
|
assert File::exist?(file), "file #{file} does not exist"
|
61
|
-
text = IO.
|
61
|
+
text = IO.read("#{file}")
|
62
62
|
assert_match(/Test ma poule/, text)
|
63
63
|
|
64
64
|
# image
|
@@ -100,7 +100,7 @@ class TestOrangemmsNet < Test::Unit::TestCase
|
|
100
100
|
file = mms.media['text/plain'][0]
|
101
101
|
assert_not_nil file
|
102
102
|
assert File::exist?(file), "file #{file} does not exist"
|
103
|
-
text = IO.
|
103
|
+
text = IO.read("#{file}")
|
104
104
|
assert_match(/pozdro600/, text)
|
105
105
|
mms.purge
|
106
106
|
end
|
data/test/test_pm_sprint_com.rb
CHANGED
@@ -242,7 +242,7 @@ class TestPmSprintCom < Test::Unit::TestCase
|
|
242
242
|
assert_equal 2, mms.media['text/plain'].size
|
243
243
|
|
244
244
|
# test that the message was extracted from the ajax response
|
245
|
-
message = IO.
|
245
|
+
message = IO.read(mms.media['text/plain'].first)
|
246
246
|
assert_equal "First text content.", message
|
247
247
|
|
248
248
|
# test that the was removed ()
|
@@ -20,7 +20,7 @@ class TestPxtVodafoneNetNz < Test::Unit::TestCase
|
|
20
20
|
file = @mms.media['text/plain'][0]
|
21
21
|
assert_not_nil(file)
|
22
22
|
assert(File::exist?(file), "file #{file} does not exist")
|
23
|
-
text = IO.
|
23
|
+
text = IO.read("#{file}")
|
24
24
|
assert_match(/Kia ora ano Luke/, text)
|
25
25
|
|
26
26
|
assert_match(/Kia ora ano Luke/, @mms.body)
|
data/test/test_tmomail_net.rb
CHANGED
@@ -37,7 +37,7 @@ class TestTmomailNet < Test::Unit::TestCase
|
|
37
37
|
file = mms.media['text/plain'][0]
|
38
38
|
assert_not_nil file
|
39
39
|
assert File::exist?(file), "file #{file} does not exist"
|
40
|
-
text = IO.
|
40
|
+
text = IO.read("#{file}")
|
41
41
|
assert_equal "Lillies", text.strip
|
42
42
|
|
43
43
|
mms.purge
|
data/test/test_unicel_com.rb
CHANGED
data/test/test_vzwpix_com.rb
CHANGED
@@ -79,7 +79,7 @@ www.verizonwireless.com/getitnow/getpix.}
|
|
79
79
|
assert_not_nil file
|
80
80
|
assert_equal true, File::exist?(file)
|
81
81
|
|
82
|
-
text = IO.
|
82
|
+
text = IO.read("#{file}")
|
83
83
|
assert_match(/hello world/, text)
|
84
84
|
mms.purge
|
85
85
|
end
|
@@ -102,7 +102,7 @@ www.verizonwireless.com/getitnow/getpix.}
|
|
102
102
|
file = mms.media['text/plain'][0]
|
103
103
|
assert_not_nil file
|
104
104
|
assert_equal true, File::exist?(file)
|
105
|
-
text = IO.
|
105
|
+
text = IO.read("#{file}")
|
106
106
|
assert_no_match(/Regexp.escape(@ad_old)/, text)
|
107
107
|
assert_no_match(/Regexp.escape@greet/, text)
|
108
108
|
assert_equal "? Weird", text
|
@@ -139,7 +139,7 @@ www.verizonwireless.com/getitnow/getpix.}
|
|
139
139
|
file = mms.media['text/plain'][0]
|
140
140
|
assert_not_nil file
|
141
141
|
assert_equal true, File::exist?(file)
|
142
|
-
text = IO.
|
142
|
+
text = IO.read("#{file}")
|
143
143
|
assert_match(/hello world/, text)
|
144
144
|
mms.purge
|
145
145
|
end
|
@@ -151,7 +151,7 @@ www.verizonwireless.com/getitnow/getpix.}
|
|
151
151
|
assert_equal 'yahoo.com', mms.carrier
|
152
152
|
|
153
153
|
assert_not_nil mms.media['text/plain']
|
154
|
-
assert_equal "Wonderful picture!", IO.
|
154
|
+
assert_equal "Wonderful picture!", IO.read(mms.media['text/plain'].first).strip
|
155
155
|
|
156
156
|
assert_not_nil mms.media['image/jpeg'].first
|
157
157
|
assert_match(/\/IMG00016\.jpg$/, mms.media['image/jpeg'].first)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mms2r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -375,18 +375,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
375
375
|
- - ! '>='
|
376
376
|
- !ruby/object:Gem::Version
|
377
377
|
version: '0'
|
378
|
-
segments:
|
379
|
-
- 0
|
380
|
-
hash: 4273706323397208345
|
381
378
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
382
379
|
none: false
|
383
380
|
requirements:
|
384
381
|
- - ! '>='
|
385
382
|
- !ruby/object:Gem::Version
|
386
383
|
version: '0'
|
387
|
-
segments:
|
388
|
-
- 0
|
389
|
-
hash: 4273706323397208345
|
390
384
|
requirements: []
|
391
385
|
rubyforge_project: mms2r
|
392
386
|
rubygems_version: 1.8.23
|