| 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'
MC/DC0%0/1
$Astroboy::ABS_MUSIC ||= $ENV{"HOME"} . '/music'
$Astroboy::ABS_MUSIC
Truth table50%1/2
A
A= $Astroboy::ABS_MUSIC
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 22 | 1 | ▶ | -d $_[1] | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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'
MC/DC0%0/1
$Astroboy::ABS_MUSIC ||= $ENV{"HOME"} . '/music'
$Astroboy::ABS_MUSIC
Truth table50%1/2
A
A= $Astroboy::ABS_MUSIC
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 64 | 0 | return $artist; | |||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | 0 | return; | |||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | |||||||||||||
| 71 | 7 | 1; | |||||||||||
| 72 | |||||||||||||
| 73 | __END__ | ||||||||||||