lib/Mite/App/Command.pm.mite.pm

filter: Statementstmt 77.7% 98 / 126 Branchbran 39.5% 19 / 48 Conditioncond 30.0% 12 / 40 MC/DCmcdc 0.0% 0 / 26 Subroutinesub 62.0% 18 / 29 Podpod 0.0% 0 / 8 totaltotal 53.0% 147 / 277 CC 39 SCAR 29.1
CC
39
Cov
60%
DOES
72.0
new
30.7
DESTROY
13.1
CRAP 18.3
« lib/Mite/Trait/HasRoles.pm.mite.pm ↑ Summary blib/lib/Mite/Attribute/SHV/CodeGen.pm »
1 {
2  
3 24 package Mite::App::Command;
4 24 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 24 ▶ no warnings qw( once void );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 24 our $USES_MITE = "Mite::Class";
9 24 our $MITE_SHIM = "Mite::Shim";
10 24 our $MITE_VERSION = "0.013000";
11  
12 # Mite keywords
13 24 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=1.2
14 24 my ( $SHIM, $CALLER ) =
15 ( "Mite::Shim", "Mite::App::Command" );
16 (
17 *after, *around, *before, *extends, *field,
18 *has, *param, *signature_for, *with
19 )
20 24 = do {
21  
22 package Mite::Shim;
23 24 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 (
25 0 ▶ sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 ▶ sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 0 ▶ sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 ▶ sub { },
Subroutine __ANON__: not called CC=1 SCAR=0.0
29 0 ▶ sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 48 ▶ sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
31 0 ▶ sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 0 ▶ sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
33 0 ▶ sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 24 );
35 };
36 }
37  
38 # Mite imports
39 24 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
40 24 require Scalar::Util;
41 24 *STRICT = \&Mite::Shim::STRICT;
42 24 *bare = \&Mite::Shim::bare;
43 24 *blessed = \&Scalar::Util::blessed;
44 24 *carp = \&Mite::Shim::carp;
45 24 *confess = \&Mite::Shim::confess;
46 24 *croak = \&Mite::Shim::croak;
47 24 *false = \&Mite::Shim::false;
48 24 *guard = \&Mite::Shim::guard;
49 24 *lazy = \&Mite::Shim::lazy;
50 24 *lock = \&Mite::Shim::lock;
51 24 *ro = \&Mite::Shim::ro;
52 24 *rw = \&Mite::Shim::rw;
53 24 *rwp = \&Mite::Shim::rwp;
54 24 *true = \&Mite::Shim::true;
55 24 *unlock = \&Mite::Shim::unlock;
56 }
57  
58 # Gather metadata for constructor and destructor
59 120 ▶ sub __META__ {
Subroutine __META__: called CC=4 SCAR=14.1
60 24 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
61 120 my $class = shift;
62 120 ▶ $class = ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
01200
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
63 120 my $linear_isa = mro::get_linear_isa($class);
64 return {
65 BUILD => [
66 240 ▶ map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
Branch: 1 branch
BranchTrueFalseTotal
*{$_;}{'CODE'} ? : 120 120 240
67 240 map { "$_\::BUILD" } reverse @$linear_isa
68 ],
69 DEMOLISH => [
70 0 ▶ map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
Branch: 1 branch
BranchTrueFalseTotal
*{$_;}{'CODE'} ? : 0 240 240
71 120 map { "$_\::DEMOLISH" } @$linear_isa
72 ],
73 HAS_BUILDARGS => $class->can('BUILDARGS'),
74 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
75 };
76 }
77  
78 # Standard Moose/Moo-style constructor
79 120 ▶ sub new {
Subroutine new: called CC=15 SCAR=34.2
Pod undocumented
80 120 ▶ my $class = ref( $_[0] ) ? ref(shift) : shift;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 120 120
81 120 ▶ my $meta = ( $Mite::META{$class} ||= $class->__META__ );
Condition33%1/3
$Mite::META{$class} ||= $class->__META__
l!l&&r!l&&!r
01200
MC/DC0%0/2
$Mite::META{$class} ||= $class->__META__
$Mite::META{$class} $class->__META__
Truth table33%1/3
A ||= B
A= $Mite::META{$class}B= $class->__META__
ABresult
1X1
011
000
82 120 my $self = bless {}, $class;
83 my $args =
84 $meta->{HAS_BUILDARGS}
85 ? $class->BUILDARGS(@_)
86 0 ▶ : { ( @_ == 1 ) ? %{ $_[0] } : @_ };
Branch: 2 branches
BranchTrueFalseTotal
$meta->{'HAS_BUILDARGS'} ? : 0 120 120
@_ == 1 ? : 0 120 120
87 120 my $no_build = delete $args->{__no_BUILD__};
88  
89 # Attribute app (type: Object)
90 # has declaration, file lib/Mite/App/Command.pm, line 11
91 120 ▶ croak "Missing key in constructor: app" unless exists $args->{"app"};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args->{"app"} 0 120 120
92 120 ▶ blessed( $args->{"app"} )
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($args->{"app"}) or croak("Type check failed in constructor: %s should be %s", "app", "Object") 120 0 120
93 or croak "Type check failed in constructor: %s should be %s", "app",
94 "Object";
95 120 $self->{"app"} = $args->{"app"};
96 require Scalar::Util && Scalar::Util::weaken( $self->{"app"} )
97 120 ▶ if ref $self->{"app"};
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->{"app"} 120 0 120
Condition50%2/4
ref $self->{'app'} && (require Scalar::Util && builtin::weaken($self->{'app'}))
!ll
0120
require Scalar::Util and builtin::weaken($self->{"app"})
!ll
0120
MC/DC0%0/3
ref $self->{'app'} && (require Scalar::Util && builtin::weaken($self->{'app'}))
ref $self->{'app'} require Scalar::Util builtin::weaken($self->{"app"})
Truth table0%0/4
A && B and C
A= ref $self->{'app'}B= require Scalar::UtilC= builtin::weaken($self->{"app"})
ABCresult
0XX0
10X0
1100
1111
98  
99 # Attribute kingpin_command (type: Object)
100 # has declaration, file lib/Mite/App/Command.pm, line 19
101 120 ▶ if ( exists $args->{"kingpin_command"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"kingpin_command"}) 0 120 120
102 0 ▶ blessed( $args->{"kingpin_command"} )
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($args->{"kingpin_command"}) or croak("Type check failed in constructor: %s should be %s", "kingpin_command", "Object") 0 0 0
103 or croak "Type check failed in constructor: %s should be %s",
104 "kingpin_command", "Object";
105 0 $self->{"kingpin_command"} = $args->{"kingpin_command"};
106 }
107  
108 # Call BUILD methods
109 120 ▶ $self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } );
Branch: 1 branch
BranchTrueFalseTotal
if not $no_build and @{$meta->{"BUILD"} or [];} 120 0 120
Condition40%2/5
not $no_build and @{$meta->{"BUILD"} or [];}
!ll&&!rl&&r
00120
$meta->{'BUILD'} || []
l!l
1200
MC/DC0%0/2
not $no_build and @{$meta->{"BUILD"} or [];}
not $no_build @{$meta->{"BUILD"} or [];}
MC/DC0%0/1
$meta->{'BUILD'} || []
$meta->{'BUILD'}
Truth table33%1/3
not(A) and B
A= not $no_buildB= @{$meta->{"BUILD"} or [];}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $meta->{'BUILD'}
Aresult
11
00
110  
111 # Unrecognized parameters
112 120 my @unknown = grep not(/\A(?:app|kingpin_command)\z/), keys %{$args};
113 @unknown
114 120 ▶ and croak(
Branch: 1 branch
BranchTrueFalseTotal
@unknown and croak('Unexpected keys in constructor: ' . join(", ", sort(@unknown))) 0 120 120
115 "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
116  
117 120 return $self;
118 }
119  
120 # Used by constructor to call BUILD methods
121 120 ▶ sub BUILDALL {
Subroutine BUILDALL: called CC=4 SCAR=15.2
Pod undocumented
122 120 my $class = ref( $_[0] );
123 120 ▶ my $meta = ( $Mite::META{$class} ||= $class->__META__ );
Condition33%1/3
$Mite::META{$class} ||= $class->__META__
l!l&&r!l&&!r
12000
MC/DC0%0/2
$Mite::META{$class} ||= $class->__META__
$Mite::META{$class} $class->__META__
Truth table33%1/3
A ||= B
A= $Mite::META{$class}B= $class->__META__
ABresult
1X1
011
000
124 120 ▶ $_->(@_) for @{ $meta->{BUILD} || [] };
Condition50%1/2
$meta->{'BUILD'} || []
l!l
1200
MC/DC0%0/1
$meta->{'BUILD'} || []
$meta->{'BUILD'}
Truth table50%1/2
A
A= $meta->{'BUILD'}
Aresult
11
00
125 }
126  
127 # Destructor should call DEMOLISH methods
128 120 ▶ sub DESTROY {
Subroutine DESTROY: called CC=7 SCAR=25.7
129 120 my $self = shift;
130 120 ▶ my $class = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
12000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
131 120 ▶ my $meta = ( $Mite::META{$class} ||= $class->__META__ );
Condition33%1/3
$Mite::META{$class} ||= $class->__META__
l!l&&r!l&&!r
12000
MC/DC0%0/2
$Mite::META{$class} ||= $class->__META__
$Mite::META{$class} $class->__META__
Truth table33%1/3
A ||= B
A= $Mite::META{$class}B= $class->__META__
ABresult
1X1
011
000
132 120 ▶ my $in_global_destruction =
Branch: 1 branch
BranchTrueFalseTotal
defined ${^GLOBAL_PHASE} ? : 120 0 120
133 defined ${^GLOBAL_PHASE}
134 ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
135 : Devel::GlobalDestruction::in_global_destruction();
136 120 ▶ for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
Condition50%1/2
$meta->{'DEMOLISH'} || []
l!l
1200
MC/DC0%0/1
$meta->{'DEMOLISH'} || []
$meta->{'DEMOLISH'}
Truth table50%1/2
A
A= $meta->{'DEMOLISH'}
Aresult
11
00
137 0 my $e = do {
138 0 local ( $?, $@ );
139 0 eval { $demolisher->( $self, $in_global_destruction ) };
140 0 $@;
141 };
142 24 ▶ no warnings 'misc'; # avoid (in cleanup) warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
143 0 ▶ die $e if $e; # rethrow
Branch: 1 branch
BranchTrueFalseTotal
if $e 0 0 0
144 }
145 120 return;
146 }
147  
148 my $__XS = !$ENV{PERL_ONLY}
149 24 ▶ && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
Condition33%1/3
!$ENV{'PERL_ONLY'} && eval { do { require Class::XSAccessor; 'Class::XSAccessor'->VERSION('1.19') } }
!ll&&!rl&&r
0024
MC/DC0%0/2
!$ENV{'PERL_ONLY'} && eval { do { require Class::XSAccessor; 'Class::XSAccessor'->VERSION('1.19') } }
!$ENV{'PERL_ONLY'} eval { do { require Class::XSAccessor; 'Class::XSAccessor'->VERSION('1.19') } }
Truth table33%1/3
not(A) && B
A= !$ENV{'PERL_ONLY'}B= eval { do { require Class::XSAccessor; 'Class::XSAccessor'->VERSION('1.19') } }
ABresult
0X0
100
111
150  
151 # Accessors for app
152 # has declaration, file lib/Mite/App/Command.pm, line 11
153 24 ▶ if ($__XS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($__XS) { } 24 0 24
154 24 Class::XSAccessor->import(
155 chained => 1,
156 "getters" => { "app" => "app" },
157 );
158 }
159 else {
160 0 ▶ *app = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
161 0 ▶ @_ == 1 or croak('Reader "app" usage: $self->app()');
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("Reader \"app\" usage: \$self->app()") 0 0 0
162 0 $_[0]{"app"};
163 0 };
164 }
165  
166 163 ▶ sub _assert_blessed_app {
Subroutine _assert_blessed_app: called CC=2 SCAR=7.0
167 163 my $object = do { $_[0]{"app"} };
168 163 ▶ blessed($object) or croak("app is not a blessed object");
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($object) or croak("app is not a blessed object") 163 0 163
169 163 $object;
170 }
171  
172 # Delegated methods for app
173 # has declaration, file lib/Mite/App/Command.pm, line 11
174 27 ▶ sub config { shift->_assert_blessed_app->config(@_) }
Subroutine config: called CC=1 SCAR=0.0
Pod undocumented
175 120 ▶ sub kingpin { shift->_assert_blessed_app->kingpin(@_) }
Subroutine kingpin: called CC=1 SCAR=0.0
Pod undocumented
176 16 ▶ sub project { shift->_assert_blessed_app->project(@_) }
Subroutine project: called CC=1 SCAR=0.0
Pod undocumented
177  
178 # Accessors for kingpin_command
179 # has declaration, file lib/Mite/App/Command.pm, line 19
180 128 ▶ sub kingpin_command {
Subroutine kingpin_command: called CC=4 SCAR=14.1
Pod undocumented
181 128 ▶ @_ == 1
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("Reader \"kingpin_command\" usage: \$self->kingpin_command()") 128 0 128
182 or croak('Reader "kingpin_command" usage: $self->kingpin_command()');
183 (
184 exists( $_[0]{"kingpin_command"} ) ? $_[0]{"kingpin_command"} : (
185 128 ▶ $_[0]{"kingpin_command"} = do {
Branch: 1 branch
BranchTrueFalseTotal
exists $_[0]{'kingpin_command'} ? : 8 120 128
186 120 my $default_value = $_[0]->_build_kingpin_command;
187 120 ▶ blessed($default_value)
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($default_value) or croak("Type check failed in default: %s should be %s", "kingpin_command", "Object") 120 0 120
188 or croak( "Type check failed in default: %s should be %s",
189 "kingpin_command", "Object" );
190 120 $default_value;
191 }
192 )
193 );
194 }
195  
196 # See UNIVERSAL
197 0 ▶ sub DOES {
Subroutine DOES: not called CC=8 SCAR=42.8
Pod undocumented
198 0 my ( $self, $role ) = @_;
199 0 our %DOES;
200 0 ▶ return $DOES{$role} if exists $DOES{$role};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Mite::App::Command::DOES{$role} 0 0 0
201 0 ▶ return 1 if $role eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $role eq __PACKAGE__ 0 0 0
202 0 ▶ if ( $INC{'Moose/Util.pm'}
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Moose/Util.pm"} and my $meta = Moose::Util::find_meta(ref $self || $self)) 0 0 0
Condition0%0/6
$INC{"Moose/Util.pm"} and my $meta = Moose::Util::find_meta(ref $self || $self)
!ll&&!rl&&r
000
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
$INC{"Moose/Util.pm"} and my $meta = Moose::Util::find_meta(ref $self || $self)
$INC{"Moose/Util.pm"} my $meta = Moose::Util::find_meta(ref $self || $self)
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A and B
A= $INC{"Moose/Util.pm"}B= my $meta = Moose::Util::find_meta(ref $self || $self)
ABresult
0X0
100
111
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
203 and my $meta = Moose::Util::find_meta( ref $self or $self ) )
204 {
205 0 ▶ $meta->can('does_role') and $meta->does_role($role) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$meta->can("does_role") and $meta->does_role($role) and return 1 0 0 0
Condition0%0/3
$meta->can("does_role") and $meta->does_role($role)
!ll&&!rl&&r
000
MC/DC0%0/2
$meta->can("does_role") and $meta->does_role($role)
$meta->can("does_role") $meta->does_role($role)
Truth table0%0/3
A and B
A= $meta->can("does_role")B= $meta->does_role($role)
ABresult
0X0
100
111
206 }
207 0 return $self->SUPER::DOES($role);
208 }
209  
210 # Alias for Moose/Moo-compatibility
211 0 ▶ sub does {
Subroutine does: not called CC=1 SCAR=6.9
Pod undocumented
212 0 shift->DOES(@_);
213 }
214  
215 24 1;
216 }
« lib/Mite/Trait/HasRoles.pm.mite.pm ↑ Summary blib/lib/Mite/Attribute/SHV/CodeGen.pm »