| 1 | 5 | ▶ | use 5.008008; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | package Ask; | ||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 5 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||
| 8 | 5 | our $VERSION = '0.015'; | |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Moo::Role qw(); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Module::Runtime qw(use_module use_package_optimistically); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use Module::Pluggable ( | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | 5 | search_path => 'Ask', | |||||||||||||||||||||||||||||||||
| 15 | except => [qw/ Ask::API Ask::Functions Ask::Question /], | ||||||||||||||||||||||||||||||||||
| 16 | inner => 0, | ||||||||||||||||||||||||||||||||||
| 17 | require => 0, | ||||||||||||||||||||||||||||||||||
| 18 | sub_name => '__plugins', | ||||||||||||||||||||||||||||||||||
| 19 | 5 | ); | |||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | sub import { | ||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=10.1
| |||||||||||||||||||||||||||||||||||
| 23 | 5 | shift; | |||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 25 | 0 | require Ask::Functions; | |||||||||||||||||||||||||||||||||
| 26 | 0 | unshift @_, 'Ask::Functions'; | |||||||||||||||||||||||||||||||||
| 27 | 0 | goto( $_[0]->can( 'import' ) ); | |||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | sub plugins { | ||||||||||||||||||||||||||||||||
|
Subroutine
plugins: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 32 | 3 | __plugins( @_ ); | |||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | sub backends { | ||||||||||||||||||||||||||||||||
|
Subroutine
backends: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 36 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 37 | 30 | sort { $b->quality <=> $a->quality } | |||||||||||||||||||||||||||||||||
| 38 | grep { | ||||||||||||||||||||||||||||||||||
| 39 | 3 | eval { use_package_optimistically( $_ )->DOES( 'Ask::API' ) } | |||||||||||||||||||||||||||||||||
| 40 | } $class->plugins; | ||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | sub detect { | ||||||||||||||||||||||||||||||||
|
Subroutine
detect: called CC=12 SCAR=31.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 44 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my %args = @_ == 1 ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | 3 | my @implementations = $class->backends; | |||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | if ( exists $ENV{PERL_ASK_BACKEND} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 50 | 3 | @implementations = use_module( $ENV{PERL_ASK_BACKEND} ); | |||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||
| 52 | ▶ | elsif ( $ENV{AUTOMATED_TESTING} | |||||||||||||||||||||||||||||||||
|
Condition0%0/6
$ENV{"AUTOMATED_TESTING"} or $ENV{"PERL_MM_USE_DEFAULT"} or not @implementations
$ENV{"AUTOMATED_TESTING"} or $ENV{"PERL_MM_USE_DEFAULT"}
MC/DC0%0/3
$ENV{"AUTOMATED_TESTING"} or $ENV{"PERL_MM_USE_DEFAULT"} or not @implementations
$ENV{"AUTOMATED_TESTING"}
$ENV{"PERL_MM_USE_DEFAULT"}
not @implementations
Truth table0%0/4
A or B or not(C)
A= $ENV{"AUTOMATED_TESTING"}B= $ENV{"PERL_MM_USE_DEFAULT"}C= not @implementations
| |||||||||||||||||||||||||||||||||||
| 53 | or $ENV{PERL_MM_USE_DEFAULT} | ||||||||||||||||||||||||||||||||||
| 54 | or not @implementations ) | ||||||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||||||
| 56 | 0 | @implementations = use_module( 'Ask::Fallback' ); | |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | 3 | ▶ | my @traits = @{ delete( $args{traits} ) || [] }; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{'traits'} || []
MC/DC100%1/1
delete $args{'traits'} || []
delete $args{'traits'}
Truth table100%2/2
A
A= delete $args{'traits'}
| |||||||||||||||||||||||||||||||||||
| 60 | 3 | for my $i ( @implementations ) { | |||||||||||||||||||||||||||||||||
| 61 | 3 | ▶ | my $k = @traits ? "Moo::Role"->create_class_with_roles( $i, @traits ) : $i; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 62 | 3 | ▶ | my $self = eval { $k->new( { %args, %{ $args{$i} or {} } } ) } or next; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$args{$i} || {}
MC/DC0%0/1
$args{$i} || {}
$args{$i}
Truth table50%1/2
A
A= $args{$i}
| |||||||||||||||||||||||||||||||||||
| 63 | 3 | ▶ | return $self if $self->is_usable; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | 0 | croak "No usable backend for Ask"; | |||||||||||||||||||||||||||||||||
| 67 | } #/ sub detect | ||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 1 | ▶ | sub Q { | ||||||||||||||||||||||||||||||||
|
Subroutine
Q: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 70 | 1 | require Ask::Question; | |||||||||||||||||||||||||||||||||
| 71 | 1 | 'Ask::Question'->new( @_ ); | |||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | 5 | my $instance; | |||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub instance { | ||||||||||||||||||||||||||||||||
|
Subroutine
instance: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 76 | 0 | shift; | |||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | @_ ? ( $instance = $_[0] ) : ( $instance ||= __PACKAGE__->detect ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$instance ||= __PACKAGE__->detect
MC/DC0%0/2
$instance ||= __PACKAGE__->detect
$instance
__PACKAGE__->detect
Truth table0%0/3
A ||= B
A= $instanceB= __PACKAGE__->detect
| |||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 5 | 1; | |||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||||||||