line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Changes::ADAMK::Release; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
98
|
use 5.006; |
|
5
|
|
|
|
|
63
|
|
|
5
|
|
|
|
|
200
|
|
4
|
5
|
|
|
5
|
|
29
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
208
|
|
5
|
5
|
|
|
5
|
|
38
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
182
|
|
6
|
5
|
|
|
5
|
|
34
|
use Carp (); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
120
|
|
7
|
5
|
|
|
5
|
|
26
|
use Params::Util '_INSTANCE'; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
445
|
|
8
|
5
|
|
|
5
|
|
25
|
use DateTime (); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
74
|
|
9
|
5
|
|
|
5
|
|
24
|
use DateTime::Format::CLDR (); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
132
|
|
10
|
5
|
|
|
5
|
|
30
|
use DateTime::Format::DateParse (); |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
110
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
22
|
use vars qw{$VERSION}; |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
245
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
5
|
|
|
5
|
|
85
|
$VERSION = '0.11'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
4932
|
use Module::Changes::ADAMK::Change (); |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
127
|
|
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
24
|
use Object::Tiny qw{ |
20
|
|
|
|
|
|
|
string |
21
|
|
|
|
|
|
|
version |
22
|
|
|
|
|
|
|
date |
23
|
|
|
|
|
|
|
datetime |
24
|
5
|
|
|
5
|
|
33
|
}; |
|
5
|
|
|
|
|
10
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
##################################################################### |
31
|
|
|
|
|
|
|
# Constructor |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
86
|
|
|
86
|
0
|
116
|
my $class = shift; |
35
|
86
|
|
|
|
|
361
|
my $self = bless { string => shift }, $class; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Get the paragraph strings |
38
|
86
|
|
|
|
|
358
|
my @lines = split /\n/, $self->{string}; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Find the header substrings |
41
|
86
|
|
|
|
|
202
|
my $header = shift @lines; |
42
|
86
|
50
|
|
|
|
636
|
unless ( $header =~ /^([\d_\.]+)(?:\s+(.+?\d{4}))?/ ) { |
43
|
0
|
|
|
|
|
0
|
Carp::croak("Failed to find version for release in '$header'"); |
44
|
|
|
|
|
|
|
} |
45
|
86
|
|
|
|
|
251
|
$self->{version} = $1; |
46
|
86
|
|
|
|
|
191
|
$self->{date} = $2; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Inflate the DateTime |
49
|
86
|
100
|
|
|
|
195
|
if ( $self->{date} ) { |
50
|
84
|
|
|
|
|
370
|
$self->{datetime} = DateTime::Format::DateParse->parse_datetime($self->{date}); |
51
|
84
|
50
|
|
|
|
48192
|
if ( $self->{datetime} ) { |
52
|
84
|
|
|
|
|
9412
|
$self->{datetime}->truncate( to => 'day' ); |
53
|
84
|
|
|
|
|
25780
|
$self->{datetime}->set_time_zone('floating'); |
54
|
84
|
|
|
|
|
12366
|
$self->{datetime}->set_locale('C'); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Split up the changes |
59
|
86
|
|
|
|
|
19027
|
my @current = (); |
60
|
86
|
|
|
|
|
119
|
my @changes = (); |
61
|
86
|
|
|
|
|
222
|
while ( @lines ) { |
62
|
192
|
|
|
|
|
253
|
my $line = shift @lines; |
63
|
192
|
100
|
100
|
|
|
1470
|
if ( $line =~ /^\s*-/ and @current ) { |
64
|
71
|
|
|
|
|
154
|
push @changes, [ @current ]; |
65
|
71
|
|
|
|
|
105
|
@current = (); |
66
|
|
|
|
|
|
|
} |
67
|
192
|
|
|
|
|
484
|
push @current, $line; |
68
|
|
|
|
|
|
|
} |
69
|
86
|
100
|
|
|
|
243
|
push @changes, [ @current ] if @current; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Convert to change objects |
72
|
86
|
|
|
|
|
197
|
$self->{changes} = [ ]; |
73
|
86
|
|
|
|
|
145
|
foreach my $change ( @changes ) { |
74
|
155
|
|
|
|
|
549
|
my $string = join "\n", @$change; |
75
|
155
|
|
|
|
|
737
|
my $object = Module::Changes::ADAMK::Change->new($string); |
76
|
155
|
|
|
|
|
168
|
push @{$self->{changes}}, $object; |
|
155
|
|
|
|
|
440
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
86
|
|
|
|
|
420
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub changes { |
83
|
41
|
|
|
41
|
0
|
2114
|
@{$_[0]->{changes}}; |
|
41
|
|
|
|
|
101
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
##################################################################### |
91
|
|
|
|
|
|
|
# Modification Functions |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub set_datetime_now { |
94
|
0
|
|
|
0
|
0
|
0
|
my $dt = DateTime->now; |
95
|
0
|
|
|
|
|
0
|
$_[0]->set_datetime( $dt ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub set_datetime { |
99
|
1
|
|
|
1
|
0
|
1671
|
my $self = shift; |
100
|
1
|
|
|
|
|
4
|
my $dt = shift; |
101
|
1
|
50
|
|
|
|
17
|
unless ( _INSTANCE($dt, 'DateTime') ) { |
102
|
0
|
|
|
|
|
0
|
Carp::croak('Did not pass a valid DateTime to set_datetime'); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Overwrite the datetime |
106
|
1
|
|
|
|
|
46
|
$self->{datetime} = $dt; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Overwrite the string form |
109
|
1
|
|
|
|
|
11
|
$self->{date} = $dt->strftime('%a %e %b %Y'); |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
120
|
return 1; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
##################################################################### |
119
|
|
|
|
|
|
|
# Stringification |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub as_string { |
122
|
39
|
|
|
39
|
0
|
321
|
my $self = shift; |
123
|
53
|
|
|
|
|
270
|
my @lines = ( |
124
|
|
|
|
|
|
|
$self->version . ' ' . $self->date, |
125
|
39
|
|
|
|
|
772
|
map { $_->as_string } $self->changes, |
126
|
|
|
|
|
|
|
); |
127
|
39
|
|
|
|
|
580
|
return join "\n", @lines; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub roundtrips { |
131
|
13
|
|
|
13
|
0
|
3835
|
$_[0]->string eq $_[0]->as_string |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |