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