blib/lib/SVN/Dump.pm

filter: Statementstmt 100% 45 / 45 Branchbran 100% 18 / 18 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 5 / 5 totaltotal 100% 82 / 82 SCAR 24.0
CC
11
Cov
100%
new
7.0
next_record
3.0
version
2.0
CRAP 11.0
« blib/lib/SVN/Dump/Headers.pm ↑ Summary Build »
1 package SVN::Dump;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use SVN::Dump::Reader;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 our $VERSION = '0.06';
10  
11 sub new {
12 32 ▶ my ( $class, $args ) = @_;
Subroutine new: called CC=7 SCAR=19.5
Pod documented
13 32 my $self = bless {}, $class;
14  
15 # FIXME - croak() if incompatible options
16  
17 # we have a reader
18 32 ▶ if ( exists $args->{fh} || exists $args->{file} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{'fh'} or exists $args->{'file'}) { } 29 3 32
Condition100%3/3
exists $args->{"fh"} or exists $args->{"file"}
l!l&&r!l&&!r
4253
MC/DC100%2/2
exists $args->{"fh"} or exists $args->{"file"}
exists $args->{"fh"} exists $args->{"file"}
Truth table100%3/3
A or B
A= exists $args->{"fh"}B= exists $args->{"file"}
ABresult
1X1
011
000
19 29 my ( $fh, $file ) = delete @{$args}{qw( fh file )};
20 29 ▶ if ( !$fh ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh) 25 4 29
21 25 ▶ open $fh, $file or croak "Can't open $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, $file or croak("Can't open ${file}: $!") 1 24 25
22 }
23 28 $self->{reader} = SVN::Dump::Reader->new( $fh, $args );
24 }
25 # we don't have a reader
26 else {
27 3 ▶ if( exists $args->{version} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"version"}) 2 1 3
28 2 $self->{format} = SVN::Dump::Record->new();
29 $self->{format}->set_header(
30 2 'SVN-fs-dump-format-version' => $args->{version} );
31 }
32 3 ▶ if( exists $args->{uuid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"uuid"}) 2 1 3
33 2 $self->{uuid} = SVN::Dump::Record->new();
34 2 $self->{uuid}->set_header( 'UUID' => $args->{uuid} );
35 }
36 }
37  
38 31 return $self;
39 }
40  
41 sub next_record {
42 527 ▶ my ($self) = @_;
Subroutine next_record: called CC=3 SCAR=11.0
Pod documented
43 527 my $record;
44  
45 RECORD: {
46 527 $record = $self->{reader}->read_record();
47 527 ▶ return unless $record;
Branch: 1 branch
BranchTrueFalseTotal
unless $record 27 500 527
48  
49 # keep the first records in the dump itself
50 500 my $type = $record->type();
51 500 ▶ if ( $type =~ /\A(?:format|uuid)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /\A(?:format|uuid)\z/) 56 444 500
52 56 $self->{$type} = $record;
53 }
54 }
55  
56 500 return $record;
57 }
58  
59 sub version {
60 4 ▶ my ($self) = @_;
Subroutine version: called CC=2 SCAR=6.9
Pod documented
61 return $self->{format}
62 4 ▶ ? $self->{format}->get_header('SVN-fs-dump-format-version')
Branch: 1 branch
BranchTrueFalseTotal
$self->{'format'} ? : 3 1 4
63 : '';
64 }
65 5 *format = \&version;
66  
67 sub uuid {
68 4 ▶ my ($self) = @_;
Subroutine uuid: called CC=2 SCAR=6.9
Pod documented
69 4 ▶ return $self->{uuid} ? $self->{uuid}->get_header('UUID') : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'uuid'} ? : 3 1 4
70 }
71  
72 sub as_string {
73 1 ▶ return join '', map { $_[0]->{$_}->as_string() } qw( format uuid );
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
74 }
75  
76 5 1;
77  
78 __END__
« blib/lib/SVN/Dump/Headers.pm ↑ Summary Build »