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