| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | { | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | use strict; | 
| 4 | 16 |  |  | 16 |  | 146 | use warnings; | 
|  | 16 |  |  |  |  | 68 |  | 
|  | 16 |  |  |  |  | 553 |  | 
| 5 | 16 |  |  | 16 |  | 102 | no warnings qw( once void ); | 
|  | 16 |  |  |  |  | 58 |  | 
|  | 16 |  |  |  |  | 836 |  | 
| 6 | 16 |  |  | 16 |  | 129 |  | 
|  | 16 |  |  |  |  | 69 |  | 
|  | 16 |  |  |  |  | 3152 |  | 
| 7 |  |  |  |  |  |  | our $USES_MITE    = "Mite::Class"; | 
| 8 |  |  |  |  |  |  | our $MITE_SHIM    = "Mite::Shim"; | 
| 9 |  |  |  |  |  |  | our $MITE_VERSION = "0.010007"; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | # Mite keywords | 
| 12 |  |  |  |  |  |  | BEGIN { | 
| 13 |  |  |  |  |  |  | my ( $SHIM, $CALLER ) = ( "Mite::Shim", "Mite::App" ); | 
| 14 | 16 |  |  | 16 |  | 118 | ( | 
| 15 |  |  |  |  |  |  | *after, *around, *before,        *extends, *field, | 
| 16 |  |  |  |  |  |  | *has,   *param,  *signature_for, *with | 
| 17 |  |  |  |  |  |  | ) | 
| 18 |  |  |  |  |  |  | = do { | 
| 19 | 16 |  |  |  |  | 53 |  | 
| 20 |  |  |  |  |  |  | no warnings 'redefine'; | 
| 21 |  |  |  |  |  |  | ( | 
| 22 | 16 |  |  | 16 |  | 141 | sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, | 
|  | 16 |  |  |  |  | 54 |  | 
|  | 16 |  |  |  |  | 3917 |  | 
| 23 |  |  |  |  |  |  | sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, | 
| 24 | 0 |  |  | 0 |  | 0 | sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, | 
| 25 | 0 |  |  | 0 |  | 0 | sub { }, | 
| 26 | 0 |  |  | 0 |  | 0 | sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, | 
| 27 |  |  |  | 0 |  |  | sub { $SHIM->HANDLE_has( $CALLER, has   => @_ ) }, | 
| 28 | 0 |  |  | 0 |  | 0 | sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, | 
| 29 | 48 |  |  | 48 |  | 35642 | sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, | 
| 30 | 0 |  |  | 0 |  | 0 | sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, | 
| 31 | 0 |  |  | 0 |  | 0 | ); | 
| 32 | 0 |  |  | 0 |  | 0 | } | 
| 33 | 16 |  |  |  |  | 2956 |  | 
| 34 |  |  |  |  |  |  | # Mite imports | 
| 35 |  |  |  |  |  |  | BEGIN { | 
| 36 |  |  |  |  |  |  | require Scalar::Util; | 
| 37 |  |  |  |  |  |  | *STRICT  = \&Mite::Shim::STRICT; | 
| 38 |  |  |  |  |  |  | *bare    = \&Mite::Shim::bare; | 
| 39 | 16 |  |  | 16 |  | 149 | *blessed = \&Scalar::Util::blessed; | 
| 40 | 16 |  |  |  |  | 87 | *carp    = \&Mite::Shim::carp; | 
| 41 | 16 |  |  |  |  | 79 | *confess = \&Mite::Shim::confess; | 
| 42 | 16 |  |  |  |  | 72 | *croak   = \&Mite::Shim::croak; | 
| 43 | 16 |  |  |  |  | 83 | *false   = \&Mite::Shim::false; | 
| 44 | 16 |  |  |  |  | 91 | *guard   = \&Mite::Shim::guard; | 
| 45 | 16 |  |  |  |  | 73 | *lazy    = \&Mite::Shim::lazy; | 
| 46 | 16 |  |  |  |  | 69 | *ro      = \&Mite::Shim::ro; | 
| 47 | 16 |  |  |  |  | 85 | *rw      = \&Mite::Shim::rw; | 
| 48 | 16 |  |  |  |  | 56 | *rwp     = \&Mite::Shim::rwp; | 
| 49 | 16 |  |  |  |  | 48 | *true    = \&Mite::Shim::true; | 
| 50 | 16 |  |  |  |  | 53 | } | 
| 51 | 16 |  |  |  |  | 72 |  | 
| 52 | 16 |  |  |  |  | 631 | # Gather metadata for constructor and destructor | 
| 53 |  |  |  |  |  |  | no strict 'refs'; | 
| 54 |  |  |  |  |  |  | my $class = shift; | 
| 55 |  |  |  |  |  |  | $class = ref($class) || $class; | 
| 56 |  |  |  |  |  |  | my $linear_isa = mro::get_linear_isa($class); | 
| 57 | 16 |  |  | 16 |  | 117 | return { | 
|  | 16 |  |  |  |  | 55 |  | 
|  | 16 |  |  |  |  | 5842 |  | 
| 58 | 16 |  |  | 16 |  | 52 | BUILD => [ | 
| 59 | 16 |  | 33 |  |  | 125 | map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } | 
| 60 | 16 |  |  |  |  | 326 | map { "$_\::BUILD" } reverse @$linear_isa | 
| 61 |  |  |  |  |  |  | ], | 
| 62 |  |  |  |  |  |  | DEMOLISH => [ | 
| 63 | 16 | 50 |  |  |  | 30 | map   { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } | 
|  | 16 |  |  |  |  | 121 |  | 
|  | 16 |  |  |  |  | 84 |  | 
| 64 | 16 |  |  |  |  | 88 | map { "$_\::DEMOLISH" } @$linear_isa | 
| 65 |  |  |  |  |  |  | ], | 
| 66 |  |  |  |  |  |  | HAS_BUILDARGS        => $class->can('BUILDARGS'), | 
| 67 | 16 | 50 |  |  |  | 37 | HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), | 
|  | 16 |  |  |  |  | 22413 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 68 | 16 |  |  |  |  | 67 | }; | 
|  | 16 |  |  |  |  | 59 |  | 
| 69 |  |  |  |  |  |  | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | # Standard Moose/Moo-style constructor | 
| 72 |  |  |  |  |  |  | my $class = ref( $_[0] ) ? ref(shift) : shift; | 
| 73 |  |  |  |  |  |  | my $meta  = ( $Mite::META{$class} ||= $class->__META__ ); | 
| 74 |  |  |  |  |  |  | my $self  = bless {}, $class; | 
| 75 |  |  |  |  |  |  | my $args = | 
| 76 |  |  |  |  |  |  | $meta->{HAS_BUILDARGS} | 
| 77 | 16 | 50 |  | 16 | 0 | 88 | ? $class->BUILDARGS(@_) | 
| 78 | 16 |  | 33 |  |  | 220 | : { ( @_ == 1 ) ? %{ $_[0] } : @_ }; | 
| 79 | 16 |  |  |  |  | 84 | my $no_build = delete $args->{__no_BUILD__}; | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | # Attribute commands (type: HashRef[Object]) | 
| 82 |  |  |  |  |  |  | # has declaration, file lib/Mite/App.pm, line 22 | 
| 83 | 16 | 50 |  |  |  | 10447 | do { | 
|  | 0 | 50 |  |  |  | 0 |  | 
| 84 | 16 |  |  |  |  | 47 | my $value = | 
| 85 |  |  |  |  |  |  | exists( $args->{"commands"} ) ? $args->{"commands"} : {}; | 
| 86 |  |  |  |  |  |  | do { | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 16 |  |  |  |  | 34 | ( ref($value) eq 'HASH' ) and do { | 
| 89 |  |  |  |  |  |  | my $ok = 1; | 
| 90 | 16 | 50 |  |  |  | 56 | for my $i ( values %{$value} ) { | 
| 91 | 16 | 50 |  |  |  | 36 | ( $ok = 0, last ) | 
| 92 |  |  |  |  |  |  | unless ( | 
| 93 |  |  |  |  |  |  | do { | 
| 94 | 16 | 50 |  |  |  | 111 |  | 
| 95 | 16 |  |  |  |  | 42 | use Scalar::Util (); | 
| 96 | 16 |  |  |  |  | 31 | Scalar::Util::blessed($i); | 
|  | 16 |  |  |  |  | 122 |  | 
| 97 |  |  |  |  |  |  | } | 
| 98 |  |  |  |  |  |  | ); | 
| 99 | 0 | 0 |  |  |  | 0 | }; | 
| 100 |  |  |  |  |  |  | $ok; | 
| 101 |  |  |  |  |  |  | } | 
| 102 | 16 |  |  | 16 |  | 176 | or croak "Type check failed in constructor: %s should be %s", | 
|  | 16 |  |  |  |  | 58 |  | 
|  | 16 |  |  |  |  | 8140 |  | 
| 103 | 0 |  |  |  |  | 0 | "commands", "HashRef[Object]"; | 
| 104 |  |  |  |  |  |  | $self->{"commands"} = $value; | 
| 105 |  |  |  |  |  |  | }; | 
| 106 |  |  |  |  |  |  |  | 
| 107 | 16 |  |  |  |  | 101 | # Attribute kingpin (type: Object) | 
| 108 |  |  |  |  |  |  | # has declaration, file lib/Mite/App.pm, line 28 | 
| 109 |  |  |  |  |  |  | if ( exists $args->{"kingpin"} ) { | 
| 110 |  |  |  |  |  |  | blessed( $args->{"kingpin"} ) | 
| 111 |  |  |  |  |  |  | or croak "Type check failed in constructor: %s should be %s", | 
| 112 | 16 |  |  |  |  | 106 | "kingpin", "Object"; | 
| 113 |  |  |  |  |  |  | $self->{"kingpin"} = $args->{"kingpin"}; | 
| 114 |  |  |  |  |  |  | } | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | # Attribute project (type: Mite::Project) | 
| 117 | 16 | 50 |  |  |  | 77 | # has declaration, file lib/Mite/App.pm, line 36 | 
| 118 | 0 | 0 |  |  |  | 0 | if ( exists $args->{"project"} ) { | 
| 119 |  |  |  |  |  |  | blessed( $args->{"project"} ) | 
| 120 |  |  |  |  |  |  | && $args->{"project"}->isa("Mite::Project") | 
| 121 | 0 |  |  |  |  | 0 | or croak "Type check failed in constructor: %s should be %s", | 
| 122 |  |  |  |  |  |  | "project", "Mite::Project"; | 
| 123 |  |  |  |  |  |  | $self->{"project"} = $args->{"project"}; | 
| 124 |  |  |  |  |  |  | } | 
| 125 |  |  |  |  |  |  |  | 
| 126 | 16 | 50 |  |  |  | 55 | # Call BUILD methods | 
| 127 |  |  |  |  |  |  | $self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } ); | 
| 128 | 0 | 0 | 0 |  |  | 0 |  | 
| 129 |  |  |  |  |  |  | # Unrecognized parameters | 
| 130 |  |  |  |  |  |  | my @unknown = grep not(/\A(?:commands|kingpin|project)\z/), | 
| 131 | 0 |  |  |  |  | 0 | keys %{$args}; | 
| 132 |  |  |  |  |  |  | @unknown | 
| 133 |  |  |  |  |  |  | and croak( | 
| 134 |  |  |  |  |  |  | "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); | 
| 135 | 16 | 50 | 33 |  |  | 73 |  | 
|  | 16 | 50 |  |  |  | 161 |  | 
| 136 |  |  |  |  |  |  | return $self; | 
| 137 |  |  |  |  |  |  | } | 
| 138 |  |  |  |  |  |  |  | 
| 139 | 16 |  |  |  |  | 91 | # Used by constructor to call BUILD methods | 
|  | 16 |  |  |  |  | 66 |  | 
| 140 |  |  |  |  |  |  | my $class = ref( $_[0] ); | 
| 141 | 16 | 50 |  |  |  | 71 | my $meta  = ( $Mite::META{$class} ||= $class->__META__ ); | 
| 142 |  |  |  |  |  |  | $_->(@_) for @{ $meta->{BUILD} || [] }; | 
| 143 |  |  |  |  |  |  | } | 
| 144 | 16 |  |  |  |  | 74 |  | 
| 145 |  |  |  |  |  |  | # Destructor should call DEMOLISH methods | 
| 146 |  |  |  |  |  |  | my $self  = shift; | 
| 147 |  |  |  |  |  |  | my $class = ref($self) || $self; | 
| 148 |  |  |  |  |  |  | my $meta  = ( $Mite::META{$class} ||= $class->__META__ ); | 
| 149 | 16 |  |  | 16 | 0 | 73 | my $in_global_destruction = | 
| 150 | 16 |  | 33 |  |  | 137 | defined ${^GLOBAL_PHASE} | 
| 151 | 16 | 50 |  |  |  | 31 | ? ${^GLOBAL_PHASE} eq 'DESTRUCT' | 
|  | 16 |  |  |  |  | 134 |  | 
| 152 |  |  |  |  |  |  | : Devel::GlobalDestruction::in_global_destruction(); | 
| 153 |  |  |  |  |  |  | for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { | 
| 154 |  |  |  |  |  |  | my $e = do { | 
| 155 |  |  |  |  |  |  | local ( $?, $@ ); | 
| 156 | 16 |  |  | 16 |  | 13840 | eval { $demolisher->( $self, $in_global_destruction ) }; | 
| 157 | 16 |  | 33 |  |  | 83 | $@; | 
| 158 | 16 |  | 33 |  |  | 91 | }; | 
| 159 | 16 | 50 |  |  |  | 168 | no warnings 'misc';    # avoid (in cleanup) warnings | 
| 160 |  |  |  |  |  |  | die $e if $e;          # rethrow | 
| 161 |  |  |  |  |  |  | } | 
| 162 |  |  |  |  |  |  | return; | 
| 163 | 16 | 50 |  |  |  | 37 | } | 
|  | 16 |  |  |  |  | 102 |  | 
| 164 | 0 |  |  |  |  | 0 |  | 
| 165 | 0 |  |  |  |  | 0 | my $__XS = !$ENV{PERL_ONLY} | 
| 166 | 0 |  |  |  |  | 0 | && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; | 
|  | 0 |  |  |  |  | 0 |  | 
| 167 | 0 |  |  |  |  | 0 |  | 
| 168 |  |  |  |  |  |  | # Accessors for commands | 
| 169 | 16 |  |  | 16 |  | 175 | # has declaration, file lib/Mite/App.pm, line 22 | 
|  | 16 |  |  |  |  | 70 |  | 
|  | 16 |  |  |  |  | 11919 |  | 
| 170 | 0 | 0 |  |  |  | 0 | if ($__XS) { | 
| 171 |  |  |  |  |  |  | Class::XSAccessor->import( | 
| 172 | 16 |  |  |  |  | 213 | chained   => 1, | 
| 173 |  |  |  |  |  |  | "getters" => { "commands" => "commands" }, | 
| 174 |  |  |  |  |  |  | ); | 
| 175 |  |  |  |  |  |  | } | 
| 176 |  |  |  |  |  |  | else { | 
| 177 |  |  |  |  |  |  | *commands = sub { | 
| 178 |  |  |  |  |  |  | @_ == 1 or croak('Reader "commands" usage: $self->commands()'); | 
| 179 |  |  |  |  |  |  | $_[0]{"commands"}; | 
| 180 |  |  |  |  |  |  | }; | 
| 181 |  |  |  |  |  |  | } | 
| 182 |  |  |  |  |  |  |  | 
| 183 |  |  |  |  |  |  | # Accessors for kingpin | 
| 184 |  |  |  |  |  |  | # has declaration, file lib/Mite/App.pm, line 28 | 
| 185 |  |  |  |  |  |  | my $object = do { | 
| 186 |  |  |  |  |  |  | ( | 
| 187 |  |  |  |  |  |  | exists( $_[0]{"kingpin"} ) ? $_[0]{"kingpin"} : ( | 
| 188 |  |  |  |  |  |  | $_[0]{"kingpin"} = do { | 
| 189 |  |  |  |  |  |  | my $default_value = $_[0]->_build_kingpin; | 
| 190 |  |  |  |  |  |  | blessed($default_value) | 
| 191 |  |  |  |  |  |  | or croak( | 
| 192 |  |  |  |  |  |  | "Type check failed in default: %s should be %s", | 
| 193 |  |  |  |  |  |  | "kingpin", "Object" ); | 
| 194 |  |  |  |  |  |  | $default_value; | 
| 195 |  |  |  |  |  |  | } | 
| 196 | 16 |  |  | 16 |  | 34 | ) | 
| 197 |  |  |  |  |  |  | ) | 
| 198 |  |  |  |  |  |  | }; | 
| 199 | 16 | 50 |  |  |  | 73 | blessed($object) or croak("kingpin is not a blessed object"); | 
| 200 | 0 |  |  |  |  | 0 | $object; | 
| 201 | 0 | 0 |  |  |  | 0 | } | 
| 202 |  |  |  |  |  |  |  | 
| 203 |  |  |  |  |  |  | @_ == 1 or croak('Reader "kingpin" usage: $self->kingpin()'); | 
| 204 |  |  |  |  |  |  | ( | 
| 205 | 0 |  |  |  |  | 0 | exists( $_[0]{"kingpin"} ) ? $_[0]{"kingpin"} : ( | 
| 206 |  |  |  |  |  |  | $_[0]{"kingpin"} = do { | 
| 207 |  |  |  |  |  |  | my $default_value = $_[0]->_build_kingpin; | 
| 208 |  |  |  |  |  |  | blessed($default_value) | 
| 209 |  |  |  |  |  |  | or croak( "Type check failed in default: %s should be %s", | 
| 210 | 16 | 50 |  |  |  | 85 | "kingpin", "Object" ); | 
| 211 | 16 |  |  |  |  | 84 | $default_value; | 
| 212 |  |  |  |  |  |  | } | 
| 213 |  |  |  |  |  |  | ) | 
| 214 |  |  |  |  |  |  | ); | 
| 215 | 130 | 50 |  | 130 | 0 | 361 | } | 
| 216 |  |  |  |  |  |  |  | 
| 217 |  |  |  |  |  |  | # Delegated methods for kingpin | 
| 218 | 130 | 100 |  |  |  | 1565 | # has declaration, file lib/Mite/App.pm, line 28 | 
| 219 | 16 |  |  |  |  | 84 |  | 
| 220 | 16 | 50 |  |  |  | 138 | # Accessors for project | 
| 221 |  |  |  |  |  |  | # has declaration, file lib/Mite/App.pm, line 36 | 
| 222 |  |  |  |  |  |  | my $object = do { | 
| 223 | 16 |  |  |  |  | 131 | ( | 
| 224 |  |  |  |  |  |  | exists( $_[0]{"project"} ) ? $_[0]{"project"} : ( | 
| 225 |  |  |  |  |  |  | $_[0]{"project"} = do { | 
| 226 |  |  |  |  |  |  | my $default_value = $_[0]->_build_project; | 
| 227 |  |  |  |  |  |  | blessed($default_value) | 
| 228 |  |  |  |  |  |  | && $default_value->isa("Mite::Project") | 
| 229 |  |  |  |  |  |  | or croak( | 
| 230 |  |  |  |  |  |  | "Type check failed in default: %s should be %s", | 
| 231 | 16 |  |  | 16 |  | 81 | "project", "Mite::Project" ); | 
| 232 |  |  |  |  |  |  | $default_value; | 
| 233 |  |  |  |  |  |  | } | 
| 234 |  |  |  |  |  |  | ) | 
| 235 |  |  |  |  |  |  | ) | 
| 236 | 31 |  |  | 31 |  | 48 | }; | 
| 237 |  |  |  |  |  |  | blessed($object) or croak("project is not a blessed object"); | 
| 238 |  |  |  |  |  |  | $object; | 
| 239 | 31 | 50 |  |  |  | 105 | } | 
| 240 | 0 |  |  |  |  | 0 |  | 
| 241 | 0 | 0 | 0 |  |  | 0 | @_ == 1 or croak('Reader "project" usage: $self->project()'); | 
| 242 |  |  |  |  |  |  | ( | 
| 243 |  |  |  |  |  |  | exists( $_[0]{"project"} ) ? $_[0]{"project"} : ( | 
| 244 |  |  |  |  |  |  | $_[0]{"project"} = do { | 
| 245 |  |  |  |  |  |  | my $default_value = $_[0]->_build_project; | 
| 246 | 0 |  |  |  |  | 0 | blessed($default_value) | 
| 247 |  |  |  |  |  |  | && $default_value->isa("Mite::Project") | 
| 248 |  |  |  |  |  |  | or croak( "Type check failed in default: %s should be %s", | 
| 249 |  |  |  |  |  |  | "project", "Mite::Project" ); | 
| 250 |  |  |  |  |  |  | $default_value; | 
| 251 | 31 | 50 |  |  |  | 132 | } | 
| 252 | 31 |  |  |  |  | 140 | ) | 
| 253 |  |  |  |  |  |  | ); | 
| 254 |  |  |  |  |  |  | } | 
| 255 |  |  |  |  |  |  |  | 
| 256 | 26 | 50 |  | 26 | 0 | 918 | # Delegated methods for project | 
| 257 |  |  |  |  |  |  | # has declaration, file lib/Mite/App.pm, line 36 | 
| 258 |  |  |  |  |  |  |  | 
| 259 | 26 | 100 |  |  |  | 409 | # See UNIVERSAL | 
| 260 | 14 |  |  |  |  | 106 | my ( $self, $role ) = @_; | 
| 261 | 14 | 50 | 33 |  |  | 204 | our %DOES; | 
| 262 |  |  |  |  |  |  | return $DOES{$role} if exists $DOES{$role}; | 
| 263 |  |  |  |  |  |  | return 1            if $role eq __PACKAGE__; | 
| 264 |  |  |  |  |  |  | return $self->SUPER::DOES($role); | 
| 265 | 14 |  |  |  |  | 125 | } | 
| 266 |  |  |  |  |  |  |  | 
| 267 |  |  |  |  |  |  | # Alias for Moose/Moo-compatibility | 
| 268 |  |  |  |  |  |  | shift->DOES(@_); | 
| 269 |  |  |  |  |  |  | } | 
| 270 |  |  |  |  |  |  |  | 
| 271 |  |  |  |  |  |  | 1; | 
| 272 |  |  |  |  |  |  |  |