line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
10778355
|
use strict; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
132
|
|
2
|
4
|
|
|
4
|
|
25
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
272
|
|
3
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::RewriteVersion::Transitional; # git description: v0.007-12-ge819041 |
4
|
|
|
|
|
|
|
# vim: set ts=8 sts=4 sw=4 tw=115 et : |
5
|
|
|
|
|
|
|
# ABSTRACT: Ease the transition to [RewriteVersion] in your distribution |
6
|
|
|
|
|
|
|
# KEYWORDS: plugin version rewrite munge module |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.008'; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
27
|
use Moose; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
42
|
|
11
|
|
|
|
|
|
|
extends 'Dist::Zilla::Plugin::RewriteVersion'; |
12
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::InsertVersion'; |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
28854
|
use Moose::Util::TypeConstraints 'role_type'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
37
|
|
15
|
4
|
|
|
4
|
|
1929
|
use Dist::Zilla::Util; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
116
|
|
16
|
4
|
|
|
4
|
|
25
|
use Module::Runtime 'use_module'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
30
|
|
17
|
4
|
|
|
4
|
|
2743
|
use Term::ANSIColor 'colored'; |
|
4
|
|
|
|
|
24838
|
|
|
4
|
|
|
|
|
1723
|
|
18
|
4
|
|
|
4
|
|
45
|
use namespace::autoclean; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
48
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has fallback_version_provider => ( |
21
|
|
|
|
|
|
|
is => 'ro', isa => 'Str', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has _fallback_version_provider_args => ( |
25
|
|
|
|
|
|
|
is => 'ro', isa => 'HashRef[Str]', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has _fallback_version_provider_obj => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => role_type('Dist::Zilla::Role::VersionProvider'), |
31
|
|
|
|
|
|
|
lazy => 1, |
32
|
|
|
|
|
|
|
default => sub { |
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
use_module(Dist::Zilla::Util->expand_config_package_name($self->fallback_version_provider))->new( |
35
|
|
|
|
|
|
|
zilla => $self->zilla, |
36
|
|
|
|
|
|
|
plugin_name => 'fallback version provider, via [RewriteVersion::Transitional]', |
37
|
|
|
|
|
|
|
%{ $self->_fallback_version_provider_args }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
predicate => '_using_fallback_version_provider', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
around BUILDARGS => sub |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
my $orig = shift; |
46
|
|
|
|
|
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $args = $self->$orig(@_); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my %extra_args = %$args; |
51
|
|
|
|
|
|
|
delete @extra_args{ map { $_->name } $self->meta->get_all_attributes }; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return +{ %$args, _fallback_version_provider_args => \%extra_args }; |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
around dump_config => sub |
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
59
|
|
|
|
|
|
|
my $config = $self->$orig; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$config->{+__PACKAGE__} = { |
62
|
|
|
|
|
|
|
$self->_using_fallback_version_provider |
63
|
|
|
|
|
|
|
? ( map { $_ => $self->$_ } qw(fallback_version_provider _fallback_version_provider_args) ) |
64
|
|
|
|
|
|
|
: (), |
65
|
|
|
|
|
|
|
blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (), |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$config->{ $self->fallback_version_provider } = $self->_fallback_version_provider_obj->dump_config |
69
|
|
|
|
|
|
|
if $self->_using_fallback_version_provider; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return $config; |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
around provide_version => sub |
75
|
|
|
|
|
|
|
{ |
76
|
|
|
|
|
|
|
my $orig = shift; |
77
|
|
|
|
|
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
return if $self->can('skip_version_provider') and $self->skip_version_provider; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $version = $self->$orig(@_); |
82
|
|
|
|
|
|
|
return $version if defined $version; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->log([ 'no version found in environment or file; falling back to %s', $self->fallback_version_provider ]); |
85
|
|
|
|
|
|
|
return $self->_fallback_version_provider_obj->provide_version; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $warned_underscore; |
89
|
|
|
|
|
|
|
around rewrite_version => sub |
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
my $orig = shift; |
92
|
|
|
|
|
|
|
my $self = shift; |
93
|
|
|
|
|
|
|
my ($file, $version) = @_; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$self->log([ |
96
|
|
|
|
|
|
|
colored('%s is a dangerous $VERSION to use without stripping the underscore on a subsequent line!', 'yellow'), |
97
|
|
|
|
|
|
|
$version, |
98
|
|
|
|
|
|
|
]) if $version =~ /_/ and not $warned_underscore++; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# update existing our $VERSION = '...'; entry |
101
|
|
|
|
|
|
|
return 1 if $self->$orig($file, $version); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return $self->insert_version($file, $version, $self->zilla->is_trial); |
104
|
|
|
|
|
|
|
}; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=pod |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=encoding UTF-8 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 NAME |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Dist::Zilla::Plugin::RewriteVersion::Transitional - Ease the transition to [RewriteVersion] in your distribution |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 VERSION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
version 0.008 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SYNOPSIS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
In your F<dist.ini>: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
[RewriteVersion::Transitional] |
127
|
|
|
|
|
|
|
fallback_version_provider = Git::NextVersion |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 DESCRIPTION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=for stopwords BumpVersionAfterRelease OurPkgVersion PkgVersion |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This is a L<Dist::Zilla> plugin that subclasses |
134
|
|
|
|
|
|
|
L<[RewriteVersion]|Dist::Zilla::Plugin::RewriteVersion>, to allow plugin |
135
|
|
|
|
|
|
|
bundles to transition from L<[PkgVersion]|Dist::Zilla::Plugin::PkgVersion> or |
136
|
|
|
|
|
|
|
L<[OurPkgVersion]|Dist::Zilla::Plugin::OurPkgVersion> to |
137
|
|
|
|
|
|
|
L<[RewriteVersion]|Dist::Zilla::Plugin::RewriteVersion> |
138
|
|
|
|
|
|
|
and L<[BumpVersionAfterRelease]|Dist::Zilla::Plugin::BumpVersionAfterRelease> |
139
|
|
|
|
|
|
|
without having to manually edit the F<dist.ini> or any F<.pm> files. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 Determining the distribution version |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
As with L<[RewriteVersion]|Dist::Zilla::Plugin::RewriteVersion>, the version |
144
|
|
|
|
|
|
|
can be overridden with the C<V> environment variable, or provided through some |
145
|
|
|
|
|
|
|
other means by setting C<skip_version_provider = 1>. Then, the main module (see |
146
|
|
|
|
|
|
|
L<Dist::Zilla/main module>) in the distribution is checked for a C<$VERSION> |
147
|
|
|
|
|
|
|
assignment. If one is not found, then the plugin named by the |
148
|
|
|
|
|
|
|
C<fallback_version_provider> is instantiated (with any extra configuration |
149
|
|
|
|
|
|
|
options provided) and called to determine the version. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 Munging the modules |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
When used in a distribution where the F<.pm> file(s) does not contain a |
154
|
|
|
|
|
|
|
C<$VERSION> declaration, this plugin will add one. If one is already present, |
155
|
|
|
|
|
|
|
it leaves it alone, acting just as |
156
|
|
|
|
|
|
|
L<[RewriteVersion]|Dist::Zilla::Plugin::RewriteVersion> would. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
You would then use L<[BumpVersionAfterRelease::Transitional]|Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional> |
159
|
|
|
|
|
|
|
to increment the C<$VERSION> in the F<.pm> files in the repository. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
B<Note:> If there is more than one package in a single file, if there was |
162
|
|
|
|
|
|
|
I<any> C<$VERSION> declaration in the file, no additional declarations are |
163
|
|
|
|
|
|
|
added for the other packages, even if you are using the C<global> option. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 CONFIGURATION OPTIONS |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Configuration is the same as in |
168
|
|
|
|
|
|
|
L<[RewriteVersion]|Dist::Zilla::Plugin::RewriteVersion>, with the addition of: |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 fallback_version_provider |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Specify the name (in abbreviated form) of the plugin to use as a version |
173
|
|
|
|
|
|
|
provider if the version was not already set with the C<V> environment |
174
|
|
|
|
|
|
|
variable. Not used if |
175
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::RewriteVersion/skip_version_provider> is true. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Don't forget to add this plugin as a runtime-requires prerequisite in your |
178
|
|
|
|
|
|
|
plugin bundle! |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SEE ALSO |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=over 4 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::PkgVersion> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item * |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::RewriteVersion> |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::BumpVersionAfterRelease> |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=back |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 SUPPORT |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-RewriteVersion-Transitional> |
201
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-RewriteVersion-Transitional@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-RewriteVersion-Transitional@rt.cpan.org>). |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
204
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
207
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
I am also usually active on irc, as 'ether' at C<irc.perl.org>. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 AUTHOR |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Karen Etheridge. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
220
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=cut |