| 1 | package Spellunker::Pod::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use parent qw(Pod::Simple::Methody); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | MODE_STOPWORDS => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | MODE_IGNORE => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | MODE_NORMAL => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 105 | ▶ | sub _handle_element_start { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_element_start: called CC=9 SCAR=22.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 105 | my ($self, $element_name, $attr_hash_r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 105 | $element_name =~ tr/-:./__/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 105 | ▶ | if (my $start_line = $attr_hash_r->{start_line}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 94 | $self->{start_line} = $start_line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 105 | ▶ | if ($element_name eq 'encoding') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | $self->{mode} = MODE_IGNORE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } elsif ($element_name eq 'for') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | if ($attr_hash_r->{target} eq 'stopwords') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | $self->{mode} = MODE_STOPWORDS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ▶ | } elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition88%8/9
$element_name eq "code" or $element_name eq "Verbatim" or $element_name eq "C" or $element_name eq "L"
$element_name eq "code" or $element_name eq "Verbatim" or $element_name eq "C"
$element_name eq "code" or $element_name eq "Verbatim"
MC/DC75%3/4
$element_name eq "code" or $element_name eq "Verbatim" or $element_name eq "C" or $element_name eq "L"
$element_name eq "code"
$element_name eq "Verbatim"
$element_name eq "C"
$element_name eq "L"
Truth table80%4/5
A or B or C or D
A= $element_name eq "code"B= $element_name eq "Verbatim"C= $element_name eq "C"D= $element_name eq "L"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $element_name eq 'code' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | || $element_name eq 'Verbatim' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | || $element_name eq 'C' # C<> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | || $element_name eq 'L' # L<> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 16 | $_[0]->{mode} = MODE_IGNORE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 105 | ▶ | sub _handle_element_end { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_element_end: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 105 | my ($self, $element_name, $attr_hash_r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 105 | $element_name =~ tr/-:./__/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 105 | $self->{mode} = MODE_NORMAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 10 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 10 | my $new = $self->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 10 | ▶ | $new->{'output_fh'} ||= *STDOUT{IO}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$new->{"output_fh"} ||= *STDOUT{"IO"}
MC/DC0%0/1
$new->{"output_fh"} ||= *STDOUT{"IO"}
$new->{"output_fh"}
Truth table50%1/2
A
A= $new->{"output_fh"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 10 | $new->{mode} = 'normal'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 10 | $new->accept_target_as_text(qw( text plaintext plain stopwords )); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # whether to ignore X<...> codes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 10 | $new->nix_X_codes(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # Whether to map S<...>'s to \xA0 characters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 10 | $new->nbsp_for_S(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # whether to try to keep whitespace as-is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 10 | $new->preserve_whitespace(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 10 | return $new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 10 | ▶ | sub stopwords { $_[0]->{stopwords} || [] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stopwords: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 10 | ▶ | sub lines { $_[0]->{lines} || [] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lines: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 108 | ▶ | sub start_line { $_[0]->{start_line} || 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_line: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 101 | ▶ | sub _handle_text { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_text: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 101 | my ($self, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 101 | ▶ | if ($self->{mode} eq MODE_IGNORE) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # nop. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } elsif ($self->{mode} eq MODE_STOPWORDS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | push @{$self->{stopwords}}, $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 83 | my $offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 83 | for my $line (split /\n/, $text) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 108 | push @{$self->{lines}}, [ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | $self->start_line + $offset, $line | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 108 | $offset++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||