StorageClient/MIMEType.pm

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