DeclareX.pm

filter: Statementstmt 100% 67 / 67 Branchbran 83.3% 5 / 6 Conditioncond 72.7% 8 / 11 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 100% 15 / 15 Podpod n/a totaltotal 93.2% 97 / 104 CC 13 SCAR 14.9
CC
13
Cov
95%
_keywords
9.0
import
5.0
BEGIN
1.0
CRAP 4.4
« DeclareX/Plugin/imports.pm ↑ Summary DeclareX/Registry.pm »
1 package MooseX::DeclareX;
2  
3 8 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 $MooseX::DeclareX::AUTHORITY = 'cpan:TOBYINK';
10 8 $MooseX::DeclareX::VERSION = '0.009';
11 }
12  
13 8 ▶use constant DEFAULT_KEYWORDS => [qw(class role exception)];
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 ▶use constant DEFAULT_PLUGINS => [qw(build guard std_constants)];
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 8 ▶use Class::Load 0 qw(load_class);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 8 ▶use Data::OptList 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 8 ▶use MooseX::Declare 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 8 ▶use TryCatch 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 sub import
22 23 ▶{
Subroutine import: called CC=5 SCAR=16.1
23 23 my ($class, %args) = @_;
24 23 my $caller = caller(0);
25  
26 # Simplified interface for a couple of standard plugins
27 23 foreach my $awesome (qw/ types imports /)
28 {
29 46 ▶ if (my $ness = delete $args{$awesome})
Branch: 1 branch
BranchTrueFalseTotal
if (my $ness = delete $args{$awesome}) 1 45 46
30 {
31 1 ▶ $args{plugins} ||= DEFAULT_PLUGINS;
Condition50%1/2
$args{"plugins"} ||= ["build","guard","std_constants"]
l!l
01
MC/DC0%0/1
$args{"plugins"} ||= ["build","guard","std_constants"]
$args{"plugins"}
Truth table50%1/2
A
A= $args{"plugins"}
Aresult
11
00
32 1 push @{ $args{plugins} }, $awesome, $ness;
33 }
34 }
35  
36 23 $_->setup_for($caller, %args, provided_by => $class) for __PACKAGE__->_keywords(\%args);
37
38 23 strict->import;
39 23 warnings->import;
40 23 TryCatch->import({ into => $caller });
41 }
42  
43 sub _keywords
44 23 ▶{
Subroutine _keywords: called CC=9 SCAR=22.0
45 23 my ($class, $args) = @_;
46 23 my @return;
47
48 23 ▶ my $kinds = Data::OptList::mkopt( $args->{keywords} || DEFAULT_KEYWORDS );
Condition100%2/2
$args->{'keywords'} || ['class', 'role', 'exception']
l!l
221
MC/DC100%1/1
$args->{'keywords'} || ['class', 'role', 'exception']
$args->{'keywords'}
Truth table100%2/2
A
A= $args->{'keywords'}
Aresult
11
00
49 23 foreach my $pair (@$kinds)
50 {
51 68 my ($class, $opts) = @$pair;
52 68 ▶ $opts //= {};
Condition50%1/2
$opts //= {}
l!l
068
MC/DC0%0/1
$opts //= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
53
54 68 load_class(
55 my $module = join '::' => qw[MooseX DeclareX Keyword], $class
56 );
57
58 68 ▶ my $kw = $module->new( $opts->{init} ? $opts->{init} : (identifier => $class) );
Branch: 1 branch
BranchTrueFalseTotal
$opts->{'init'} ? : 0 68 68
59 68 push @return, $kw;
60
61 my $plugins = Data::OptList::mkopt(
62 68 ▶ $opts->{plugins} || $args->{plugins} || DEFAULT_PLUGINS,
Condition80%4/5
$opts->{'plugins'} || $args->{'plugins'} || ['build', 'guard', 'std_constants']
l!l
2048
$opts->{"plugins"} or $args->{"plugins"}
l!l&&r!l&&!r
02048
MC/DC50%1/2
$opts->{'plugins'} || $args->{'plugins'} || ['build', 'guard', 'std_constants']
$opts->{"plugins"} $args->{"plugins"}
Truth table66%2/3
A or B
A= $opts->{"plugins"}B= $args->{"plugins"}
ABresult
1X1
011
000
63 );
64
65 68 foreach my $pair2 (@$plugins)
66 {
67 8 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 194 my ($class2, $opts2) = @$pair2;
69 194 ▶ next if $class2 =~ qr(
Branch: 1 branch
BranchTrueFalseTotal
if $class2 =~ qr/ method | before | after | around | override | augment | with | is | clean | dirty | mutable | try | catch /x 4 190 194
70 method | before | after | around | override | augment
71 | with | is | clean | dirty | mutable | try | catch
72 )x;
73 8 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
74
75 190 my $module2 = join '::' => (qw[MooseX DeclareX Plugin], $class2);
76 190 $module2 =~ s/Plugin::concrete$/Plugin::abstract/;
77 190 load_class $module2;
78
79 190 $module2->plugin_setup($kw, $opts2);
80 }
81 }
82
83 23 return @return;
84 }
85  
86 8 "Would you like some tea with that sugar?"
87  
88 __END__
« DeclareX/Plugin/imports.pm ↑ Summary DeclareX/Registry.pm »