blib/lib/Music/Beets/Info.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 58 CC 3 SCAR 15.0
CC
3
Cov
0%
beet_info
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.5
1 package Music::Beets::Info;
2 use strict;
3 use utf8;
4 use open qw(:std :utf8);
5  
6 BEGIN {
7 use Exporter;
8 use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
9 @ISA = qw(Exporter);
10  
11 $VERSION = '0.006';
12  
13 @EXPORT_OK = qw(beet_info);
14 %EXPORT_TAGS = [ qw() ];
15 }
16  
17 use Carp qw(croak);
18 use Encode;
19  
20 use IPC::Cmd qw(run);
21  
22 sub beet_info {
23 my $file = shift;
24 croak("Not a file: '$file'") unless -f $file;
25  
26 my $buffer;
27 my %info;
28  
29 my $quoted = quotemeta($file);
30  
31 if(scalar run(
32 command => "beet info $quoted",
33 verbose => $ENV{DEBUG} || 0,
34 buffer => \$buffer,
35 timeout => 20,
36 )) {
37 %info = map { decode_utf8($_) } ($buffer =~ /\s*(\S+):\s(.+)/g);
38 }
39 return \%info;
40 }
41  
42 1;
43  
44 __END__