mms2r 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.1.7 / 2007-08-25 (Adam Nergal, friend of Skwisgaar, but not Pickles)
2
+
3
+ * Added suport for Orange of Poland Orange mmsemail.orange.pl (Zbigniew
4
+ Sobiecki)
5
+ * Cleaned up documentation modifiers
6
+ * Cleaned out non-Ruby code idioms
7
+
1
8
  == 1.1.6 / 2007-08-11 (Mustakrakish, the Lake Troll part 2)
2
9
 
3
10
  * Redo of release mistake of 1.1.5
data/Manifest.txt CHANGED
@@ -11,6 +11,7 @@ conf/mms2r_media_ignore.yml
11
11
  conf/mms2r_media_subject.yml
12
12
  conf/mms2r_my_cingular_media_subject.yml
13
13
  conf/mms2r_nextel_media_ignore.yml
14
+ conf/mms2r_orange_poland_media_subject.yml
14
15
  conf/mms2r_sprint_media_ignore.yml
15
16
  conf/mms2r_sprint_media_subject.yml
16
17
  conf/mms2r_t_mobile_media_ignore.yml
@@ -26,6 +27,7 @@ lib/mms2r/m_mode_media.rb
26
27
  lib/mms2r/media.rb
27
28
  lib/mms2r/my_cingular_media.rb
28
29
  lib/mms2r/nextel_media.rb
30
+ lib/mms2r/orange_poland_media.rb
29
31
  lib/mms2r/sprint_media.rb
30
32
  lib/mms2r/sprint_pcs_media.rb
31
33
  lib/mms2r/t_mobile_media.rb
@@ -72,6 +74,8 @@ test/fixtures/nextel-image-01.mail
72
74
  test/fixtures/nextel-image-02.mail
73
75
  test/fixtures/nextel-image-03.mail
74
76
  test/fixtures/nextel-image-04.mail
77
+ test/fixtures/orangepoland-text-01.mail
78
+ test/fixtures/orangepoland-text-02.mail
75
79
  test/fixtures/simple-with-two-images-two-texts.mail
76
80
  test/fixtures/simple_image.mail
77
81
  test/fixtures/simple_multipart_alternative.mail
@@ -98,6 +102,7 @@ test/test_mms2r_m_mode_media.rb
98
102
  test/test_mms2r_media.rb
99
103
  test/test_mms2r_my_cingular_media.rb
100
104
  test/test_mms2r_nextel_media.rb
105
+ test/test_mms2r_orange_poland_media.rb
101
106
  test/test_mms2r_sprint_media.rb
102
107
  test/test_mms2r_sprint_pcs_media.rb
103
108
  test/test_mms2r_t_mobile_media.rb
data/README.txt CHANGED
@@ -25,6 +25,7 @@ Corpus of carriers currently processed by MMS2R:
25
25
  * Dobson/Cellular One => mms.dobson.net
26
26
  * Helio => mms.myhelio.com
27
27
  * Nextel => messaging.nextel.com
28
+ * Orange (Poland) => mmsemail.orange.pl
28
29
  * Sprint => pm.sprint.com
29
30
  * Sprint => messaging.sprintpcs.com
30
31
  * T-Mobile => tmomail.net
@@ -55,7 +56,7 @@ Corpus of carriers currently processed by MMS2R:
55
56
  # writes the user generated media to disk in a temporary subdirectory
56
57
  mms.process
57
58
 
58
- puts "MMS has default carrier subject!" if mms.get_subject.eql?("")
59
+ puts "MMS has default carrier subject!" unless mms.get_subject
59
60
 
60
61
  # access the senders phone number
61
62
  puts "MMS was from phone #{mms.get_number}"
@@ -0,0 +1,3 @@
1
+ ---
2
+ - !ruby/regexp /^Wiadomość multimedialna.\s*$/i
3
+
data/lib/mms2r.rb CHANGED
@@ -13,6 +13,7 @@ require 'mms2r/helio_media'
13
13
  require 'mms2r/m_mode_media'
14
14
  require 'mms2r/my_cingular_media'
15
15
  require 'mms2r/nextel_media'
16
+ require 'mms2r/orange_poland_media'
16
17
  require 'mms2r/sprint_media'
17
18
  require 'mms2r/sprint_pcs_media'
18
19
  require 'mms2r/t_mobile_media'
@@ -36,6 +37,7 @@ module MMS2R
36
37
  'mmode.com' => MMS2R::MModeMedia,
37
38
  'mms.mycingular.com' => MMS2R::MyCingularMedia,
38
39
  'messaging.nextel.com' => MMS2R::NextelMedia,
40
+ 'mmsemail.orange.pl' => MMS2R::OrangePolandMedia,
39
41
  'pm.sprint.com' => MMS2R::SprintMedia,
40
42
  'messaging.sprintpcs.com' => MMS2R::SprintPcsMedia,
41
43
  'tmomail.net' => MMS2R::TMobileMedia,
@@ -61,7 +63,7 @@ module MMS2R
61
63
  ##
