File Coverage

lib/URI/Title/PDF.pm
Criterion Covered Total %
statement 7 27 25.9
branch 0 12 0.0
condition 0 6 0.0
subroutine 3 4 75.0
pod 0 2 0.0
total 10 51 19.6


line stmt bran cond sub pod time code
1             package URI::Title::PDF;
2             $URI::Title::PDF::VERSION = '1.901';
3 2     2   1125 use warnings;
  2         2  
  2         59  
4 2     2   6 use strict;
  2         2  
  2         386  
5              
6             sub types {(
7 2     2 0 4 'application/pdf',
8             )}
9              
10             sub title {
11 0     0 0   my ($class, $url, $data, $type) = @_;
12              
13 0           my %fields = ();
14 0 0         my $content = URI::Title::_get_end($url) or return;
15 0           foreach my $i (qw(Producer Creator CreationDate Author Title Subject)) {
16 0           my @parts = $content =~ m#/$i \((.*?)\)#mgs;
17 0           $fields{$i} = $parts[-1]; # grab the last one, hopefully right
18             }
19              
20 0           my $title = "";
21 0           my @parts = ();
22 0 0         if ($fields{Title}) {
23 0           push @parts, "$fields{Title}";
24 0 0         if ($fields{Author}) { push @parts, "by $fields{Author}"; }
  0            
25 0 0         if ($fields{Subject}) { push @parts, "($fields{Subject})"; }
  0            
26             }
27 0 0 0       if ($fields{Creator} and $fields{Creator} ne 'Not Available') {
28 0           push @parts, "creator: $fields{Creator}";
29             }
30 0 0 0       if ($fields{Producer} and $fields{Producer} ne 'Not Available') {
31 0           push @parts, "produced: $fields{Producer}";
32             }
33 0           $title = join(' ', @parts);
34 0           return $title;
35             }
36              
37             1;
38              
39             __END__