| 1 | 3 | ▶ | use 5.006; # our | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package MetaPOD::Extractor; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | our $VERSION = 'v0.4.0'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Extract MetaPOD declarations from a file. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Moo qw( extends has ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 3 | extends 'Pod::Eventual'; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | ## no critic (Bangs::ProhibitDebuggingModule) | ||||||||||||||||||||||||||||
| 29 | 3 | ▶ | use Data::Dump qw(pp); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | has formatter_regexp => ( | ||||||||||||||||||||||||||||
| 33 | is => ro =>, | ||||||||||||||||||||||||||||
| 34 | lazy => 1, | ||||||||||||||||||||||||||||
| 35 | 1 | ▶ | builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
_build_formatter_regexp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # _Pulp__5010_qr_m_propagate_properly | ||||||||||||||||||||||||||||
| 38 | ## no critic (Compatibility::PerlMinimumVersionAndWhy) | ||||||||||||||||||||||||||||
| 39 | 1 | return qr/MetaPOD::([^[:space:]]+)/sxm; | |||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||
| 41 | 3 | ); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | has version_regexp => ( | ||||||||||||||||||||||||||||
| 44 | is => ro =>, | ||||||||||||||||||||||||||||
| 45 | lazy => 1, | ||||||||||||||||||||||||||||
| 46 | 5 | ▶ | builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
_build_version_regexp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # _Pulp__5010_qr_m_propagate_properly | ||||||||||||||||||||||||||||
| 49 | ## no critic (Compatibility::PerlMinimumVersionAndWhy) | ||||||||||||||||||||||||||||
| 50 | 5 | return qr/(v[[:digit:].]+)/sxm; | |||||||||||||||||||||||||||
| 51 | }, | ||||||||||||||||||||||||||||
| 52 | 3 | ); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | has regexp_begin_with_version => ( | ||||||||||||||||||||||||||||
| 55 | is => ro =>, | ||||||||||||||||||||||||||||
| 56 | lazy => 1, | ||||||||||||||||||||||||||||
| 57 | 3 | ▶ | builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | 3 | my $formatter_regexp = $_[0]->formatter_regexp; | |||||||||||||||||||||||||||
| 59 | 3 | my $version_regexp = $_[0]->version_regexp; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # _Pulp__5010_qr_m_propagate_properly | ||||||||||||||||||||||||||||
| 62 | ## no critic (Compatibility::PerlMinimumVersionAndWhy) | ||||||||||||||||||||||||||||
| 63 | 3 | return qr{ ^ ${formatter_regexp} \s+ ${version_regexp} \s* $ }smx; | |||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||
| 65 | 3 | ); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | has regexp_begin => ( | ||||||||||||||||||||||||||||
| 68 | is => ro =>, | ||||||||||||||||||||||||||||
| 69 | lazy => 1, | ||||||||||||||||||||||||||||
| 70 | 2 | ▶ | builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
_build_regexp_begin: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 71 | 2 | my $formatter_regexp = $_[0]->formatter_regexp; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # _Pulp__5010_qr_m_propagate_properly | ||||||||||||||||||||||||||||
| 74 | ## no critic (Compatibility::PerlMinimumVersionAndWhy) | ||||||||||||||||||||||||||||
| 75 | 2 | return qr{ ^ ${formatter_regexp} \s* $ }smx; | |||||||||||||||||||||||||||
| 76 | }, | ||||||||||||||||||||||||||||
| 77 | 3 | ); | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | has regexp_for_with_version => ( | ||||||||||||||||||||||||||||
| 80 | is => ro =>, | ||||||||||||||||||||||||||||
| 81 | lazy => 1, | ||||||||||||||||||||||||||||
| 82 | 2 | ▶ | builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 83 | 2 | my $formatter_regexp = $_[0]->formatter_regexp; | |||||||||||||||||||||||||||
| 84 | 2 | my $version_regexp = $_[0]->version_regexp; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | # _Pulp__5010_qr_m_propagate_properly | ||||||||||||||||||||||||||||
| 87 | ## no critic (Compatibility::PerlMinimumVersionAndWhy) | ||||||||||||||||||||||||||||
| 88 | 2 | return qr{ ^ ${formatter_regexp} \s+ ${version_regexp} \s+ ( .*$ ) }smx; | |||||||||||||||||||||||||||
| 89 | }, | ||||||||||||||||||||||||||||
| 90 | 3 | ); | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | has regexp_for => ( | ||||||||||||||||||||||||||||
| 93 | is => ro =>, | ||||||||||||||||||||||||||||
| 94 | lazy => 1, | ||||||||||||||||||||||||||||
| 95 | 1 | ▶ | builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 96 | 1 | my $formatter_regexp = $_[0]->formatter_regexp; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # _Pulp__5010_qr_m_propagate_properly | ||||||||||||||||||||||||||||
| 99 | ## no critic (Compatibility::PerlMinimumVersionAndWhy) | ||||||||||||||||||||||||||||
| 100 | 1 | return qr{ ^ ${formatter_regexp} \s+ ( .* $ ) $ }smx; | |||||||||||||||||||||||||||
| 101 | }, | ||||||||||||||||||||||||||||
| 102 | 3 | ); | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | has end_segment_callback => ( | ||||||||||||||||||||||||||||
| 105 | is => ro =>, | ||||||||||||||||||||||||||||
| 106 | lazy => 1, | ||||||||||||||||||||||||||||
| 107 | 4 | ▶ | builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
_build_end_segment_callback: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 108 | 4 | ▶ | return sub { }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 109 | }, | ||||||||||||||||||||||||||||
| 110 | 3 | ); | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | has segment_cache => ( | ||||||||||||||||||||||||||||
| 119 | is => ro =>, | ||||||||||||||||||||||||||||
| 120 | lazy => 1, | ||||||||||||||||||||||||||||
| 121 | writer => 'set_segment_cache', | ||||||||||||||||||||||||||||
| 122 | 0 | ▶ | builder => sub { {} }, | ||||||||||||||||||||||||||
|
Subroutine
_build_segment_cache: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 123 | 3 | ); | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | has segments => ( | ||||||||||||||||||||||||||||
| 132 | is => ro =>, | ||||||||||||||||||||||||||||
| 133 | lazy => 1, | ||||||||||||||||||||||||||||
| 134 | writer => 'set_segments', | ||||||||||||||||||||||||||||
| 135 | 5 | ▶ | builder => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 136 | 3 | ); | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | has in_segment => ( | ||||||||||||||||||||||||||||
| 151 | is => ro =>, | ||||||||||||||||||||||||||||
| 152 | lazy => 1, | ||||||||||||||||||||||||||||
| 153 | writer => 'set_in_segment', | ||||||||||||||||||||||||||||
| 154 | clearer => 'unset_in_segment', | ||||||||||||||||||||||||||||
| 155 | 5 | ▶ | builder => sub { undef }, | ||||||||||||||||||||||||||
|
Subroutine
_build_in_segment: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 156 | 3 | ); | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 3 | ▶ | sub begin_segment { | ||||||||||||||||||||||||||
|
Subroutine
begin_segment: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 165 | 3 | my ( $self, $format, $version, $start_line ) = @_; | |||||||||||||||||||||||||||
| 166 | 3 | ▶ | $self->set_segment_cache( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||
| 168 | format => $format, | ||||||||||||||||||||||||||||
| 169 | start_line => $start_line, | ||||||||||||||||||||||||||||
| 170 | ( defined $version ? ( version => $version ) : () ), | ||||||||||||||||||||||||||||
| 171 | }, | ||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||
| 173 | 3 | $self->set_in_segment(1); | |||||||||||||||||||||||||||
| 174 | 3 | return $self; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 3 | ▶ | sub end_segment { | ||||||||||||||||||||||||||
|
Subroutine
end_segment: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 184 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 185 | 3 | my $segment = $self->segment_cache; | |||||||||||||||||||||||||||
| 186 | 3 | push @{ $self->segments }, $segment; | |||||||||||||||||||||||||||
| 187 | 3 | $self->set_segment_cache( {} ); | |||||||||||||||||||||||||||
| 188 | 3 | $self->unset_in_segment(); | |||||||||||||||||||||||||||
| 189 | 3 | my $cb = $self->end_segment_callback; | |||||||||||||||||||||||||||
| 190 | 3 | $cb->($segment); | |||||||||||||||||||||||||||
| 191 | 3 | return $self; | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 3 | ▶ | sub append_segment_data { | ||||||||||||||||||||||||||
|
Subroutine
append_segment_data: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 201 | 3 | my ( $self, $segment_data ) = @_; | |||||||||||||||||||||||||||
| 202 | 3 | ▶ | $self->segment_cache->{data} ||= q{}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->segment_cache->{"data"} ||= ""
MC/DC0%0/1
$self->segment_cache->{"data"} ||= ""
$self->segment_cache->{"data"}
Truth table50%1/2
A
A= $self->segment_cache->{"data"}
| |||||||||||||||||||||||||||||
| 203 | 3 | $self->segment_cache->{data} .= $segment_data; | |||||||||||||||||||||||||||
| 204 | 3 | return $self; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 2 | ▶ | sub add_segment { | ||||||||||||||||||||||||||
|
Subroutine
add_segment: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 214 | 2 | my ( $self, $format, $version, $section_data, $start_line ) = @_; | |||||||||||||||||||||||||||
| 215 | 2 | my $segment = {}; | |||||||||||||||||||||||||||
| 216 | 2 | $segment->{format} = $format; | |||||||||||||||||||||||||||
| 217 | 2 | ▶ | $segment->{version} = $version if defined $version; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 2 | $segment->{data} = $section_data; | |||||||||||||||||||||||||||
| 219 | 2 | ▶ | $segment->{start_line} = $start_line if defined $start_line; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 2 | push @{ $self->segments }, $segment; | |||||||||||||||||||||||||||
| 222 | 2 | my $cb = $self->end_segment_callback; | |||||||||||||||||||||||||||
| 223 | 2 | $cb->($segment); | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 2 | return $self; | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 3 | ▶ | sub handle_begin { | ||||||||||||||||||||||||||
|
Subroutine
handle_begin: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 235 | 3 | my ( $self, $event ) = @_; | |||||||||||||||||||||||||||
| 236 | 3 | ▶ | if ( $self->in_segment ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | croak '=begin MetaPOD:: cannot occur inside =begin MetaPOD:: at line ' . $event->{start_line}; | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | 3 | ▶ | if ( $event->{content} =~ $self->regexp_begin_with_version ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 1 | return $self->begin_segment( $1, $2, $event->{start_line} ); | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | 2 | ▶ | if ( $event->{content} =~ $self->regexp_begin ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 2 | return $self->begin_segment( $1, undef, $event->{start_line} ); | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | 0 | return $self->handle_ignored($event); | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 3 | ▶ | sub handle_end { | ||||||||||||||||||||||||||
|
Subroutine
handle_end: called CC=6 SCAR=23.5
Pod
documented
| |||||||||||||||||||||||||||||
| 255 | 3 | my ( $self, $event ) = @_; | |||||||||||||||||||||||||||
| 256 | 3 | chomp $event->{content}; | |||||||||||||||||||||||||||
| 257 | 3 | my $statement = q{=} . $event->{command} . q{ } . $event->{content}; | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 3 | ▶ | if ( not $self->in_segment and not $event->{content} =~ $self->regexp_begin ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->in_segment or $event->{"content"} =~ $self->regexp_begin
MC/DC0%0/2
$self->in_segment or $event->{"content"} =~ $self->regexp_begin
$self->in_segment
$event->{"content"} =~ $self->regexp_begin
Truth table33%1/3
A or B
A= $self->in_segmentB= $event->{"content"} =~ $self->regexp_begin
| |||||||||||||||||||||||||||||
| 260 | 0 | return $self->handle_ignored($event); | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 3 | ▶ | if ( $self->in_segment ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 3 | my $expected_end = '=end MetaPOD::' . $self->segment_cache->{format}; | |||||||||||||||||||||||||||
| 265 | 3 | ▶ | if ( $statement ne $expected_end ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 0 | croak "$statement seen but expected $expected_end at line " . $event->{start_line}; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | 3 | return $self->end_segment(); | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ( $event->{content} =~ $self->regexp_begin ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 0 | croak "unexpected $statement without =begin MetaPOD::$1 at line" . $event->{start_line}; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | 0 | return $self->handle_ignored($event); | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 2 | ▶ | sub handle_for { | ||||||||||||||||||||||||||
|
Subroutine
handle_for: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 283 | 2 | my ( $self, $event ) = @_; | |||||||||||||||||||||||||||
| 284 | 2 | ▶ | if ( $event->{content} =~ $self->regexp_for_with_version ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 1 | return $self->add_segment( $1, $2, $3, $event->{start_line} ); | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | 1 | ▶ | if ( $event->{content} =~ $self->regexp_for ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 1 | return $self->add_segment( $1, undef, $2, $event->{start_line} ); | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | 0 | return $self->handle_ignored($event); | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 2 | ▶ | sub handle_cut { | ||||||||||||||||||||||||||
|
Subroutine
handle_cut: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 300 | 2 | my ( $self, $element ) = @_; | |||||||||||||||||||||||||||
| 301 | 2 | return $self->handle_ignored($element); | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 3 | ▶ | sub handle_text { | ||||||||||||||||||||||||||
|
Subroutine
handle_text: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 311 | 3 | my ( $self, $element ) = @_; | |||||||||||||||||||||||||||
| 312 | 3 | ▶ | return $self->handle_ignored($element) unless $self->in_segment; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | 3 | return $self->append_segment_data( $element->{content} ); | |||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 4 | ▶ | sub handle_ignored { | ||||||||||||||||||||||||||
|
Subroutine
handle_ignored: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||
| 323 | 4 | my ( $self, $element ) = @_; | |||||||||||||||||||||||||||
| 324 | 4 | ▶ | if ( $self->in_segment ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | 0 | croak 'Unexpected type ' . $element->{type} . ' inside segment ' . pp($element) . ' at line' . $element->{start_line}; | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 15 | ▶ | sub handle_event { | ||||||||||||||||||||||||||
|
Subroutine
handle_event: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 336 | 15 | my ( $self, $event ) = @_; | |||||||||||||||||||||||||||
| 337 | 15 | for my $command (qw( begin end for cut )) { | |||||||||||||||||||||||||||
| 338 | 28 | ▶ | last unless 'command' eq $event->{type}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 23 | ▶ | next unless $event->{command} eq $command; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | 10 | my $method = $self->can( 'handle_' . $command ); | |||||||||||||||||||||||||||
| 341 | 10 | return $self->$method($event); | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | 5 | ▶ | if ( 'text' eq $event->{type} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 344 | 3 | return $self->handle_text($event); | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | 2 | return $self->handle_ignored($event); | |||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 3 | 1; | |||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | __END__ | ||||||||||||||||||||||||||||