Changeset 754

Show
Ignore:
Timestamp:
05/16/06 15:11:58
Author:
miyagawa
Message:
  • Don't add new MIME types repeatedly. Instead cache MIME::Types object. Fixes #240
  • Recommend 1.16 which doesn't warn about duplicated registration.
  • Added first ever regressions test suite. h00t!
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/Makefile.PL

    r727 r754  
    2323requires('HTML::ResolveLink'); 
    2424requires('Date::Parse'); 
    25 requires('MIME::Types'); 
     25requires('MIME::Types', 1.16); 
    2626 
    2727build_requires(Test::More => 0.42); 
  • trunk/plagger/lib/Plagger/Util.pm

    r749 r754  
    2323    } 
    2424} 
     25 
     26 
    2527 
    2628sub strip_html { 
     
    131133} 
    132134 
     135our $mimetypes = MIME::Types->new; 
     136$mimetypes->addType( MIME::Type->new(type => 'video/flv', extensions => [ 'flv' ]) ); 
     137$mimetypes->addType( MIME::Type->new(type => 'audio/aac', extensions => [ 'm4a', '.aac' ]) ); 
     138 
    133139sub mime_type_of { 
    134140    my $ext = shift; 
     
    138144    } 
    139145 
    140     my $mimetypes = MIME::Types->new; 
    141     $mimetypes->addType( MIME::Type->new(type => 'video/flv', extensions => [ 'flv' ]) ); 
    142     $mimetypes->addType( MIME::Type->new(type => 'audio/aac', extensions => [ 'm4a', '.aac' ]) ); 
    143  
    144146    return $mimetypes->mimeTypeOf($ext); 
    145147}