StorageClient/MIMEType.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 59 CC 7 SCAR 35.9
CC
7
Cov
0%
get_mimetype
56.0
new
2.0
init
2.0
CRAP 36.4
1 package Net::Azure::StorageClient::MIMEType;
2 use strict;
3 use warnings;
4 {
5 $Net::Azure::StorageClient::MIMEType = '0.1';
6 }
7  
8 sub new {
9 my $class = shift;
10 my $obj = bless {}, $class;
11 $obj->init( @_ );
12 }
13  
14 sub init {
15 my $obj = shift;
16 my %args = @_;
17 $obj->{ default } = $args{ default } || 'application/octet-stream';
18 return $obj;
19 }
20  
21 sub get_mimetype {
22 my $self = shift;
23 my $filename = shift;
24 my $default = shift;
25 if ( ( ref $self ) ne 'Azure::StorageClient::MIMEType' ) {
26 $default = $filename;
27 $filename = $self;
28 }
29 my $mime_types = {
30 'css' => 'text/css',
31 'html' => 'text/html',
32 'mtml' => 'text/html',
33 'xhtml' => 'application/xhtml+xml',
34 'htm' => 'text/html',
35 'txt' => 'text/plain',
36 'rtx' => 'text/richtext',
37 'tsv' => 'text/tab-separated-values',
38 'csv' => 'text/csv',
39 'hdml' => 'text/x-hdml; charset=Shift_JIS',
40 'xml' => 'application/xml',
41 'rdf' => 'application/rss+xml',
42 'xsl' => 'text/xsl',
43 'mpeg' => 'video/mpeg',
44 'mpg' => 'video/mpeg',
45 'mpe' => 'video/mpeg',
46 'qt' => 'video/quicktime',
47 'avi' => 'video/x-msvideo',
48 'movie' => 'video/x-sgi-movie',
49 'ice' => 'x-conference/x-cooltalk',
50 'svr' => 'x-world/x-svr',
51 'vrml' => 'x-world/x-vrml',
52 'wrl' => 'x-world/x-vrml',
53 'vrt' => 'x-world/x-vrt',
54 'spl' => 'application/futuresplash',
55 'hqx' => 'application/mac-binhex40',
56 'doc' => 'application/msword',
57 'pdf' => 'application/pdf',
58 'ai' => 'application/postscript',
59 'eps' => 'application/postscript',
60 'ps' => 'application/postscript',
61 'ppt' => 'application/vnd.ms-powerpoint',
62 'rtf' => 'application/rtf',
63 'dcr' => 'application/x-director',
64 'dir' => 'application/x-director',
65 'dxr' => 'application/x-director',
66 'js' => 'application/javascript',
67 'dvi' => 'application/x-dvi',
68 'gtar' => 'application/x-gtar',
69 'gzip' => 'application/x-gzip',
70 'latex' => 'application/x-latex',
71 'lzh' => 'application/x-lha',
72 'swf' => 'application/x-shockwave-flash',
73 'sit' => 'application/x-stuffit',
74 'tar' => 'application/x-tar',
75 'tcl' => 'application/x-tcl',
76 'tex' => 'application/x-texinfo',
77 'texinfo'=> 'application/x-texinfo',
78 'texi' => 'application/x-texi',
79 'src' => 'application/x-wais-source',
80 'zip' => 'application/zip',
81 'au' => 'audio/basic',
82 'snd' => 'audio/basic',
83 'midi' => 'audio/midi',
84 'mid' => 'audio/midi',
85 'kar' => 'audio/midi',
86 'mpga' => 'audio/mpeg',
87 'mp2' => 'audio/mpeg',
88 'mp3' => 'audio/mpeg',
89 'ra' => 'audio/x-pn-realaudio',
90 'ram' => 'audio/x-pn-realaudio',
91 'rm' => 'audio/x-pn-realaudio',
92 'rpm' => 'x-pn-realaudio-plugin',
93 'wav' => 'audio/x-wav',
94 'bmp' => 'image/bmp',
95 'gif' => 'image/gif',
96 'jpeg' => 'image/jpeg',
97 'jpg' => 'image/jpeg',
98 'jpe' => 'image/jpeg',
99 'png' => 'image/png',
100 'tiff' => 'image/tiff',
101 'tif' => 'image/tiff',
102 'pnm' => 'image/x-portable-anymap',
103 'ras' => 'image/x-cmu-raster',
104 'pnm' => 'image/x-portable-anymap',
105 'pbm' => 'image/x-portable-bitmap',
106 'pgm' => 'image/x-portable-graymap',
107 'ppm' => 'image/x-portable-pixmap',
108 'rgb' => 'image/x-rgb',
109 'xbm' => 'image/x-xbitmap',
110 'xls' => 'application/vnd.ms-excel',
111 'xpm' => 'image/x-pixmap',
112 'xwd' => 'image/x-xwindowdump',
113 'ico' => 'image/vnd.microsoft.icon',
114 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
115 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
116 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
117 'json' => 'application/json',
118 };
119 if ( $filename =~ /\.([^.]+)\z/ ) {
120 my $extension = lc( $1 );
121 if ( $extension && $mime_types->{ $extension } ) {
122 return $mime_types->{ $extension };
123 }
124 }
125 if (! $default ) {
126 if ( ( ref $self ) eq 'Azure::StorageClient::MIMEType' ) {
127 $default = $self->{ default };
128 }
129 }
130 $default = 'application/octet-stream' unless $default;
131 return $default;
132 }
133  
134 1;