lib/Astroboy/Base.pm

filter: Statementstmt 60.7% 31 / 51 Branchbran 25.0% 3 / 12 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 72.7% 8 / 11 Podpod 0.0% 0 / 4 totaltotal 52.3% 44 / 84 CC 10 SCAR 22.9
CC
10
Cov
54%
artist_guess
30.0
debug
6.0
artists
6.0
CRAP 9.9
« lib/Astroboy.pm ↑ Summary blib/script/m4amp3.pl »
1 package Astroboy::Base;
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use vars qw(@ISA $VERSION @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 @ISA = qw/Exporter/;
6 7 @EXPORT = qw(debug abs_music artists artists_count artist_guess);
7 7 ▶use LEOCHARRE::Dir;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use LEOCHARRE::Class2;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 __PACKAGE__->make_count_for('artists');
13 7 ▶$Astroboy::ABS_MUSIC ||= $ENV{HOME}.'/music';
Condition50%1/2
$Astroboy::ABS_MUSIC ||= $ENV{"HOME"} . '/music'
l!l
07
MC/DC0%0/1
$Astroboy::ABS_MUSIC ||= $ENV{"HOME"} . '/music'
$Astroboy::ABS_MUSIC
Truth table50%1/2
A
A= $Astroboy::ABS_MUSIC
Aresult
11
00
14  
15 7 $VERSION = sprintf "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)/g;
16  
17 0 ▶sub debug { $Astroboy::DEBUG and print STDERR "@_"; 1 }
Subroutine debug: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$Astroboy::DEBUG and print STDERR join($", @_) 0 0 0
18  
19 4 ▶sub abs_music {
Subroutine abs_music: called CC=4 SCAR=14.2
Pod undocumented
20
21 4 ▶ if( $_[1] ){
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1]) 1 3 4
22 1 ▶ -d $_[1]
Branch: 1 branch
BranchTrueFalseTotal
-d $_[1] or warn "Not dir on disk: $_[1]" 1 0 1
23 or warn("Not dir on disk: $_[1]");
24 1 $Astroboy::ABS_MUSIC = $_[1];
25 }
26 4 ▶ $Astroboy::ABS_MUSIC ||= $ENV{HOME}.'/music';
Condition50%1/2
$Astroboy::ABS_MUSIC ||= $ENV{"HOME"} . '/music'
l!l
40
MC/DC0%0/1
$Astroboy::ABS_MUSIC ||= $ENV{"HOME"} . '/music'
$Astroboy::ABS_MUSIC
Truth table50%1/2
A
A= $Astroboy::ABS_MUSIC
Aresult
11
00
27 }
28  
29
30 0 ▶sub artists {
Subroutine artists: not called CC=2 SCAR=17.9
Pod undocumented
31 0 my $self = shift;
32  
33 0 ▶ unless( $self->{artists} ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"artists"}) 0 0 0
34
35 0 my @a = sort ( LEOCHARRE::Dir::lsd( abs_music() ) );
36 0 $self->{artists} = [@a];
37 }
38 0 $self->{artists};
39 }
40  
41  
42  
43  
44 0 ▶sub artist_guess {
Subroutine artist_guess: not called CC=5 SCAR=34.0
Pod undocumented
45 0 my ($self,$path) = ($_[0],lc($_[1]));
46  
47 #TODO consider using String::Similarity::Group
48  
49 0 ▶ unless($self->{artists_match}){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"artists_match"}) 0 0 0
50 0 my $artists = $self->artists;
51 0 for (@$artists){
52 0 my $a = lc ($_);
53 0 $a=~s/_+/ /g;
54 0 $a=~s/^\s+|\s+$//g;
55 0 $self->{artists_match}->{$a}++;
56 }
57 }
58  
59  
60 # just return first match
61 0 for my $artist ( keys %{$self->{artists_match}} ){
62
63 0 ▶ $path=~/\b$artist\b/ or next;
Branch: 1 branch
BranchTrueFalseTotal
$path =~ /\b$artist\b/ or next 0 0 0
64 0 return $artist;
65 }
66
67 0 return;
68 }
69  
70  
71 7 1;
72  
73 __END__
« lib/Astroboy.pm ↑ Summary blib/script/m4amp3.pl »