62
64
  # MMS2R Library version
63
65
 
64
- VERSION = '1.1.6'
66
+ VERSION = '1.1.7'
65
67
 
66
68
  end
67
69
 
data/lib/mms2r/media.rb CHANGED
@@ -92,6 +92,8 @@ module MMS2R
92
92
  @body = nil
93
93
  @default_media = nil
94
94
  @default_text = nil
95
+
96
+ #TODO: new should be 'create' refactor to this behavior
95
97
  end
96
98
 
97
99
  ##
@@ -116,7 +118,7 @@ module MMS2R
116
118
  return @subject if @subject # we've already done the work
117
119
 
118
120
  subject = @mail.subject
119
- return @subject ||= nil if subject.nil? || subject.strip.length == 0
121
+ return @subject ||= nil if subject.nil? || subject.strip.empty?
120
122
 
121
123
  # subject is not already set, lets see what our defaults are
122
124
  a = Array.new
@@ -128,7 +130,7 @@ module MMS2R
128
130
  f = clz.yaml_file_name(clz, :subject)
129
131
  yf = File.join(self.class.conf_dir(), "#{f}")
130
132
  a = a + YAML::load_file(yf) if File::exist?(yf)
131
- return @subject ||= subject if a.size == 0
133
+ return @subject ||= subject if a.empty?
132
134
  return @subject ||= nil if a.detect{|r| r.match(subject.strip)}
133
135
  return @subject ||= subject
134
136
  end
@@ -195,7 +197,7 @@ module MMS2R
195
197
  # note: auto-purging is a feature of calling process() with a block, purge
196
198
  # must be explicitly called otherwise
197
199
 
198
- def process()
200
+ def process() # :yields: media_type, file
199
201
  @logger.info("#{self.class} processing") unless @logger.nil?
200
202
 
201
203
  # build up all the parts
@@ -269,8 +271,8 @@ module MMS2R
269
271
  f = clz.yaml_file_name(clz, :ignore)
270
272
  yf = File.join(self.class.conf_dir(), "#{f}")
271
273
  if File::exist?(yf)
272
- h2 = YAML::load_file(yf)
273
- h2.each do |k,v|
274
+ ignores = YAML::load_file(yf)
275
+ ignores.each do |k,v|
274
276
  unless h[k]
275
277
  h[k] = v
276
278
  else
@@ -279,7 +281,7 @@ module MMS2R
279
281
  end
280
282
  end
281
283
  a ||= h[type]
282
- return false if h.size == 0 || a.nil?
284
+ return false if h.empty? || a.nil?
283
285
 
284
286
  m = /^([^\/]+)\//.match(type)[1]
285
287
  # fire each regular expression, only break if there is a match
@@ -542,11 +544,11 @@ module MMS2R
542
544
  files.concat(media[k]) if /^#{t}\//.match(k)
543
545
  end
544
546
  end
545
- return nil if files.size == 0
547
+ return nil if files.empty?
546
548
 
547
549
  #get the largest file
550
+ file = nil # explicitly declare the file and sile
548
551
  size = 0
549
- file = nil # explicitly declare the file
550
552
 
551
553
  files.each do |f|
552
554
  # this will safely evaluate since we wouldn't be looking at
@@ -578,7 +580,7 @@ module MMS2R
578
580
  self
579
581
  end.send(:define_method, :content_type) { mime_type }
580
582
 
581
- return file
583
+ file
582
584
  end
583
585
 
584
586
  end
@@ -0,0 +1,10 @@
1
+ module MMS2R
2
+
3
+ ##
4
+ # Orange-Poland version of MMS2R::Media
5
+ #
6
+ # Orange-Poland adds its own subject if it's empty.
7
+
8
+ class MMS2R::OrangePolandMedia < MMS2R::Media
9
+ end
10
+ end
@@ -78,7 +78,7 @@ module MMS2R
78
78
  doc.search("/html/body//pre").each do |pre|
79
79
  type = 'text/plain'
80
80
  text = pre.inner_html.strip
81
- next if text.size == 0
81
+ next if text.empty?
82
82
  type, text = transform_text(type, text)
83
83
  type, file = sprint_write_file(type, text.strip)
84
84
  add_file(type, file) unless type.nil? || file.nil?
