line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Babble; |
2
|
|
|
|
|
|
|
$Dist::Zilla::Plugin::Babble::VERSION = '0.003'; |
3
|
1
|
|
|
1
|
|
3461429
|
use Carp 'croak'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
73
|
|
4
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
7323
|
use MooseX::Types::Moose qw/ArrayRef Str/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
6
|
1
|
|
|
1
|
|
5353
|
use MooseX::Types::Perl qw/StrictVersionStr/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
7
|
1
|
|
|
1
|
|
2326
|
use List::Util 'any'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
678
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileMunger', |
10
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
11
|
|
|
|
|
|
|
default_finders => [ ':InstallModules', ':ExecFiles' ], |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub mvp_multivalue_args { |
15
|
|
|
|
|
|
|
return qw/files plugins/; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub mvp_aliases { |
19
|
|
|
|
|
|
|
return { |
20
|
2
|
|
|
2
|
0
|
415
|
file => 'files', |
21
|
|
|
|
|
|
|
plugin => 'plugins', |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has files => ( |
26
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
27
|
|
|
|
|
|
|
traits => ['Array'], |
28
|
|
|
|
|
|
|
lazy => 1, |
29
|
|
|
|
|
|
|
default => sub { [] }, |
30
|
|
|
|
|
|
|
handles => { |
31
|
|
|
|
|
|
|
files => 'elements', |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has plugins => ( |
36
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
37
|
|
|
|
|
|
|
traits => ['Array'], |
38
|
|
|
|
|
|
|
lazy => 1, |
39
|
|
|
|
|
|
|
builder => '_build_plugins', |
40
|
|
|
|
|
|
|
handles => { |
41
|
|
|
|
|
|
|
plugins => 'elements', |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my %supported_since = ( |
46
|
|
|
|
|
|
|
'::CoreSignatures' => '5.028', |
47
|
|
|
|
|
|
|
'::State' => '5.010', |
48
|
|
|
|
|
|
|
'::DefinedOr' => '5.010', |
49
|
|
|
|
|
|
|
'::PostfixDeref' => '5.020', |
50
|
|
|
|
|
|
|
'::SubstituteAndReturn' => '5.014', |
51
|
|
|
|
|
|
|
'::Ellipsis' => '5.012', |
52
|
|
|
|
|
|
|
'::PackageBlock' => '5.014', |
53
|
|
|
|
|
|
|
'::PackageVersion' => '5.012', |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _build_plugins { |
57
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
58
|
1
|
|
|
|
|
7
|
my @plugins = grep { $supported_since{$_} > $self->for_version } keys %supported_since; |
|
8
|
|
|
|
|
240
|
|
59
|
1
|
|
|
|
|
38
|
return \@plugins; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has for_version => ( |
63
|
|
|
|
|
|
|
is => 'ro', |
64
|
|
|
|
|
|
|
isa => StrictVersionStr, |
65
|
|
|
|
|
|
|
default => '5.008', |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has transformer => ( |
69
|
|
|
|
|
|
|
is => 'ro', |
70
|
|
|
|
|
|
|
init_arg => undef, |
71
|
|
|
|
|
|
|
lazy => 1, |
72
|
|
|
|
|
|
|
builder => '_build_transformer', |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _build_transformer { |
76
|
2
|
|
|
2
|
|
6
|
my $self = shift; |
77
|
2
|
|
|
|
|
607
|
require Babble::PluginChain; |
78
|
2
|
|
|
|
|
84487
|
my $pc = Babble::PluginChain->new; |
79
|
2
|
|
|
|
|
1293
|
$pc->add_plugin($_) for $self->plugins; |
80
|
2
|
|
|
|
|
46794
|
return $pc; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub munge_files { |
84
|
2
|
|
|
2
|
0
|
89950
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
2
|
50
|
|
|
|
89
|
if (my %filename = map { $_ => 1 } $self->files) { |
|
0
|
|
|
|
|
0
|
|
87
|
0
|
|
|
|
|
0
|
foreach my $file (@{ $self->zilla->files }) { |
|
0
|
|
|
|
|
0
|
|
88
|
0
|
0
|
|
|
|
0
|
$self->munge_file($file) if $filename{$file->name}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
2
|
|
|
|
|
7
|
$self->munge_file($_) for @{ $self->found_files }; |
|
2
|
|
|
|
|
14
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
2
|
|
|
|
|
17
|
return; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub munge_file { |
99
|
2
|
|
|
2
|
0
|
3202
|
my ($self, $file) = @_; |
100
|
2
|
|
|
|
|
15
|
my $content = $file->content; |
101
|
2
|
|
|
|
|
2197
|
my $pc = $self->transformer; |
102
|
2
|
50
|
|
|
|
5
|
eval { |
103
|
2
|
|
|
|
|
9
|
$file->content($pc->transform_document($content)); |
104
|
2
|
|
|
|
|
1559938
|
1; |
105
|
|
|
|
|
|
|
} or croak 'Could not munge ' . $file->name . ': ' . $@; |
106
|
2
|
|
|
|
|
43
|
return; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
110
|
1
|
|
|
1
|
|
9
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
'For Science®'; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# ABSTRACT: EXPERIMENTAL Automatic Babble substitution in Dist::Zilla |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4 noet : |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=pod |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=encoding UTF-8 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 NAME |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Babble - EXPERIMENTAL Automatic Babble substitution in Dist::Zilla |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 VERSION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
version 0.003 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SYNOPSIS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
[Babble] |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#or |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
[Babble] |
140
|
|
|
|
|
|
|
for_version = 5.010 # don't translate defined-or or state |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#or |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
[Babble] |
145
|
|
|
|
|
|
|
plugin = ::CoreSignatures # only signature transformation |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 DESCRIPTION |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Are you in need of Damian's Mad Science™? Are you lacking Matt's Voodoo? Do you want to mix all of the complexities of dzil's transformations with that stack? Then you're in the right place. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This module translates various modern Perl langauge features into their older equivalents using L<Babble|Babble>. It is highly experimental, and comes with no warranties whatsoever. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
By default it transforms code to be able to compile on perl C<5.008>. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Leon Timmermans <leont@cpan.org> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Leon Timmermans. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
164
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |