File Coverage

blib/lib/App/SmokeBrew/PerlVersion.pm
Criterion Covered Total %
statement 28 35 80.0
branch 2 8 25.0
condition n/a
subroutine 9 11 81.8
pod 4 4 100.0
total 43 58 74.1


line stmt bran cond sub pod time code
1             package App::SmokeBrew::PerlVersion;
2             $App::SmokeBrew::PerlVersion::VERSION = '1.00';
3             #ABSTRACT: Moose role for perl versions
4              
5 4     4   3660 use strict;
  4         13  
  4         139  
6 4     4   21 use warnings;
  4         9  
  4         123  
7              
8 4     4   945 use Moose::Role;
  4         10230  
  4         32  
9 4     4   21730 use Perl::Version;
  4         2511  
  4         111  
10 4     4   2456 use Module::CoreList;
  4         93986  
  4         51  
11 4     4   2033 use App::SmokeBrew::Types qw[PerlVersion];
  4         11  
  4         36  
12              
13             has 'version' => (
14             is => 'ro',
15             isa => 'PerlVersion',
16             required => 1,
17             coerce => 1,
18             );
19              
20             sub perl_version {
21 3     3 1 7 my $self = shift;
22 3         106 ( my $numify = $self->version->numify ) =~ s/_//g;
23 3 50       191 my $pv = 'perl'.( $numify < 5.006 ? $self->version->numify : $self->version->normal );
24 3         96 $pv =~ s/perlv/perl-/g;
25 3         17 return $pv;
26             }
27              
28             sub is_dev_release {
29 0     0 1 0 my $self = shift;
30 0 0       0 return 0 unless $self->version->numify >= 5.006;
31 0         0 return $self->version->version % 2;
32             }
33              
34             sub can_quadmath {
35 1     1 1 2 my $self = shift;
36 1 50       35 return 0 unless $self->version->numify >= 5.021004;
37 0           return 1;
38             }
39              
40             sub can_jobs {
41 0     0 1   my $self = shift;
42 0 0         return 0 unless $self->version->numify >= 5.019004;
43 0           return 1;
44             }
45              
46 4     4   4835 no Moose::Role;
  4         9  
  4         34  
47              
48             qq[Smokin'];
49              
50             __END__
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             App::SmokeBrew::PerlVersion - Moose role for perl versions
59              
60             =head1 VERSION
61              
62             version 1.00
63              
64             =head1 SYNOPSIS
65              
66             use Moose;
67              
68             with 'App::SmokeBrew::PerlVersion';
69              
70             =head1 DESCRIPTION
71              
72             App::SmokeBrew::PerlVersion is a L<Moose::Role> consumed by various parts of L<smokebrew> that provides
73             a required attribute and some methods.
74              
75             =head1 ATTRIBUTES
76              
77             =over
78              
79             =item C<version>
80              
81             A required attribute.
82              
83             A L<Perl::Version> object.
84              
85             Coerced from C<Str> via C<new> in L<Perl::Version>
86              
87             Constrained to existing in L<Module::CoreList> C<released> and being >= C<5.006>
88              
89             =back
90              
91             =head1 METHODS
92              
93             These are methods provided by the role.
94              
95             =over
96              
97             =item C<perl_version>
98              
99             Returns the normalised perl version prefixed with C<perl->.
100              
101             =item C<is_dev_release>
102              
103             Returns true if the perl version is a C<development> perl release, false otherwise.
104              
105             =item C<can_quadmath>
106              
107             Returns true if the perl version is capable of being built with C<quadmath>.
108              
109             =item C<can_jobs>
110              
111             Returns true if the perl version is safely capable of being built with C<make -j>.
112              
113             =back
114              
115             =head1 SEE ALSO
116              
117             L<smokebrew>
118              
119             L<Moose::Role>
120              
121             L<App::SmokeBrew::Types>
122              
123             L<Perl::Version>
124              
125             =head1 AUTHOR
126              
127             Chris Williams <chris@bingosnet.co.uk>
128              
129             =head1 COPYRIGHT AND LICENSE
130              
131             This software is copyright (c) 2020 by Chris Williams.
132              
133             This is free software; you can redistribute it and/or modify it under
134             the same terms as the Perl 5 programming language system itself.
135              
136             =cut