line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
34219
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
118
|
|
2
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
166
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Module::Data; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
3
|
|
|
3
|
|
103
|
$Module::Data::AUTHORITY = 'cpan:KENTNL'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$Module::Data::VERSION = '0.012'; # TRIAL |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Introspect context information about modules in @INC |
13
|
3
|
|
|
3
|
|
6943
|
use Moo; |
|
3
|
|
|
|
|
80918
|
|
|
3
|
|
|
|
|
25
|
|
14
|
3
|
|
|
3
|
|
10426
|
use Sub::Quote; |
|
3
|
|
|
|
|
12326
|
|
|
3
|
|
|
|
|
2782
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
around BUILDARGS => sub { |
17
|
|
|
|
|
|
|
my ( $orig, $class, @args ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
unshift @args, 'package' if @args % 2 == 1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
return $class->$orig(@args); |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has package => ( |
27
|
|
|
|
|
|
|
required => 1, |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => quote_sub q{} |
30
|
|
|
|
|
|
|
. q{die "given undef for 'package' , expects a Str/module name" if not defined $_[0];} |
31
|
|
|
|
|
|
|
. q{die " ( 'package' => $_[0] ) is not a Str/module name, got a ref : " . ref $_[0] if ref $_[0];} |
32
|
|
|
|
|
|
|
. q{require Module::Runtime;} |
33
|
|
|
|
|
|
|
. q{Module::Runtime::check_module_name( $_[0] );}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has _notional_name => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
lazy => 1, |
39
|
|
|
|
|
|
|
default => quote_sub q{} . q{require Module::Runtime;} . q{return Module::Runtime::module_notional_filename( $_[0]->package );}, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub loaded { |
44
|
3
|
|
|
3
|
1
|
7
|
my ($self) = @_; |
45
|
3
|
|
|
|
|
36
|
return exists $INC{ $self->_notional_name }; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
## no critic ( ProhibitBuiltinHomonyms ) |
50
|
|
|
|
|
|
|
sub require { |
51
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
52
|
0
|
0
|
|
|
|
0
|
return $self->package if $self->loaded; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
require Module::Runtime; |
55
|
0
|
|
|
|
|
0
|
Module::Runtime::require_module( $self->package ); |
56
|
0
|
|
|
|
|
0
|
return $self->package; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _find_module_perl { |
60
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
61
|
0
|
|
|
|
|
0
|
$self->require; |
62
|
0
|
|
|
|
|
0
|
return $INC{ $self->_notional_name }; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _find_module_emulate { |
66
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
67
|
0
|
|
|
|
|
0
|
require Path::ScanINC; |
68
|
0
|
|
|
|
|
0
|
Path::ScanINC->VERSION('0.011'); |
69
|
0
|
|
|
|
|
0
|
return Path::ScanINC->new()->first_file( $self->_notional_name ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _find_module_optimistic { |
73
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
74
|
1
|
50
|
|
|
|
4
|
return $INC{ $self->_notional_name } if $self->loaded; |
75
|
0
|
|
|
|
|
0
|
return $self->_find_module_emulate; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
## use critic |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
has path => ( |
82
|
|
|
|
|
|
|
is => 'ro', |
83
|
|
|
|
|
|
|
lazy => 1, |
84
|
|
|
|
|
|
|
init_arg => undef, |
85
|
|
|
|
|
|
|
builder => '_build_path', |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _build_path { |
89
|
1
|
|
|
1
|
|
341
|
my ( $self, ) = @_; |
90
|
1
|
|
|
|
|
5
|
my $value = $self->_find_module_optimistic; |
91
|
1
|
50
|
|
|
|
507
|
return if not defined $value; |
92
|
1
|
|
|
|
|
1129
|
require Path::Tiny; |
93
|
1
|
|
|
|
|
14324
|
return Path::Tiny::path( $value )->absolute; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has root => ( |
98
|
|
|
|
|
|
|
is => 'ro', |
99
|
|
|
|
|
|
|
lazy => 1, |
100
|
|
|
|
|
|
|
init_arg => undef, |
101
|
|
|
|
|
|
|
builder => '_build_root', |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _build_root { |
105
|
1
|
|
|
1
|
|
1232
|
my ($path) = $_[0]->path; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Parent ne Self is the only cross-platform way |
108
|
|
|
|
|
|
|
# I can think of that will stop at the top of a tree |
109
|
|
|
|
|
|
|
# as / is not applicable on windows. |
110
|
1
|
|
|
|
|
130
|
while ( $path->parent->absolute ne $path->absolute ) { |
111
|
3
|
100
|
|
|
|
260
|
if ( not $path->is_dir ) { |
112
|
1
|
|
|
|
|
56
|
$path = $path->parent; |
113
|
1
|
|
|
|
|
33
|
next; |
114
|
|
|
|
|
|
|
} |
115
|
2
|
100
|
|
|
|
124
|
if ( $path->child( $_[0]->_notional_name )->absolute eq $_[0]->path->absolute ) { |
116
|
1
|
|
|
|
|
178
|
return $path->absolute; |
117
|
|
|
|
|
|
|
} |
118
|
1
|
|
|
|
|
139
|
$path = $path->parent; |
119
|
|
|
|
|
|
|
} |
120
|
0
|
|
|
|
|
0
|
return; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _version_perl { |
126
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
127
|
0
|
|
|
|
|
0
|
$self->require; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# has to load the code into memory to work |
130
|
0
|
|
|
|
|
0
|
return $self->package->VERSION; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub _version_emulate { |
134
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
135
|
0
|
|
|
|
|
0
|
my $path = $self->path; |
136
|
0
|
|
|
|
|
0
|
require Module::Metadata; |
137
|
0
|
|
|
|
|
0
|
my $i = Module::Metadata->new_from_file( $path, collect_pod => 0 ); |
138
|
0
|
|
|
|
|
0
|
return $i->version( $self->package ); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub _version_optimistic { |
142
|
2
|
|
|
2
|
|
4
|
my ($self) = @_; |
143
|
2
|
50
|
|
|
|
6
|
return $self->package->VERSION if $self->loaded; |
144
|
0
|
|
|
|
|
0
|
return $self->_version_emulate; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub version { |
148
|
2
|
|
|
2
|
1
|
120
|
my ( $self, @junk ) = @_; |
149
|
2
|
|
|
|
|
7
|
return $self->_version_optimistic; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
3
|
|
|
3
|
|
28
|
no Moo; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
27
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
__END__ |