« blib/lib/Langertha/Holmgang/Sim/Linux/Helm.pm
↑ Summary
blib/lib/Langertha/Holmgang/Sim/Linux/Accounts.pm »
| 1 | package Langertha::Holmgang::Excerpt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Excerpts from a suite's statute texts under quellen/, set into messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 36 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 36 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 36 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 36 | ▶ | use Digest::SHA (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 36 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 36 | ▶ | use Path::Tiny qw( path ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 36 | ▶ | use Langertha::Holmgang::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 36 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # the file of an excerpt, relative to the suite directory; a true constant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 36 | my $FILE_RE = qr{\Aquellen/[a-z0-9][a-z0-9-]*\.txt\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # parsed sources kept at most, by the SHA-256 of their bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 36 | my $CACHE_MAX = 16; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 74 | ▶ | has _cache => ( is => 'ro', default => sub { {} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 21 | ▶ | sub _refuse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refuse: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my ( $self, $field, $reason ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refuse: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | Langertha::Holmgang::Error->throw( $field, $reason ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 55 | ▶ | sub source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: called CC=15 SCAR=41.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my ( $self, $dir, $file, $field ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: not called CC=15 SCAR=41.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $self->_refuse( $field, 'path quellen/<name>.txt (lower-case letters, digits, dashes)' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition25%3/12
not defined $file or ref $file or not $file =~ /$FILE_RE/
not defined $file or ref $file
not defined $file or ref $file or not $file =~ /$FILE_RE/
not defined $file or ref $file
MC/DC33%1/3
not defined $file or ref $file or not $file =~ /$FILE_RE/
not defined $file
ref $file
not $file =~ /$FILE_RE/
MC/DC0%0/3
not defined $file or ref $file or not $file =~ /$FILE_RE/
not defined $file
ref $file
not $file =~ /$FILE_RE/
Truth table50%2/4
not(A) or B or not(C)
A= not defined $fileB= ref $fileC= not $file =~ /$FILE_RE/
Truth table0%0/4
not(A) or B or not(C)
A= not defined $fileB= ref $fileC= not $file =~ /$FILE_RE/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | if !defined $file || ref $file || $file !~ $FILE_RE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $self->_refuse( $field, 'an excerpt needs the suite directory to be read from' ) unless defined $dir && length $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
defined $dir and length $dir
defined $dir and length $dir
MC/DC50%1/2
defined $dir and length $dir
defined $dir
length $dir
MC/DC0%0/2
defined $dir and length $dir
defined $dir
length $dir
Truth table66%2/3
A and B
A= defined $dirB= length $dir
Truth table0%0/3
A and B
A= defined $dirB= length $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $root = eval { path($dir)->realpath }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $self->_refuse( $field, 'suite directory not readable: '.$dir ) unless $root && $root->is_dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
$root and $root->is_dir
$root and $root->is_dir
MC/DC0%0/2
$root and $root->is_dir
$root
$root->is_dir
MC/DC0%0/2
$root and $root->is_dir
$root
$root->is_dir
Truth table33%1/3
A and B
A= $rootB= $root->is_dir
Truth table0%0/3
A and B
A= $rootB= $root->is_dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $p = path( $root, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | $self->_refuse( $field, $file.' is missing in the suite' ) unless -e $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $real = eval { $p->realpath }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | $self->_refuse( $field, 'outside the suite directory' ) unless $real && $root->subsumes($real); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$real and $root->subsumes($real)
$real and $root->subsumes($real)
MC/DC50%1/2
$real and $root->subsumes($real)
$real
$root->subsumes($real)
MC/DC0%0/2
$real and $root->subsumes($real)
$real
$root->subsumes($real)
Truth table66%2/3
A and B
A= $realB= $root->subsumes($real)
Truth table0%0/3
A and B
A= $realB= $root->subsumes($real)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $self->_refuse( $field, 'not a plain file' ) unless -f $real; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $raw = eval { $real->slurp_raw }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $self->_refuse( $field, 'not readable' ) unless defined $raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $sha = Digest::SHA::sha256_hex($raw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $c = $self->_cache; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my $src = $c->{$sha} //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$c->{$sha} //= do {
%$c = () if keys %$c >= $CACHE_MAX;
$self->_parse($raw, $file, $field)
}
$$c{$sha} //= do {
%$c = () if keys %$c >= $CACHE_MAX;
$self->_parse($raw, $file, $field)
}
MC/DC0%0/2
$c->{$sha} //= do {
%$c = () if keys %$c >= $CACHE_MAX;
$self->_parse($raw, $file, $field)
}
$c->{$sha}
do {
%$c = () if keys %$c >= $CACHE_MAX;
$self->_parse($raw, $file, $field)
}
MC/DC0%0/2
$$c{$sha} //= do {
%$c = () if keys %$c >= $CACHE_MAX;
$self->_parse($raw, $file, $field)
}
$$c{$sha}
do {
%$c = () if keys %$c >= $CACHE_MAX;
$self->_parse($raw, $file, $field)
}
Truth table66%2/3
A //= B
A= $c->{$sha}B= do {
%$c = () if keys %$c >= $CACHE_MAX;
$self->_parse($raw, $file, $field)
}
Truth table0%0/3
A //= B
A= $$c{$sha}B= do {
%$c = () if keys %$c >= $CACHE_MAX;
$self->_parse($raw, $file, $field)
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | %$c = () if keys %$c >= $CACHE_MAX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $self->_parse( $raw, $file, $field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return { %$src, path => "$real", sha256 => $sha }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 12 | ▶ | sub _parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse: called CC=14 SCAR=37.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my ( $self, $raw, $file, $field ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse: not called CC=14 SCAR=37.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $text = eval { Encode::decode( 'UTF-8', $raw, Encode::FB_CROAK ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $self->_refuse( $field, $file.': not UTF-8' ) unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my ( $headtext, $body ) = split /^---\n/m, $text, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $self->_refuse( $field, $file.": head (lines 'Key: value') and '---' missing" ) unless defined $body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my %head; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | for ( split /\n/, $headtext ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | next unless /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | /\A([^:]+):\s*(.*)\z/ or $self->_refuse( $field, $file.': head line without a colon' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $head{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $body =~ s/\A\n+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my ( @norms, $pending ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | while ( $body =~ /\G((?:[^\n]+\n)+)(?:\n+|\z)/gc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $block = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $at = $-[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $end = $+[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ( $block =~ /\A((?:§|Artikel)\s+\d+[a-z]*)\b([^\n]*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | push @norms, { label => $1, title => "$1$2", start => $pending // $at, end => $end }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$pending // $at
$pending // $at
MC/DC0%0/2
$pending // $at
$pending
$at
MC/DC0%0/2
$pending // $at
$pending
$at
Truth table66%2/3
A // B
A= $pendingB= $at
Truth table0%0/3
A // B
A= $pendingB= $at
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | undef $pending; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $pending //= $at; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$pending //= $at
$pending //= $at
MC/DC0%0/2
$pending //= $at
$pending
$at
MC/DC0%0/2
$pending //= $at
$pending
$at
Truth table66%2/3
A //= B
A= $pendingB= $at
Truth table0%0/3
A //= B
A= $pendingB= $at
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | my $pos = pos($body) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
pos $body // 0
pos $body // 0
MC/DC100%1/1
pos $body // 0
pos $body
MC/DC0%0/1
pos $body // 0
pos $body
Truth table100%2/2
A
A= pos $body
Truth table0%0/2
A
A= pos $body
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | $self->_refuse( $field, $file.': the rest after position '.$pos.' is no block' ) if $pos < length $body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $seen{ $_->{label} }++ and $self->_refuse( $field, $file.': provision '.$_->{label}.' twice' ) for @norms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return { head => \%head, body => $body, norms => \@norms }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 45 | ▶ | sub text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: called CC=10 SCAR=32.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my ( $self, $spec, $f, $dir ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: not called CC=10 SCAR=32.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | $self->_refuse( $f, 'auszug: { datei, von, bis } expected' ) unless ref $spec eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my @extra = grep { !/\A(?:datei|von|bis)\z/ } sort keys %$spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $self->_refuse( $f.'.'.$extra[0], 'unknown key' ) if @extra; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $datei = $spec->{datei}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $q = $self->source( $dir, $datei, $f.'.datei' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my %pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | @pos{ map { $_->{label} } @{ $q->{norms} } } = 0 .. $#{ $q->{norms} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | for my $k (qw( von bis )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $v = $spec->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $self->_refuse( $f.'.'.$k, 'the label of a provision (such as "§ 305" or "Artikel 28")' ) if !defined $v || ref $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
not defined $v or ref $v
not defined $v or ref $v
MC/DC50%1/2
not defined $v or ref $v
not defined $v
ref $v
MC/DC0%0/2
not defined $v or ref $v
not defined $v
ref $v
Truth table66%2/3
not(A) or B
A= not defined $vB= ref $v
Truth table0%0/3
not(A) or B
A= not defined $vB= ref $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $self->_refuse( $f.'.'.$k, $v.' is not in '.$datei ) unless exists $pos{$v}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my ( $from_i, $to_i ) = @pos{ $spec->{von}, $spec->{bis} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $self->_refuse( $f.'.bis', $spec->{bis}.' comes before '.$spec->{von} ) if $to_i < $from_i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $n = $q->{norms}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $from = $n->[$from_i]{start}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $to = $n->[$to_i]{end}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $head = $q->{head}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | return join '', ( $head->{Titel} // $datei ), "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 'Auszug: '.$spec->{von}.' bis '.$spec->{bis}."\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ( defined $head->{Stand} ? 'Stand: '.$head->{Stand}."\n" : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | "\n", substr( $q->{body}, $from, $to - $from ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
$head->{"Titel"} // $datei
$$head{"Titel"} // $datei
MC/DC0%0/2
$head->{"Titel"} // $datei
$head->{"Titel"}
$datei
MC/DC0%0/2
$$head{"Titel"} // $datei
$$head{"Titel"}
$datei
Truth table33%1/3
A // B
A= $head->{"Titel"}B= $datei
Truth table0%0/3
A // B
A= $$head{"Titel"}B= $datei
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 909 | ▶ | sub expand { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my ( $self, $v, $f, $dir ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand: not called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 143 | ▶ | my $one = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my ( $p, $pf ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | return $p unless ref $p eq 'HASH' && exists $p->{auszug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
ref $p eq "HASH" and exists $p->{"auszug"}
ref $p eq "HASH" and exists $$p{"auszug"}
MC/DC100%2/2
ref $p eq "HASH" and exists $p->{"auszug"}
ref $p eq "HASH"
exists $p->{"auszug"}
MC/DC0%0/2
ref $p eq "HASH" and exists $$p{"auszug"}
ref $p eq "HASH"
exists $$p{"auszug"}
Truth table100%3/3
A and B
A= ref $p eq "HASH"B= exists $p->{"auszug"}
Truth table0%0/3
A and B
A= ref $p eq "HASH"B= exists $$p{"auszug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $self->_refuse( $pf, 'auszug: { ... } alone, without other keys' ) unless keys %$p == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | return $self->text( $p->{auszug}, $pf.'.auszug', $dir ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | return [ $one->( $v, $f ) ] if ref $v eq 'HASH' && exists $v->{auszug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
ref $v eq "HASH" and exists $v->{"auszug"}
ref $v eq "HASH" and exists $$v{"auszug"}
MC/DC100%2/2
ref $v eq "HASH" and exists $v->{"auszug"}
ref $v eq "HASH"
exists $v->{"auszug"}
MC/DC0%0/2
ref $v eq "HASH" and exists $$v{"auszug"}
ref $v eq "HASH"
exists $$v{"auszug"}
Truth table100%3/3
A and B
A= ref $v eq "HASH"B= exists $v->{"auszug"}
Truth table0%0/3
A and B
A= ref $v eq "HASH"B= exists $$v{"auszug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return $v unless ref $v eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return [ map { $one->( $v->[$_], $f.'['.$_.']' ) } 0 .. $#$v ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 141 | ▶ | sub files { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
files: called CC=4 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my ( $self, $v ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
files: not called CC=4 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | my @parts = ref $v eq 'ARRAY' ? @$v : ($v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return map { $_->{auszug}{datei} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | grep { ref $_ eq 'HASH' && ref $_->{auszug} eq 'HASH' && defined $_->{auszug}{datei} } @parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition41%5/12
ref $_ eq 'HASH' && ref $_->{'auszug'} eq 'HASH' && defined $_->{'auszug'}{'datei'}
ref $_ eq "HASH" and ref $_->{"auszug"} eq "HASH"
ref $_ eq 'HASH' && ref $$_{'auszug'} eq 'HASH' && defined $$_{'auszug'}{'datei'}
ref $_ eq "HASH" and ref $$_{"auszug"} eq "HASH"
MC/DC66%2/3
ref $_ eq 'HASH' && ref $_->{'auszug'} eq 'HASH' && defined $_->{'auszug'}{'datei'}
ref $_ eq "HASH"
ref $_->{"auszug"} eq "HASH"
defined $_->{'auszug'}{'datei'}
MC/DC0%0/3
ref $_ eq 'HASH' && ref $$_{'auszug'} eq 'HASH' && defined $$_{'auszug'}{'datei'}
ref $_ eq "HASH"
ref $$_{"auszug"} eq "HASH"
defined $$_{'auszug'}{'datei'}
Truth table75%3/4
A and B && C
A= ref $_ eq "HASH"B= ref $_->{"auszug"} eq "HASH"C= defined $_->{'auszug'}{'datei'}
Truth table0%0/4
A and B && C
A= ref $_ eq "HASH"B= ref $$_{"auszug"} eq "HASH"C= defined $$_{'auszug'}{'datei'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 36 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||