@@ -0,0 +1,7 @@
1
+ From: 48509123456@mmsemail.orange.pl
2
+ To: foo@bar.com
3
+ Subject: Wiadomość multimedialna.
4
+ Message-ID: <3633598.1180262316735.JavaMail.wluser@mms-ag1-m-vas>
5
+ Date: Tue, 6 Jun 2006 06:06:06 -0600
6
+
7
+ pozdro600
@@ -0,0 +1,7 @@
1
+ From: 48509123456@mmsemail.orange.pl
2
+ To: foo@bar.com
3
+ Subject: whazzup
4
+ Message-ID: <3633598.1180262316735.JavaMail.wluser@mms-ag1-m-vas>
5
+ Date: Tue, 6 Jun 2006 06:06:06 -0600
6
+
7
+ pozdro600
@@ -0,0 +1,42 @@
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
+ class MMS2R::OrangePolandMediaTest < Test::Unit::TestCase
11
+ include MMS2R::TestHelper
12
+
13
+ def test_empty_subject
14
+ mail = TMail::Mail.parse(load_mail('orangepoland-text-01.mail').join)
15
+ mms = MMS2R::Media.create(mail)
16
+ assert_equal MMS2R::OrangePolandMedia, mms.class, "expected a #{MMS2R::OrangePolandMedia} and received a #{mms.class}"
17
+ mms.process
18
+ assert_nil mms.get_subject
19
+ assert_not_nil mms.media['text/plain']
20
+ file = mms.media['text/plain'][0]
21
+ assert_not_nil file
22
+ assert File::exist?(file), "file #{file} does not exist"
23
+ text = IO.readlines("#{file}").join
24
+ assert_match(/pozdro600/, text)
25
+ mms.purge
26
+ end
27
+
28
+ def test_non_empty_subject
29
+ mail = TMail::Mail.parse(load_mail('orangepoland-text-02.mail').join)
30
+ mms = MMS2R::Media.create(mail)
31
+ assert_equal MMS2R::OrangePolandMedia, mms.class, "expected a #{MMS2R::OrangePolandMedia} and received a #{mms.class}"
32
+ mms.process
33
+ assert mms.get_subject, "whazzup"
34
+ assert_not_nil mms.media['text/plain']
35
+ file = mms.media['text/plain'][0]
36
+ assert_not_nil file
37
+ assert File::exist?(file), "file #{file} does not exist"
38
+ text = IO.readlines("#{file}").join
39
+ assert_match(/pozdro600/, text)
40
+ mms.purge
41
+ end
42
+ end
metadata CHANGED
@@ -3,15 +3,15 @@ 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.6
7
- date: 2007-08-11 00:00:00 -07:00
6
+ version: 1.1.7
7
+ date: 2007-08-27 00:00:00 -07:00
8
8
  summary: Extract user media from MMS (and not carrier cruft)
9
9
  require_paths:
10
10
  - lib
11
11
  email: mikemondragon@gmail.com
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 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: * 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 * 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 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: * 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 * 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
@@ -42,6 +42,7 @@ files:
42
42
  - conf/mms2r_media_subject.yml
43
43
  - conf/mms2r_my_cingular_media_subject.yml
44
44
  - conf/mms2r_nextel_media_ignore.yml
45
+ - conf/mms2r_orange_poland_media_subject.yml
45
46
  - conf/mms2r_sprint_media_ignore.yml
46
47
  - conf/mms2r_sprint_media_subject.yml
47
48
  - conf/mms2r_t_mobile_media_ignore.yml
@@ -57,6 +58,7 @@ files:
57
58
  - lib/mms2r/media.rb
58
59
  - lib/mms2r/my_cingular_media.rb
59
60
  - lib/mms2r/nextel_media.rb
61
+ - lib/mms2r/orange_poland_media.rb
60
62
  - lib/mms2r/sprint_media.rb
61
63
  - lib/mms2r/sprint_pcs_media.rb
62
64
  - lib/mms2r/t_mobile_media.rb
@@ -103,6 +105,8 @@ files:
103
105
  - test/fixtures/nextel-image-02.mail
104
106
  - test/fixtures/nextel-image-03.mail
105
107
  - test/fixtures/nextel-image-04.mail
108
+ - test/fixtures/orangepoland-text-01.mail
109
+ - test/fixtures/orangepoland-text-02.mail
106
110
  - test/fixtures/simple-with-two-images-two-texts.mail
107
111
  - test/fixtures/simple_image.mail
108
112
  - test/fixtures/simple_multipart_alternative.mail
@@ -129,6 +133,7 @@ files:
129
133
  - test/test_mms2r_media.rb
130
134
  - test/test_mms2r_my_cingular_media.rb
131
135
  - test/test_mms2r_nextel_media.rb
136
+ - test/test_mms2r_orange_poland_media.rb
132
137
  - test/test_mms2r_sprint_media.rb
133
138
  - test/test_mms2r_sprint_pcs_media.rb
134
139
  - test/test_mms2r_t_mobile_media.rb
@@ -138,6 +143,7 @@ files:
138
143
  - vendor/plugins/mms2r/lib/autotest/mms2r.rb
139
144
  test_files:
140
145
  - test/test_mms2r_cingular_me_media.rb
146
+ - test/test_mms2r_orange_poland_media.rb
141
147
  - test/test_mms2r_helio_media.rb
142
148
  - test/test_mms2r_sprint_pcs_media.rb
143
149
  - test/test_mms2r_media.rb
@@ -190,5 +196,5 @@ dependencies:
190
196
  requirements:
191
197
  - - ">="
192
198
  - !ruby/object:Gem::Version
193
- version: 1.2.1
199
+ version: 1.3.0
194
200
  version: