Changes.pm

filter: Statementstmt 70.8% 292 / 412 Branchbran 47.1% 115 / 244 Conditioncond 33.8% 62 / 183 MC/DCmcdc 9.0% 9 / 99 Subroutinesub 83.0% 44 / 53 Podpod 93.5% 29 / 31 totaltotal 53.9% 551 / 1022 CC 197 SCAR 59.4
CC
197
Cov
56%
parse
951.2
delete_release
90.0
new_group
39.8
CRAP 380.2
↑ Summary Changes/Version.pm »
1 ##----------------------------------------------------------------------------
2 ## Changes file management - ~/lib/Changes.pm
3 ## Version v0.4.2
4 ## Copyright(c) 2026 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2022/12/09
7 ## Modified 2026/04/25
8 ## All rights reserved
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package Changes;
15 BEGIN
16 18 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
17 18 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 18 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 18 ▶ use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 18 ▶ use parent qw( Module::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 18 ▶ use vars qw( $VERSION $VERSION_LAX_REGEX $DATE_DISTZILA_RE $DATETIME_RE );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 18 ▶ use Changes::Release;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 18 ▶ use Changes::Group;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 18 ▶ use Changes::Change;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 18 ▶ use Wanted;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 # From version::regex
27 18 our $VERSION_LAX_REGEX = qr/(?^x: (?^x:
28 (?<has_v>v) (?<ver>(?^:[0-9]+) (?: (?^:\.[0-9]+)+ (?^:_[0-9]+)? )?)
29 |
30 (?<ver>(?^:[0-9]+)? (?^:\.[0-9]+){2,} (?^:_[0-9]+)?)
31 ) | (?^x: (?<ver>(?^:[0-9]+) (?: (?^:\.[0-9]+) | \. )? (?^:_[0-9]+)?)
32 |
33 (?<ver>(?^:\.[0-9]+) (?^:_[0-9]+)?)
34 )
35 )/;
36 # 2022-12-11 08:07:12 Asia/Tokyo
37 18 our $DATE_DISTZILA_RE = qr/
38 (?<r_year>\d{4})
39 -
40 (?<r_month>\d{1,2})
41 -
42 (?<r_day>\d{1,2})
43 (?<r_dt_space>[[:blank:]\h]+)
44 (?<r_hour>\d{1,2})
45 :
46 (?<r_minute>\d{1,2})
47 :
48 (?<r_second>\d{1,2})
49 (?<r_tz_space>[[:blank:]\h]+)
50 (?<r_tz>\S+)
51 /x;
52 18 our $VERSION = 'v0.4.2';
53 };
54  
55 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 sub init
59 22 ▶{
Subroutine init: called CC=2 SCAR=6.9
Pod documented
60 22 my $self = shift( @_ );
61 22 $self->{defaults} = undef;
62 22 $self->{elements} = [];
63 22 $self->{epilogue} = undef;
64 22 $self->{file} = undef;
65 22 $self->{max_width} = 0;
66 22 $self->{mode} = '+<';
67 22 $self->{nl} = "\n";
68 22 $self->{preamble} = undef;
69 22 $self->{releases} = [];
70 22 $self->{time_zone} = undef;
71 22 $self->{type} = undef;
72 22 $self->{wrapper} = undef;
73 22 $self->{_init_strict_use_sub} = 1;
74 22 $self->{_init_params_order} = [qw( preset )];
75 22 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 22 0 22
76 22 return( $self );
77 }
78  
79 sub add_epilogue
80 1 ▶{
Subroutine add_epilogue: called CC=6 SCAR=22.9
Pod documented
81 1 my( $self, $text ) = @_;
82 1 ▶ if( !defined( $text ) || !length( "$text" ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $text and length "$text") 0 1 1
Condition33%1/3
defined $text and length "$text"
!ll&&!rl&&r
001
MC/DC0%0/2
defined $text and length "$text"
defined $text length "$text"
Truth table33%1/3
A and B
A= defined $textB= length "$text"
ABresult
0X0
100
111
83 {
84 0 return( $self->error( "No text was provided to add an epilogue." ) );
85 }
86 1 my $elements = $self->elements;
87 1 my $last = $elements->last;
88 1 ▶ if( defined( $last ) && !$self->_is_a( $last => 'Changes::NewLine' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $last and not $self->_is_a($last, "Changes::NewLine")) 0 1 1
Condition33%1/3
defined $last and not $self->_is_a($last, "Changes::NewLine")
!ll&&!rl&&r
100
MC/DC0%0/2
defined $last and not $self->_is_a($last, "Changes::NewLine")
defined $last not $self->_is_a($last, "Changes::NewLine")
Truth table33%1/3
A and not(B)
A= defined $lastB= not $self->_is_a($last, "Changes::NewLine")
ABresult
0X0
100
111
89 {
90 0 ▶ $elements->push( $self->new_line( nl => ( $self->nl // "\n" ) ) );
Condition0%0/2
$self->nl // "\n"
l!l
00
MC/DC0%0/1
$self->nl // "\n"
$self->nl
Truth table0%0/2
A
A= $self->nl
Aresult
11
00
91 }
92 1 $self->epilogue( $text );
93 1 return( $self );
94 }
95  
96 sub add_preamble
97 1 ▶{
Subroutine add_preamble: called CC=3 SCAR=12.7
Pod documented
98 1 my( $self, $text ) = @_;
99 1 ▶ if( !defined( $text ) || !length( "$text" ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $text and length "$text") 0 1 1
Condition33%1/3
defined $text and length "$text"
!ll&&!rl&&r
001
MC/DC0%0/2
defined $text and length "$text"
defined $text length "$text"
Truth table33%1/3
A and B
A= defined $textB= length "$text"
ABresult
0X0
100
111
100 {
101 0 return( $self->error( "No text was provided to add a premable." ) );
102 }
103 1 $self->preamble( $text );
104 1 return( $self );
105 }
106  
107 sub add_release
108 4 ▶{
Subroutine add_release: called CC=11 SCAR=25.4
Pod documented
109 4 my $self = shift( @_ );
110 4 my( $rel, $opts );
111 4 my $elements = $self->elements;
112 4 ▶ if( scalar( @_ ) == 1 && $self->_is_a( $_[0] => 'Changes::Release' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ == 1 and $self->_is_a($_[0], 'Changes::Release')) { } 2 2 4
Condition66%2/3
scalar @_ == 1 and $self->_is_a($_[0], "Changes::Release")
!ll&&!rl&&r
202
MC/DC50%1/2
scalar @_ == 1 and $self->_is_a($_[0], "Changes::Release")
scalar @_ == 1 $self->_is_a($_[0], "Changes::Release")
Truth table66%2/3
A and B
A= scalar @_ == 1B= $self->_is_a($_[0], "Changes::Release")
ABresult
0X0
100
111
113 {
114 2 $rel = shift( @_ );
115 2 ▶ if( $elements->exists( $rel ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($elements->exists($rel)) 0 2 2
116 {
117 0 return( $self->error( "A very same release object with version '", $rel->version, "' is already registered." ) );
118 }
119 2 my $vers = $rel->version;
120 2 ▶ if( length( "$vers" ) )
Branch: 1 branch
BranchTrueFalseTotal
if (length "$vers") 2 0 2
121 {
122 2 ▶ my $same = $elements->grep(sub{ $self->_is_a( $_ => 'Changes::Release' ) && $_->version == "$vers" });
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_a($_, "Changes::Release") and $_->version == "$vers" 1 1 2
123 2 ▶ return( $self->error( "A similar release with version '$vers' is already registered." ) ) if( !$same->is_empty );
Branch: 1 branch
BranchTrueFalseTotal
unless $same->is_empty 0 2 2
124 }
125 }
126 else
127 {
128 2 $opts = $self->_get_args_as_hash( @_ );
129 2 ▶ if( exists( $opts->{version} ) && defined( $opts->{version} ) && length( "$opts->{version}" ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts->{"version"} and defined $opts->{"version"} and length qq[$opts->{"version"}]) 2 0 2
Condition33%2/6
exists $opts->{"version"} and defined $opts->{"version"} and length qq[$opts->{"version"}]
!ll&&!rl&&r
002
exists $opts->{"version"} and defined $opts->{"version"}
!ll&&!rl&&r
002
MC/DC0%0/3
exists $opts->{"version"} and defined $opts->{"version"} and length qq[$opts->{"version"}]
exists $opts->{"version"} defined $opts->{"version"} length qq[$opts->{"version"}]
Truth table25%1/4
A and B and C
A= exists $opts->{"version"}B= defined $opts->{"version"}C= length qq[$opts->{"version"}]
ABCresult
0XX0
10X0
1100
1111
130 {
131 2 my $vers = $opts->{version};
132 2 ▶ my $same = $elements->grep(sub{ $self->_is_a( $_ => 'Changes::Release' ) && $_->version == "$vers" });
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_a($_, "Changes::Release") and $_->version == "$vers" 1 1 2
133 2 ▶ return( $self->error( "A similar release with version '$vers' is already registered." ) ) if( !$same->is_empty );
Branch: 1 branch
BranchTrueFalseTotal
unless $same->is_empty 0 2 2
134 }
135 2 ▶ $rel = $self->new_release( %$opts ) || return( $self->pass_error );
Condition50%1/2
$self->new_release(%$opts) || (return $self->pass_error)
l!l
20
MC/DC0%0/1
$self->new_release(%$opts) || (return $self->pass_error)
$self->new_release(%$opts)
Truth table50%1/2
A
A= $self->new_release(%$opts)
Aresult
11
00
136 2 return( $self->add_release( $rel ) );
137 }
138 2 $elements->unshift( $self->new_line );
139 2 $elements->unshift( $rel );
140 2 return( $rel );
141 }
142  
143 sub as_string
144 21 ▶{
Subroutine as_string: called CC=5 SCAR=16.2
Pod documented
145 21 my $self = shift( @_ );
146 21 my $lines = $self->new_array;
147 21 my $preamble = $self->preamble;
148 21 my $epilogue = $self->epilogue;
149 21 ▶ if( defined( $preamble ) && !$preamble->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $preamble and not $preamble->is_empty) 4 17 21
Condition66%2/3
defined $preamble and not $preamble->is_empty
!ll&&!rl&&r
1704
MC/DC50%1/2
defined $preamble and not $preamble->is_empty
defined $preamble not $preamble->is_empty
Truth table66%2/3
A and not(B)
A= defined $preambleB= not $preamble->is_empty
ABresult
0X0
100
111
150 {
151 4 $lines->push( $preamble->scalar );
152 }
153  
154 $self->elements->foreach(sub
155 71 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.4
156 71 my $str;
157 71 ▶ $str = $_->as_string if( $self->_can( $_ => 'as_string' ) );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_can($_, "as_string") 71 0 71
158 71 ▶ if( defined( $str ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $str) 71 0 71
159 {
160 71 $lines->push( $str->scalar );
161 }
162 21 });
163 21 ▶ if( defined( $epilogue ) && !$epilogue->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $epilogue and not $epilogue->is_empty) 2 19 21
Condition66%2/3
defined $epilogue and not $epilogue->is_empty
!ll&&!rl&&r
1902
MC/DC50%1/2
defined $epilogue and not $epilogue->is_empty
defined $epilogue not $epilogue->is_empty
Truth table66%2/3
A and not(B)
A= defined $epilogueB= not $epilogue->is_empty
ABresult
0X0
100
111
164 {
165 2 $lines->push( $epilogue->scalar );
166 }
167 21 return( $lines->join( '' ) );
168 }
169  
170 {
171 18 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
172 18 *serialize = \&as_string;
173 18 *serialise = \&as_string;
174 }
175  
176 114 ▶sub defaults { return( shift->_set_get_hash_as_mix_object( { field => 'defaults', undef_ok => 1 }, @_ ) ); }
Subroutine defaults: called CC=1 SCAR=0.0
Pod documented
177  
178 sub delete_release
179 0 ▶{
Subroutine delete_release: not called CC=9 SCAR=45.0
Pod documented
180 0 my $self = shift( @_ );
181 0 my $elements = $self->elements;
182 0 my $removed = $self->new_array;
183 0 foreach my $rel ( @_ )
184 {
185 0 ▶ if( $self->_is_a( $rel => 'Changes::Release' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_a($rel, 'Changes::Release')) { } 0 0 0
186 {
187 0 my $pos = $elements->pos( $rel );
188 0 my $until = 1;
189 0 ▶ while( defined( $elements->[ $pos + $until ] ) && $self->_is_a( $elements->[ $pos + $until ] => 'Changes::NewLine' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$elements[$pos + $until] and $self->_is_a($$elements[$pos + $until], "Changes::NewLine")) 0 0 0
Condition0%0/3
defined $$elements[$pos + $until] and $self->_is_a($$elements[$pos + $until], "Changes::NewLine")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $$elements[$pos + $until] and $self->_is_a($$elements[$pos + $until], "Changes::NewLine")
defined $$elements[$pos + $until] $self->_is_a($$elements[$pos + $until], "Changes::NewLine")
Truth table0%0/3
A and B
A= defined $$elements[$pos + $until]B= $self->_is_a($$elements[$pos + $until], "Changes::NewLine")
ABresult
0X0
100
111
190 {
191 0 $until++;
192 }
193 0 $elements->delete( $pos, $until );
194 0 $removed->push( $rel );
195 }
196 else
197 {
198 0 my $vers = $rel;
199 0 ▶ if( !defined( $vers ) || !length( "$vers" ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $vers and length "$vers") 0 0 0
Condition0%0/3
defined $vers and length "$vers"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $vers and length "$vers"
defined $vers length "$vers"
Truth table0%0/3
A and B
A= defined $versB= length "$vers"
ABresult
0X0
100
111
200 {
201 0 ▶ warn( "No version provided to remove its corresponding release object.\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
202 0 next;
203 }
204 0 ▶ my $found = $elements->grep(sub{ $self->_is_a( $_ => 'Changes::Release' ) && $_->version == $vers });
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_a($_, "Changes::Release") and $_->version == $vers 0 0 0
205 0 ▶ if( $found->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if ($found->is_empty) 0 0 0
206 {
207 0 next;
208 }
209 $found->foreach(sub
210 0 ▶ {
Subroutine __ANON__: not called CC=2 SCAR=17.9
211 0 my $deleted = $self->delete_release( $_ );
212 0 ▶ $removed->push( $deleted->list ) if( !$deleted->is_empty );
Branch: 1 branch
BranchTrueFalseTotal
if not $deleted->is_empty 0 0 0
213 0 });
214 }
215 }
216 0 return( $removed );
217 }
218  
219 128 ▶sub elements { return( shift->_set_get_array_as_object( 'elements', @_ ) ); }
Subroutine elements: called CC=1 SCAR=0.0
Pod documented
220  
221 24 ▶sub epilogue { return( shift->_set_get_scalar_as_object( 'epilogue', @_ ) ); }
Subroutine epilogue: called CC=1 SCAR=0.0
Pod documented
222  
223 4 ▶sub file { return( shift->_set_get_file( 'file', @_ ) ); }
Subroutine file: called CC=1 SCAR=0.0
Pod documented
224  
225 sub freeze
226 20 ▶{
Subroutine freeze: called CC=1 SCAR=0.0
Pod undocumented
227 20 my $self = shift( @_ );
228 $self->elements->foreach(sub
229 67 ▶ {
Subroutine __ANON__: called CC=2 SCAR=6.9
230 67 ▶ if( $self->_can( $_ => 'freeze' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_can($_, "freeze")) 44 23 67
231 {
232 44 $_->freeze;
233 }
234 20 });
235 20 return( $self );
236 }
237  
238 0 ▶sub history { return( shift->releases( @_ ) ); }
Subroutine history: not called CC=1 SCAR=6.9
Pod documented
239  
240 sub load
241 1 ▶{
Subroutine load: called CC=8 SCAR=22.4
Pod documented
242 1 my $this = shift( @_ );
243 1 ▶ my $file = shift( @_ ) ||
Condition50%1/2
shift @_ || (return $this->error('No changes file was provided to load.'))
l!l
10
MC/DC0%0/1
shift @_ || (return $this->error('No changes file was provided to load.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
244 return( $this->error( "No changes file was provided to load." ) );
245 1 my $opts = $this->_get_args_as_hash( @_ );
246 1 ▶ my $self = $this->new( %$opts ) ||
Condition50%1/2
$this->new(%$opts) || (return $this->pass_error)
l!l
10
MC/DC0%0/1
$this->new(%$opts) || (return $this->pass_error)
$this->new(%$opts)
Truth table50%1/2
A
A= $this->new(%$opts)
Aresult
11
00
247 return( $this->pass_error );
248 1 ▶ my $f = $self->new_file( $file ) ||
Condition50%1/2
$self->new_file($file) || (return $this->pass_error($self->error))
l!l
10
MC/DC0%0/1
$self->new_file($file) || (return $this->pass_error($self->error))
$self->new_file($file)
Truth table50%1/2
A
A= $self->new_file($file)
Aresult
11
00
249 return( $this->pass_error( $self->error ) );
250 1 ▶ my $mode = $self->mode // '+<';
Condition50%1/2
$self->mode // "+<"
l!l
10
MC/DC0%0/1
$self->mode // "+<"
$self->mode
Truth table50%1/2
A
A= $self->mode
Aresult
11
00
251 1 ▶ $f->open( "$mode", { binmode => 'utf-8', autoflush => 1 } ) ||
Branch: 1 branch
BranchTrueFalseTotal
$f->open("$mode", {"binmode", "utf-8", "autoflush", 1}) or return $this->pass_error($f->error) 1 0 1
252 return( $this->pass_error( $f->error ) );
253 # my $lines = $f->lines( chomp => 1 ) ||
254 1 ▶ my $lines = $f->lines ||
Condition50%1/2
$f->lines || (return $this->pass_error($f->error))
l!l
10
MC/DC0%0/1
$f->lines || (return $this->pass_error($f->error))
$f->lines
Truth table50%1/2
A
A= $f->lines
Aresult
11
00
255 return( $this->pass_error( $f->error ) );
256 1 ▶ $self->parse( $lines ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->parse($lines) or return $self->pass_error 1 0 1
257 1 $self->freeze;
258 1 return( $self );
259 }
260  
261 sub load_data
262 19 ▶{
Subroutine load_data: called CC=5 SCAR=17.1
Pod documented
263 19 my $this = shift( @_ );
264 19 my $data = shift( @_ );
265 19 my $opts = $this->_get_args_as_hash( @_ );
266 19 ▶ my $self = $this->new( %$opts ) ||
Condition50%1/2
$this->new(%$opts) || (return $this->pass_error)
l!l
190
MC/DC0%0/1
$this->new(%$opts) || (return $this->pass_error)
$this->new(%$opts)
Truth table50%1/2
A
A= $this->new(%$opts)
Aresult
11
00
267 return( $this->pass_error );
268 19 ▶ return( $self ) if( !defined( $data ) || !length( "$data" ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data and length "$data" 0 19 19
Condition33%1/3
defined $data and length "$data"
!ll&&!rl&&r
0019
MC/DC0%0/2
defined $data and length "$data"
defined $data length "$data"
Truth table33%1/3
A and B
A= defined $dataB= length "$data"
ABresult
0X0
100
111
269 19 my $lines = $self->new_array( [split( /(?<=\n)/, $data )] );
270 # $lines->chomp;
271 19 ▶ $self->parse( $lines ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->parse($lines) or return $self->pass_error 19 0 19
272 19 $self->freeze;
273 19 return( $self );
274 }
275  
276 22 ▶sub max_width { return( shift->_set_get_number( 'max_width', @_ ) ); }
Subroutine max_width: called CC=1 SCAR=0.0
Pod documented
277  
278 sub new_change
279 41 ▶{
Subroutine new_change: called CC=6 SCAR=24.3
Pod documented
280 41 my $self = shift( @_ );
281 41 my $opts = $self->_get_args_as_hash( @_ );
282 41 my $defaults = $self->defaults;
283 41 ▶ if( defined( $defaults ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $defaults) 0 41 41
284 {
285 0 foreach my $opt ( qw( spacer1 marker spacer2 ) )
286 {
287 0 ▶ $opts->{ $opt } //= $defaults->{ $opt } if( defined( $defaults->{ $opt } ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $defaults->{$opt} 0 0 0
Condition0%0/3
$opts->{$opt} //= $defaults->{$opt}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{$opt} //= $defaults->{$opt}
$opts->{$opt} $defaults->{$opt}
Truth table0%0/3
A //= B
A= $opts->{$opt}B= $defaults->{$opt}
ABresult
1X1
011
000
288 }
289 }
290 41 ▶ my $c = Changes::Change->new( $opts ) ||
Condition50%1/2
'Changes::Change'->new($opts) || (return $self->pass_error('Changes::Change'->error))
l!l
410
MC/DC0%0/1
'Changes::Change'->new($opts) || (return $self->pass_error('Changes::Change'->error))
'Changes::Change'->new($opts)
Truth table50%1/2
A
A= 'Changes::Change'->new($opts)
Aresult
11
00
291 return( $self->pass_error( Changes::Change->error ) );
292 41 return( $c );
293 }
294  
295 sub new_group
296 6 ▶{
Subroutine new_group: called CC=9 SCAR=36.8
Pod documented
297 6 my $self = shift( @_ );
298 6 my $opts = $self->_get_args_as_hash( @_ );
299 6 my $defaults = $self->defaults;
300 6 ▶ if( defined( $defaults ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $defaults) 0 6 6
301 {
302 0 my $def = { %$defaults };
303 0 foreach my $opt ( qw( spacer type ) )
304 {
305 0 ▶ if( !defined( $opts->{ "group_${opt}" } ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $$opts{"group_$opt"} and exists $$def{"group_$opt"} and defined $$def{"group_$opt"} and length $$def{"group_$opt"}) 0 0 0
Condition0%0/9
not defined $$opts{"group_$opt"} and exists $$def{"group_$opt"} and defined $$def{"group_$opt"} and length $$def{"group_$opt"}
!ll&&!rl&&r
000
not defined $$opts{"group_$opt"} and exists $$def{"group_$opt"} and defined $$def{"group_$opt"}
!ll&&!rl&&r
000
not defined $$opts{"group_$opt"} and exists $$def{"group_$opt"}
!ll&&!rl&&r
000
MC/DC0%0/4
not defined $$opts{"group_$opt"} and exists $$def{"group_$opt"} and defined $$def{"group_$opt"} and length $$def{"group_$opt"}
not defined $$opts{"group_$opt"} exists $$def{"group_$opt"} defined $$def{"group_$opt"} length $$def{"group_$opt"}
Truth table0%0/5
not(A) and B and C and D
A= not defined $$opts{"group_$opt"}B= exists $$def{"group_$opt"}C= defined $$def{"group_$opt"}D= length $$def{"group_$opt"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
306 exists( $def->{ "group_${opt}" } ) &&
307 defined( $def->{ "group_${opt}" } ) &&
308 length( $def->{ "group_${opt}" } ) )
309 {
310 0 $opts->{ $opt } = CORE::delete( $def->{ "group_${opt}" } );
311 }
312 }
313 0 ▶ $opts->{defaults} //= $def;
Condition0%0/3
$opts->{"defaults"} //= $def
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{"defaults"} //= $def
$opts->{"defaults"} $def
Truth table0%0/3
A //= B
A= $opts->{"defaults"}B= $def
ABresult
1X1
011
000
314 }
315 6 ▶ my $g = Changes::Group->new( $opts ) ||
Condition50%1/2
'Changes::Group'->new($opts) || (return $self->pass_error('Changes::Group'->error))
l!l
60
MC/DC0%0/1
'Changes::Group'->new($opts) || (return $self->pass_error('Changes::Group'->error))
'Changes::Group'->new($opts)
Truth table50%1/2
A
A= 'Changes::Group'->new($opts)
Aresult
11
00
316 return( $self->pass_error( Changes::Group->error ) );
317 6 return( $g );
318 }
319  
320 sub new_line
321 25 ▶{
Subroutine new_line: called CC=3 SCAR=11.4
Pod documented
322 25 my $self = shift( @_ );
323 25 ▶ $self->_load_class( 'Changes::NewLine' ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class("Changes::NewLine") or return $self->pass_error 25 0 25
324 25 ▶ my $nl = Changes::NewLine->new( @_ ) ||
Condition50%1/2
'Changes::NewLine'->new(@_) || (return $self->pass_error('Changes::NewLine'->error))
l!l
250
MC/DC0%0/1
'Changes::NewLine'->new(@_) || (return $self->pass_error('Changes::NewLine'->error))
'Changes::NewLine'->new(@_)
Truth table50%1/2
A
A= 'Changes::NewLine'->new(@_)
Aresult
11
00
325 return( $self->pass_error( Changes::NewLine->error ) );
326 25 return( $nl );
327 }
328  
329 sub new_release
330 46 ▶{
Subroutine new_release: called CC=9 SCAR=22.7
Pod documented
331 46 my $self = shift( @_ );
332 46 my $opts = $self->_get_args_as_hash( @_ );
333 46 my $defaults = $self->defaults;
334 46 ▶ if( defined( $defaults ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $defaults) 2 44 46
335 {
336 2 my $def = { %$defaults };
337 2 foreach my $opt ( qw( datetime_formatter format spacer time_zone ) )
338 {
339 8 ▶ if( !defined( $opts->{ $opt } ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{$opt} and exists $def->{$opt} and defined $def->{$opt} and length $def->{$opt}) 4 4 8
Condition66%6/9
not defined $opts->{$opt} and exists $def->{$opt} and defined $def->{$opt} and length $def->{$opt}
!ll&&!rl&&r
404
not defined $opts->{$opt} and exists $def->{$opt} and defined $def->{$opt}
!ll&&!rl&&r
404
not defined $opts->{$opt} and exists $def->{$opt}
!ll&&!rl&&r
044
MC/DC25%1/4
not defined $opts->{$opt} and exists $def->{$opt} and defined $def->{$opt} and length $def->{$opt}
not defined $opts->{$opt} exists $def->{$opt} defined $def->{$opt} length $def->{$opt}
Truth table40%2/5
not(A) and B and C and D
A= not defined $opts->{$opt}B= exists $def->{$opt}C= defined $def->{$opt}D= length $def->{$opt}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
340 exists( $def->{ $opt } ) &&
341 defined( $def->{ $opt } ) &&
342 length( $def->{ $opt } ) )
343 {
344 4 $opts->{ $opt } = CORE::delete( $def->{ $opt } );
345 }
346 }
347 2 ▶ $opts->{defaults} //= $def;
Condition33%1/3
$opts->{"defaults"} //= $def
l!l&&r!l&&!r
020
MC/DC0%0/2
$opts->{"defaults"} //= $def
$opts->{"defaults"} $def
Truth table33%1/3
A //= B
A= $opts->{"defaults"}B= $def
ABresult
1X1
011
000
348 }
349 46 ▶ my $rel = Changes::Release->new( $opts ) ||
Condition50%1/2
'Changes::Release'->new($opts) || (return $self->pass_error('Changes::Release'->error))
l!l
460
MC/DC0%0/1
'Changes::Release'->new($opts) || (return $self->pass_error('Changes::Release'->error))
'Changes::Release'->new($opts)
Truth table50%1/2
A
A= 'Changes::Release'->new($opts)
Aresult
11
00
350 return( $self->pass_error( Changes::Release->error ) );
351 46 return( $rel );
352 }
353  
354 sub new_version
355 0 ▶{
Subroutine new_version: not called CC=3 SCAR=24.8
Pod documented
356 0 my $self = shift( @_ );
357 0 ▶ $self->_load_class( 'Changes::Version' ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class("Changes::Version") or return $self->pass_error 0 0 0
358 0 ▶ my $v = Changes::Version->new( @_ ) ||
Condition0%0/2
'Changes::Version'->new(@_) || (return $self->pass_error('Changes::Version'->error))
l!l
00
MC/DC0%0/1
'Changes::Version'->new(@_) || (return $self->pass_error('Changes::Version'->error))
'Changes::Version'->new(@_)
Truth table0%0/2
A
A= 'Changes::Version'->new(@_)
Aresult
11
00
359 return( $self->pass_error( Changes::Version->error ) );
360 0 return( $v );
361 }
362  
363 2 ▶sub nl { return( shift->_set_get_scalar_as_object( 'nl', @_ ) ); }
Subroutine nl: called CC=1 SCAR=0.0
Pod documented
364  
365 sub parse
366 20 ▶{
Subroutine parse: called CC=97 SCAR=68.6
Pod documented
367 20 my $self = shift( @_ );
368 20 ▶ my $lines = shift( @_ ) || return( $self->error( "No array reference of lines was provided." ) );
Condition50%1/2
shift @_ || (return $self->error('No array reference of lines was provided.'))
l!l
200
MC/DC0%0/1
shift @_ || (return $self->error('No array reference of lines was provided.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
369 20 ▶ return( $self->error( "Data provided is not an array reference of lines." ) ) if( !$self->_is_array( $lines ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_array($lines) 0 20 20
370 20 $lines = $self->new_array( $lines );
371 20 my $preamble = $self->new_scalar;
372 20 my $epilogue;
373 20 my $elements = $self->new_array;
374 # Temporary array buffer of new lines found that we store here until we read more of the context in the Changes file and we decide what to do with them.
375 20 my $nls = $self->new_array;
376 20 ▶ my $max_width = $self->max_width // 0;
Condition50%1/2
$self->max_width // 0
l!l
200
MC/DC0%0/1
$self->max_width // 0
$self->max_width
Truth table50%1/2
A
A= $self->max_width
Aresult
11
00
377 20 my $debug = $self->debug;
378 20 my( $group, $release, $change );
379 # $type is the Changes file type. It contains the value guessed, otherwise it remains undef
380 20 my $type = $self->type;
381 20 my $wrapper = $self->wrapper;
382 20 my $tz = $self->time_zone;
383 20 my $defaults = $self->defaults;
384 # Cache it
385 20 ▶ unless( defined( $DATETIME_RE ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Changes::DATETIME_RE) 15 5 20
386 {
387 15 $DATETIME_RE = $self->_get_datetime_regexp( 'all' );
388 }
389 20 ▶ for( my $i = 0; $i < scalar( @$lines ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$lines) 127 20 147
390 {
391 127 my $l = $lines->[$i];
392 # DistZilla release line
393 # 0.01 2022-12-11 08:07:12 Asia/Tokyo
394 127 ▶ if( $l =~ /^
Branch: 9 branches
BranchTrueFalseTotal
if ($l =~ /^ [[:blank:]\h]* (?<r_vers>$Changes::VERSION_LAX_REGEX) (?<v_space>[[:blank:]\h][[:blank:]\h\W]*) (?<r_datetime>$Changes::DATE_DISTZILA_RE) [[:blank:]\h]* (?<r_nl>[\015\012]+)?$ /msx) { } 2 125 127
elsif ($l =~ /^ [[:blank:]\h]* (?<r_vers>$Changes::VERSION_LAX_REGEX) (?<v_space>[[:blank:]\h][[:blank:]\h\W]*) (?<r_date>$Changes::DATETIME_RE) (?: (?<d_space>[[:blank:]\h]+) (?<r_note>.+?))?(?<r_nl>[\015\012]+)? $/msx) { } 34 91 125
elsif ($l =~ /^ [[:blank:]\h]* (?<r_vers>$Changes::VERSION_LAX_REGEX) (?: (?<v_space>[[:blank:]\h][[:blank:]\h\W]*) (?<r_note>[^\015\012]*) )? (?<r_nl>[\015\012]+)? /msx) { } 8 83 91
elsif ($l =~ /^(?<g_space>[[:blank:]\h]+)(?<data>(?:\[(?<g_name>[^\]]+)\]|(?<g_name_colon>\w[^\:]+)\:))[[:blank:]\h]*(?<g_nl>[\015\012]+)?$/ms) { } 6 77 83
elsif (defined $release and $l =~ /^(?<c_space1>[[:blank:]\h]*)(?<marker>(?:[^\w[:blank:]\h]|[\_\x{30FC}]))(?<c_space2>[[:blank:]\h]+)(?<c_text>.+?)(?<c_nl>[\015\012]+)?$/ms) { } 41 36 77
elsif ($l =~ /^(?<space>[[:blank:]\h]+)(?<data>\S+.*?)(?<c_nl>[\015\012]+)?$/ms) { } 4 32 36
elsif ($l =~ /^(?<space>[[:blank:]\h]*)(?<nl>[\015\012]+)?$/) { } 27 5 32
elsif ($elements->is_empty) { } 4 1 5
elsif ($l =~ /^(\S+.*?)(?<nl>[\015\012]+)?$/ms and !($nls->is_empty || defined $epilogue) || defined $epilogue && !defined($release) && !defined($group) && !defined($change) and not $elements->is_empty) { } 1 0 1
395 [[:blank:]\h]*
396 (?<r_vers>$VERSION_LAX_REGEX)
397 (?<v_space>[[:blank:]\h][[:blank:]\h\W]*)
398 (?<r_datetime>$DATE_DISTZILA_RE)
399 [[:blank:]\h]*
400 (?<r_nl>[\015\012]+)?$
401 /msx )
402 {
403 2 my $re = { %+ };
404 # Create the DateTime::Lite object
405 2 ▶ $self->_load_class( 'DateTime::Lite' ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class("DateTime::Lite") or return $self->pass_error 2 0 2
406 2 ▶ $self->_load_class( 'DateTime::Lite::TimeZone' ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class("DateTime::Lite::TimeZone") or return $self->pass_error 2 0 2
407 2 ▶ $self->_load_class( 'DateTime::Format::Lite' ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class("DateTime::Format::Lite") or return $self->pass_error 2 0 2
408 2 my( $dt, $tz, $fmt );
409 # try-catch
410 2 local $@;
411 2 $tz = DateTime::Lite::TimeZone->new( name => $re->{r_tz} );
412 2 ▶ if( !defined( $tz ) && DateTime::Lite::TimeZone->error )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $tz and "DateTime::Lite::TimeZone"->error) 0 2 2
Condition33%1/3
not defined $tz and "DateTime::Lite::TimeZone"->error
!ll&&!rl&&r
200
MC/DC0%0/2
not defined $tz and "DateTime::Lite::TimeZone"->error
not defined $tz "DateTime::Lite::TimeZone"->error
Truth table33%1/3
not(A) and B
A= not defined $tzB= "DateTime::Lite::TimeZone"->error
ABresult
0X0
100
111
413 {
414 0 ▶ if( DateTime::Lite::TimeZone->error->message =~ /Unknown[[:blank:]\h]+time[[:blank:]\h]+zone[[:blank:]\h]+/i )
Branch: 1 branch
BranchTrueFalseTotal
if ('DateTime::Lite::TimeZone'->error->message =~ /Unknown[[:blank:]\h]+time[[:blank:]\h]+zone[[:blank:]\h]+/i) { } 0 0 0
415 {
416 0 ▶ warn( "Warning only: invalid time zone '$re->{r_tz}' specified in release at line ", ( $i + 1 ), "\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
417 0 $tz = DateTime::Lite::TimeZone->new( name => 'UTC' );
418 }
419 else
420 {
421 0 ▶ warn( "Warning only: error trying to instantiate a new DateTime::Lite::TimeZone object with time zone '$re->{r_tz}': ", DateTime::Lite->error->message, "\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
422 0 $tz = DateTime::Lite::TimeZone->new( name => 'UTC' );
423 }
424 }
425  
426  
427 2 $fmt = DateTime::Format::Lite->new(
428 pattern => "%F$re->{r_dt_space}%T$re->{r_tz_space}%O",
429 );
430 2 ▶ if( !defined( $fmt ) && DateTime::Format::Lite->error )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $fmt and "DateTime::Format::Lite"->error) 0 2 2
Condition33%1/3
not defined $fmt and "DateTime::Format::Lite"->error
!ll&&!rl&&r
200
MC/DC0%0/2
not defined $fmt and "DateTime::Format::Lite"->error
not defined $fmt "DateTime::Format::Lite"->error
Truth table33%1/3
not(A) and B
A= not defined $fmtB= "DateTime::Format::Lite"->error
ABresult
0X0
100
111
431 {
432 0 ▶ warn( "Error only: failed to create a DateTime::Format::Lite with pattern '%F$re->{r_dt_space}%T$re->{r_tz_space}%Z': ", DateTime::Format::Lite->error->message, "\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
433 0 $fmt = DateTime::Format::Lite->new(
434 pattern => "%F %T %O",
435 );
436 }
437  
438 # try-catch
439 $dt = DateTime::Lite->new(
440 year => $re->{r_year},
441 month => $re->{r_month},
442 day => $re->{r_day},
443 hour => $re->{r_hour},
444 minute => $re->{r_minute},
445 second => $re->{r_second},
446 2 time_zone => $tz,
447 );
448 2 $dt->set_formatter( $fmt );
449 2 ▶ if( !defined( $dt ) && DateTime::Lite->error )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $dt and "DateTime::Lite"->error) 0 2 2
Condition33%1/3
not defined $dt and "DateTime::Lite"->error
!ll&&!rl&&r
200
MC/DC0%0/2
not defined $dt and "DateTime::Lite"->error
not defined $dt "DateTime::Lite"->error
Truth table33%1/3
not(A) and B
A= not defined $dtB= "DateTime::Lite"->error
ABresult
0X0
100
111
450 {
451 0 ▶ warn( "Warning only: error trying to instantiate a DateTime::Lite value based on the date and time of the release at line ", ( $i + 1 ), ": ", DateTime::Lite->error->message, "\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
452 0 $dt = DateTime::Lite->now( time_zone => $tz );
453 }
454  
455 2 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 1 1 2
456 {
457 1 $elements->push( $nls->list );
458 1 $nls->reset;
459 }
460 2 undef( $group );
461 $release = $self->new_release(
462 version => $re->{r_vers},
463 datetime => $dt,
464 spacer => $re->{v_space},
465 ( defined( $re->{r_note} ) ? ( note => $re->{r_note} ) : () ),
466 raw => $l,
467 line => ( $i + 1 ),
468 container => $self,
469 # Could be undef if this is the last line with no trailing crlf
470 nl => $re->{r_nl},
471 2 ▶ ( defined( $tz ) ? ( time_zone => $tz ) : () ),
Branch: 3 branches
BranchTrueFalseTotal
defined $re->{'r_note'} ? : 0 2 2
defined $tz ? : 2 0 2
defined $defaults ? : 0 2 2
472 ( defined( $defaults ) ? ( defaults => $defaults ) : () ),
473 debug => $debug,
474 );
475 2 $elements->push( $release );
476 2 ▶ if( defined( $preamble ) && !$preamble->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $preamble and not $preamble->is_empty) 0 2 2
Condition33%1/3
defined $preamble and not $preamble->is_empty
!ll&&!rl&&r
020
MC/DC0%0/2
defined $preamble and not $preamble->is_empty
defined $preamble not $preamble->is_empty
Truth table33%1/3
A and not(B)
A= defined $preambleB= not $preamble->is_empty
ABresult
0X0
100
111
477 {
478 0 $self->preamble( $preamble );
479 0 undef( $preamble );
480 }
481 2 ▶ unless( defined( $type ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type) 2 0 2
482 {
483 2 $type = 'distzilla';
484 2 $self->type( $type );
485 }
486 }
487 # Release line
488 # v0.1.0 2022-11-17T08:12:31+0900
489 # 0.01 - 2022-11-17
490 elsif( $l =~ /^
491 [[:blank:]\h]*
492 (?<r_vers>$VERSION_LAX_REGEX)
493 (?<v_space>[[:blank:]\h][[:blank:]\h\W]*)
494 (?<r_date>$DATETIME_RE)
495 (?:
496 (?<d_space>[[:blank:]\h]+)
497 (?<r_note>.+?))?(?<r_nl>[\015\012]+)?
498 $/msx )
499 {
500 34 my $re = { %+ };
501 34 ▶ my $dt = $self->_parse_timestamp( $re->{r_date} ) ||
Condition50%1/2
$self->_parse_timestamp($re->{'r_date'}) || (return $self->pass_error('Cannot parse datetime timestamp although the regular expression matched: ', $self->error->message))
l!l
340
MC/DC0%0/1
$self->_parse_timestamp($re->{'r_date'}) || (return $self->pass_error('Cannot parse datetime timestamp although the regular expression matched: ', $self->error->message))
$self->_parse_timestamp($re->{'r_date'})
Truth table50%1/2
A
A= $self->_parse_timestamp($re->{'r_date'})
Aresult
11
00
502 return( $self->pass_error( "Cannot parse datetime timestamp although the regular expression matched: ", $self->error->message ) );
503 34 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 16 18 34
504 {
505 16 $elements->push( $nls->list );
506 16 $nls->reset;
507 }
508 34 undef( $group );
509 $release = $self->new_release(
510 version => $re->{r_vers},
511 # datetime => $re->{r_date},
512 datetime => $dt,
513 spacer => $re->{v_space},
514 ( defined( $re->{r_note} ) ? ( note => $re->{r_note} ) : () ),
515 raw => $l,
516 line => ( $i + 1 ),
517 container => $self,
518 # Could be undef if this is the last line with no trailing crlf
519 nl => $re->{r_nl},
520 34 ▶ ( defined( $tz ) ? ( time_zone => $tz ) : () ),
Branch: 3 branches
BranchTrueFalseTotal
defined $re->{'r_note'} ? : 2 32 34
defined $tz ? : 0 34 34
defined $defaults ? : 0 34 34
521 ( defined( $defaults ) ? ( defaults => $defaults ) : () ),
522 debug => $debug,
523 );
524 34 $elements->push( $release );
525 34 ▶ if( defined( $preamble ) && !$preamble->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $preamble and not $preamble->is_empty) 3 31 34
Condition100%3/3
defined $preamble and not $preamble->is_empty
!ll&&!rl&&r
1303
MC/DC100%2/2
defined $preamble and not $preamble->is_empty
defined $preamble not $preamble->is_empty
Truth table100%3/3
A and not(B)
A= defined $preambleB= not $preamble->is_empty
ABresult
0X0
100
111
526 {
527 3 $self->preamble( $preamble );
528 3 undef( $preamble );
529 }
530 }
531 elsif( $l =~ /^
532 [[:blank:]\h]*
533 (?<r_vers>$VERSION_LAX_REGEX)
534 (?:
535 (?<v_space>[[:blank:]\h][[:blank:]\h\W]*)
536 (?<r_note>[^\015\012]*)
537 )?
538 (?<r_nl>[\015\012]+)?
539 /msx )
540 {
541 8 my $re = { %+ };
542 8 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 5 3 8
543 {
544 5 $elements->push( $nls->list );
545 5 $nls->reset;
546 }
547 8 undef( $group );
548 $release = $self->new_release(
549 version => $re->{r_vers},
550 spacer => $re->{v_space},
551 ( defined( $re->{r_note} ) ? ( note => $re->{r_note} ) : () ),
552 raw => $l,
553 line => ( $i + 1 ),
554 container => $self,
555 # Could be undef if this is the last line with no trailing crlf
556 nl => $re->{r_nl},
557 8 ▶ ( defined( $tz ) ? ( time_zone => $tz ) : () ),
Branch: 3 branches
BranchTrueFalseTotal
defined $re->{'r_note'} ? : 7 1 8
defined $tz ? : 0 8 8
defined $defaults ? : 0 8 8
558 ( defined( $defaults ) ? ( defaults => $defaults ) : () ),
559 debug => $debug,
560 );
561 8 $elements->push( $release );
562 8 ▶ if( defined( $preamble ) && !$preamble->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $preamble and not $preamble->is_empty) 0 8 8
Condition33%1/3
defined $preamble and not $preamble->is_empty
!ll&&!rl&&r
080
MC/DC0%0/2
defined $preamble and not $preamble->is_empty
defined $preamble not $preamble->is_empty
Truth table33%1/3
A and not(B)
A= defined $preambleB= not $preamble->is_empty
ABresult
0X0
100
111
563 {
564 0 $self->preamble( $preamble );
565 0 undef( $preamble );
566 }
567 }
568 # Group line
569 elsif( $l =~ /^(?<g_space>[[:blank:]\h]+)(?<data>(?:\[(?<g_name>[^\]]+)\]|(?<g_name_colon>\w[^\:]+)\:))[[:blank:]\h]*(?<g_nl>[\015\012]+)?$/ms )
570 {
571 6 my $re = { %+ };
572 # Depending on where we are we treat this either as a group, or as a mere comment of a release change
573 # 1) This is a continuity of the previous change line
574 # We assert this by checking if the space before is longer than the prefix of the change, which would imply an indentation that would put it below the change, and thus not a group
575 6 ▶ if( defined( $change ) && length( $re->{g_space} // '' ) > $change->prefix->length )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $change and length($re->{'g_space'} // '') > $change->prefix->length) { } 0 6 6
Condition60%3/5
defined $change and length($re->{"g_space"} // "") > $change->prefix->length
!ll&&!rl&&r
330
$re->{"g_space"} // ""
l!l
30
MC/DC50%1/2
defined $change and length($re->{"g_space"} // "") > $change->prefix->length
defined $change $re->{"g_space"}
Truth table66%2/3
A and B
A= defined $changeB= $re->{"g_space"}
ABresult
0X0
100
111
576 {
577 0 $change->text->append( $re->{data} );
578 # Since this is a wrapped line, we remove any excessive leading spaces and replace them by just one space
579 0 $l =~ s/^[[:blank:]\h]+/ /g;
580 0 $change->raw->push( $l );
581 }
582 else
583 {
584 # A group is above a change, so if we already have an ongoing change object, we stop using it
585 6 undef( $change );
586 $group = $self->new_group(
587 name => ( $re->{g_name} // $re->{g_name_colon} ),
588 spacer => $re->{g_space},
589 raw => $l,
590 line => ( $i + 1 ),
591 type => ( defined( $re->{g_name_colon} ) ? 'colon' : 'bracket' ),
592 # Could be undef if this is the last line with no trailing crlf
593 nl => $re->{g_nl},
594 6 ▶ ( defined( $defaults ) ? ( defaults => $defaults ) : () ),
Branch: 2 branches
BranchTrueFalseTotal
defined $re->{'g_name_colon'} ? : 0 6 6
defined $defaults ? : 0 6 6
Condition33%1/3
$re->{"g_name"} // $re->{"g_name_colon"}
l!l&&r!l&&!r
600
MC/DC0%0/2
$re->{"g_name"} // $re->{"g_name_colon"}
$re->{"g_name"} $re->{"g_name_colon"}
Truth table33%1/3
A // B
A= $re->{"g_name"}B= $re->{"g_name_colon"}
ABresult
1X1
011
000
595 debug => $debug,
596 );
597 6 ▶ if( !defined( $release ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $release) { } 0 6 6
598 {
599 0 ▶ warn( "Found a group token outside of a release information at line ", ( $i + 1 ), "\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
600 0 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 0 0 0
601 {
602 0 $elements->push( $nls->list );
603 0 $nls->reset;
604 }
605 0 $elements->push( $group );
606 }
607 else
608 {
609 6 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 0 6 6
610 {
611 0 $release->elements->push( $nls->list );
612 0 $nls->reset;
613 }
614 6 $release->elements->push( $group );
615 }
616 }
617 }
618 # Change line
619 ▶ elsif( defined( $release ) &&
Condition100%3/3
defined $release and $l =~ /^(?<c_space1>[[:blank:]\h]*)(?<marker>(?:[^\w[:blank:]\h]|[\_\x{30FC}]))(?<c_space2>[[:blank:]\h]+)(?<c_text>.+?)(?<c_nl>[\015\012]+)?$/ms
!ll&&!rl&&r
82841
MC/DC100%2/2
defined $release and $l =~ /^(?<c_space1>[[:blank:]\h]*)(?<marker>(?:[^\w[:blank:]\h]|[\_\x{30FC}]))(?<c_space2>[[:blank:]\h]+)(?<c_text>.+?)(?<c_nl>[\015\012]+)?$/ms
defined $release $l =~ /^(?<c_space1>[[:blank:]\h]*)(?<marker>(?:[^\w[:blank:]\h]|[\_\x{30FC}]))(?<c_space2>[[:blank:]\h]+)(?<c_text>.+?)(?<c_nl>[\015\012]+)?$/ms
Truth table100%3/3
A and B
A= defined $releaseB= $l =~ /^(?<c_space1>[[:blank:]\h]*)(?<marker>(?:[^\w[:blank:]\h]|[\_\x{30FC}]))(?<c_space2>[[:blank:]\h]+)(?<c_text>.+?)(?<c_nl>[\015\012]+)?$/ms
ABresult
0X0
100
111
620 $l =~ /^(?<c_space1>[[:blank:]\h]*)(?<marker>(?:[^\w[:blank:]\h]|[\_\x{30FC}]))(?<c_space2>[[:blank:]\h]+)(?<c_text>.+?)(?<c_nl>[\015\012]+)?$/ms )
621 {
622 41 my $re = { %+ };
623 $change = $self->new_change(
624 ( defined( $re->{c_space1} ) ? ( spacer1 => $re->{c_space1} ) : () ),
625 ( defined( $re->{c_space2} ) ? ( spacer2 => $re->{c_space2} ) : () ),
626 marker => $re->{marker},
627 max_width => $max_width,
628 ( defined( $re->{c_text} ) ? ( text => $re->{c_text} ) : () ),
629 # Could be undef if this is the last line with no trailing crlf
630 nl => $re->{c_nl},
631 # raw => "$l\n",
632 41 ▶ raw => $l,
Branch: 4 branches
BranchTrueFalseTotal
defined $re->{'c_space1'} ? : 41 0 41
defined $re->{'c_space2'} ? : 41 0 41
defined $re->{'c_text'} ? : 41 0 41
defined $wrapper ? : 0 41 41
Condition50%1/2
$self->new_change(defined $re->{'c_space1'} ? ('spacer1', $re->{'c_space1'}) : (), defined $re->{'c_space2'} ? ('spacer2', $re->{'c_space2'}) : (), 'marker', $re->{'marker'}, 'max_width', $max_width, defined $re->{'c_text'} ? ('text', $re->{'c_text'}) : (), 'nl', $re->{'c_nl'}, 'raw', $l, defined $wrapper ? ('wrapper', $wrapper) : (), 'line', $i + 1, 'debug', $debug) || (return $self->pass_error)
l!l
410
MC/DC0%0/1
$self->new_change(defined $re->{'c_space1'} ? ('spacer1', $re->{'c_space1'}) : (), defined $re->{'c_space2'} ? ('spacer2', $re->{'c_space2'}) : (), 'marker', $re->{'marker'}, 'max_width', $max_width, defined $re->{'c_text'} ? ('text', $re->{'c_text'}) : (), 'nl', $re->{'c_nl'}, 'raw', $l, defined $wrapper ? ('wrapper', $wrapper) : (), 'line', $i + 1, 'debug', $debug) || (return $self->pass_error)
$self->new_change(defined $re->{'c_space1'} ? ('spacer1', $re->{'c_space1'}) : (), defined $re->{'c_space2'} ? ('spacer2', $re->{'c_space2'}) : (), 'marker', $re->{'marker'}, 'max_width', $max_width, defined $re->{'c_text'} ? ('text', $re->{'c_text'}) : (), 'nl', $re->{'c_nl'}, 'raw', $l, defined $wrapper ? ('wrapper', $wrapper) : (), 'line', $i + 1, 'debug', $debug)
Truth table50%1/2
A
A= $self->new_change(defined $re->{'c_space1'} ? ('spacer1', $re->{'c_space1'}) : (), defined $re->{'c_space2'} ? ('spacer2', $re->{'c_space2'}) : (), 'marker', $re->{'marker'}, 'max_width', $max_width, defined $re->{'c_text'} ? ('text', $re->{'c_text'}) : (), 'nl', $re->{'c_nl'}, 'raw', $l, defined $wrapper ? ('wrapper', $wrapper) : (), 'line', $i + 1, 'debug', $debug)
Aresult
11
00
633 ( defined( $wrapper ) ? ( wrapper => $wrapper ) : () ),
634 line => ( $i + 1 ),
635 debug => $debug,
636 ) || return( $self->pass_error );
637  
638 41 ▶ if( defined( $group ) )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $group) { } 7 34 41
elsif (defined $release) { } 34 0 34
639 {
640 7 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 0 7 7
641 {
642 0 $group->elements->push( $nls->list );
643 0 $nls->reset;
644 }
645 7 $group->elements->push( $change );
646 }
647 elsif( defined( $release ) )
648 {
649 34 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 0 34 34
650 {
651 0 $release->elements->push( $nls->list );
652 0 $nls->reset;
653 }
654 34 $release->elements->push( $change );
655 }
656 else
657 {
658 0 ▶ warn( "Found a change token outside of a release information at line ", ( $i + 1 ), "\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
659 0 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 0 0 0
660 {
661 0 $elements->push( $nls->list );
662 0 $nls->reset;
663 }
664 0 $elements->push( $change );
665 }
666 }
667 # Some previous line continuity
668 elsif( $l =~ /^(?<space>[[:blank:]\h]+)(?<data>\S+.*?)(?<c_nl>[\015\012]+)?$/ms )
669 {
670 4 my $re = { %+ };
671 # We have an ongoing change, so this is likely a wrapped line. We append the text
672 4 ▶ if( defined( $change ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $change) { } 4 0 4
673 {
674 4 ▶ $change->text->append( ( $change->nl // $self->nl ) . ( $re->{space} . $re->{data} ) );
Condition33%1/3
$change->nl // $self->nl
l!l&&r!l&&!r
400
MC/DC0%0/2
$change->nl // $self->nl
$change->nl $self->nl
Truth table33%1/3
A // B
A= $change->nlB= $self->nl
ABresult
1X1
011
000
675 # Which might be undef if, for example, this is the last line and there is no trailing crlf
676 4 $change->nl( $re->{c_nl} );
677 4 $change->raw->append( $l );
678 }
679 # Ok, then some weirdly formatted change text
680 else
681 {
682 $change = $self->new_change(
683 ( defined( $re->{c_space1} ) ? ( spacer1 => $re->{c_space1} ) : () ),
684 ( defined( $re->{c_space2} ) ? ( spacer2 => $re->{c_space2} ) : () ),
685 marker => $re->{marker},
686 max_width => $max_width,
687 ( defined( $re->{c_text} ) ? ( text => $re->{c_text} ) : () ),
688 nl => $re->{c_nl},
689 # raw => "$l\n",
690 0 ▶ raw => $l,
Branch: 3 branches
BranchTrueFalseTotal
defined $re->{'c_space1'} ? : 0 0 0
defined $re->{'c_space2'} ? : 0 0 0
defined $re->{'c_text'} ? : 0 0 0
Condition0%0/2
$self->new_change(defined $re->{'c_space1'} ? ('spacer1', $re->{'c_space1'}) : (), defined $re->{'c_space2'} ? ('spacer2', $re->{'c_space2'}) : (), 'marker', $re->{'marker'}, 'max_width', $max_width, defined $re->{'c_text'} ? ('text', $re->{'c_text'}) : (), 'nl', $re->{'c_nl'}, 'raw', $l, 'line', $i + 1, 'debug', $debug) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->new_change(defined $re->{'c_space1'} ? ('spacer1', $re->{'c_space1'}) : (), defined $re->{'c_space2'} ? ('spacer2', $re->{'c_space2'}) : (), 'marker', $re->{'marker'}, 'max_width', $max_width, defined $re->{'c_text'} ? ('text', $re->{'c_text'}) : (), 'nl', $re->{'c_nl'}, 'raw', $l, 'line', $i + 1, 'debug', $debug) || (return $self->pass_error)
$self->new_change(defined $re->{'c_space1'} ? ('spacer1', $re->{'c_space1'}) : (), defined $re->{'c_space2'} ? ('spacer2', $re->{'c_space2'}) : (), 'marker', $re->{'marker'}, 'max_width', $max_width, defined $re->{'c_text'} ? ('text', $re->{'c_text'}) : (), 'nl', $re->{'c_nl'}, 'raw', $l, 'line', $i + 1, 'debug', $debug)
Truth table0%0/2
A
A= $self->new_change(defined $re->{'c_space1'} ? ('spacer1', $re->{'c_space1'}) : (), defined $re->{'c_space2'} ? ('spacer2', $re->{'c_space2'}) : (), 'marker', $re->{'marker'}, 'max_width', $max_width, defined $re->{'c_text'} ? ('text', $re->{'c_text'}) : (), 'nl', $re->{'c_nl'}, 'raw', $l, 'line', $i + 1, 'debug', $debug)
Aresult
11
00
691 line => ( $i + 1 ),
692 debug => $debug,
693 ) || return( $self->pass_error );
694 0 ▶ if( defined( $group ) )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $group) { } 0 0 0
elsif (defined $release) { } 0 0 0
695 {
696 0 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 0 0 0
697 {
698 0 $group->elements->push( $nls->list );
699 0 $nls->reset;
700 }
701 0 $group->elements->push( $change );
702 }
703 elsif( defined( $release ) )
704 {
705 0 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($nls->is_empty) 0 0 0
706 {
707 0 $release->elements->push( $nls->list );
708 0 $nls->reset;
709 }
710 0 $release->elements->push( $change );
711 }
712 }
713 }
714 # Blank line
715 elsif( $l =~ /^(?<space>[[:blank:]\h]*)(?<nl>[\015\012]+)?$/ )
716 {
717 27 my $re = { %+ };
718 # If we are still in the preamble, this might just be a multi lines preamble
719 27 ▶ if( $elements->is_empty )
Branch: 2 branches
BranchTrueFalseTotal
if ($elements->is_empty) { } 4 23 27
elsif (defined $release) { } 23 0 23
720 {
721 # $preamble->append( "$l\n" );
722 4 $preamble->append( $l );
723 }
724 # Otherwise, this is a blank line, which separates elements
725 elsif( defined( $release ) )
726 {
727 23 undef( $change );
728 23 undef( $group );
729 # We do not undef the latest release object, because we could have blank lines inside a release section
730 # $release->changes->push( $self->new_line );
731 $nls->push( $self->new_line(
732 line => ( $i + 1 ),
733 (
734 ( defined( $re->{nl} ) && defined( $re->{space} ) )
735 23 ▶ ? ( nl => ( $re->{space} // '' ) . ( $re->{nl} // '' ) )
Branch: 1 branch
BranchTrueFalseTotal
defined $re->{'nl'} && defined $re->{'space'} ? : 23 0 23
Condition42%3/7
defined $re->{"nl"} and defined $re->{"space"}
!ll&&!rl&&r
0023
$re->{"space"} // ""
l!l
230
$re->{"nl"} // ""
l!l
230
MC/DC0%0/2
defined $re->{"nl"} and defined $re->{"space"}
defined $re->{"nl"} defined $re->{"space"}
MC/DC0%0/1
$re->{"space"} // ""
$re->{"space"}
MC/DC0%0/1
$re->{"nl"} // ""
$re->{"nl"}
Truth table33%1/3
A and B
A= defined $re->{"nl"}B= defined $re->{"space"}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $re->{"space"}
Aresult
11
00
Truth table50%1/2
A
A= $re->{"nl"}
Aresult
11
00
736 : ( nl => undef )
737 ),
738 raw => $l,
739 debug => $debug
740 ));
741 }
742 else
743 {
744 0 ▶ warn( "I found an empty line outside a release and no release object to associate it to.\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
745 # $releases->push( $self->new_line );
746 0 $nls->push( $self->new_line( raw => $l, debug => $debug ) );
747 }
748 }
749 # Preamble
750 elsif( $elements->is_empty )
751 {
752 4 $preamble->append( $l );
753 }
754 # Epilogue
755 # We found a line with no leading space with new blank lines before it and no epilogue yet, or maybe no blank lines, but with epilogue already set.
756 ▶ elsif( $l =~ /^(\S+.*?)(?<nl>[\015\012]+)?$/ms &&
Condition19%4/21
$l =~ /^(\S+.*?)(?<nl>[\015\012]+)?$/ms and !($nls->is_empty || defined $epilogue) || defined $epilogue && !defined($release) && !defined($group) && !defined($change) and not $elements->is_empty
!ll&&!rl&&r
001
$l =~ /^(\S+.*?)(?<nl>[\015\012]+)?$/ms and !($nls->is_empty || defined $epilogue) || defined $epilogue && !defined($release) && !defined($group) && !defined($change)
!ll&&!rl&&r
001
not $nls->is_empty || defined $epilogue or defined $epilogue and not defined $release and not defined $group and not defined $change
l!l&&r!l&&!r
100
$nls->is_empty || defined $epilogue
l!l&&r!l&&!r
001
defined $epilogue and not defined $release and not defined $group and not defined $change
!ll&&!rl&&r
000
defined $epilogue and not defined $release and not defined $group
!ll&&!rl&&r
000
defined $epilogue and not defined $release
!ll&&!rl&&r
000
MC/DC0%0/8
$l =~ /^(\S+.*?)(?<nl>[\015\012]+)?$/ms and !($nls->is_empty || defined $epilogue) || defined $epilogue && !defined($release) && !defined($group) && !defined($change) and not $elements->is_empty
$l =~ /^(\S+.*?)(?<nl>[\015\012]+)?$/ms $nls->is_empty defined $epilogue defined $epilogue not defined $release not defined $group not defined $change not $elements->is_empty
Truth table6%1/15
A and not(B || C) or D and not(E) and not(F) and not(G) and not(H)
A= $l =~ /^(\S+.*?)(?<nl>[\015\012]+)?$/msB= $nls->is_emptyC= defined $epilogueD= defined $epilogueE= not defined $releaseF= not defined $groupG= not defined $changeH= not $elements->is_empty
ABCDEFGHresult
0XXXXXXX0
11X0XXXX0
11X10XXX0
11X110XX0
11X1110X0
1010XXXX0
10110XXX0
101110XX0
1011110X0
100XXXX00
11X111100
101111100
100XXXX11
11X111111
101111111
757 (
758 ( !$nls->is_empty && !defined( $epilogue ) ) ||
759 ( defined( $epilogue ) && !defined( $release ) && !defined( $group ) && !defined( $change ) )
760 ) &&
761 # If elements are empty this would rather be part of the preamble
762 !$elements->is_empty )
763 {
764 1 my $re = { %+ };
765 1 ▶ if( !$nls->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if (not $nls->is_empty) { } 1 0 1
766 {
767 1 $elements->push( $nls->list );
768 1 $nls->reset;
769 1 undef( $release );
770 1 undef( $change );
771 1 undef( $group );
772 1 $epilogue = $self->new_scalar( $l );
773 1 $self->epilogue( $epilogue );
774 }
775 else
776 {
777 0 $epilogue->append( $l );
778 }
779 }
780 else
781 {
782 0 chomp( $l );
783 0 ▶ warn( "Found an unrecognisable line: '$l'\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
784 }
785 }
786 20 $self->elements( $elements );
787 20 return( $self );
788 }
789  
790 45 ▶sub preamble { return( shift->_set_get_scalar_as_object({
Subroutine preamble: called CC=1 SCAR=0.1
Pod documented
791 field => 'preamble',
792 callbacks =>
793 {
794 set => sub
795 4 ▶ {
Subroutine __ANON__: called CC=7 SCAR=20.5
796 4 my( $self, $text ) = @_;
797 4 ▶ if( defined( $text ) && $text->defined )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $text and $text->defined) 4 0 4
Condition33%1/3
defined $text and $text->defined
!ll&&!rl&&r
004
MC/DC0%0/2
defined $text and $text->defined
defined $text $text->defined
Truth table33%1/3
A and B
A= defined $textB= $text->defined
ABresult
0X0
100
111
798 {
799 4 ▶ unless( $text =~ /[\015\012]$/ms )
Branch: 1 branch
BranchTrueFalseTotal
unless ($text =~ /[\015\012]$/ms) 1 3 4
800 {
801 1 ▶ $text->append( $self->nl // "\n" );
Condition50%1/2
$self->nl // "\n"
l!l
10
MC/DC0%0/1
$self->nl // "\n"
$self->nl
Truth table50%1/2
A
A= $self->nl
Aresult
11
00
802 }
803 4 ▶ unless( $text =~ /[\015\012]{2,}$/ms )
Branch: 1 branch
BranchTrueFalseTotal
unless ($text =~ /[\015\012]{2,}$/ms) 1 3 4
804 {
805 1 ▶ $text->append( $self->nl // "\n" );
Condition50%1/2
$self->nl // "\n"
l!l
10
MC/DC0%0/1
$self->nl // "\n"
$self->nl
Truth table50%1/2
A
A= $self->nl
Aresult
11
00
806 }
807 }
808 4 return( $text );
809 },
810 }
811 45 }, @_ ) ); }
812  
813 sub preset
814 0 ▶{
Subroutine preset: not called CC=3 SCAR=24.8
Pod documented
815 0 my $self = shift( @_ );
816 0 ▶ my $set = shift( @_ ) || return( $self->error( "No set name was provided." ) );
Condition0%0/2
shift @_ || (return $self->error('No set name was provided.'))
l!l
00
MC/DC0%0/1
shift @_ || (return $self->error('No set name was provided.'))
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
817 my $sets =
818 {
819 standard =>
820 {
821 # for Changes::Release
822 datetime_formatter => sub
823 0 ▶ {
Subroutine __ANON__: not called CC=3 SCAR=24.8
824 0 ▶ my $dt = shift( @_ ) || DateTime::Lite->now;
Condition0%0/3
shift @_ || 'DateTime::Lite'->now
l!l&&r!l&&!r
000
MC/DC0%0/2
shift @_ || 'DateTime::Lite'->now
shift @_ 'DateTime::Lite'->now
Truth table0%0/3
A || B
A= shift @_B= 'DateTime::Lite'->now
ABresult
1X1
011
000
825 0 require DateTime::Format::Lite;
826 0 my $fmt = DateTime::Format::Lite->new(
827 pattern => '%FT%T%z',
828 locale => 'en_GB',
829 );
830 0 $dt->set_formatter( $fmt );
831 0 my $tz = $self->time_zone;
832 0 ▶ $dt->set_time_zone( $tz ) if( $tz );
Branch: 1 branch
BranchTrueFalseTotal
if $tz 0 0 0
833 0 return( $dt );
834 },
835 # No need to provide it if it is just a space though, because it will default to it anyway
836 0 spacer => ' ',
837 # for Changes::Change
838 spacer1 => "\t",
839 spacer2 => ' ',
840 marker => '-',
841 max_width => 72,
842 # wrapper => $code_reference,
843 # for Changes::Group
844 group_spacer => "\t",
845 group_type => 'bracket', # [Some group]
846 }
847 };
848 0 ▶ return( $self->error( "Set requested ($set) is not supported." ) ) if( !exists( $sets->{ $set } ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $sets->{$set} 0 0 0
849 0 my $def = $sets->{ $set };
850 0 $self->defaults( $def );
851 0 return( $self );
852 }
853  
854 sub releases
855 62 ▶{
Subroutine releases: called CC=1 SCAR=0.0
Pod documented
856 62 my $self = shift( @_ );
857 62 ▶ my $a = $self->elements->grep(sub{ $self->_is_a( $_ => 'Changes::Release' ) });
Subroutine __ANON__: called CC=1 SCAR=0.0
858 62 return( $a );
859 }
860  
861 0 ▶sub remove_release { return( shift->delete_release( @_ ) ); }
Subroutine remove_release: not called CC=1 SCAR=6.9
Pod documented
862  
863 sub reset
864 0 ▶{
Subroutine reset: not called CC=5 SCAR=34.0
Pod undocumented
865 0 my $self = shift( @_ );
866 0 ▶ if( (
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{"_reset"} && defined $self->{"_reset"} && length $self->{"_reset"} and scalar @_) 0 0 0
Condition0%0/8
not exists $self->{"_reset"} && defined $self->{"_reset"} && length $self->{"_reset"} and scalar @_
!ll
00
exists $self->{'_reset'} && defined $self->{'_reset'} && length $self->{'_reset'}
!ll&&!rl&&r
000
exists $self->{"_reset"} and defined $self->{"_reset"}
!ll&&!rl&&r
000
MC/DC0%0/3
not exists $self->{"_reset"} && defined $self->{"_reset"} && length $self->{"_reset"} and scalar @_
exists $self->{"_reset"} defined $self->{"_reset"} length $self->{'_reset'}
Truth table0%0/4
not(A and B && C)
A= exists $self->{"_reset"}B= defined $self->{"_reset"}C= length $self->{'_reset'}
ABCresult
1110
0XX1
10X1
1101
867 !exists( $self->{_reset} ) ||
868 !defined( $self->{_reset} ) ||
869 !CORE::length( $self->{_reset} )
870 ) && scalar( @_ ) )
871 {
872 0 $self->{_reset} = scalar( @_ );
873 0 $self->{_reset_normalise} = 1;
874 }
875 0 return( $self );
876 }
877  
878 sub time_zone
879 20 ▶{
Subroutine time_zone: called CC=8 SCAR=35.6
Pod documented
880 20 my $self = shift( @_ );
881 20 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 20 20
882 {
883 0 my $v = shift( @_ );
884 0 ▶ if( $self->_is_a( $v => 'DateTime::Lite::TimeZone' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_a($v, 'DateTime::Lite::TimeZone')) { } 0 0 0
885 {
886 0 $self->{time_zone} = $v;
887 }
888 else
889 {
890 0 ▶ $self->_load_class( 'DateTime::Lite::TimeZone' ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class("DateTime::Lite::TimeZone") or return $self->pass_error 0 0 0
891 # try-catch
892 0 local $@;
893 0 my $tz = DateTime::Lite::TimeZone->new( name => "$v" );
894 0 $self->{time_zone} = $tz;
895 0 ▶ if( !defined( $tz ) && DateTime::Lite::TimeZone->error )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $tz and "DateTime::Lite::TimeZone"->error) 0 0 0
Condition0%0/3
not defined $tz and "DateTime::Lite::TimeZone"->error
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $tz and "DateTime::Lite::TimeZone"->error
not defined $tz "DateTime::Lite::TimeZone"->error
Truth table0%0/3
not(A) and B
A= not defined $tzB= "DateTime::Lite::TimeZone"->error
ABresult
0X0
100
111
896 {
897 0 return( $self->error( "Error setting time zone for '$v': ", DateTime::Lite::TimeZone->error->message ) );
898 }
899 }
900 # $self->reset(1);
901 }
902 20 ▶ if( !defined( $self->{time_zone} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'time_zone'}) { } 20 0 20
903 {
904 20 ▶ if( Wanted::want( 'OBJECT' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (Wanted::want('OBJECT')) { } 0 20 20
905 {
906 0 require Module::Generic::Null;
907 0 rreturn( Module::Generic::Null->new( wants => 'OBJECT' ) );
908 }
909 else
910 {
911 20 return;
912 }
913 }
914 else
915 {
916 0 return( $self->{time_zone} );
917 }
918 }
919  
920 23 ▶sub type { return( shift->_set_get_scalar_as_object( 'type', @_ ) ); }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
921  
922 20 ▶sub wrapper { return( shift->_set_get_code( 'wrapper', @_ ) ); }
Subroutine wrapper: called CC=1 SCAR=0.0
Pod documented
923  
924 sub write
925 1 ▶{
Subroutine write: called CC=7 SCAR=23.0
Pod documented
926 1 my $self = shift( @_ );
927 1 ▶ my $f = $self->file ||
Condition50%1/2
$self->file || (return $self->error('No Changes file has been set to write to.'))
l!l
10
MC/DC0%0/1
$self->file || (return $self->error('No Changes file has been set to write to.'))
$self->file
Truth table50%1/2
A
A= $self->file
Aresult
11
00
928 return( $self->error( "No Changes file has been set to write to." ) );
929 1 my $str = $self->as_string;
930 1 ▶ return( $self->pass_error ) if( !defined( $str ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 0 1 1
931 1 ▶ if( $str->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if ($str->is_empty) 0 1 1
932 {
933 0 ▶ warn( "Warning only: nothing to write to change file $f\n" ) if( $self->_warnings_is_enabled );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_warnings_is_enabled 0 0 0
934 0 return( $self );
935 }
936 1 ▶ my $fh = $f->open( '>', { binmode => 'utf-8', autoflush => 1 } ) ||
Condition50%1/2
$f->open('>', {'binmode', 'utf-8', 'autoflush', 1}) || (return $self->pass_error($f->error))
l!l
10
MC/DC0%0/1
$f->open('>', {'binmode', 'utf-8', 'autoflush', 1}) || (return $self->pass_error($f->error))
$f->open('>', {'binmode', 'utf-8', 'autoflush', 1})
Truth table50%1/2
A
A= $f->open('>', {'binmode', 'utf-8', 'autoflush', 1})
Aresult
11
00
937 return( $self->pass_error( $f->error ) );
938 1 ▶ $fh->print( $str->scalar ) || return( $self->pass_error( $fh->error ) );
Branch: 1 branch
BranchTrueFalseTotal
$fh->print($str->scalar) or return $self->pass_error($fh->error) 1 0 1
939 1 $fh->close;
940 1 return( $self );
941 }
942  
943 18 1;
944 # NOTE: POD
945 __END__
↑ Summary Changes/Version.pm »