line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Base::Lib; |
2
|
4
|
|
|
4
|
|
14237
|
use base 'Mojo::Base'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
1754
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub import { |
7
|
7
|
|
|
7
|
|
15556
|
my $class = shift; |
8
|
|
|
|
|
|
|
#~ return unless my $flag = shift; |
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
|
|
21
|
my ($flag, $findbin,); |
11
|
7
|
|
|
|
|
14
|
my @flags = (); |
12
|
7
|
|
|
|
|
9
|
my @libs = (); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# parse flags |
15
|
7
|
|
66
|
|
|
34
|
while ((my $it = shift) || @_) { |
16
|
12
|
50
|
0
|
|
|
23
|
unshift @_, @$it |
17
|
|
|
|
|
|
|
and next |
18
|
|
|
|
|
|
|
if ref $it eq 'ARRAY'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
next |
21
|
12
|
50
|
33
|
|
|
67
|
unless defined($it) && $it =~ m'/|\w';# / root lib? lets |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# controll flag |
24
|
12
|
100
|
|
|
|
41
|
if ($it =~ s'^(-\w+)'') { |
25
|
|
|
|
|
|
|
|
26
|
7
|
|
|
|
|
17
|
$flag = $1; |
27
|
7
|
100
|
50
|
|
|
42
|
push @flags, $flag |
28
|
|
|
|
|
|
|
and next |
29
|
|
|
|
|
|
|
unless $flag eq '-lib'; |
30
|
|
|
|
|
|
|
|
31
|
3
|
50
|
|
|
|
8
|
unshift @_, split m'[:;]+', $it # -lib:foo;bar |
32
|
|
|
|
|
|
|
if $it; |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
19
|
next; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} else { # non controll |
37
|
|
|
|
|
|
|
|
38
|
5
|
100
|
50
|
|
|
29
|
push @flags, $it |
|
|
|
66
|
|
|
|
|
39
|
|
|
|
|
|
|
and next |
40
|
|
|
|
|
|
|
unless $flag && $flag eq '-lib';# non lib items |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# abs lib |
45
|
4
|
100
|
50
|
|
|
20
|
push @libs, $it |
46
|
|
|
|
|
|
|
and next |
47
|
|
|
|
|
|
|
if $it =~ m'^/'; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# relative lib |
50
|
3
|
|
33
|
|
|
23
|
$findbin ||= do { |
51
|
3
|
|
|
|
|
1297
|
require FindBin; |
52
|
3
|
|
|
|
|
1648
|
$FindBin::Bin; |
53
|
|
|
|
|
|
|
}; |
54
|
3
|
|
|
|
|
24
|
push @libs, $findbin.'/'.$it; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
7
|
100
|
66
|
|
|
23
|
if ( @libs && (my @ok_libs = grep{ my $lib = $_; not scalar grep($lib eq $_, @INC) } @libs) ) { |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
25
|
|
58
|
3
|
|
|
|
|
1203
|
require lib; |
59
|
3
|
|
|
|
|
1343
|
lib->import(@ok_libs); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$flag = shift @flags |
63
|
7
|
100
|
|
|
|
499
|
or return; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Base |
66
|
5
|
100
|
33
|
|
|
30
|
if ($flag eq '-base') { $flag = $class } |
|
1
|
100
|
|
|
|
2
|
|
|
|
50
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Strict |
69
|
3
|
|
|
|
|
3
|
elsif ($flag eq '-strict') { $flag = undef } |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Module |
72
|
|
|
|
|
|
|
elsif ((my $file = $flag) && !$flag->can('new')) { |
73
|
1
|
|
|
|
|
4
|
$file =~ s!::|'!/!g; |
74
|
1
|
|
|
|
|
252
|
require "$file.pm"; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# ISA |
78
|
5
|
100
|
|
|
|
16
|
if ($flag) { |
79
|
2
|
|
|
|
|
4
|
my $caller = caller; |
80
|
4
|
|
|
4
|
|
29652
|
no strict 'refs'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
477
|
|
81
|
2
|
|
|
|
|
1
|
push @{"${caller}::ISA"}, $flag; |
|
2
|
|
|
|
|
19
|
|
82
|
2
|
|
|
0
|
|
12
|
_monkey_patch $caller, 'has', sub { attr($caller, @_) }; |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Mojo modules are strict! |
86
|
5
|
|
|
|
|
81
|
$_->import for qw(strict warnings utf8); |
87
|
5
|
|
|
|
|
1633
|
feature->import(':5.10'); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=encoding utf8 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Доброго всем |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 Mojo::Base::Lib |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! ! |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 VERSION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
0.001 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Mojo::Base::Lib - use Mojo::Base::Lib 'SomeBaseClass',-lib, qw(rel/path/lib /abs/path/lib); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SYNOPSIS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Based on L where you found three forms usage. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This module provide a fourth extended form for add extra lib directories to perl's search path. See |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
use Mojo::Base -lib, qw(rel/path/lib /abs/path/lib); |
118
|
|
|
|
|
|
|
use Mojo::Base -lib, ['lib1', 'lib2']; |
119
|
|
|
|
|
|
|
use Mojo::Base '-lib:lib1:lib2;lib3'; |
120
|
|
|
|
|
|
|
use Mojo::Base -strict, qw(-lib lib1 lib2); |
121
|
|
|
|
|
|
|
use Mojo::Base qw(-base -lib lib1 lib2); |
122
|
|
|
|
|
|
|
use Mojo::Base 'SomeBaseClass', qw(-lib lib1 lib2); |
123
|
|
|
|
|
|
|
use Mojo::Base qw(-lib lib1 lib2), 'SomeBaseClass'; # same above, different order allow |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
For relative lib path will use L module and C<$FindBin::Bin> is prepends to that lib. |
126
|
|
|
|
|
|
|
Libs always applied first even its last on flags list. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
All three L forms works also. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SEE ALSO |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Михаил Че (Mikhail Che), C<< >> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 BUGS / CONTRIBUTING |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Please report any bugs or feature requests at L. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 COPYRIGHT |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Copyright 2016 Mikhail Che. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
147
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |