lib/AudioFile/Info/Build.pm

filter: Statementstmt 34.2% 13 / 38 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 27.6% 18 / 65 CC 13 SCAR 49.4
CC
13
Cov
23%
ACTION_install
182.0
BEGIN
1.0
BEGIN
1.0
CRAP 139.4
↑ Summary blib/lib/AudioFile/Info/Ogg/Vorbis/Header/PurePerl.pm »
1 package AudioFile::Info::Build;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base 'Module::Build';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶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=13 SCAR=52.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 ($score);
36 0 my @types = qw[ogg mp3];
37 0 my @modes = qw[read write];
38  
39 0 for my $type (@types) {
40 0 for my $mode (@modes) {
41 0 ▶ $score->{$type} += 50 if $config->{$pkg}{"${mode}_${type}"};
Branch: 1 branch
BranchTrueFalseTotal
if $config->{$pkg}{"${mode}_$type"} 0 0 0
42 }
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 for (@types) {
48 0 ▶ $score->{$_} += 10 if $score->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $score->{$_} 0 0 0
49 }
50 }
51  
52 # if no default set and this plugin has a score, or if this plugin
53 # score higher than the existing default, then set default
54 0 for (@types) {
55 0 ▶ if ($score->{$_} and (not exists $config->{default}{$_}
Branch: 1 branch
BranchTrueFalseTotal
if ($score->{$_} and !exists $config->{"default"}{$_} || $score->{$_} >= $config->{"default"}{$_}{"score"}) 0 0 0
Condition0%0/6
$score->{$_} and !exists $config->{"default"}{$_} || $score->{$_} >= $config->{"default"}{$_}{"score"}
!ll&&!rl&&r
000
not exists $config->{"default"}{$_} or $score->{$_} >= $config->{"default"}{$_}{"score"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$score->{$_} and !exists $config->{"default"}{$_} || $score->{$_} >= $config->{"default"}{$_}{"score"}
$score->{$_} not exists $config->{"default"}{$_} $score->{$_} >= $config->{"default"}{$_}{"score"}
Truth table0%0/4
A and not(B) or C
A= $score->{$_}B= not exists $config->{"default"}{$_}C= $score->{$_} >= $config->{"default"}{$_}{"score"}
ABCresult
0XX0
1000
11X1
1011
56 or $score->{$_} >= $config->{default}{$_}{score})) {
57 0 $config->{default}{$_} = { name => $pkg, score => $score->{$_} };
58 0 warn "AudioFile::Info - Default $_ handler is now $pkg\n";
59 }
60 }
61  
62 0 DumpFile($path, $config);
63 }
64  
65 2 1;
66  
67 =head1 NAME
68  
69 AudioFile::Info::Build - Build utilities for AudioFile::Info.
70  
71 =head1 DESCRIPTION
72  
73 This is a module which is used as part of the build system for
74 AudioFile::Info plugins.
75  
76 See L<AudioFile::Info> for more details.
77  
78 =head1 METHODS
79  
80 =head2 ACTION_install
81  
82 Overrides the ACTION_install method from Module::Build.
83  
84 =head1 AUTHOR
85  
86 Dave Cross, E<lt>dave@perlhacks.comE<gt>
87  
88 =head1 COPYRIGHT AND LICENSE
89  
90 Copyright 2003 by Dave Cross
91  
92 This library is free software; you can redistribute it and/or modify
93 it under the same terms as Perl itself.
94  
95 =cut
96  
↑ Summary blib/lib/AudioFile/Info/Ogg/Vorbis/Header/PurePerl.pm »