File Coverage

blib/lib/Dist/Zilla/Plugin/VersionFromModule.pm
Criterion Covered Total %
statement 14 14 100.0
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 18 20 90.0


line stmt bran cond sub pod time code
1             #---------------------------------------------------------------------
2             package Dist::Zilla::Plugin::VersionFromModule;
3             #
4             # Copyright 2009 Christopher J. Madsen
5             #
6             # Author: Christopher J. Madsen <perl@cjmweb.net>
7             # Created: 23 Sep 2009
8             #
9             # This program is free software; you can redistribute it and/or modify
10             # it under the same terms as Perl itself.
11             #
12             # This program is distributed in the hope that it will be useful,
13             # but WITHOUT ANY WARRANTY; without even the implied warranty of
14             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
15             # GNU General Public License or the Artistic License for more details.
16             #
17             # ABSTRACT: Get distribution version from its main_module
18             #---------------------------------------------------------------------
19              
20             our $VERSION = '0.08';
21             # This file is part of Dist-Zilla-Plugins-CJM 4.27 (August 29, 2015)
22              
23 3     3   48957338 use Moose;
  3         4  
  3         24  
24             with 'Dist::Zilla::Role::VersionProvider';
25             with 'Dist::Zilla::Role::ModuleInfo';
26              
27              
28             sub provide_version {
29 11     11 0 640256 my ($self) = @_;
30              
31 11         565 my $main_module = $self->zilla->main_module;
32 11         16457 my $module = $main_module->name;
33              
34 11         783 my $pm_info = $self->get_module_info($main_module);
35 11         18647 my $ver = $pm_info->version;
36              
37 11 50       196 die "Unable to get version from $module" unless defined $ver;
38              
39 11         247 $self->log("dist version $ver (from $module)");
40              
41 11         4850 "$ver"; # Need to stringify version object
42             } # end provide_version
43              
44             #=====================================================================
45             # Package Return Value:
46              
47 3     3   17992 no Moose;
  3         7  
  3         21  
48             __PACKAGE__->meta->make_immutable;
49             1;
50              
51             __END__
52              
53             =head1 NAME
54              
55             Dist::Zilla::Plugin::VersionFromModule - Get distribution version from its main_module
56              
57             =head1 VERSION
58              
59             This document describes version 0.08 of
60             Dist::Zilla::Plugin::VersionFromModule, released August 29, 2015
61             as part of Dist-Zilla-Plugins-CJM version 4.27.
62              
63             =head1 SYNOPSIS
64              
65             In your F<dist.ini>:
66              
67             [VersionFromModule]
68              
69             =head1 DESCRIPTION
70              
71             If included, this plugin will set the distribution's version from the
72             C<main_module>'s version. (You should not specify a version in your
73             F<dist.ini>.)
74              
75             =head1 INCOMPATIBILITIES
76              
77             Since it will always return a version, VersionFromModule should not be
78             used with any other VersionProvider plugins.
79              
80              
81             =for Pod::Coverage
82             provide_version
83              
84             =head1 BUGS AND LIMITATIONS
85              
86             No bugs have been reported.
87              
88             =head1 AUTHOR
89              
90             Christopher J. Madsen S<C<< <perl AT cjmweb.net> >>>
91              
92             Please report any bugs or feature requests
93             to S<C<< <bug-Dist-Zilla-Plugins-CJM AT rt.cpan.org> >>>
94             or through the web interface at
95             L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=Dist-Zilla-Plugins-CJM >>.
96              
97             You can follow or contribute to Dist-Zilla-Plugins-CJM's development at
98             L<< https://github.com/madsen/dist-zilla-plugins-cjm >>.
99              
100             =head1 COPYRIGHT AND LICENSE
101              
102             This software is copyright (c) 2015 by Christopher J. Madsen.
103              
104             This is free software; you can redistribute it and/or modify it under
105             the same terms as the Perl 5 programming language system itself.
106              
107             =head1 DISCLAIMER OF WARRANTY
108              
109             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
110             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
111             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
112             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
113             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
114             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
115             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
116             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
117             NECESSARY SERVICING, REPAIR, OR CORRECTION.
118              
119             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
120             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
121             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
122             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
123             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
124             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
125             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
126             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
127             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
128             SUCH DAMAGES.
129              
130             =cut