blib/lib/SVN/Dump/Headers.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 14 / 14 Conditioncond 83.3% 5 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 10 / 10 Podpod 100% 6 / 6 totaltotal 97.4% 77 / 79 SCAR 24.8
CC
12
Cov
98%
new
6.0
type
5.0
as_string
3.0
CRAP 12.0
« blib/lib/SVN/Dump/Record.pm ↑ Summary blib/lib/SVN/Dump.pm »
1 package SVN::Dump::Headers;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use Scalar::Util qw( reftype );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 my $NL = "\012";
9  
10 sub new {
11 697 ▶ my ( $class, $headers ) = @_;
Subroutine new: called CC=6 SCAR=17.9
Pod documented
12 697 ▶ croak 'First parameter must be a HASH reference'
Branch: 1 branch
BranchTrueFalseTotal
if defined $headers and not ref $headers && builtin::reftype($headers) eq "HASH" 3 694 697
Condition83%5/6
defined $headers and not ref $headers && builtin::reftype($headers) eq "HASH"
!ll&&!rl&&r
69223
ref $headers && builtin::reftype($headers) eq 'HASH'
!ll&&!rl&&r
302
MC/DC66%2/3
defined $headers and not ref $headers && builtin::reftype($headers) eq "HASH"
defined $headers ref $headers builtin::reftype($headers) eq 'HASH'
Truth table75%3/4
A and not(B && C)
A= defined $headersB= ref $headersC= builtin::reftype($headers) eq 'HASH'
ABCresult
0XX0
1110
10X1
1101
13 if defined $headers
14 && !( ref $headers && reftype $headers eq 'HASH' );
15 694 my $self = bless {}, $class;
16 694 ▶ $self->set( $_ => $headers->{$_} ) for keys %{ $headers || {} };
Branch: 1 branch
BranchTrueFalseTotal
$headers or {} 692 2 694
17 694 return $self;
18 }
19  
20 13 my %headers = (
21 revision => [
22 qw(
23 Revision-number
24 Prop-content-length
25 Content-length
26 )
27  
28 ],
29 node => [
30 qw(
31 Node-path
32 Node-kind
33 Node-action
34 Node-copyfrom-rev
35 Node-copyfrom-path
36 Prop-delta
37 Prop-content-length
38 Text-copy-source-md5
39 Text-copy-source-sha1
40 Text-delta
41 Text-content-length
42 Text-content-md5
43 Text-content-sha1
44 Content-length
45 )
46 ],
47 uuid => ['UUID'],
48 format => ['SVN-fs-dump-format-version'],
49 );
50  
51 # FIXME Prop-delta and Text-delta in version 3
52  
53 sub as_string {
54 849 ▶ my ($self) = @_;
Subroutine as_string: called CC=3 SCAR=11.0
Pod documented
55 849 my $string = '';
56  
57 849 for my $k ( @{ $headers{ $self->type() } } ) {
58 $string .= "$k: $self->{$k}$NL"
59 7261 ▶ if exists $self->{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{$k} 3517 3744 7261
60 }
61  
62 849 return $string . $NL;
63 }
64  
65 sub type {
66 2206 ▶ my ($self) = @_;
Subroutine type: called CC=5 SCAR=16.1
Pod documented
67  
68 my $type =
69 exists $self->{'Node-path'} ? 'node'
70 : exists $self->{'Revision-number'} ? 'revision'
71 : exists $self->{'UUID'} ? 'uuid'
72 2206 ▶ : exists $self->{'SVN-fs-dump-format-version'} ? 'format'
Branch: 4 branches
BranchTrueFalseTotal
exists $self->{'Node-path'} ? : 1154 1052 2206
exists $self->{'Revision-number'} ? : 801 251 1052
exists $self->{'UUID'} ? : 124 127 251
exists $self->{'SVN-fs-dump-format-version'} ? : 124 3 127
73 : croak 'Unable to determine the record type';
74  
75 2203 return $type;
76 }
77  
78 sub set {
79 120 ▶ my ($self, $h, $v) = @_;
Subroutine set: called CC=1 SCAR=0.0
Pod documented
80  
81 # FIXME shall we check that the header value is valid?
82 120 $h =~ tr/_/-/; # allow _ for - simplification
83 120 return $self->{$h} = $v;
84 }
85  
86 sub get {
87 186 ▶ my ($self, $h) = @_;
Subroutine get: called CC=1 SCAR=0.0
Pod documented
88 186 $h =~ tr/_/-/; # allow _ for - simplification
89 186 return $self->{$h};
90 }
91  
92 sub keys {
93 6 ▶ my ($self) = @_;
Subroutine keys: called CC=1 SCAR=0.0
Pod documented
94 6 return grep { exists $self->{$_} } @{ $headers{$self->type()} };
95 }
96  
97 13 1;
98  
99 __END__
« blib/lib/SVN/Dump/Record.pm ↑ Summary blib/lib/SVN/Dump.pm »