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