line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
2
|
|
|
2
|
|
97675
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
87
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
139
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Gentoo::ChangeLog::Parser::Eventual::Simple; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
2
|
|
|
2
|
|
71
|
$Gentoo::ChangeLog::Parser::Eventual::Simple::AUTHORITY = 'cpan:KENTNL'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
{ |
10
|
|
|
|
|
|
|
$Gentoo::ChangeLog::Parser::Eventual::Simple::VERSION = '0.1.2'; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: A very crude ChangeLog -> Graph translation. |
14
|
|
|
|
|
|
|
{ |
15
|
2
|
|
|
2
|
|
13
|
use Carp qw( croak ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
318
|
|
16
|
2
|
|
|
2
|
|
5324
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use namespace::clean -except => 'meta'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has '_parser' => ( |
22
|
|
|
|
|
|
|
isa => 'Object', |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
lazy => 1, |
25
|
|
|
|
|
|
|
default => sub { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
require Gentoo::ChangeLog::Parser::Eventual; |
28
|
|
|
|
|
|
|
Gentoo::ChangeLog::Parser::Eventual->new( |
29
|
|
|
|
|
|
|
callback => sub { |
30
|
|
|
|
|
|
|
$self->_callback->( $self, @_ ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has '_callback' => ( |
37
|
|
|
|
|
|
|
isa => 'CodeRef', |
38
|
|
|
|
|
|
|
is => 'rw', |
39
|
|
|
|
|
|
|
lazy => 1, |
40
|
|
|
|
|
|
|
default => sub { croak('NOT REALLY AUTOMATIC, need to specify _callback') }, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub parse_lines { |
45
|
|
|
|
|
|
|
my ( $class, $lines ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my @output; |
48
|
|
|
|
|
|
|
my %stash; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $instance = $class->new( |
51
|
|
|
|
|
|
|
_callback => sub { |
52
|
|
|
|
|
|
|
my ( $self, $parser, $event, $opts ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# warn "\e[31m$event \e[32m" . $opts->{line} . " => \e[0m" . $opts->{content} . "\n"; |
55
|
|
|
|
|
|
|
return if $event eq 'start'; |
56
|
|
|
|
|
|
|
if ( $event eq 'header' ) { |
57
|
|
|
|
|
|
|
$stash{header} = []; |
58
|
|
|
|
|
|
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
if ( $event eq 'header_comment' ) { |
61
|
|
|
|
|
|
|
push @{ $stash{header} }, $opts; |
62
|
|
|
|
|
|
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
if ( $event eq 'header_end' ) { |
65
|
|
|
|
|
|
|
push @output, { 'header' => $stash{header}, line => $stash{header}->[0]->{line} }; |
66
|
|
|
|
|
|
|
delete $stash{header}; |
67
|
|
|
|
|
|
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
if ( $event eq 'change_header' ) { |
70
|
|
|
|
|
|
|
$stash{changeheader} = []; |
71
|
|
|
|
|
|
|
push @{ $stash{changeheader} }, $opts; |
72
|
|
|
|
|
|
|
$stash{changebody} = []; |
73
|
|
|
|
|
|
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
if ( $event eq 'begin_change_header' ) { |
76
|
|
|
|
|
|
|
$stash{changeheader} = []; |
77
|
|
|
|
|
|
|
push @{ $stash{changeheader} }, $opts; |
78
|
|
|
|
|
|
|
$stash{changebody} = []; |
79
|
|
|
|
|
|
|
return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
if ( $event eq 'continue_change_header' ) { |
82
|
|
|
|
|
|
|
push @{ $stash{changeheader} }, $opts; |
83
|
|
|
|
|
|
|
return; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
if ( $event eq 'end_change_header' ) { |
86
|
|
|
|
|
|
|
push @{ $stash{changeheader} }, $opts; |
87
|
|
|
|
|
|
|
return; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
if ( $event eq 'change_body' ) { |
90
|
|
|
|
|
|
|
push @{ $stash{changebody} }, $opts; |
91
|
|
|
|
|
|
|
return; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
if ( $event eq 'end_change_body' ) { |
94
|
|
|
|
|
|
|
push @output, { |
95
|
|
|
|
|
|
|
change => { |
96
|
|
|
|
|
|
|
header => $stash{changeheader}, |
97
|
|
|
|
|
|
|
body => $stash{changebody}, |
98
|
|
|
|
|
|
|
}, |
99
|
|
|
|
|
|
|
line => $stash{changeheader}->[0]->{'line'}, |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
delete $stash{changeheader}; |
103
|
|
|
|
|
|
|
delete $stash{changebody}; |
104
|
|
|
|
|
|
|
return; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
if ( $event eq 'release_line' ) { |
107
|
|
|
|
|
|
|
push @output, { release => $opts, line => $opts->{line} }; |
108
|
|
|
|
|
|
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
if ( $event eq 'blank' ) { |
111
|
|
|
|
|
|
|
push @output, { 'blank' => $opts, line => $opts->{line} }; |
112
|
|
|
|
|
|
|
return; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
push @output, { UNHANDLED => { $event => $opts } }; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $i = 0; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
for my $line ( @{$lines} ) { |
121
|
|
|
|
|
|
|
$instance->_parser->handle_line( $line, { line => $i } ); |
122
|
|
|
|
|
|
|
$i++; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
if ( exists $stash{header} ) { |
125
|
|
|
|
|
|
|
push @output, { header => $stash{header}, line => $stash{header}->[0]->{line} }; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
if ( exists $stash{changeheader} ) { |
128
|
|
|
|
|
|
|
push @output, |
129
|
|
|
|
|
|
|
{ |
130
|
|
|
|
|
|
|
change => { |
131
|
|
|
|
|
|
|
header => $stash{changeheader}, |
132
|
|
|
|
|
|
|
body => ( exists $stash{changebody} ? $stash{changebody} : {} ), |
133
|
|
|
|
|
|
|
}, |
134
|
|
|
|
|
|
|
line => $stash{changeheader}->[0]->{line}, |
135
|
|
|
|
|
|
|
}; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
return [ sort { $a->{line} <=> $b->{line} } @output ]; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
140
|
|
|
|
|
|
|
no Moose; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
1; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__END__ |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=pod |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 NAME |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Gentoo::ChangeLog::Parser::Eventual::Simple - A very crude ChangeLog -> Graph translation. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 VERSION |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
version 0.1.2 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 SYNOPSIS |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
use Gentoo::ChangeLog::Parser::Eventual::Simple; |
159
|
|
|
|
|
|
|
use Path::Class qw( file ); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my $arrayRef = Gentoo::ChangeLog::Parser::Eventual::Simple->parse_lines( |
162
|
|
|
|
|
|
|
file("some_file")->slurp( chomp => 1 ) |
163
|
|
|
|
|
|
|
); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 DESCRIPTION |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This is a very simple consumer of L<< C<Gentoo::ChangeLog::Parser::Eventual>|Gentoo::ChangeLog::Parser::Eventual >> |
168
|
|
|
|
|
|
|
that uses the events to accumulate an array of hash objects describing the source document. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 METHODS |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 parse_lines |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head3 Specification: $arrayref = $class->parse_lines( @list_of_lines ) |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Each line should be pre-chomped. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head3 Example: |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
my $arrayRef = Gentoo::ChangeLog::Parser::Eventual::Simple->parse_lines( |
181
|
|
|
|
|
|
|
file("some_file")->slurp( chomp => 1 ) |
182
|
|
|
|
|
|
|
); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Kent Fredric <kentnl@cpan.org>. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
193
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |