mms2r 1.0.3 → 1.0.4
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 +8 -0
- data/lib/mms2r/media.rb +7 -2
- data/lib/mms2r/sprint_media.rb +14 -12
- data/lib/mms2r/version.rb +1 -1
- data/test/test_mms2r_sprint.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 1.0.4 / 2007-04-09 (Metalocalypse)
|
2
|
+
|
3
|
+
* fix teardown in test_mms2r_sprint.rb (shanesbrain.net)
|
4
|
+
* clean up Net::HTTP in MMS2R::SprintMedia (shanesbrain.net)
|
5
|
+
* added accessor MMS2R::Media.media_dir
|
6
|
+
* fixed a nil issue with underlying tmp working dir
|
7
|
+
* added exception handling around Net::HTTP in MMS2R::SprintMedia
|
8
|
+
|
1
9
|
== 1.0.3 / 2007-04-05 (Paper Cut)
|
2
10
|
|
3
11
|
* Cleaned up packaging and errors in example found by Shane V. http://shanesbrain.net/
|
data/lib/mms2r/media.rb
CHANGED
@@ -68,7 +68,6 @@ module MMS2R
|
|
68
68
|
}
|
69
69
|
|
70
70
|
class MMS2R::Media
|
71
|
-
|
72
71
|
##
|
73
72
|
# TMail object that the media files were derived from.
|
74
73
|
attr_reader :mail
|
@@ -86,6 +85,12 @@ module MMS2R
|
|
86
85
|
|
87
86
|
attr_reader :carrier
|
88
87
|
|
88
|
+
##
|
89
|
+
# Base working dir where media for a unique mms message are
|
90
|
+
# dropped
|
91
|
+
|
92
|
+
attr_reader :media_dir
|
93
|
+
|
89
94
|
##
|
90
95
|
# Creates a new Media comprised of a mail
|
91
96
|
# a logger. Logger is an instance attribute allowing
|
@@ -289,7 +294,7 @@ module MMS2R
|
|
289
294
|
"#{Time.now.to_i}.#{self.class.default_ext(self.class.part_type?(part))}"
|
290
295
|
end
|
291
296
|
|
292
|
-
@@tmp_dir = File.join(Dir.tmpdir, ENV['USER'],'mms2r')
|
297
|
+
@@tmp_dir = File.join(Dir.tmpdir, (ENV['USER'].nil? ? '':ENV['USER']), 'mms2r')
|
293
298
|
|
294
299
|
##
|
295
300
|
# Get the temporary directory where media files are written to.
|
data/lib/mms2r/sprint_media.rb
CHANGED
@@ -19,7 +19,6 @@ module MMS2R
|
|
19
19
|
# the URL to the media on Sprint's content server.
|
20
20
|
|
21
21
|
def process_media(part)
|
22
|
-
part.base64_decode
|
23
22
|
if self.class.part_type?(part).eql?('text/plain')
|
24
23
|
file_name = filename?(part)
|
25
24
|
type, content = transform_text(part)
|
@@ -30,19 +29,22 @@ module MMS2R
|
|
30
29
|
img = imgs[2].attributes['src']
|
31
30
|
#here's where the content is, now download it
|
32
31
|
url = URI.parse(img)
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
begin
|
33
|
+
res = Net::HTTP.get_response(url)
|
34
|
+
file_name ="#{img.match(/\/RECIPIENT\/([^\/]+)\//)[1]}.#{self.class.default_ext(res.content_type)}"
|
35
|
+
type = res.content_type
|
36
|
+
content = res.body
|
37
|
+
rescue
|
38
|
+
@logger.error("#{self.class} processing error, #{$!}") unless @logger.nil?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
unless type.nil?
|
42
|
+
file = File.join(msg_tmp_dir(),file_name)
|
43
|
+
@logger.info("#{self.class} writing file #{file}") unless @logger.nil?
|
44
|
+
File.open(file,'w'){ |f|
|
45
|
+
f.write(content)
|
36
46
|
}
|
37
|
-
file_name ="#{img.match(/\/RECIPIENT\/([^\/]+)\//)[1]}.#{self.class.default_ext(res.content_type)}"
|
38
|
-
type = res.content_type
|
39
|
-
content = res.body
|
40
47
|
end
|
41
|
-
file = File.join(msg_tmp_dir(),file_name)
|
42
|
-
@logger.info("#{self.class} writing file #{file}") unless @logger.nil?
|
43
|
-
File.open(file,'w'){ |f|
|
44
|
-
f.write(content)
|
45
|
-
}
|
46
48
|
return type, file
|
47
49
|
end
|
48
50
|
end
|
data/lib/mms2r/version.rb
CHANGED
data/test/test_mms2r_sprint.rb
CHANGED
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
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.4
|
7
|
+
date: 2007-04-10 00:00:00 -07:00
|
8
8
|
summary: Extract media from MMS
|
9
9
|
require_paths:
|
10
10
|
- lib
|