line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zooky::DistIni; |
2
|
|
|
|
|
|
|
$Dist::Zooky::DistIni::VERSION = '0.24'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Generates a Dist::Zilla dist.ini file |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1265
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
6
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
7
|
2
|
|
|
2
|
|
727
|
use Class::Load (); |
|
2
|
|
|
|
|
23173
|
|
|
2
|
|
|
|
|
44
|
|
8
|
2
|
|
|
2
|
|
860
|
use Moose; |
|
2
|
|
|
|
|
748459
|
|
|
2
|
|
|
|
|
46
|
|
9
|
2
|
|
|
2
|
|
14881
|
use Module::Load::Conditional qw[check_install]; |
|
2
|
|
|
|
|
30099
|
|
|
2
|
|
|
|
|
136
|
|
10
|
2
|
|
|
2
|
|
799
|
use Module::Pluggable search_path => 'Dist::Zooky::DistIni', except => 'Dist::Zooky::DistIni::Prereqs'; |
|
2
|
|
|
|
|
12198
|
|
|
2
|
|
|
|
|
13
|
|
11
|
2
|
|
|
2
|
|
963
|
use Dist::Zooky::DistIni::Prereqs; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
713
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::TextTemplate'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'type' => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
isa => 'Str', |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'metadata' => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => 'HashRef', |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'bundle' => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => 'Str', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $temphead = |
33
|
|
|
|
|
|
|
q|name = {{ $name }} |
34
|
|
|
|
|
|
|
version = {{ $version }} |
35
|
|
|
|
|
|
|
{{ $OUT .= join "\n", map { "author = $_" } @authors; }} |
36
|
|
|
|
|
|
|
{{ $OUT .= join "\n", map { "license = $_" } @licenses; }} |
37
|
|
|
|
|
|
|
{{ ( my $holder = $authors[0] ) =~ s/\s*\<.+?\>\s*//g; "copyright_holder = $holder"; }} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $tempstd = |
42
|
|
|
|
|
|
|
q|[GatherDir] |
43
|
|
|
|
|
|
|
[PruneCruft] |
44
|
|
|
|
|
|
|
[ManifestSkip] |
45
|
|
|
|
|
|
|
[MetaYAML] |
46
|
|
|
|
|
|
|
[MetaJSON] |
47
|
|
|
|
|
|
|
[License] |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
{{ -e 'README' ? ';[Readme]' : '[Readme]'; }} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
[ExecDir] |
52
|
|
|
|
|
|
|
{{ $OUT = "dir = scripts" if -d 'scripts' }} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
[ExtraTests] |
55
|
|
|
|
|
|
|
[ShareDir] |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
{{ $OUT .= +( $type eq 'ModBuild' ? '[ModuleBuild]' : '[MakeMaker]' ) }} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
[Manifest] |
60
|
|
|
|
|
|
|
[TestRelease] |
61
|
|
|
|
|
|
|
[ConfirmRelease] |
62
|
|
|
|
|
|
|
[UploadToCPAN]|; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub write { |
65
|
2
|
|
|
2
|
1
|
839
|
my $self = shift; |
66
|
2
|
|
50
|
|
|
9
|
my $file = shift || 'dist.ini'; |
67
|
2
|
|
|
|
|
5
|
my %stash; |
68
|
2
|
|
|
|
|
59
|
$stash{type} = $self->type; |
69
|
|
|
|
|
|
|
$stash{$_} = $self->metadata->{prereqs}->{$_}->{requires} |
70
|
2
|
|
|
|
|
51
|
for qw(configure build runtime); |
71
|
2
|
|
|
|
|
52
|
$stash{$_} = $self->metadata->{$_} for qw(author license version name); |
72
|
2
|
|
|
|
|
14
|
$stash{"${_}s"} = delete $stash{$_} for qw(author license); |
73
|
2
|
100
|
|
|
|
46
|
my $template = $temphead . ( $self->bundle ? q|[@| . $self->bundle . qq|]| : $tempstd ) . "\n"; |
74
|
2
|
|
|
|
|
13
|
my $content = $self->fill_in_string( |
75
|
|
|
|
|
|
|
$template, |
76
|
|
|
|
|
|
|
\%stash, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
3701
|
foreach my $plugin ( $self->plugins ) { |
80
|
4
|
|
|
|
|
4270
|
Class::Load::load_class( $plugin ); |
81
|
4
|
|
|
|
|
237
|
my $add = $plugin->new( type => $self->type, metadata => $self->metadata )->content; |
82
|
4
|
50
|
|
|
|
107
|
next unless $add; |
83
|
0
|
|
|
|
|
0
|
$content = join "\n", $content, $add; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
46
|
my $prereqs = Dist::Zooky::DistIni::Prereqs->new( type => $self->type, metadata => $self->metadata )->content; |
87
|
2
|
50
|
|
|
|
70
|
$content = join("\n", $content, $prereqs) if $prereqs; |
88
|
|
|
|
|
|
|
|
89
|
2
|
50
|
|
|
|
214
|
open my $ini, '>', $file or die "Could not open '$file': $!\n"; |
90
|
2
|
|
|
|
|
14
|
print $ini $content; |
91
|
2
|
|
|
|
|
101
|
close $ini; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
95
|
2
|
|
|
2
|
|
21
|
no Moose; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
qq[And Dist::Zooky too!]; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=pod |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=encoding UTF-8 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 NAME |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Dist::Zooky::DistIni - Generates a Dist::Zilla dist.ini file |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 VERSION |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
version 0.24 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SYNOPSIS |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $meta = { |
116
|
|
|
|
|
|
|
type => 'MakeMaker', |
117
|
|
|
|
|
|
|
name => 'Foo-Bar', |
118
|
|
|
|
|
|
|
version => '0.02', |
119
|
|
|
|
|
|
|
author => [ 'Duck Dodgers', 'Ivor Biggun' ], |
120
|
|
|
|
|
|
|
license => [ 'Perl_5' ], |
121
|
|
|
|
|
|
|
prereqs => { |
122
|
|
|
|
|
|
|
'runtime' => { |
123
|
|
|
|
|
|
|
'requires' => { 'Moo::Cow' => '0.19' }, |
124
|
|
|
|
|
|
|
}, |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
my $distini = Dist::Zooky::DistIni->new( metadata => $meta ); |
129
|
|
|
|
|
|
|
$distini->write(); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 DESCRIPTION |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Dist::Zooky::DistIni takes meta data and writes a L<Dist::Zilla> C<dist.ini> file. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
These attributes are passed to DistIni plugins. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item C<type> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
A required attribute, the type of distribution, C<MakeMaker> for L<ExtUtils::MakeMaker> or |
144
|
|
|
|
|
|
|
L<Module::Install> ( yeah, I know ) based distributions, or C<ModBuild> for L<Module::Build> |
145
|
|
|
|
|
|
|
based distributions. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item C<metadata> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
A required attribute. This is a C<HASHREF> of meta data. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 METHODS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item C<write> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Writes a C<dist.ini> file with the provides C<metadata>. Takes an optional parameter, which is the filename |
160
|
|
|
|
|
|
|
to write to, the default being C<dist.ini>. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=back |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 NAME |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Dist::Zooky::DistIni - Generates a Dist::Zilla dist.ini file |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Chris Williams <chris@bingosnet.co.uk> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Chris Williams. |
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 |