line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Prereqs::FromCPANfile; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
969651
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
455
|
use Module::CPANfile; |
|
1
|
|
|
|
|
5949
|
|
|
1
|
|
|
|
|
47
|
|
7
|
1
|
|
|
1
|
|
7
|
use Try::Tiny; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
65
|
|
8
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::PrereqSource', 'Dist::Zilla::Role::MetaProvider'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has cpanfile => (is => 'ro', lazy => 1, builder => '_build_cpanfile'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _build_cpanfile { |
14
|
1
|
|
|
1
|
|
4
|
my $self = shift; |
15
|
|
|
|
|
|
|
|
16
|
1
|
50
|
|
|
|
43
|
return unless -e 'cpanfile'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
try { |
19
|
1
|
|
|
1
|
|
72
|
$self->log("Parsing 'cpanfile' to extract prereqs"); |
20
|
1
|
|
|
|
|
491
|
Module::CPANfile->load; |
21
|
|
|
|
|
|
|
} catch { |
22
|
0
|
|
|
0
|
|
0
|
$self->log_fatal($_); |
23
|
1
|
|
|
|
|
28
|
}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub register_prereqs { |
27
|
1
|
|
|
1
|
0
|
81559
|
my $self = shift; |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
|
|
65
|
my $cpanfile = $self->cpanfile or return; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
4
|
my $prereqs = $cpanfile->prereq_specs; |
32
|
1
|
|
|
|
|
1442
|
for my $phase (keys %$prereqs) { |
33
|
2
|
|
|
|
|
575
|
for my $type (keys %{$prereqs->{$phase}}) { |
|
2
|
|
|
|
|
8
|
|
34
|
3
|
|
|
|
|
42
|
$self->zilla->register_prereqs( |
35
|
|
|
|
|
|
|
{ type => $type, phase => $phase }, |
36
|
3
|
|
|
|
|
288
|
%{$prereqs->{$phase}{$type}}, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub metadata { |
43
|
1
|
|
|
1
|
0
|
9132
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
46
|
my $cpanfile = $self->cpanfile or return {}; |
46
|
1
|
50
|
|
|
|
6
|
my @features = $cpanfile->features or return {}; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
2014
|
my $features = {}; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
3
|
for my $feature (@features) { |
51
|
2
|
|
|
|
|
587
|
$features->{$feature->identifier} = { |
52
|
|
|
|
|
|
|
description => $feature->description, |
53
|
|
|
|
|
|
|
prereqs => $feature->prereqs->as_string_hash, |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
550
|
return { optional_features => $features }; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
61
|
1
|
|
|
1
|
|
6178
|
no Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding utf-8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=for stopwords |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Prereqs::FromCPANfile - Parse cpanfile for prereqs |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# dist.ini |
77
|
|
|
|
|
|
|
[Prereqs::FromCPANfile] |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Prereqs::FromCPANfile is a L<Dist::Zilla> plugin |
82
|
|
|
|
|
|
|
to read I<cpanfile> to determine prerequisites for your distribution. This |
83
|
|
|
|
|
|
|
does the B<opposite of> what L<Dist::Zilla::Plugin::CPANFile> does, which |
84
|
|
|
|
|
|
|
is to I<create> a C<cpanfile> using the prereqs collected elsewhere. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
When C<feature> DSL is used in C<cpanfile>, it will correctly be |
87
|
|
|
|
|
|
|
converted to C<optional_features> in META data. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
B<DO NOT USE THIS PLUGIN IN COMBINATION WITH Plugin::CPANFile>. You will |
90
|
|
|
|
|
|
|
probably be complained about creating duplicate files from dzil. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Copyright 2013- Tatsuhiko Miyagawa |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
103
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<Module::CPANfile> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |