mms2r 1.1.8 → 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 1.1.9 / 2007-09-08 (Rebecca Nightrod - controlling girlfriend of Nathan
2
+ Explosion)
3
+
4
+ * fixed broken support for act_as_attachment and attachment_fu
5
+
1
6
  == 1.1.8 / 2007-09-08 (James Grishnack - Head of Behemoth Productions, producer
2
7
  of Blood Ocean)
3
8
 
@@ -65,7 +65,7 @@ module MMS2R
65
65
  ##
66
66
  # MMS2R Library version
67
67
 
68
- VERSION = '1.1.8'
68
+ VERSION = '1.1.9'
69
69
 
70
70
  end
71
71
 
@@ -403,9 +403,7 @@ module MMS2R
403
403
  # Helper to add a file to the media hash.
404
404
 
405
405
  def add_file(type, file)
406
- if @media[type].nil?
407
- @media[type] = Array.new
408
- end
406
+ @media[type] = [] unless @media[type]
409
407
  @media[type] << file
410
408
  end
411
409
 
@@ -549,8 +547,9 @@ module MMS2R
549
547
  return nil if files.empty?
550
548
 
551
549
  #get the largest file
552
- file = nil # explicitly declare the file and sile
550
+ file = nil # explicitly declare the file and size
553
551
  size = 0
552
+ mime_type = nil
554
553
 
555
554
  files.each do |f|
556
555
  # this will safely evaluate since we wouldn't be looking at
@@ -558,6 +557,11 @@ module MMS2R
558
557
  if File.size(f) > size
559
558
  size = File.size(f)
560
559
  file = File.new(f)
560
+ # media is hash of types to arrays of file names
561
+ # detect on the hash returns an array, the 0th element is
562
+ # the mime type of the file that was found in the files array
563
+ # i.e. {'text/foo' => ['/foo/bar.txt', '/hello/world.txt']}
564
+ mime_type = media.detect{|k,v| v.detect{|fl| fl == f}}[0] rescue nil
561
565
  end
562
566
  end
563
567
 
@@ -374,6 +374,35 @@ class MMS2R::MediaTest < Test::Unit::TestCase
374
374
  mms.purge
375
375
  end
376
376
 
377
+ def test_get_attachment_should_return_duck_typed_file
378
+
379
+ mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
380
+ mms = MMS2R::Media.create(mail)
381
+ mms.process
382
+
383
+ file_size = 43
384
+ base_name = 'spacer.gif'
385
+ mime_type = 'image/gif'
386
+
387
+ test = mms.media[mime_type].first
388
+ assert_not_nil test
389
+ assert_file_size test, file_size
390
+ assert File::exist?(test), "file #{test} does not exist"
391
+ assert_equal base_name, File.basename(test), "file #{test} does not exist as #{base_name}"
392
+
393
+ # get_media calls get_attachment and
394
+ # get_attachment should return a file that has some duck sauce for
395
+ # act_as_attachment and attachment_fu
396
+ file = mms.get_media
397
+ assert_not_nil file, "file #{file} does not exist"
398
+ assert_equal test, file.local_path
399
+ assert_equal base_name, file.original_filename
400
+ assert_equal file_size, file.size
401
+ assert_equal mime_type, file.content_type
402
+
403
+ mms.purge
404
+ end
405
+
377
406
  def test_yaml_file_name
378
407
  assert_equal 'mms2r_my_cingular_media_subject.yml', MMS2R::Media.yaml_file_name(MMS2R::MyCingularMedia,:subject)
379
408
  assert_equal 'mms2r_t_mobile_media_subject.yml', MMS2R::Media.yaml_file_name(MMS2R::TMobileMedia,:subject)
metadata CHANGED
@@ -3,7 +3,7 @@ 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.8
6
+ version: 1.1.9
7
7
  date: 2007-09-08 00:00:00 -07:00
8
8
  summary: Extract user media from MMS (and not carrier cruft)
9
9
  require_paths: