| 1 | package Acme::MetaSyntactic::List; | ||||||||||||||||||||||||||||
| 2 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 23 | ▶ | use Acme::MetaSyntactic (); # do not export metaname and friends | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 23 | ▶ | use Acme::MetaSyntactic::RemoteList; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 23 | ▶ | use List::Util qw( shuffle ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 23 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 23 | our @ISA = qw( Acme::MetaSyntactic::RemoteList ); | |||||||||||||||||||||||||||
| 9 | 23 | our $VERSION = '1.001'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub init { | ||||||||||||||||||||||||||||
| 12 | 23 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 23 | my $class = caller(0); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 23 | ▶ | $data ||= Acme::MetaSyntactic->load_data($class); | ||||||||||||||||||||||||||
|
Condition66%2/3
$data ||= "Acme::MetaSyntactic"->load_data($class)
MC/DC0%0/2
$data ||= "Acme::MetaSyntactic"->load_data($class)
$data
"Acme::MetaSyntactic"->load_data($class)
Truth table66%2/3
A ||= B
A= $dataB= "Acme::MetaSyntactic"->load_data($class)
| |||||||||||||||||||||||||||||
| 16 | 23 | ▶ | croak "The optional argument to init() must be a hash reference" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | if ref $data ne 'HASH'; | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 23 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 23 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 23 | ${"$class\::Theme"} = ( split /::/, $class )[-1]; | |||||||||||||||||||||||||||
| 22 | 23 | @{"$class\::List"} = do { my %seen; | |||||||||||||||||||||||||||
| 23 | 23 | grep !$seen{$_}++, split /\s+/, $data->{names} }; | |||||||||||||||||||||||||||
| 24 | 23 | *{"$class\::import"} = sub { | |||||||||||||||||||||||||||
| 25 | 13 | ▶ | my $callpkg = caller(0); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 13 | my $theme = ${"$class\::Theme"}; | |||||||||||||||||||||||||||
| 27 | 13 | my $meta = $class->new(); | |||||||||||||||||||||||||||
| 28 | 13 | ▶ | *{"$callpkg\::meta$theme"} = sub { $meta->name(@_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 23 | }; | |||||||||||||||||||||||||||
| 30 | 23 | ${"$class\::meta"} = $class->new(); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub name { | ||||||||||||||||||||||||||||
| 34 | 37 | ▶ | my ( $self, $count ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 37 | my $class = ref $self; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 37 | ▶ | if( ! $class ) { # called as a class method! | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | $class = $self; | |||||||||||||||||||||||||||
| 39 | 23 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | 0 | $self = ${"$class\::meta"}; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 37 | ▶ | if( defined $count && $count == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $count and $count == 0
MC/DC100%2/2
defined $count and $count == 0
defined $count
$count == 0
Truth table100%3/3
A and B
A= defined $countB= $count == 0
| |||||||||||||||||||||||||||||
| 44 | 23 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | return | ||||||||||||||||||||||||||||
| 46 | 11 | ▶ | wantarray ? shuffle @{"$class\::List"} : scalar @{"$class\::List"}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 26 | ▶ | $count ||= 1; | ||||||||||||||||||||||||||
|
Condition100%2/2
$count ||= 1
MC/DC100%1/1
$count ||= 1
$count
Truth table100%2/2
A
A= $count
| |||||||||||||||||||||||||||||
| 50 | 26 | my $list = $self->{cache}; | |||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||
| 52 | 23 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 26 | ▶ | if (@{"$class\::List"}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 24 | ▶ | push @$list, shuffle @{"$class\::List"} while @$list < $count; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 26 | splice( @$list, 0, $count ); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | sub new { | ||||||||||||||||||||||||||||
| 61 | 65 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 65 | bless { cache => [] }, $class; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | sub theme { | ||||||||||||||||||||||||||||
| 67 | 2 | ▶ | my $class = ref $_[0] || $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
theme: called CC=2 SCAR=7.0
Pod
documented
Condition66%2/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table66%2/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||
| 68 | 23 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 69 | 2 | return ${"$class\::Theme"}; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 23 | 1; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||