line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: a simple module-from-template plugin |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Moose; |
4
|
2
|
|
|
2
|
|
1339
|
with 'Dist::Zilla::Role::ModuleMaker', |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
18
|
|
5
|
|
|
|
|
|
|
'Dist::Zilla::Role::TextTemplate'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Dist::Zilla::Pragmas; |
8
|
2
|
|
|
2
|
|
14691
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
23
|
|
9
|
|
|
|
|
|
|
use Dist::Zilla::Path; |
10
|
2
|
|
|
2
|
|
16
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
19
|
|
11
|
|
|
|
|
|
|
use namespace::autoclean; |
12
|
2
|
|
|
2
|
|
668
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
19
|
|
13
|
|
|
|
|
|
|
use autodie; |
14
|
2
|
|
|
2
|
|
186
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
51
|
|
15
|
|
|
|
|
|
|
use Sub::Exporter::ForMethods; |
16
|
2
|
|
|
2
|
|
12182
|
use Data::Section 0.200002 # encoding and bytes |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
38
|
|
17
|
|
|
|
|
|
|
{ installer => Sub::Exporter::ForMethods::method_installer }, |
18
|
2
|
|
|
|
|
23
|
'-setup'; |
19
|
2
|
|
|
2
|
|
475
|
use Dist::Zilla::File::InMemory; |
|
2
|
|
|
|
|
63
|
|
20
|
2
|
|
|
2
|
|
2931
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
728
|
|
21
|
|
|
|
|
|
|
#pod =head1 MINTING CONFIGURATION |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod This module is part of the standard configuration of the default L<Dist::Zilla> |
24
|
|
|
|
|
|
|
#pod Minting Profile, and all profiles that don't set a custom ':DefaultModuleMaker' |
25
|
|
|
|
|
|
|
#pod so you don't need to normally do anything to configure it. |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod dzil new Some::Module |
28
|
|
|
|
|
|
|
#pod # creates ./Some-Module/* |
29
|
|
|
|
|
|
|
#pod # creates ./Some-Module/lib/Some/Module.pm |
30
|
|
|
|
|
|
|
#pod |
31
|
|
|
|
|
|
|
#pod However, for those who wish to configure this ( or any subclasses ) this is |
32
|
|
|
|
|
|
|
#pod presently required: |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod [TemplateModule / :DefaultModuleMaker] |
35
|
|
|
|
|
|
|
#pod ; template = SomeFile.pm |
36
|
|
|
|
|
|
|
#pod |
37
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
38
|
|
|
|
|
|
|
#pod |
39
|
|
|
|
|
|
|
#pod This is a L<ModuleMaker|Dist::Zilla::Role::ModuleMaker> used for creating new |
40
|
|
|
|
|
|
|
#pod Perl modules files when minting a new dist with C<dzil new>. It uses |
41
|
|
|
|
|
|
|
#pod L<Text::Template> (via L<Dist::Zilla::Role::TextTemplate>) to render a template |
42
|
|
|
|
|
|
|
#pod into a Perl module. The template is given two variables for use in rendering: |
43
|
|
|
|
|
|
|
#pod C<$name>, the module name; and C<$dist>, the Dist::Zilla object. The module is |
44
|
|
|
|
|
|
|
#pod always created as a file under F<./lib>. |
45
|
|
|
|
|
|
|
#pod |
46
|
|
|
|
|
|
|
#pod By default, the template looks something like this: |
47
|
|
|
|
|
|
|
#pod |
48
|
|
|
|
|
|
|
#pod use strict; |
49
|
|
|
|
|
|
|
#pod use warnings; |
50
|
|
|
|
|
|
|
#pod package {{ $name }}; |
51
|
|
|
|
|
|
|
#pod |
52
|
|
|
|
|
|
|
#pod 1; |
53
|
|
|
|
|
|
|
#pod |
54
|
|
|
|
|
|
|
#pod =attr template |
55
|
|
|
|
|
|
|
#pod |
56
|
|
|
|
|
|
|
#pod The C<template> parameter may be given to the plugin to provide a different |
57
|
|
|
|
|
|
|
#pod filename, absolute or relative to the build/profile directory. |
58
|
|
|
|
|
|
|
#pod |
59
|
|
|
|
|
|
|
#pod If this parameter is not specified, this module will use the boilerplate module |
60
|
|
|
|
|
|
|
#pod template included in this module. |
61
|
|
|
|
|
|
|
#pod |
62
|
|
|
|
|
|
|
#pod =cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has template => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
isa => 'Str', |
67
|
|
|
|
|
|
|
predicate => 'has_template', |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my ($self, $arg) = @_; |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
2
|
0
|
7
|
my $template; |
73
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
12
|
if ($self->has_template) { |
75
|
|
|
|
|
|
|
$template = path( $self->template )->slurp_utf8; |
76
|
2
|
50
|
|
|
|
79
|
} else { |
77
|
0
|
|
|
|
|
0
|
$template = ${ $self->section_data('Module.pm') }; |
78
|
|
|
|
|
|
|
} |
79
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
15
|
|
80
|
|
|
|
|
|
|
my $content = $self->fill_in_string( |
81
|
|
|
|
|
|
|
$template, |
82
|
|
|
|
|
|
|
{ |
83
|
|
|
|
|
|
|
dist => \($self->zilla), |
84
|
|
|
|
|
|
|
name => $arg->{name}, |
85
|
|
|
|
|
|
|
}, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
2
|
|
|
|
|
802
|
my $filename = $arg->{name} =~ s{::}{/}gr; |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
16
|
my $file = Dist::Zilla::File::InMemory->new({ |
91
|
|
|
|
|
|
|
name => "lib/$filename.pm", |
92
|
2
|
|
|
|
|
95
|
content => $content, |
93
|
|
|
|
|
|
|
}); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$self->add_file($file); |
96
|
|
|
|
|
|
|
} |
97
|
2
|
|
|
|
|
15
|
|
98
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=pod |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=encoding UTF-8 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 NAME |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Dist::Zilla::Plugin::TemplateModule - a simple module-from-template plugin |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 VERSION |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
version 6.028 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 DESCRIPTION |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This is a L<ModuleMaker|Dist::Zilla::Role::ModuleMaker> used for creating new |
116
|
|
|
|
|
|
|
Perl modules files when minting a new dist with C<dzil new>. It uses |
117
|
|
|
|
|
|
|
L<Text::Template> (via L<Dist::Zilla::Role::TextTemplate>) to render a template |
118
|
|
|
|
|
|
|
into a Perl module. The template is given two variables for use in rendering: |
119
|
|
|
|
|
|
|
C<$name>, the module name; and C<$dist>, the Dist::Zilla object. The module is |
120
|
|
|
|
|
|
|
always created as a file under F<./lib>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
By default, the template looks something like this: |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
use strict; |
125
|
|
|
|
|
|
|
use warnings; |
126
|
|
|
|
|
|
|
package {{ $name }}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 PERL VERSION |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
133
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
134
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
135
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
138
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
139
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
140
|
|
|
|
|
|
|
the minimum required perl. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 template |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
The C<template> parameter may be given to the plugin to provide a different |
147
|
|
|
|
|
|
|
filename, absolute or relative to the build/profile directory. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
If this parameter is not specified, this module will use the boilerplate module |
150
|
|
|
|
|
|
|
template included in this module. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 MINTING CONFIGURATION |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This module is part of the standard configuration of the default L<Dist::Zilla> |
155
|
|
|
|
|
|
|
Minting Profile, and all profiles that don't set a custom ':DefaultModuleMaker' |
156
|
|
|
|
|
|
|
so you don't need to normally do anything to configure it. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
dzil new Some::Module |
159
|
|
|
|
|
|
|
# creates ./Some-Module/* |
160
|
|
|
|
|
|
|
# creates ./Some-Module/lib/Some/Module.pm |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
However, for those who wish to configure this ( or any subclasses ) this is |
163
|
|
|
|
|
|
|
presently required: |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
[TemplateModule / :DefaultModuleMaker] |
166
|
|
|
|
|
|
|
; template = SomeFile.pm |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo SIGNES. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
177
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
__[ Module.pm ]__ |
182
|
|
|
|
|
|
|
use strict; |
183
|
|
|
|
|
|
|
use warnings; |
184
|
|
|
|
|
|
|
package {{ $name }}; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
1; |