AudioFile-Info-MP3-ID3Lib
view release on metacpan or search on metacpan
lib/AudioFile/Info/Build.pm view on Meta::CPAN
package AudioFile::Info::Build;
use strict;
use warnings;
use base 'Module::Build';
use YAML qw(LoadFile DumpFile);
sub ACTION_install {
my $self = shift;
$self->SUPER::ACTION_install(@_);
require AudioFile::Info;
die "Can't find the installation of AudioFile::Info\n" if $@;
my $pkg = $self->notes('package');
my $path = $INC{'AudioFile/Info.pm'};
$path =~ s/Info.pm$/plugins.yaml/;
my $config;
if (-f $path) {
$config = LoadFile($path);
}
$config->{$pkg} = $self->notes('config');
# calculate "usefulness" score
my ($mp3, $ogg);
for (qw(read write)) {
$mp3 += 50 if $config->{$pkg}{"${_}_mp3"};
}
for (qw(read write)) {
$ogg +=50 if $config->{$pkg}{"${_}_ogg"};
}
# prefer non-perl implementations
unless ($config->{$pkg}{pure_perl}) {
$mp3 += 10 if $mp3;
$ogg += 10 if $ogg;
}
# if no default set and this plugin has a score, or if this plugin
# score higher than the existing default, then set default
set_default_handler($config, 'mp3', $mp3, $pkg);
set_default_handler($config, 'ogg', $ogg, $pkg);
DumpFile($path, $config);
}
sub set_default_handler {
my ($config, $type, $val, $pkg) = @_;
if ($val and (not exists $config->{default}{$type}
or $val >= $config->{default}{$type}{score})) {
$config->{default}{$type} = { name => $pkg, score => $val };
warn "AudioFile::Info - Default $type handler is now $pkg\n";
}
return;
}
1;
=head1 NAME
( run in 0.783 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )