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