line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
404
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
73
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::lsplugins::Module; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.003001'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Transient data about a traversed plugin/role/module |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
468
|
use Moose qw( has ); |
|
1
|
|
|
|
|
422623
|
|
|
1
|
|
|
|
|
8
|
|
14
|
1
|
|
|
1
|
|
4966
|
use Try::Tiny qw( try catch ); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1102
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'file' => ( is => ro =>, required => 1 ); |
17
|
|
|
|
|
|
|
has 'plugin_root' => ( is => ro =>, required => 1 ); |
18
|
|
|
|
|
|
|
has 'plugin_basename' => ( is => ro =>, required => 1 ); |
19
|
|
|
|
|
|
|
has 'plugin_name' => ( is => ro =>, lazy_build => 1 ); |
20
|
|
|
|
|
|
|
has '_version' => ( is => ro =>, lazy_build => 1 ); |
21
|
|
|
|
|
|
|
has 'version' => ( is => ro =>, lazy_build => 1 ); |
22
|
|
|
|
|
|
|
has 'abstract' => ( is => ro =>, lazy_build => 1 ); |
23
|
|
|
|
|
|
|
has 'roles' => ( is => ro =>, lazy_build => 1 ); |
24
|
|
|
|
|
|
|
has '_module_metadata' => ( is => ro =>, lazy_build => 1 ); |
25
|
|
|
|
|
|
|
has '_loaded_module' => ( is => ro =>, lazy_build => 1 ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _build_plugin_name { |
28
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
29
|
0
|
|
|
|
|
|
my $rpath = $self->file->relative( $self->plugin_root ); |
30
|
0
|
|
|
|
|
|
$rpath =~ s/[.]pm\z//msx; |
31
|
0
|
|
|
|
|
|
$rpath =~ s{/}{::}gmsx; |
32
|
0
|
|
|
|
|
|
return $rpath; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _build_version { |
36
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
37
|
0
|
|
|
|
|
|
my $v = $self->_version; |
38
|
0
|
0
|
|
|
|
|
return $v if defined $v; |
39
|
0
|
|
|
|
|
|
return 'undef'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _build__module_metadata { |
43
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
44
|
0
|
|
|
|
|
|
require Module::Metadata; |
45
|
0
|
|
|
|
|
|
return Module::Metadata->new_from_file( $self->file ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _build__version { |
49
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
50
|
0
|
|
|
|
|
|
return $self->_module_metadata->version; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _build_abstract { |
54
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
55
|
0
|
|
|
|
|
|
require Dist::Zilla::Util; |
56
|
|
|
|
|
|
|
## no critic ( Subroutines::ProtectPrivateSubs ) |
57
|
0
|
|
|
|
|
|
my $e = Dist::Zilla::Util::PEA->_new(); |
58
|
0
|
|
|
|
|
|
$e->read_file( $self->file->stringify ); |
59
|
0
|
|
|
|
|
|
return $e->{abstract}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _build__loaded_module { |
63
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
64
|
0
|
|
|
|
|
|
require Module::Runtime; |
65
|
0
|
|
|
|
|
|
my $module = $self->plugin_basename . q[::] . $self->plugin_name; |
66
|
0
|
|
|
|
|
|
my $failed = 0; |
67
|
|
|
|
|
|
|
try { |
68
|
0
|
|
|
0
|
|
|
Module::Runtime::require_module($module); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
catch { |
71
|
0
|
|
|
0
|
|
|
require Carp; |
72
|
0
|
|
|
|
|
|
Carp::carp( q[Uhoh, ] . $module . q[ failed to load] ); |
73
|
|
|
|
|
|
|
## no critic (ErrorHandling::RequireCarping) |
74
|
0
|
|
|
|
|
|
warn $_; |
75
|
0
|
|
|
|
|
|
$failed = 1; |
76
|
0
|
|
|
|
|
|
}; |
77
|
0
|
0
|
|
|
|
|
return if $failed; |
78
|
0
|
|
|
|
|
|
return $module; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _build_roles { |
82
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
83
|
0
|
|
|
|
|
|
my $module = $self->_loaded_module(); |
84
|
0
|
0
|
|
|
|
|
return [] if not defined $module; |
85
|
0
|
0
|
|
|
|
|
return [] if not $module->can('meta'); |
86
|
0
|
0
|
|
|
|
|
return [] if not $module->meta->can('calculate_all_roles_with_inheritance'); |
87
|
0
|
|
|
|
|
|
my @roles = $module->meta->calculate_all_roles_with_inheritance; |
88
|
0
|
|
|
|
|
|
my @out; |
89
|
0
|
|
|
|
|
|
for my $role (@roles) { |
90
|
0
|
|
|
|
|
|
push @out, $role->name; |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
|
return \@out; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub loaded_module_does { |
105
|
0
|
|
|
0
|
1
|
|
my ( $self, $role ) = @_; |
106
|
0
|
|
|
|
|
|
$role =~ s/\A-/Dist::Zilla::Role::/msx; |
107
|
0
|
0
|
|
|
|
|
return unless $self->_loaded_module; |
108
|
0
|
0
|
|
|
|
|
return unless $self->_loaded_module->can('does'); |
109
|
0
|
|
|
|
|
|
return $self->_loaded_module->does($role); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
1
|
|
7
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
113
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=pod |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=encoding UTF-8 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 NAME |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Dist::Zilla::lsplugins::Module - Transient data about a traversed plugin/role/module |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 VERSION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
version 0.003001 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 METHODS |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 C<loaded_module_does> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Loads the module, using C<_loaded_module>, and returns C<undef> |
135
|
|
|
|
|
|
|
as soon as it can't proceed further. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
If it can proceed to calling C<does>, it will return true if the C<plugin> C<does> the specified role. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 AUTHOR |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
148
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |