| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
3
|
|
|
3
|
|
2472616
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
106
|
|
|
2
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
233
|
|
|
3
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::RewriteVersion::Transitional; # git description: v0.006-2-gc821b7b |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Ease the transition to [RewriteVersion] in your distribution |
|
5
|
|
|
|
|
|
|
# KEYWORDS: plugin version rewrite munge module |
|
6
|
|
|
|
|
|
|
# vim: set ts=8 sts=4 sw=4 tw=115 et : |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
18
|
use Moose; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
|
|
extends 'Dist::Zilla::Plugin::RewriteVersion'; |
|
12
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::InsertVersion'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
18250
|
use Moose::Util::TypeConstraints 'role_type'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
31
|
|
|
15
|
3
|
|
|
3
|
|
1299
|
use Dist::Zilla::Util; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
94
|
|
|
16
|
3
|
|
|
3
|
|
16
|
use Module::Runtime 'use_module'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
28
|
|
|
17
|
3
|
|
|
3
|
|
2661
|
use Term::ANSIColor 'colored'; |
|
|
3
|
|
|
|
|
21294
|
|
|
|
3
|
|
|
|
|
1557
|
|
|
18
|
3
|
|
|
3
|
|
35
|
use namespace::autoclean; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
34
|
|
|
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
|
|
|
|
|
|
|
}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$config->{ $self->fallback_version_provider } = $self->_fallback_version_provider_obj->dump_config |
|
68
|
|
|
|
|
|
|
if $self->_using_fallback_version_provider; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return $config; |
|
71
|
|
|
|
|
|
|
}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
around provide_version => sub |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
|
|
|
|
|
|
my $orig = shift; |
|
76
|
|
|
|
|
|
|
my $self = shift; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return if $self->can('skip_version_provider') and $self->skip_version_provider; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $version = $self->$orig(@_); |
|
81
|
|
|
|
|
|
|
return $version if defined $version; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$self->log([ 'no version found in environment or file; falling back to %s', $self->fallback_version_provider ]); |
|
84
|
|
|
|
|
|
|
return $self->_fallback_version_provider_obj->provide_version; |
|
85
|
|
|
|
|
|
|
}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $warned_underscore; |
|
88
|
|
|
|
|
|
|
around rewrite_version => sub |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
|
|
|
|
|
|
my $orig = shift; |
|
91
|
|
|
|
|
|
|
my $self = shift; |
|
92
|
|
|
|
|
|
|
my ($file, $version) = @_; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$self->log([ |
|
95
|
|
|
|
|
|
|
colored('%s is a dangerous $VERSION to use without stripping the underscore on a subsequent line!', 'yellow'), |
|
96
|
|
|
|
|
|
|
$version, |
|
97
|
|
|
|
|
|
|
]) if $version =~ /_/ and not $warned_underscore++; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# update existing our $VERSION = '...'; entry |
|
100
|
|
|
|
|
|
|
return 1 if $self->$orig($file, $version); |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
return $self->insert_version($file, $version, $self->zilla->is_trial); |
|
103
|
|
|
|
|
|
|
}; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=pod |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=encoding UTF-8 |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 NAME |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Dist::Zilla::Plugin::RewriteVersion::Transitional - Ease the transition to [RewriteVersion] in your distribution |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 VERSION |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
version 0.007 |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
In your F<dist.ini>: |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
[RewriteVersion::Transitional] |
|
126
|
|
|
|
|
|
|
fallback_version_provider = Git::NextVersion |
|
127
|
|
|
|
|
|
|
version_regexp = ^v([\d._]+)$ |
|
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 SUPPORT |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=for stopwords irc |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-RewriteVersion-Transitional> |
|
185
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-RewriteVersion-Transitional@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-RewriteVersion-Transitional@rt.cpan.org>). |
|
186
|
|
|
|
|
|
|
I am also usually active on irc, as 'ether' at C<irc.perl.org>. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=over 4 |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::PkgVersion> |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item * |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::RewriteVersion> |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item * |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::BumpVersionAfterRelease> |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=back |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 AUTHOR |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Karen Etheridge. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
215
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |