| 1 | 115 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 2 | 115 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 115 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | package Mite::Project; | ||||||||||||||||||||||||||||||||||||||
| 6 | 115 | ▶ | use Mite::Miteception -all; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 115 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||
| 9 | 115 | our $VERSION = '0.013000'; | |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | has sources => | ||||||||||||||||||||||||||||||||||||||
| 12 | is => ro, | ||||||||||||||||||||||||||||||||||||||
| 13 | isa => HashRef[MiteSource], | ||||||||||||||||||||||||||||||||||||||
| 14 | 117 | ▶ | default => sub { {} }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | has config => | ||||||||||||||||||||||||||||||||||||||
| 17 | is => ro, | ||||||||||||||||||||||||||||||||||||||
| 18 | isa => MiteConfig, | ||||||||||||||||||||||||||||||||||||||
| 19 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||
| 20 | 112 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 21 | 112 | require Mite::Config; | |||||||||||||||||||||||||||||||||||||
| 22 | 112 | state $config = Mite::Config->new; | |||||||||||||||||||||||||||||||||||||
| 23 | 112 | return $config; | |||||||||||||||||||||||||||||||||||||
| 24 | 115 | }; | |||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | 115 | has _module_fakeout_namespace => | |||||||||||||||||||||||||||||||||||||
| 27 | is => rw, | ||||||||||||||||||||||||||||||||||||||
| 28 | isa => Str | Undef; | ||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | 115 | has debug => | |||||||||||||||||||||||||||||||||||||
| 31 | is => rw, | ||||||||||||||||||||||||||||||||||||||
| 32 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||
| 33 | default => false; | ||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||
| 35 | 115 | ▶ | use Mite::Source; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 36 | 115 | ▶ | use Mite::Class; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | 289 | ▶ | sub classes { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
classes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 39 | 289 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||
| 41 | 611 | my %classes = map { %{$_->classes} } | |||||||||||||||||||||||||||||||||||||
| 42 | 289 | values %{$self->sources}; | |||||||||||||||||||||||||||||||||||||
| 43 | 289 | return \%classes; | |||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | # Careful not to create a class. | ||||||||||||||||||||||||||||||||||||||
| 47 | 288 | ▶ | sub class { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 48 | 288 | my ( $self, $name ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||
| 50 | 288 | return $self->classes->{$name}; | |||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | # Careful not to create a source. | ||||||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | sub source { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
source: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 55 | 2 | my ( $self, $file ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 2 | return $self->sources->{$file}; | |||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | sub add_sources { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
add_sources: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 61 | 2 | my ( $self, @sources ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | 2 | for my $source (@sources) { | |||||||||||||||||||||||||||||||||||||
| 64 | 3 | $self->sources->{$source->file} = $source; | |||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | 158 | ▶ | sub source_for { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
source_for: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 69 | 158 | my ( $self, $file ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | # Normalize the path. | ||||||||||||||||||||||||||||||||||||||
| 72 | 158 | $file = Path::Tiny::path($file)->realpath; | |||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | 158 | ▶ | return $self->sources->{$file} ||= Mite::Source->new( | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->sources->{$file} ||= "Mite::Source"->new("file", $file, "project", $self)
MC/DC0%0/2
$self->sources->{$file} ||= "Mite::Source"->new("file", $file, "project", $self)
$self->sources->{$file}
"Mite::Source"->new("file", $file, "project", $self)
Truth table66%2/3
A ||= B
A= $self->sources->{$file}B= "Mite::Source"->new("file", $file, "project", $self)
| |||||||||||||||||||||||||||||||||||||||
| 75 | file => $file, | ||||||||||||||||||||||||||||||||||||||
| 76 | project => $self | ||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||
| 80 | # This is the shim Mite.pm uses when compiling. | ||||||||||||||||||||||||||||||||||||||
| 81 | 115 | signature_for inject_mite_functions => ( | |||||||||||||||||||||||||||||||||||||
| 82 | named => [ | ||||||||||||||||||||||||||||||||||||||
| 83 | package => Any, | ||||||||||||||||||||||||||||||||||||||
| 84 | file => Any, | ||||||||||||||||||||||||||||||||||||||
| 85 | kind => Optional[Str], | ||||||||||||||||||||||||||||||||||||||
| 86 | arg => HashRef, { default => {} }, | ||||||||||||||||||||||||||||||||||||||
| 87 | shim => Str, | ||||||||||||||||||||||||||||||||||||||
| 88 | x_source => Optional[Object], | ||||||||||||||||||||||||||||||||||||||
| 89 | x_pkg => Optional[Object], | ||||||||||||||||||||||||||||||||||||||
| 90 | ], | ||||||||||||||||||||||||||||||||||||||
| 91 | named_to_list => true, | ||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | 119 | ▶ | sub inject_mite_functions { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
inject_mite_functions: called CC=11 SCAR=29.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 95 | 119 | my ( $self, $package, $file, $kind, $arg, $shim, $source, $pkg ) = @_; | |||||||||||||||||||||||||||||||||||||
| 96 | 119 | ▶ | $kind //= ( $arg->{'-role'} ? 'role' : 'class' ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$kind //= $arg->{"-role"} ? "role" : "class"
MC/DC0%0/1
$kind //= $arg->{"-role"} ? "role" : "class"
$kind
Truth table50%1/2
A
A= $kind
| |||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||
| 98 | 119 | ▶ | my $fake_ns = $self->can('_module_fakeout_namespace') && $self->_module_fakeout_namespace; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->can('_module_fakeout_namespace') && $self->_module_fakeout_namespace
MC/DC0%0/2
$self->can('_module_fakeout_namespace') && $self->_module_fakeout_namespace
$self->can('_module_fakeout_namespace')
$self->_module_fakeout_namespace
Truth table33%1/3
A && B
A= $self->can('_module_fakeout_namespace')B= $self->_module_fakeout_namespace
| |||||||||||||||||||||||||||||||||||||||
| 99 | 119 | ▶ | if ( defined( $fake_ns ) and not $package =~ /^\Q$fake_ns/ ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $fake_ns and not $package =~ /^\Q$fake_ns\E/
MC/DC0%0/2
defined $fake_ns and not $package =~ /^\Q$fake_ns\E/
defined $fake_ns
not $package =~ /^\Q$fake_ns\E/
Truth table33%1/3
A and not(B)
A= defined $fake_nsB= not $package =~ /^\Q$fake_ns\E/
| |||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $package = "$fake_ns\::$package"; | |||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||
| 103 | 119 | ▶ | warn "Gather: $package\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||
| 105 | 119 | ▶ | $source //= $self->source_for( | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$source //= $self->source_for(Path::Tiny::path($Mite::REAL_FILENAME // $file))
$Mite::REAL_FILENAME // $file
MC/DC0%0/2
$source //= $self->source_for(Path::Tiny::path($Mite::REAL_FILENAME // $file))
$source
$self->source_for(Path::Tiny::path($Mite::REAL_FILENAME // $file))
MC/DC0%0/2
$Mite::REAL_FILENAME // $file
$Mite::REAL_FILENAME
$file
Truth table33%1/3
A //= B
A= $sourceB= $self->source_for(Path::Tiny::path($Mite::REAL_FILENAME // $file))
Truth table33%1/3
A // B
A= $Mite::REAL_FILENAMEB= $file
| |||||||||||||||||||||||||||||||||||||||
| 106 | Path::Tiny::path( $Mite::REAL_FILENAME // $file ) | ||||||||||||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||||||||||||
| 108 | 119 | ▶ | $pkg //= $source->class_for( | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pkg //= $source->class_for($package, $kind eq "role" ? "Mite::Role" : "Mite::Class")
MC/DC0%0/2
$pkg //= $source->class_for($package, $kind eq "role" ? "Mite::Role" : "Mite::Class")
$pkg
$source->class_for($package, $kind eq "role" ? "Mite::Role" : "Mite::Class")
Truth table33%1/3
A //= B
A= $pkgB= $source->class_for($package, $kind eq "role" ? "Mite::Role" : "Mite::Class")
| |||||||||||||||||||||||||||||||||||||||
| 109 | $package, | ||||||||||||||||||||||||||||||||||||||
| 110 | $kind eq 'role' ? 'Mite::Role' : 'Mite::Class', | ||||||||||||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||||||||||||
| 112 | 119 | $pkg->shim_name( $shim ); | |||||||||||||||||||||||||||||||||||||
| 113 | 119 | $pkg->arg( $arg ); | |||||||||||||||||||||||||||||||||||||
| 114 | 119 | $pkg->inject_mite_functions( $file, $arg ); | |||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||
| 117 | 84 | ▶ | sub write_mites { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
write_mites: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 118 | 84 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||
| 120 | 84 | for my $source (values %{$self->sources}) { | |||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | warn "Write mite: ${\ $source->compiled->file }\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 122 | 92 | $source->compiled->write( | |||||||||||||||||||||||||||||||||||||
| 123 | module_fakeout_namespace => $self->_module_fakeout_namespace, | ||||||||||||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||
| 127 | 84 | return; | |||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||
| 130 | 95 | ▶ | sub _project_mopper_file { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_project_mopper_file: called CC=3 SCAR=13.2
| |||||||||||||||||||||||||||||||||||||||
| 131 | 95 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||
| 133 | 95 | my ( $mop_package, $mop_dir ); | |||||||||||||||||||||||||||||||||||||
| 134 | 95 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 135 | 95 | my $config = $self->config; | |||||||||||||||||||||||||||||||||||||
| 136 | 95 | $mop_package = $config->data->{mop}; | |||||||||||||||||||||||||||||||||||||
| 137 | 17 | $mop_dir = $config->data->{source_from}; | |||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||
| 139 | 17 | ▶ | $mop_package and $mop_dir; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$mop_package && $mop_dir
MC/DC0%0/2
$mop_package && $mop_dir
$mop_package
$mop_dir
Truth table33%1/3
A && B
A= $mop_packageB= $mop_dir
| |||||||||||||||||||||||||||||||||||||||
| 140 | } or return; | ||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $mop_file = $mop_package; | |||||||||||||||||||||||||||||||||||||
| 143 | 0 | $mop_file =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||
| 144 | 0 | $mop_file .= ".pm"; | |||||||||||||||||||||||||||||||||||||
| 145 | 0 | return Path::Tiny::path($mop_dir, $mop_file); | |||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||
| 148 | 4 | ▶ | sub write_mopper { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
write_mopper: called CC=6 SCAR=34.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 149 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | my $mop_file = $self->_project_mopper_file or return; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $dir = Path::Tiny::path( $self->config->data->{source_from} ); | |||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $code = $self->_compile_mop_header; | |||||||||||||||||||||||||||||||||||||
| 156 | 0 | for my $source ( sort { $a->file cmp $b->file } values %{ $self->sources } ) { | |||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $relative_name = $source->file->relative($dir); | |||||||||||||||||||||||||||||||||||||
| 158 | 0 | $code .= $source->_compile_mop( $relative_name ); | |||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||
| 160 | 0 | for my $class ( sort { $a->name cmp $b->name } values %{ $self->classes } ) { | |||||||||||||||||||||||||||||||||||||
| 161 | 0 | $code .= $class->_compile_mop_postamble; | |||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if ( my $yuck = $self->_module_fakeout_namespace ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $code =~ s/$yuck\:://g; | |||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $code .= "\ntrue;\n\n"; | |||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | warn "Write MOP: $mop_file\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $mop_file->spew( $code ); | |||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub _compile_mop_header { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_compile_mop_header: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 178 | 0 | return sprintf <<'CODE', ( $self->config->data->{mop} ) x 3; | |||||||||||||||||||||||||||||||||||||
| 179 | package %s; | ||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||
| 181 | use Moose (); | ||||||||||||||||||||||||||||||||||||||
| 182 | use Moose::Util (); | ||||||||||||||||||||||||||||||||||||||
| 183 | use Moose::Util::MetaRole (); | ||||||||||||||||||||||||||||||||||||||
| 184 | use Moose::Util::TypeConstraints (); | ||||||||||||||||||||||||||||||||||||||
| 185 | use constant { true => !!1, false => !!0 }; | ||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||
| 187 | my $META_CLASS = do { | ||||||||||||||||||||||||||||||||||||||
| 188 | package %s::Meta::Class; | ||||||||||||||||||||||||||||||||||||||
| 189 | use Moose; | ||||||||||||||||||||||||||||||||||||||
| 190 | extends 'Moose::Meta::Class'; | ||||||||||||||||||||||||||||||||||||||
| 191 | around _immutable_options => sub { | ||||||||||||||||||||||||||||||||||||||
| 192 | my ( $next, $self, @args ) = ( shift, shift, @_ ); | ||||||||||||||||||||||||||||||||||||||
| 193 | return $self->$next( replace_constructor => 1, @args ); | ||||||||||||||||||||||||||||||||||||||
| 194 | }; | ||||||||||||||||||||||||||||||||||||||
| 195 | __PACKAGE__->meta->make_immutable; | ||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||
| 197 | __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||
| 198 | }; | ||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||
| 200 | my $META_ROLE = do { | ||||||||||||||||||||||||||||||||||||||
| 201 | package %s::Meta::Role; | ||||||||||||||||||||||||||||||||||||||
| 202 | use Moose; | ||||||||||||||||||||||||||||||||||||||
| 203 | extends 'Moose::Meta::Role'; | ||||||||||||||||||||||||||||||||||||||
| 204 | my $built_ins = qr/\A( DOES | does | __META__ | __FINALIZE_APPLICATION__ | | ||||||||||||||||||||||||||||||||||||||
| 205 | CREATE_CLASS | APPLY_TO )\z/x; | ||||||||||||||||||||||||||||||||||||||
| 206 | around get_method => sub { | ||||||||||||||||||||||||||||||||||||||
| 207 | my ( $next, $self, $method_name ) = ( shift, shift, @_ ); | ||||||||||||||||||||||||||||||||||||||
| 208 | return if $method_name =~ $built_ins; | ||||||||||||||||||||||||||||||||||||||
| 209 | return $self->$next( @_ ); | ||||||||||||||||||||||||||||||||||||||
| 210 | }; | ||||||||||||||||||||||||||||||||||||||
| 211 | around get_method_list => sub { | ||||||||||||||||||||||||||||||||||||||
| 212 | my ( $next, $self ) = ( shift, shift ); | ||||||||||||||||||||||||||||||||||||||
| 213 | return grep !/$built_ins/, $self->$next( @_ ); | ||||||||||||||||||||||||||||||||||||||
| 214 | }; | ||||||||||||||||||||||||||||||||||||||
| 215 | around _get_local_methods => sub { | ||||||||||||||||||||||||||||||||||||||
| 216 | my ( $next, $self ) = ( shift, shift ); | ||||||||||||||||||||||||||||||||||||||
| 217 | my %%map = %%{ $self->_full_method_map }; | ||||||||||||||||||||||||||||||||||||||
| 218 | return map $map{$_}, $self->get_method_list; | ||||||||||||||||||||||||||||||||||||||
| 219 | }; | ||||||||||||||||||||||||||||||||||||||
| 220 | __PACKAGE__->meta->make_immutable; | ||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||
| 222 | __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||
| 223 | }; | ||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||
| 225 | CODE | ||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||
| 228 | 115 | signature_for load_files => ( | |||||||||||||||||||||||||||||||||||||
| 229 | pos => [ ArrayRef, 0 ], | ||||||||||||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||
| 232 | 83 | ▶ | sub load_files { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
load_files: called CC=5 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 233 | 83 | my ( $self, $files, $inc_dir ) = @_; | |||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||
| 235 | 83 | local $Mite::COMPILING = eval { $self->config->data->{shim} } | |||||||||||||||||||||||||||||||||||||
| 236 | // $ENV{TEST_MITE_SHIM} | ||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | // do { warn 'Attempting to compile, but no shim in config'; exit 1; }; | ||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
(eval {
do {
$self->config->data->{"shim"}
}
} // $ENV{"TEST_MITE_SHIM"}) // do {
warn "Attempting to compile, but no shim in config";
exit 1
}
eval {
do {
$self->config->data->{"shim"}
}
} // $ENV{"TEST_MITE_SHIM"}
MC/DC0%0/3
(eval {
do {
$self->config->data->{"shim"}
}
} // $ENV{"TEST_MITE_SHIM"}) // do {
warn "Attempting to compile, but no shim in config";
exit 1
}
eval {
do {
$self->config->data->{"shim"}
}
}
$ENV{"TEST_MITE_SHIM"}
do {
warn "Attempting to compile, but no shim in config";
exit 1
}
Truth table50%2/4
A // B // C
A= eval {
do {
$self->config->data->{"shim"}
}
}B= $ENV{"TEST_MITE_SHIM"}C= do {
warn "Attempting to compile, but no shim in config";
exit 1
}
| |||||||||||||||||||||||||||||||||||||||
| 238 | 83 | local @INC = @INC; | |||||||||||||||||||||||||||||||||||||
| 239 | 83 | ▶ | unshift @INC, $inc_dir if defined $inc_dir; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 240 | 83 | for my $file (@$files) { | |||||||||||||||||||||||||||||||||||||
| 241 | 91 | $self->_load_file( $file, $inc_dir ); | |||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||
| 244 | 83 | return; | |||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||
| 247 | 91 | ▶ | sub _load_file { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_file: called CC=11 SCAR=37.7
| |||||||||||||||||||||||||||||||||||||||
| 248 | 91 | my ( $self, $file, $inc_dir ) = @_; | |||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||
| 250 | 91 | ▶ | if ( $self->{_already}{$file}++ ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | warn "Skipping $file: already loaded\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||
| 255 | 91 | ▶ | if ( defined $self->_project_mopper_file | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->_project_mopper_file and $file eq $self->_project_mopper_file
MC/DC0%0/2
defined $self->_project_mopper_file and $file eq $self->_project_mopper_file
defined $self->_project_mopper_file
$file eq $self->_project_mopper_file
Truth table33%1/3
A and B
A= defined $self->_project_mopper_fileB= $file eq $self->_project_mopper_file
| |||||||||||||||||||||||||||||||||||||||
| 256 | and $file eq $self->_project_mopper_file ) { | ||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | warn "Skipping $file: it's the mop\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||
| 261 | 91 | ▶ | warn "Load module: $file\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||
| 263 | 91 | $file = Path::Tiny::path($file); | |||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||
| 265 | 91 | ▶ | if ( defined $self->_module_fakeout_namespace ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $ns = $self->_module_fakeout_namespace; | |||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $code = $file->slurp; | |||||||||||||||||||||||||||||||||||||
| 269 | 0 | $code =~ s/package /package $ns\::/; | |||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||
| 271 | 0 | do { | |||||||||||||||||||||||||||||||||||||
| 272 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||
| 273 | 0 | local $Mite::REAL_FILENAME = "$file"; | |||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | eval("$code; 1") or do die($@); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 275 | }; | ||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||
| 280 | 91 | ▶ | if ( my $pm_file = eval { $file->relative($inc_dir) } ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 281 | 91 | require $pm_file; | |||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||
| 283 | else { | ||||||||||||||||||||||||||||||||||||||
| 284 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | eval( $file->slurp ) or die $@; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||
| 288 | 91 | return; | |||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||
| 291 | 8 | ▶ | sub find_pms { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
find_pms: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 292 | 8 | my ( $self, $dir ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 293 | 8 | ▶ | $dir //= $self->config->data->{source_from}; | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$dir //= $self->config->data->{"source_from"}
MC/DC0%0/2
$dir //= $self->config->data->{"source_from"}
$dir
$self->config->data->{"source_from"}
Truth table66%2/3
A //= B
A= $dirB= $self->config->data->{"source_from"}
| |||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||
| 295 | return $self->_recurse_directory( | ||||||||||||||||||||||||||||||||||||||
| 296 | $dir, | ||||||||||||||||||||||||||||||||||||||
| 297 | 39 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||
| 298 | 39 | my $path = shift; | |||||||||||||||||||||||||||||||||||||
| 299 | 39 | ▶ | return false if -d $path; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 300 | 25 | ▶ | return false unless $path =~ m{\.pm$}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 301 | 21 | ▶ | return false if $path =~ m{\.mite\.pm$}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 302 | 19 | return true; | |||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||
| 304 | 8 | ); | |||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||
| 307 | 5 | ▶ | sub load_directory { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
load_directory: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 308 | 5 | my ( $self, $dir ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 309 | 5 | ▶ | $dir //= $self->config->data->{source_from}; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$dir //= $self->config->data->{"source_from"}
MC/DC0%0/2
$dir //= $self->config->data->{"source_from"}
$dir
$self->config->data->{"source_from"}
Truth table33%1/3
A //= B
A= $dirB= $self->config->data->{"source_from"}
| |||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||
| 311 | 5 | $self->load_files( [$self->find_pms($dir)], $dir ); | |||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||
| 313 | 5 | return; | |||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||
| 316 | 9 | ▶ | sub find_mites { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
find_mites: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 317 | 9 | my ( $self, $dir ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 318 | 9 | ▶ | $dir //= $self->config->data->{compiled_to}; | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$dir //= $self->config->data->{"compiled_to"}
MC/DC0%0/2
$dir //= $self->config->data->{"compiled_to"}
$dir
$self->config->data->{"compiled_to"}
Truth table66%2/3
A //= B
A= $dirB= $self->config->data->{"compiled_to"}
| |||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||
| 320 | return $self->_recurse_directory( | ||||||||||||||||||||||||||||||||||||||
| 321 | $dir, | ||||||||||||||||||||||||||||||||||||||
| 322 | 56 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||
| 323 | 56 | my $path = shift; | |||||||||||||||||||||||||||||||||||||
| 324 | 56 | ▶ | return false if -d $path; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 325 | 39 | ▶ | return true if $path =~ m{\.mite\.pm$}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 326 | 27 | return false; | |||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||
| 328 | 9 | ); | |||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||
| 331 | 4 | ▶ | sub clean_mites { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_mites: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 332 | 4 | my ( $self, $dir ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 333 | 4 | ▶ | $dir //= $self->config->data->{compiled_to}; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$dir //= $self->config->data->{"compiled_to"}
MC/DC0%0/2
$dir //= $self->config->data->{"compiled_to"}
$dir
$self->config->data->{"compiled_to"}
Truth table33%1/3
A //= B
A= $dirB= $self->config->data->{"compiled_to"}
| |||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||
| 335 | 4 | for my $file ($self->find_mites($dir)) { | |||||||||||||||||||||||||||||||||||||
| 336 | 6 | ▶ | warn "Clean mite: $file\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 337 | 6 | Path::Tiny::path($file)->remove; | |||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||
| 340 | 4 | return; | |||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||
| 343 | 3 | ▶ | sub clean_shim { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_shim: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 344 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | warn "Clean shim: ${\ $self->_project_shim_file }\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 346 | 3 | return $self->_project_shim_file->remove; | |||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||
| 349 | # Recursively gather all the pm files in a directory | ||||||||||||||||||||||||||||||||||||||
| 350 | 115 | signature_for _recurse_directory => ( | |||||||||||||||||||||||||||||||||||||
| 351 | pos => [ Path, CodeRef ], | ||||||||||||||||||||||||||||||||||||||
| 352 | ); | ||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||
| 354 | 17 | ▶ | sub _recurse_directory { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_recurse_directory: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||
| 355 | 17 | my ( $self, $dir, $check ) = @_; | |||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||
| 357 | 17 | my @pm_files; | |||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||
| 359 | 17 | my $iter = $dir->iterator({ recurse => 1, follow_symlinks => 1 }); | |||||||||||||||||||||||||||||||||||||
| 360 | 17 | ▶ | while( my $path = $iter->() ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 361 | 95 | ▶ | next unless $check->($path); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 362 | 31 | push @pm_files, $path; | |||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||
| 365 | 17 | return @pm_files; | |||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||
| 368 | 9 | ▶ | sub init_project { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
init_project: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 369 | 9 | my ( $self, $project_name ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||
| 371 | 9 | ▶ | warn "Init\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||
| 373 | 9 | $self->config->make_mite_dir; | |||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||
| 375 | 9 | ▶ | $self->write_default_config( | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 376 | $project_name | ||||||||||||||||||||||||||||||||||||||
| 377 | ) if !-e $self->config->config_file; | ||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||
| 379 | 9 | return; | |||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||
| 382 | 6 | ▶ | sub add_mite_shim { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
add_mite_shim: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 383 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||
| 385 | 6 | my $shim_file = $self->_project_shim_file; | |||||||||||||||||||||||||||||||||||||
| 386 | 6 | $shim_file->parent->mkpath; | |||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||
| 388 | 6 | ▶ | warn "Write shim: $shim_file\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||
| 390 | 6 | my $shim_package = $self->config->data->{shim}; | |||||||||||||||||||||||||||||||||||||
| 391 | 6 | ▶ | return $shim_file if $shim_package eq 'Mite::Shim'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||
| 393 | 6 | my $src_shim = $self->_find_mite_shim; | |||||||||||||||||||||||||||||||||||||
| 394 | 6 | my $code = $src_shim->slurp; | |||||||||||||||||||||||||||||||||||||
| 395 | 6 | $code =~ s/package Mite::Shim;/package $shim_package;/; | |||||||||||||||||||||||||||||||||||||
| 396 | 6 | $code =~ s/^Mite::Shim\b/$shim_package/ms; | |||||||||||||||||||||||||||||||||||||
| 397 | 6 | $shim_file->spew( $code ); | |||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||
| 399 | 6 | return $shim_file; | |||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||
| 402 | 10 | ▶ | sub _project_shim_file { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_project_shim_file: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 403 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||
| 405 | 10 | my $config = $self->config; | |||||||||||||||||||||||||||||||||||||
| 406 | 10 | my $shim_package = $config->data->{shim}; | |||||||||||||||||||||||||||||||||||||
| 407 | 10 | my $shim_dir = $config->data->{source_from}; | |||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||
| 409 | 10 | my $shim_file = $shim_package; | |||||||||||||||||||||||||||||||||||||
| 410 | 10 | $shim_file =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||
| 411 | 10 | $shim_file .= ".pm"; | |||||||||||||||||||||||||||||||||||||
| 412 | 10 | return Path::Tiny::path($shim_dir, $shim_file); | |||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||
| 415 | 6 | ▶ | sub _find_mite_shim { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_mite_shim: called CC=4 SCAR=15.9
| |||||||||||||||||||||||||||||||||||||||
| 416 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||
| 418 | 6 | for my $dir (@INC) { | |||||||||||||||||||||||||||||||||||||
| 419 | # Avoid code refs in @INC | ||||||||||||||||||||||||||||||||||||||
| 420 | 16 | ▶ | next if ref $dir; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||
| 422 | 16 | my $shim = Path::Tiny::path($dir, "Mite", "Shim.pm"); | |||||||||||||||||||||||||||||||||||||
| 423 | 16 | ▶ | return $shim if -e $shim; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||
| 426 | 0 | croak <<"ERROR"; | |||||||||||||||||||||||||||||||||||||
| 427 | Can't locate Mite::Shim in \@INC. \@INC contains: | ||||||||||||||||||||||||||||||||||||||
| 428 | 0 | @{[ map { " $_\n" } grep { !ref($_) } @INC ]} | |||||||||||||||||||||||||||||||||||||
| 429 | ERROR | ||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||
| 432 | 9 | ▶ | sub write_default_config { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
write_default_config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 433 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 434 | 9 | my $project_name = Str->(shift); | |||||||||||||||||||||||||||||||||||||
| 435 | 9 | my %args = @_; | |||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||
| 437 | 9 | my $libdir = Path::Tiny::path('lib'); | |||||||||||||||||||||||||||||||||||||
| 438 | 9 | $self->config->write_config({ | |||||||||||||||||||||||||||||||||||||
| 439 | project => $project_name, | ||||||||||||||||||||||||||||||||||||||
| 440 | shim => $project_name.'::Mite', | ||||||||||||||||||||||||||||||||||||||
| 441 | source_from => $libdir.'', | ||||||||||||||||||||||||||||||||||||||
| 442 | compiled_to => $libdir.'', | ||||||||||||||||||||||||||||||||||||||
| 443 | %args | ||||||||||||||||||||||||||||||||||||||
| 444 | }); | ||||||||||||||||||||||||||||||||||||||
| 445 | 9 | return; | |||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||
| 448 | { | ||||||||||||||||||||||||||||||||||||||
| 449 | # Get/set the default for a class | ||||||||||||||||||||||||||||||||||||||
| 450 | 115 | my %Defaults; | |||||||||||||||||||||||||||||||||||||
| 451 | 266 | ▶ | sub default { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 452 | 266 | my $class = shift; | |||||||||||||||||||||||||||||||||||||
| 453 | 266 | ▶ | return $Defaults{$class} ||= $class->new; | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$Defaults{$class} ||= $class->new
MC/DC0%0/2
$Defaults{$class} ||= $class->new
$Defaults{$class}
$class->new
Truth table66%2/3
A ||= B
A= $Defaults{$class}B= $class->new
| |||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||
| 456 | 1 | ▶ | sub set_default { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
set_default: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 457 | 1 | my ( $class, $new_default ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||
| 458 | 1 | $Defaults{$class} = $new_default; | |||||||||||||||||||||||||||||||||||||
| 459 | 1 | return; | |||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||
| 463 | 115 | 1; | |||||||||||||||||||||||||||||||||||||