| 1 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2008 Martin Scharrer <martin@scharrer-online.de> | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # This is open source software under the GPL v3 or later. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # $Id: Node.pm 103 2008-10-14 21:11:21Z martin $ | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package SVN::Dumpfile::Node; | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use SVN::Dumpfile::Node::Headers; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use SVN::Dumpfile::Node::Properties; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use SVN::Dumpfile::Node::Content; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 11 | ▶ | use Date::Parse; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 11 | Readonly my $NL => chr(10); | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | our $VERSION = do { '$Rev: 103 $' =~ /\$Rev: (\d+) \$/; '0.13' . ".$1" }; | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 43 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=24.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 43 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 43 | ▶ | my $class = ref $arg || $arg; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $arg || $arg
MC/DC0%0/2
ref $arg || $arg
ref $arg
$arg
Truth table66%2/3
A || B
A= ref $argB= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 43 | my %hasharg; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 43 | my $hargref = \%hasharg; | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 43 | ▶ | if ( @_ == 1 && ref( $_[0] ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $hargref = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | elsif ( @_ % 2 == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 43 | %hasharg = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | 43 | $hargref = \%hasharg; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ▶ | elsif ( @_ == 1 && !defined $_[0] ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ == 1 and not defined $_[0]
MC/DC0%0/2
@_ == 1 and not defined $_[0]
@_ == 1
not defined $_[0]
Truth table0%0/3
A and not(B)
A= @_ == 1B= not defined $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Ignore single undef value | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | carp | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | "${class}::new() awaits a hashref or even array with key/value pairs." | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | . "Ignoring all arguments."; | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | headers => SVN::Dumpfile::Node::Headers->new( $hargref->{'headers'} ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | properties => | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | SVN::Dumpfile::Node::Properties->new( $hargref->{'properties'} ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 43 | contents => SVN::Dumpfile::Node::Content->new( $hargref->{'content'} ), | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | changed => scalar keys %$hargref, | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 43 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | sub newrev { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
newrev: called CC=17 SCAR=41.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | my $class = ref $arg || $arg; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $arg || $arg
MC/DC0%0/2
ref $arg || $arg
ref $arg
$arg
Truth table33%1/3
A || B
A= ref $argB= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | my $r; | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | if ( @_ == 1 && ref( $_[0] ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $r = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | elsif ( @_ % 2 == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | $r = {@_}; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ▶ | elsif ( @_ == 1 && !defined $_[0] ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@_ == 1 and not defined $_[0]
MC/DC0%0/2
@_ == 1 and not defined $_[0]
@_ == 1
not defined $_[0]
Truth table0%0/3
A and not(B)
A= @_ == 1B= not defined $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # Ignore single undef value | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | carp | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | "${class}::newrev() awaits a hashref or even array with key/value pairs." | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | . "Ignoring all arguments."; | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | my $strdate; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | if ( !exists $r->{date} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
not exists $r->{"date"} or $r->{"date"} =~ /^\d+$/ or $strdate = str2time($r->{"date"})
not exists $r->{"date"} or $r->{"date"} =~ /^\d+$/
MC/DC0%0/3
not exists $r->{"date"} or $r->{"date"} =~ /^\d+$/ or $strdate = str2time($r->{"date"})
not exists $r->{"date"}
$r->{"date"} =~ /^\d+$/
$strdate = str2time($r->{"date"})
Truth table25%1/4
not(A) or B or C
A= not exists $r->{"date"}B= $r->{"date"} =~ /^\d+$/C= $strdate = str2time($r->{"date"})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | || $r->{date} =~ /^\d+$/ | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | || ( $strdate = str2time( $r->{date} ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | my $time = $strdate || $r->{date} || time; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$strdate || $r->{'date'} || time
$strdate or $r->{"date"}
MC/DC0%0/2
$strdate || $r->{'date'} || time
$strdate
$r->{"date"}
Truth table33%1/3
A or B
A= $strdateB= $r->{"date"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | my ( $sec, $min, $hour, $mday, $mon, $year ) = gmtime($time); | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # '2006-05-10T13:31:40.486172Z' | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | $r->{date} = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | "%04d-%02d-%02dT%02d:%02d:%02d.%06dZ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | $year + 1900, | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | $mon + 1, $mday, $hour, $min, $sec, 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | elsif ( $r->{date} !~ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | carp "Wrong format for new revision node given. Import of resulting " | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | . "dumpfile might break."; | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | return $class->new( | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | headers => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 'Revision-number' => $r->{number} || 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 'Prop-content-length' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 'Content-length' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | properties => { | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 'svn:author' => $r->{author} || $ENV{USER} || '(unknown)', | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 'svn:date' => $r->{date}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | (exists $r->{'log'}) ? ('svn:log' => $r->{'log'}) : () | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition42%3/7
$r->{'number'} || 0
$r->{'author'} || $ENV{'USER'} || '(unknown)'
$r->{"author"} or $ENV{"USER"}
MC/DC0%0/1
$r->{'number'} || 0
$r->{'number'}
MC/DC0%0/2
$r->{'author'} || $ENV{'USER'} || '(unknown)'
$r->{"author"}
$ENV{"USER"}
Truth table50%1/2
A
A= $r->{'number'}
Truth table33%1/3
A or B
A= $r->{"author"}B= $ENV{"USER"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | sub content : lvalue { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | $self->{contents}->value(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 35 | ▶ | sub contents { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contents: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 35 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 35 | return $self->{contents}; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | ▶ | sub has_contents { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_contents: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | ▶ | return unless exists $self->{contents}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | return $self->{contents}->exists; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 18 | ▶ | sub header : lvalue { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 18 | my ( $self, $h, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 18 | ▶ | $self->{headers}->{$h} = $value | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | if defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 18 | $self->{headers}->{$h}; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 24 | ▶ | sub headers { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 24 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | 24 | return $self->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | ▶ | sub has_header { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_header: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | my $header = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3 | ▶ | return unless exists $self->{headers}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | return exists $self->{headers}->{$header}; | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 20 | ▶ | sub has_headers { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_headers: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 20 | ▶ | return if not exists $self->{headers}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 20 | return scalar keys %{ $self->{headers} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 7 | ▶ | sub property : lvalue { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
property: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 7 | my ( $self, $prop, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 7 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return $self->{properties}->{property}; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 7 | ▶ | $self->{properties}->{property}->{$prop} = $value | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | if defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | $self->{properties}->{property}->{$prop}; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | ▶ | sub has_property { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_property: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | my $prop = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | return | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | unless exists $self->{properties} | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 4 | ▶ | and exists $self->{properties}->{property}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"properties"} and exists $self->{"properties"}{"property"}
MC/DC0%0/2
exists $self->{"properties"} and exists $self->{"properties"}{"property"}
exists $self->{"properties"}
exists $self->{"properties"}{"property"}
Truth table33%1/3
A and B
A= exists $self->{"properties"}B= exists $self->{"properties"}{"property"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | return exists $self->{properties}->{property}->{$prop}; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 12 | ▶ | sub properties { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
properties: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | 12 | return $self->{properties}; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | ▶ | sub has_properties { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_properties: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | return | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | unless exists $self->{properties} | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | and exists $self->{properties}->{property}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"properties"} and exists $self->{"properties"}{"property"}
MC/DC0%0/2
exists $self->{"properties"} and exists $self->{"properties"}{"property"}
exists $self->{"properties"}
exists $self->{"properties"}{"property"}
Truth table33%1/3
A and B
A= exists $self->{"properties"}B= exists $self->{"properties"}{"property"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | return scalar keys %{ $self->{properties}->{property} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 9 | ▶ | sub changed { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
changed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | 9 | $self->{changed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 9 | ▶ | sub has_changed { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_changed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 9 | return $self->{changed}; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | sub is_rev { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_rev: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | return exists $self->{headers}{'Revision-number'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | sub revnum : lvalue { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
revnum: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | my ( $self, $value ) = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | $self->{headers}{'Revision-number'} = $value | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | if defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | $self->{headers}{'Revision-number'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 29 | ▶ | sub read { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 29 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 29 | my $fh = shift; # Filehandle to read | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | 29 | my $line; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 29 | ▶ | return unless defined $fh and eval { $fh->isa('IO::Handle') }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $fh and eval {
do {
$fh->isa("IO::Handle")
}
}
MC/DC0%0/2
defined $fh and eval {
do {
$fh->isa("IO::Handle")
}
}
defined $fh
eval {
do {
$fh->isa("IO::Handle")
}
}
Truth table33%1/3
A and B
A= defined $fhB= eval {
do {
$fh->isa("IO::Handle")
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 29 | my $header = $self->{'headers'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 29 | my $irs = IO::Handle->input_record_separator($NL); | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 29 | $self->{headers}->read($fh); | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | 29 | ▶ | return if $fh->eof; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # Get properties when they exist (but then they can be empty also!) | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | $self->{properties}->read( $fh, $header->{'Prop-content-length'} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 26 | ▶ | if exists $header->{'Prop-content-length'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # Get content | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | $self->{contents}->read( $fh, $header->{'Text-content-length'} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 26 | ▶ | if exists $header->{'Text-content-length'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # Save delimiter blank lines to be able to restore the input file exact | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 26 | $self->{delim} = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 26 | my $c; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 26 | ▶ | while ( $c = $fh->getc and $c eq $NL ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c = $fh->getc and $c eq $NL
MC/DC100%2/2
$c = $fh->getc and $c eq $NL
$c = $fh->getc
$c eq $NL
Truth table100%3/3
A and B
A= $c = $fh->getcB= $c eq $NL
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 43 | $self->{delim} .= $c; | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 26 | ▶ | $fh->ungetc( ord $c ) if defined $c; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 26 | IO::Handle->input_record_separator($irs); | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 26 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ################# | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ## Write node entry to filehandle | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 18 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=13 SCAR=29.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 18 | my $self = shift; # Hash (as reference) with node to be written | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | 18 | my $fh = shift; # Filehandle to write to | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | 18 | my $ret = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 18 | ▶ | croak "Given argument is not a valid file handle." | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | unless defined $fh; | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 18 | my $header = $self->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 18 | ▶ | return unless ( $header->number ); # skip if there is no header | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 18 | ▶ | $self->recalc_headers if $self->{changed}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 18 | ▶ | $ret &&= $self->{headers}->write($fh); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ret &&= $self->{"headers"}->write($fh)
MC/DC0%0/2
$ret &&= $self->{"headers"}->write($fh)
$ret
$self->{"headers"}->write($fh)
Truth table33%1/3
A &&= B
A= $retB= $self->{"headers"}->write($fh)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # Properties | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | $ret &&= $self->{properties}->write($fh) | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | if ( exists $header->{'Prop-content-length'} | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 18 | ▶ | and $header->{'Prop-content-length'} > 0 ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $header->{"Prop-content-length"} and $header->{"Prop-content-length"} > 0
$ret &&= $self->{"properties"}->write($fh)
MC/DC0%0/2
exists $header->{"Prop-content-length"} and $header->{"Prop-content-length"} > 0
exists $header->{"Prop-content-length"}
$header->{"Prop-content-length"} > 0
MC/DC0%0/2
$ret &&= $self->{"properties"}->write($fh)
$ret
$self->{"properties"}->write($fh)
Truth table33%1/3
A and B
A= exists $header->{"Prop-content-length"}B= $header->{"Prop-content-length"} > 0
Truth table33%1/3
A &&= B
A= $retB= $self->{"properties"}->write($fh)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # Content | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | $ret &&= $self->{contents}->write($fh) | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | if ( exists $header->{'Text-content-length'} | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 18 | ▶ | and $header->{'Text-content-length'} > 0 ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
exists $header->{"Text-content-length"} and $header->{"Text-content-length"} > 0
$ret &&= $self->{"contents"}->write($fh)
MC/DC50%1/2
exists $header->{"Text-content-length"} and $header->{"Text-content-length"} > 0
exists $header->{"Text-content-length"}
$header->{"Text-content-length"} > 0
MC/DC0%0/2
$ret &&= $self->{"contents"}->write($fh)
$ret
$self->{"contents"}->write($fh)
Truth table66%2/3
A and B
A= exists $header->{"Text-content-length"}B= $header->{"Text-content-length"} > 0
Truth table33%1/3
A &&= B
A= $retB= $self->{"contents"}->write($fh)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 18 | ▶ | $ret &&= $fh->print( exists $self->{delim} ? $self->{delim} : $NL ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ret &&= $fh->print(exists $self->{"delim"} ? $self->{"delim"} : $NL)
MC/DC0%0/2
$ret &&= $fh->print(exists $self->{"delim"} ? $self->{"delim"} : $NL)
$ret
$fh->print(exists $self->{"delim"} ? $self->{"delim"} : $NL)
Truth table33%1/3
A &&= B
A= $retB= $fh->print(exists $self->{"delim"} ? $self->{"delim"} : $NL)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 18 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 18 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 18 | ▶ | return '' unless ( $self->has_headers ); # skip if there are no header | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 18 | ▶ | $self->recalc_headers if $self->{changed}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | return '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | . $self->{headers}->as_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | . $NL | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | . $self->{properties}->as_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | . $self->{contents}->as_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 18 | ▶ | . ( $self->{delim} || $NL ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'delim'} || $NL
MC/DC0%0/2
$self->{'delim'} || $NL
$self->{'delim'}
$NL
Truth table33%1/3
A || B
A= $self->{'delim'}B= $NL
| |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 17 | ▶ | sub recalc_headers { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recalc_headers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 17 | $self->recalc_textcontent_header; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | 17 | $self->recalc_prop_header; | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 17 | $self->{changed} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 297 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ################# | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ## recalc_content_header - Recalculate 'Content-length' header | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # Depends on correct values in other headers. | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # Will be called by other recalc-functions. | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 17 | ▶ | sub recalc_content_header { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recalc_content_header: called CC=3 SCAR=11.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | 17 | my $header = $self->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||
| 309 | 11 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 17 | my $header_existed = exists $header->{'Content-length'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | $header->{'Content-length'} | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 17 | = $header->{'Text-content-length'} + $header->{'Prop-content-length'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 17 | ▶ | if ( $header->{'Content-length'} == 0 && !$header_existed ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$header->{"Content-length"} == 0 and not $header_existed
MC/DC0%0/2
$header->{"Content-length"} == 0 and not $header_existed
$header->{"Content-length"} == 0
not $header_existed
Truth table33%1/3
A and not(B)
A= $header->{"Content-length"} == 0B= not $header_existed
| |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | delete $header->{'Content-length'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ################# | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ## recalc_textcontent_header - Recalculate 'Text-content'* and dependend headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 17 | ▶ | sub recalc_textcontent_header { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recalc_textcontent_header: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 11 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 11 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | 17 | my $header = $self->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 17 | my $oldlength = $header->{'Text-content-length'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 333 | 17 | my $header_existed = exists $header->{'Text-content-length'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | my $length | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | = defined $self->{'contents'} | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 17 | ▶ | ? $self->{'contents'}->length | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | : 0; | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 17 | ▶ | if ( !$header_existed && $length == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $header_existed and $length == 0
MC/DC50%1/2
not $header_existed and $length == 0
not $header_existed
$length == 0
Truth table66%2/3
not(A) and B
A= not $header_existedB= $length == 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 13 | delete $header->{'Text-content-length'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | 13 | delete $header->{'Text-content-md5'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 4 | $header->{'Text-content-length'} = $length; | |||||||||||||||||||||||||||||||||||||||||||||
| 346 | 4 | $header->{'Text-content-md5'} = md5_hex( ${ $self->{'contents'} } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | $self->recalc_content_header | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 17 | ▶ | if ( $oldlength != $header->{'Text-content-length'} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | ################# | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ## recalc_prop_header - Recalculate 'Prop-content-length' and dependend headers | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ##### | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 17 | ▶ | sub recalc_prop_header { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recalc_prop_header: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 11 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | 17 | my $header = $self->{'headers'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | 17 | my $prop = $self->{'properties'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # Don't remove or create header unless necessary | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 17 | my $header_existed = exists $header->{'Prop-content-length'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # Correct properties length: | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 17 | $header->{'Prop-content-length'} = $prop->length; | |||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 17 | ▶ | if ( !$header_existed && $header->{'Prop-content-length'} eq 10 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $header_existed and $header->{"Prop-content-length"} eq 10
MC/DC0%0/2
not $header_existed and $header->{"Prop-content-length"} eq 10
not $header_existed
$header->{"Prop-content-length"} eq 10
Truth table33%1/3
not(A) and B
A= not $header_existedB= $header->{"Prop-content-length"} eq 10
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | delete $header->{'Prop-content-length'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 17 | $self->recalc_content_header; | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||