lib/AudioFile/Info/Build.pm

filter: Statementstmt 32.5% 13 / 40 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 66.6% 4 / 6 Podpod 50.0% 1 / 2 totaltotal 24.6% 18 / 73 CC 13 SCAR 41.9
CC
13
Cov
21%
ACTION_install
110.0
set_default_handler
20.0
BEGIN
1.0
CRAP 65.8
↑ Summary blib/lib/AudioFile/Info/MP3/Tag.pm »
1 package AudioFile::Info::Build;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base 'Module::Build';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use YAML qw(LoadFile DumpFile);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub ACTION_install {
Subroutine ACTION_install: not called CC=10 SCAR=47.0
Pod documented
11 0 my $self = shift;
12  
13 0 $self->SUPER::ACTION_install(@_);
14  
15 0 require AudioFile::Info;
16  
17 0 ▶ die "Can't find the installation of AudioFile::Info\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
18  
19 0 my $pkg = $self->notes('package');
20  
21 0 my $path = $INC{'AudioFile/Info.pm'};
22  
23 0 $path =~ s/Info.pm$/plugins.yaml/;
24  
25 0 my $config;
26  
27 0 ▶ if (-f $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $path) 0 0 0
28 0 $config = LoadFile($path);
29 }
30  
31 0 $config->{$pkg} = $self->notes('config');
32  
33 # calculate "usefulness" score
34  
35 0 my ($mp3, $ogg);
36  
37 0 for (qw(read write)) {
38 0 ▶ $mp3 += 50 if $config->{$pkg}{"${_}_mp3"};
Branch: 1 branch
BranchTrueFalseTotal
if $config->{$pkg}{"${_}_mp3"} 0 0 0
39 }
40  
41 0 for (qw(read write)) {
42 0 ▶ $ogg +=50 if $config->{$pkg}{"${_}_ogg"};
Branch: 1 branch
BranchTrueFalseTotal
if $config->{$pkg}{"${_}_ogg"} 0 0 0
43 }
44  
45 # prefer non-perl implementations
46 0 ▶ unless ($config->{$pkg}{pure_perl}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($config->{$pkg}{"pure_perl"}) 0 0 0
47 0 ▶ $mp3 += 10 if $mp3;
Branch: 1 branch
BranchTrueFalseTotal
if $mp3 0 0 0
48 0 ▶ $ogg += 10 if $ogg;
Branch: 1 branch
BranchTrueFalseTotal
if $ogg 0 0 0
49 }
50  
51 # if no default set and this plugin has a score, or if this plugin
52 # score higher than the existing default, then set default
53 0 set_default_handler($config, 'mp3', $mp3, $pkg);
54 0 set_default_handler($config, 'ogg', $ogg, $pkg);
55  
56 0 DumpFile($path, $config);
57 }
58  
59 0 ▶sub set_default_handler {
Subroutine set_default_handler: not called CC=4 SCAR=30.0
Pod undocumented
60 0 my ($config, $type, $val, $pkg) = @_;
61  
62 0 ▶ if ($val and (not exists $config->{default}{$type}
Branch: 1 branch
BranchTrueFalseTotal
if ($val and !exists $config->{"default"}{$type} || $val >= $config->{"default"}{$type}{"score"}) 0 0 0
Condition0%0/6
$val and !exists $config->{"default"}{$type} || $val >= $config->{"default"}{$type}{"score"}
!ll&&!rl&&r
000
not exists $config->{"default"}{$type} or $val >= $config->{"default"}{$type}{"score"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$val and !exists $config->{"default"}{$type} || $val >= $config->{"default"}{$type}{"score"}
$val not exists $config->{"default"}{$type} $val >= $config->{"default"}{$type}{"score"}
Truth table0%0/4
A and not(B) or C
A= $valB= not exists $config->{"default"}{$type}C= $val >= $config->{"default"}{$type}{"score"}
ABCresult
0XX0
1000
11X1
1011
63 or $val >= $config->{default}{$type}{score})) {
64 0 $config->{default}{$type} = { name => $pkg, score => $val };
65 0 warn "AudioFile::Info - Default $type handler is now $pkg\n";
66 }
67  
68 0 return;
69 }
70  
71 1 1;
72  
73 =head1 NAME
74  
75 AudioFile::Info::Build - Build utilities for AudioFile::Info.
76  
77 =head1 DESCRIPTION
78  
79 This is a module which is used as part of the build system for
80 AudioFile::Info plugins.
81  
82 See L<AudioFile::Info> for more details.
83  
84 =head1 METHODS
85  
86 =head2 ACTION_install
87  
88 Overrides the ACTION_install method from Module::Build.
89  
90 =head1 AUTHOR
91  
92 Dave Cross, E<lt>dave@dave.org.ukE<gt>
93  
94 =head1 COPYRIGHT AND LICENSE
95  
96 Copyright 2003 by Dave Cross
97  
98 This library is free software; you can redistribute it and/or modify
99 it under the same terms as Perl itself.
100  
101 =cut
102  
↑ Summary blib/lib/AudioFile/Info/MP3/Tag.pm »