File Coverage

blib/lib/Dist/Zilla/Plugin/BumpVersionAfterRelease/Transitional.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1 4     4   190267 use strict;
  4         11  
  4         125  
2 4     4   19 use warnings;
  4         10  
  4         229  
3             package Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional;
4             # vim: set ts=8 sts=4 sw=4 tw=115 et :
5             # ABSTRACT: Ease the transition to [BumpVersionAfterRelease] in your distribution
6             # KEYWORDS: plugin version rewrite munge module
7              
8             our $VERSION = '0.008';
9              
10 4     4   23 use Moose;
  4         10  
  4         31  
11             extends 'Dist::Zilla::Plugin::BumpVersionAfterRelease';
12             with 'Dist::Zilla::Role::InsertVersion';
13 4     4   24894 use Path::Tiny;
  4         11  
  4         208  
14 4     4   25 use namespace::autoclean;
  4         9  
  4         37  
15              
16             around dump_config => sub
17             {
18             my ($orig, $self) = @_;
19             my $config = $self->$orig;
20              
21             $config->{+__PACKAGE__} = {
22             # TODO
23             blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (),
24             };
25              
26             return $config;
27             };
28              
29             around rewrite_version => sub
30             {
31             my $orig = shift;
32             my $self = shift;
33             my ($file, $version) = @_;
34              
35             # update existing our $VERSION = '...'; entry
36             return 1 if $self->$orig($file, $version);
37              
38             # note that $file is the file in the distribution, whereas we want to
39             # modify the file in the source repository.
40             my $source_file = Dist::Zilla::File::OnDisk->new(
41             name => path($file->_original_name)->stringify,
42             encoding => $file->encoding,
43             );
44              
45             if ($self->insert_version($source_file, $version))
46             {
47             # append+truncate to preserve file mode
48             path($source_file->name)->append_raw({ truncate => 1 }, $source_file->encoded_content);
49             return 1;
50             }
51              
52             return;
53             };
54              
55             __PACKAGE__->meta->make_immutable;
56              
57             __END__
58              
59             =pod
60              
61             =encoding UTF-8
62              
63             =head1 NAME
64              
65             Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional - Ease the transition to [BumpVersionAfterRelease] in your distribution
66              
67             =head1 VERSION
68              
69             version 0.008
70              
71             =head1 SYNOPSIS
72              
73             In your F<dist.ini>:
74              
75             [BumpVersionAfterRelease::Transitional]
76              
77             =head1 DESCRIPTION
78              
79             =for stopwords BumpVersionAfterRelease OurPkgVersion PkgVersion
80              
81             This is a L<Dist::Zilla> plugin that subclasses
82             L<[BumpVersionAfterRelease]|Dist::Zilla::Plugin::BumpVersionAfterRelease>, to allow plugin
83             bundles to transition from L<[PkgVersion]|Dist::Zilla::Plugin::PkgVersion> or
84             L<[OurPkgVersion]|Dist::Zilla::Plugin::OurPkgVersion> to
85             L<[RewriteVersion]|Dist::Zilla::Plugin::RewriteVersion>
86             and L<[BumpVersionAfterRelease]|Dist::Zilla::Plugin::BumpVersionAfterRelease>
87             without having to manually edit the F<dist.ini> or any F<.pm> files.
88              
89             After releasing your distribution,
90             L<[BumpVersionAfterRelease]|Dist::Zilla::Plugin::BumpVersionAfterRelease> is
91             invoked to update the C<$VERSION> assignment in the module(s) in the
92             repository to the next version. If no such expression exists in the module,
93             one is added.
94              
95             B<Note:> If there is more than one package in a single file, if there was
96             I<any> C<$VERSION> declaration in the file, no additional declarations are
97             added for the other packages, even if you are using the C<global> option.
98              
99             =head1 CONFIGURATION OPTIONS
100              
101             Configuration is the same as in
102             L<[BumpVersionAfterRelease]|Dist::Zilla::Plugin::BumpVersionAfterRelease>.
103              
104             =head1 SEE ALSO
105              
106             =over 4
107              
108             =item *
109              
110             L<Dist::Zilla::Plugin::RewriteVersion::Transitional>
111              
112             =item *
113              
114             L<Dist::Zilla::Plugin::PkgVersion>
115              
116             =item *
117              
118             L<Dist::Zilla::Plugin::RewriteVersion>
119              
120             =item *
121              
122             L<Dist::Zilla::Plugin::BumpVersionAfterRelease>
123              
124             =back
125              
126             =head1 SUPPORT
127              
128             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-RewriteVersion-Transitional>
129             (or L<bug-Dist-Zilla-Plugin-RewriteVersion-Transitional@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-RewriteVersion-Transitional@rt.cpan.org>).
130              
131             There is also a mailing list available for users of this distribution, at
132             L<http://dzil.org/#mailing-list>.
133              
134             There is also an irc channel available for users of this distribution, at
135             L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>.
136              
137             I am also usually active on irc, as 'ether' at C<irc.perl.org>.
138              
139             =head1 AUTHOR
140              
141             Karen Etheridge <ether@cpan.org>
142              
143             =head1 COPYRIGHT AND LICENCE
144              
145             This software is copyright (c) 2014 by Karen Etheridge.
146              
147             This is free software; you can redistribute it and/or modify it under
148             the same terms as the Perl 5 programming language system itself.
149              
150             =cut