mms2r 3.6.0 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ ### 3.6.1 / 2012-02-11 (Mr. Gojira - Owner Mr. Gojira's Driving School)
2
+
3
+ * 1 minor enhancement
4
+ * use Net::HTTP#get2 to fetch Sprint content
5
+
1
6
  ### 3.6.0 / 2012-01-19 (Agent 216 - assassin, master of infiltration and sabotage)
2
7
 
3
8
  * 1 major enhancement
data/lib/mms2r.rb CHANGED
@@ -39,7 +39,7 @@ module MMS2R
39
39
  ##
40
40
  # MMS2R library version
41
41
 
42
- VERSION = '3.6.0'
42
+ VERSION = '3.6.1'
43
43
 
44
44
  ##
45
45
  # Spoof User-Agent, primarily for the Sprint CDN
@@ -50,9 +50,10 @@ module MMS2R
50
50
  # Simple convenience function to make it a one-liner:
51
51
  # MMS2R.parse raw_mail or MMS2R.parse File.load(raw_mail)
52
52
  # Combined w/ the method_missing delegation, this should behave as an enhanced Mail object, more or less.
53
- def self.parse raw_mail
53
+ def self.parse raw_mail, options = {}
54
54
  mail = Mail.new raw_mail
55
- MMS2R::Media.new(mail) end
55
+ MMS2R::Media.new(mail, options)
56
+ end
56
57
 
57
58
  end
58
59
 
@@ -134,17 +134,19 @@ module MMS2R
134
134
  unless @is_video
135
135
  query={}
136
136
  uri.query.split('&').each{|a| p=a.split('='); query[p[0]] = p[1]}
137
- query.delete_if{|k, v| k == 'limitsize' or k == 'squareoutput' }
137
+ query.delete_if{|k, v| k == 'limitsize' || k == 'squareoutput' }
138
138
  uri.query = query.map{|k,v| "#{k}=#{v}"}.join("&")
139
139
  end
140
140
  # sprint is a ghetto, they expect to see & for video request
141
141
  uri.query = uri.query.gsub(/&/, "&") if @is_video
142
142
 
143
143
  connection = Net::HTTP.new(uri.host, uri.port)
144
- response, content = connection.get(
144
+ #connection.set_debug_output $stdout
145
+ response = connection.get2(
145
146
  uri.request_uri,
146
147
  { "User-Agent" => MMS2R::Media::USER_AGENT }
147
148
  )
149
+ content = response.body
148
150
  rescue StandardError => err
149
151
  log("#{self.class} processing error, #{$!}", :error)
150
152
  next
data/mms2r.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "mms2r"
5
- s.version = "3.4.0"
5
+ s.version = "3.6.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Mike Mondragon"]
@@ -8,16 +8,17 @@ class TestPmSprintCom < Test::Unit::TestCase
8
8
  body = mock('body')
9
9
  connection = mock('connection')
10
10
  response.expects(:content_type).twice.returns('image/jpeg')
11
+ response.expects(:body).returns(body)
11
12
  response.expects(:code).never
12
13
  Net::HTTP.expects(:new).with('pictures.sprintpcs.com', 80).once.returns connection
13
- connection.expects(:get).with(
14
+ connection.expects(:get2).with(
14
15
  # 1.9.2
15
16
  # '//mmps/RECIPIENT/001_2066c7013e7ca833_1/2?inviteToken=PE5rJ5PdYzzwk7V7zoXU&outquality=90&ext=.jpg&iconifyVideo=true&wm=1'
16
17
  # 1.8.7
17
18
  # '//mmps/RECIPIENT/001_2066c7013e7ca833_1/2?wm=1&ext=.jpg&outquality=90&iconifyVideo=true&inviteToken=PE5rJ5PdYzzwk7V7zoXU'
18
19
  kind_of(String),
19
20
  { "User-Agent" => MMS2R::Media::USER_AGENT }
20
- ).once.returns([response, body])
21
+ ).once.returns(response)
21
22
  end
22
23
 
23
24
  def mock_sprint_purged_image(message_id)
@@ -25,16 +26,17 @@ class TestPmSprintCom < Test::Unit::TestCase
25
26
  body = mock('body')
26
27
  connection = mock('connection')
27
28
  response.expects(:content_type).once.returns('text/html')
29
+ response.expects(:body).returns(body)
28
30
  response.expects(:code).once.returns('500')
29
31
  Net::HTTP.expects(:new).with('pictures.sprintpcs.com', 80).once.returns connection
30
- connection.expects(:get).with(
32
+ connection.expects(:get2).with(
31
33
  # 1.9.2
32
34
  # '//mmps/RECIPIENT/001_2066c7013e7ca833_1/2?inviteToken=PE5rJ5PdYzzwk7V7zoXU&outquality=90&ext=.jpg&iconifyVideo=true&wm=1'
33
35
  # 1.8.7
34
36
  # '//mmps/RECIPIENT/001_2066c7013e7ca833_1/2?wm=1&ext=.jpg&outquality=90&iconifyVideo=true&inviteToken=PE5rJ5PdYzzwk7V7zoXU'
35
37
  kind_of(String),
36
38
  { "User-Agent" => MMS2R::Media::USER_AGENT }
37
- ).once.returns([response, body])
39
+ ).once.returns(response)
38
40
  end
39
41
 
40
42
  def test_mms_should_have_text
@@ -68,12 +70,13 @@ class TestPmSprintCom < Test::Unit::TestCase
68
70
  body = mock('body')
69
71
  connection = mock('connection')
70
72
  response.expects(:content_type).twice.returns('video/quicktime')
73
+ response.expects(:body).returns(body)
71
74
  response.expects(:code).never
72
75
  Net::HTTP.expects(:new).with('pictures.sprintpcs.com', 80).once.returns connection
73
- connection.expects(:get).with(
76
+ connection.expects(:get2).with(
74
77
  kind_of(String),
75
78
  { "User-Agent" => MMS2R::Media::USER_AGENT }
76
- ).once.returns([response, body])
79
+ ).once.returns(response)
77
80
 
78
81
  mms = MMS2R::Media.new(mail)
79
82
  assert_equal '2068675309', mms.number
@@ -146,34 +149,13 @@ class TestPmSprintCom < Test::Unit::TestCase
146
149
  body = mock('body')
147
150
  connection = mock('connection')
148
151
  response.expects(:content_type).times(4).returns('image/jpeg')
152
+ response.expects(:body).twice.returns(body)
149
153
  response.expects(:code).never
150
154
  Net::HTTP.expects(:new).with('pictures.sprintpcs.com', 80).twice.returns connection
151
- connection.expects(:get).with(
155
+ connection.expects(:get2).with(
152
156
  kind_of(String),
153
157
  { "User-Agent" => MMS2R::Media::USER_AGENT }
154
- ).twice.returns([response, body])
155
-
156
- # response1 = mock('response1')
157
- # body1 = mock('body1')
158
- # connection1 = mock('connection1')
159
- # response1.expects(:content_type).at_least_once.returns('image/jpeg')
160
- # response1.expects(:code).never
161
- # Net::HTTP.expects(:new).with('pictures.sprintpcs.com', 80).once.returns connection1
162
- # connection1.expects(:get).with(
163
- # kind_of(String),
164
- # { "User-Agent" => MMS2R::Media::USER_AGENT }
165
- # ).once.returns([response1, body1])
166
-
167
- # response2 = mock('response2')
168
- # body2 = mock('body2')
169
- # connection2 = mock('connection2')
170
- # response2.expects(:content_type).at_least_once.returns('image/jpeg')
171
- # response2.expects(:code).never
172
- # Net::HTTP.expects(:new).with('pictures.sprintpcs.com', 80).once.returns connection2
173
- # connection2.expects(:get).with(
174
- # kind_of(String),
175
- # { "User-Agent" => MMS2R::Media::USER_AGENT }
176
- # ).once.returns([response2, body2])
158
+ ).twice.returns(response)
177
159
 
178
160
  mms = MMS2R::Media.new(mail)
179
161
  assert_equal '2068675309', mms.number
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mms2r
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.6.0
5
+ version: 3.6.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mike Mondragon
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-19 00:00:00 Z
13
+ date: 2012-02-12 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -308,7 +308,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
308
308
  requirements:
309
309
  - - ">="
310
310
  - !ruby/object:Gem::Version
311
- hash: -1579114988942475097
311
+ hash: -2400410557387373563
312
312
  segments:
313
313
  - 0
314
314
  version: "0"