blib/lib/CPAN/Testers/Schema/Result/PerlVersion.pm

filter: Statementstmt 100% 21 / 21 Branchbran 70.0% 7 / 10 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 93.1% 41 / 44 SCAR 20.8
CC
8
Cov
92%
new
8.1
BEGIN
1.0
BEGIN
1.0
CRAP 8.0
« blib/lib/CPAN/Testers/Schema.pm ↑ Summary blib/lib/CPAN/Testers/Schema/ResultSet/TestReport.pm »
1 15 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package CPAN::Testers::Schema::Result::PerlVersion;
3 15 our $VERSION = '0.025';
4 # ABSTRACT: Metadata about Perl versions
5  
6 #pod =head1 SYNOPSIS
7 #pod
8 #pod my $perl = $schema->resultset( 'PerlVersion' )->find( '5.26.0' );
9 #pod say "Stable" unless $perl->devel;
10 #pod
11 #pod $schema->resultset( 'PerlVersion' )->find_or_create({
12 #pod version => '5.30.0', # Version reported by Perl
13 #pod perl => '5.30.0', # Parsed Perl version string
14 #pod patch => 0, # Has patches applied
15 #pod devel => 0, # Is development version (odd minor version)
16 #pod });
17 #pod
18 #pod # Fill in metadata automatically
19 #pod $schema->resultset( 'PerlVersion' )->find_or_create({
20 #pod version => '5.31.0 patch 1231',
21 #pod # devel will be set to 1
22 #pod # patch will be set to 1
23 #pod # perl will be set to 5.31.0
24 #pod });
25 #pod
26 #pod =head1 DESCRIPTION
27 #pod
28 #pod This table holds metadata about known Perl versions. Through this table we can
29 #pod quickly list which Perl versions are stable/development.
30 #pod
31 #pod =head1 SEE ALSO
32 #pod
33 #pod L<DBIx::Class::Row>, L<CPAN::Testers::Schema>
34 #pod
35 #pod =cut
36  
37 15 ▶use CPAN::Testers::Schema::Base 'Result';
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 15 table 'perl_version';
40  
41 #pod =attr version
42 #pod
43 #pod The Perl version reported by the tester. This is the primary key.
44 #pod
45 #pod =cut
46  
47 15 primary_column version => {
48 data_type => 'varchar',
49 size => 255,
50 is_nullable => 0,
51 };
52  
53 #pod =attr perl
54 #pod
55 #pod The parsed version of Perl in C<REVISION.VERSION.SUBVERSION> format.
56 #pod
57 #pod If not specified when creating a new row, the Perl version will be parsed
58 #pod and this field updated accordingly.
59 #pod
60 #pod =cut
61  
62 15 column perl => {
63 data_type => 'varchar',
64 size => 32,
65 is_nullable => 1,
66 };
67  
68 #pod =attr patch
69 #pod
70 #pod If true (C<1>), this Perl has patches applied. Defaults to false (C<0>).
71 #pod
72 #pod If not specified when creating a new row, the Perl version will be parsed
73 #pod and this field updated accordingly.
74 #pod
75 #pod =cut
76  
77 15 column patch => {
78 data_type => 'tinyint',
79 size => 1,
80 default_value => 0,
81 };
82  
83 #pod =attr devel
84 #pod
85 #pod If true (C<1>), this Perl is a development Perl version. Development Perl
86 #pod versions have an odd C<VERSION> field (the second number) like C<5.27.0>,
87 #pod C<5.29.0>, C<5.31.0>, etc... Release candidates (like C<5.28.0 RC0>) are
88 #pod also considered development versions.
89 #pod
90 #pod If not specified when creating a new row, the Perl version will be parsed
91 #pod and this field updated accordingly.
92 #pod
93 #pod =cut
94  
95 15 column devel => {
96 data_type => 'tinyint',
97 size => 1,
98 default_value => 0,
99 };
100  
101 #pod =method new
102 #pod
103 #pod The constructor will automatically fill in any missing information based
104 #pod on the supplied C<version> field.
105 #pod
106 #pod =cut
107  
108 ▶sub new( $class, $attrs ) {
Subroutine new: called CC=8 SCAR=20.9
Pod documented
109 23 ▶ if ( !$attrs->{perl} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attrs->{"perl"}) 23 0 23
110 23 ( $attrs->{perl} ) = $attrs->{version} =~ m{^v?(\d+\.\d+\.\d+)};
111 }
112 23 ▶ if ( !$attrs->{patch} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attrs->{"patch"}) 23 0 23
113 23 ▶ $attrs->{patch} = ( $attrs->{version} =~ m{patch} ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$attrs->{'version'} =~ /patch/u ? : 4 19 23
114 }
115 23 ▶ if ( !$attrs->{devel} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attrs->{"devel"}) 23 0 23
116 23 my ( $version ) = $attrs->{version} =~ m{^v?\d+\.(\d+)};
117 $attrs->{devel} =
118 (
119 ( $version >= 7 && $version % 2 ) ||
120 23 ▶ $attrs->{version} =~ m{^v?\d+\.\d+\.\d+ RC\d+}
Branch: 1 branch
BranchTrueFalseTotal
$version >= 7 && $version % 2 || $attrs->{'version'} =~ /^v?\d+\.\d+\.\d+ RC\d+/u ? : 9 14 23
Condition100%6/6
$version >= 7 and $version % 2 or $attrs->{"version"} =~ /^v?\d+\.\d+\.\d+ RC\d+/u
l!l&&r!l&&!r
7214
$version >= 7 and $version % 2
!ll&&!rl&&r
2147
MC/DC100%3/3
$version >= 7 and $version % 2 or $attrs->{"version"} =~ /^v?\d+\.\d+\.\d+ RC\d+/u
$version >= 7 $version % 2 $attrs->{"version"} =~ /^v?\d+\.\d+\.\d+ RC\d+/u
Truth table80%4/5
A and B or C
A= $version >= 7B= $version % 2C= $attrs->{"version"} =~ /^v?\d+\.\d+\.\d+ RC\d+/u
ABCresult
11X1
0X11
1011
0X00
1000
121 ) ? 1 : 0;
122 }
123 23 return $class->next::method( $attrs );
124 }
125  
126 15 1;
127  
128 __END__
129  
130 =pod
131  
132 =head1 NAME
133  
134 CPAN::Testers::Schema::Result::PerlVersion - Metadata about Perl versions
135  
136 =head1 VERSION
137  
138 version 0.025
139  
140 =head1 SYNOPSIS
141  
142 my $perl = $schema->resultset( 'PerlVersion' )->find( '5.26.0' );
143 say "Stable" unless $perl->devel;
144  
145 $schema->resultset( 'PerlVersion' )->find_or_create({
146 version => '5.30.0', # Version reported by Perl
147 perl => '5.30.0', # Parsed Perl version string
148 patch => 0, # Has patches applied
149 devel => 0, # Is development version (odd minor version)
150 });
151  
152 # Fill in metadata automatically
153 $schema->resultset( 'PerlVersion' )->find_or_create({
154 version => '5.31.0 patch 1231',
155 # devel will be set to 1
156 # patch will be set to 1
157 # perl will be set to 5.31.0
158 });
159  
160 =head1 DESCRIPTION
161  
162 This table holds metadata about known Perl versions. Through this table we can
163 quickly list which Perl versions are stable/development.
164  
165 =head1 ATTRIBUTES
166  
167 =head2 version
168  
169 The Perl version reported by the tester. This is the primary key.
170  
171 =head2 perl
172  
173 The parsed version of Perl in C<REVISION.VERSION.SUBVERSION> format.
174  
175 If not specified when creating a new row, the Perl version will be parsed
176 and this field updated accordingly.
177  
178 =head2 patch
179  
180 If true (C<1>), this Perl has patches applied. Defaults to false (C<0>).
181  
182 If not specified when creating a new row, the Perl version will be parsed
183 and this field updated accordingly.
184  
185 =head2 devel
186  
187 If true (C<1>), this Perl is a development Perl version. Development Perl
188 versions have an odd C<VERSION> field (the second number) like C<5.27.0>,
189 C<5.29.0>, C<5.31.0>, etc... Release candidates (like C<5.28.0 RC0>) are
190 also considered development versions.
191  
192 If not specified when creating a new row, the Perl version will be parsed
193 and this field updated accordingly.
194  
195 =head1 METHODS
196  
197 =head2 new
198  
199 The constructor will automatically fill in any missing information based
200 on the supplied C<version> field.
201  
202 =head1 SEE ALSO
203  
204 L<DBIx::Class::Row>, L<CPAN::Testers::Schema>
205  
206 =head1 AUTHORS
207  
208 =over 4
209  
210 =item *
211  
212 Oriol Soriano <oriolsoriano@gmail.com>
213  
214 =item *
215  
216 Doug Bell <preaction@cpan.org>
217  
218 =back
219  
220 =head1 COPYRIGHT AND LICENSE
221  
222 This software is copyright (c) 2018 by Oriol Soriano, Doug Bell.
223  
224 This is free software; you can redistribute it and/or modify it under
225 the same terms as the Perl 5 programming language system itself.
226  
227 =cut
« blib/lib/CPAN/Testers/Schema.pm ↑ Summary blib/lib/CPAN/Testers/Schema/ResultSet/TestReport.pm »