| 1 | package Data::Sah::Compiler::TextResultRole; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 29 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 29 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 29 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 29 | ▶ | use Mo qw(default); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 29 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | # can be changed to tab, for example | ||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | has indent_character => (is => 'rw', default => sub {''}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 29 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||||||
| 14 | 29 | our $DATE = '2024-02-16'; # DATE | |||||||||||||||||||||||||||||||
| 15 | 29 | our $DIST = 'Data-Sah'; # DIST | |||||||||||||||||||||||||||||||
| 16 | 29 | our $VERSION = '0.917'; # VERSION | |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub add_result { | ||||||||||||||||||||||||||||||
|
Subroutine
add_result: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 19 | 0 | my ($self, $cd, @args) = @_; | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $cd->{result} //= []; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$cd->{"result"} //= []
MC/DC0%0/1
$cd->{"result"} //= []
$cd->{"result"}
Truth table0%0/2
A
A= $cd->{"result"}
| |||||||||||||||||||||||||||||||||
| 22 | 0 | push @{ $cd->{result} }, $self->indent($cd, join("", @args)); | |||||||||||||||||||||||||||||||
| 23 | 0 | $self; | |||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | # BEGIN COPIED FROM String::Indent | ||||||||||||||||||||||||||||||||
| 27 | 5199 | ▶ | sub _indent { | ||||||||||||||||||||||||||||||
|
Subroutine
_indent: called CC=8 SCAR=23.4
| |||||||||||||||||||||||||||||||||
| 28 | 5199 | my ($indent, $str, $opts) = @_; | |||||||||||||||||||||||||||||||
| 29 | 5199 | ▶ | $opts //= {}; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts //= {}
MC/DC0%0/1
$opts //= {}
$opts
Truth table50%1/2
A
A= $opts
| |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 5199 | ▶ | my $ibl = $opts->{indent_blank_lines} // 1; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts->{"indent_blank_lines"} // 1
MC/DC0%0/1
$opts->{"indent_blank_lines"} // 1
$opts->{"indent_blank_lines"}
Truth table50%1/2
A
A= $opts->{"indent_blank_lines"}
| |||||||||||||||||||||||||||||||||
| 32 | 5199 | ▶ | my $fli = $opts->{first_line_indent} // $indent; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"first_line_indent"} // $indent
MC/DC0%0/2
$opts->{"first_line_indent"} // $indent
$opts->{"first_line_indent"}
$indent
Truth table33%1/3
A // B
A= $opts->{"first_line_indent"}B= $indent
| |||||||||||||||||||||||||||||||||
| 33 | 5199 | ▶ | my $sli = $opts->{subsequent_lines_indent} // $indent; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"subsequent_lines_indent"} // $indent
MC/DC0%0/2
$opts->{"subsequent_lines_indent"} // $indent
$opts->{"subsequent_lines_indent"}
$indent
Truth table33%1/3
A // B
A= $opts->{"subsequent_lines_indent"}B= $indent
| |||||||||||||||||||||||||||||||||
| 34 | #say "D:ibl=<$ibl>, fli=<$fli>, sli=<$sli>"; | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 5199 | my $i = 0; | |||||||||||||||||||||||||||||||
| 37 | 5199 | ▶ | $str =~ s/^([^\r\n]?)/$i++; !$ibl && !$1 ? "$1" : $i==1 ? "$fli$1" : "$sli$1"/egm; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$ibl || $1
MC/DC0%0/2
$ibl || $1
$ibl
$1
Truth table33%1/3
A || B
A= $iblB= $1
| |||||||||||||||||||||||||||||||||
| 38 | 5199 | $str; | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | # END COPIED FROM String::Indent | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 5199 | ▶ | sub indent { | ||||||||||||||||||||||||||||||
|
Subroutine
indent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 43 | 5199 | my ($self, $cd, $str) = @_; | |||||||||||||||||||||||||||||||
| 44 | _indent( | ||||||||||||||||||||||||||||||||
| 45 | $self->indent_character x $cd->{indent_level}, | ||||||||||||||||||||||||||||||||
| 46 | 5199 | $str, | |||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub inc_indent { | ||||||||||||||||||||||||||||||
|
Subroutine
inc_indent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 51 | 0 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||
| 52 | 0 | $cd->{indent_level}++; | |||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub dec_indent { | ||||||||||||||||||||||||||||||
|
Subroutine
dec_indent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 56 | 0 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||
| 57 | 0 | $cd->{indent_level}--; | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 566 | ▶ | sub indent_str { | ||||||||||||||||||||||||||||||
|
Subroutine
indent_str: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 61 | 566 | my ($self, $cd) = @_; | |||||||||||||||||||||||||||||||
| 62 | 566 | $self->indent_character x $cd->{indent_level}; | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 29 | 1; | |||||||||||||||||||||||||||||||
| 66 | # ABSTRACT: Role for compilers that produce text result (array of lines) | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||||||