blib/lib/SVN/Dump/Property.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 7 / 7 totaltotal 100% 58 / 58 SCAR 16.1
CC
5
Cov
100%
as_string
3.0
set
2.0
delete
2.0
CRAP 5.0
« Build ↑ Summary blib/lib/SVN/Dump/Text.pm »
1 package SVN::Dump::Property;
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  
6 13 my $NL = "\012";
7  
8 # FIXME should I use Tie::Hash::IxHash or Tie::Hash::Indexed?
9 sub new {
10 468 ▶ my ( $class, @args ) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
11 468 return bless {
12 keys => [],
13 hash => {},
14 }, $class;
15 }
16  
17 sub set {
18 801 ▶ my ( $self, $k, $v ) = @_;
Subroutine set: called CC=2 SCAR=6.9
Pod documented
19  
20 801 ▶ push @{ $self->{keys} }, $k if !exists $self->{hash}->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"hash"}{$k} 800 1 801
21 801 $self->{hash}{$k} = $v;
22 }
23 9 ▶sub get { return $_[0]{hash}{ $_[1] }; }
Subroutine get: called CC=1 SCAR=0.0
Pod documented
24 3 ▶sub keys { return @{ $_[0]{keys} }; }
Subroutine keys: called CC=1 SCAR=0.0
Pod documented
25 3 ▶sub values { return @{ $_[0]{hash} }{ @{ $_[0]{keys} } }; }
Subroutine values: called CC=1 SCAR=0.0
Pod documented
26 sub delete {
27 9 ▶ my ( $self, @keys ) = @_;
Subroutine delete: called CC=2 SCAR=6.9
Pod documented
28 9 ▶ return if !@keys;
Branch: 1 branch
BranchTrueFalseTotal
unless @keys 1 8 9
29 8 my $re = qr/^@{[join '|', map { quotemeta } @keys]}$/;
30 8 $self->{keys} = [ grep { !/$re/ } @{ $self->{keys} } ];
31 8 delete @{ $self->{hash} }{@keys};
32 }
33  
34 sub as_string {
35 607 ▶ my ($self) = @_;
Subroutine as_string: called CC=3 SCAR=11.0
Pod documented
36 607 my $string = '';
37  
38 $string .=
39 defined $self->{hash}{$_}
40 # existing key
41 ? ( "K " . length($_) . $NL ) . "$_$NL"
42 . ( "V " . length( $self->{hash}{$_} ) . $NL )
43 . "$self->{hash}{$_}$NL"
44 # deleted key (v3)
45 : ( "D " . length($_) . "$NL$_$NL" )
46 607 ▶ for @{ $self->{keys} };
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'hash'}{$_} ? : 1031 5 1036
47  
48 # end marker
49 607 $string .= "PROPS-END$NL";
50  
51 607 return $string;
52 }
53  
54 13 1;
55  
56 __END__
« Build ↑ Summary blib/lib/SVN/Dump/Text.pm »