blib/lib/HTML/EP/Session/Dumper.pm

filter: Statementstmt 40.4% 17 / 42 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 4 totaltotal 23.4% 22 / 94 CC 15 SCAR 35.2
CC
15
Cov
23%
Open
72.0
Store
30.0
Delete
12.0
CRAP 33.9
« blib/lib/HTML/EP.pm ↑ Summary blib/lib/HTML/EP/Session/Cookie.pm »
1 # -*- perl -*-
2 #
3 # HTML::EP - A Perl based HTML extension.
4 #
5 #
6 # Copyright (C) 1998 Jochen Wiedmann
7 # Am Eisteich 9
8 # 72555 Metzingen
9 # Germany
10 #
11 # Phone: +49 7123 14887
12 # Email: joe@ispsoft.de
13 #
14 # All rights reserved.
15 #
16 # You may distribute this module under the terms of either
17 # the GNU General Public License or the Artistic License, as
18 # specified in the Perl README file.
19 #
20 ############################################################################
21  
22 1 require 5.004;
23 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Data::Dumper ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Safe ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Fcntl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Symbol ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29  
30 package HTML::EP::Session::Dumper;
31  
32 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
33 0 my($proto, $ep, $id, $attr) = @_;
34 0 my $session = { '_ep_data' => { 'fh' => $attr->{'fh'} } };
35 0 ▶ bless($session, (ref($proto) || $proto));
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
36 }
37  
38 0 ▶sub Open {
Subroutine Open: not called CC=8 SCAR=42.8
Pod undocumented
39 0 my($proto, $ep, $id, $attr) = @_;
40 0 my $fh = Symbol::gensym();
41 0 ▶ sysopen($fh, $id, Fcntl::O_RDWR()|Fcntl::O_CREAT())
Branch: 1 branch
BranchTrueFalseTotal
sysopen $fh, $id, 66 or die "Failed to open $id for writing: $!" 0 0 0
42 or die "Failed to open $id for writing: $!";
43 0 ▶ flock($fh, Fcntl::LOCK_EX()) or die "Failed to lock $id: $!";
Branch: 1 branch
BranchTrueFalseTotal
flock $fh, 2 or die "Failed to lock ${id}: $!" 0 0 0
44 0 ▶ return $proto->new($ep, $id, {'fh' => $fh}) if eof($fh);
Branch: 1 branch
BranchTrueFalseTotal
if eof $fh 0 0 0
45 0 local $/ = undef;
46 0 my $contents = <$fh>;
47 0 ▶ die "Failed to read $id: $!" unless defined $contents;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $contents 0 0 0
48 0 my $self = Safe->new()->reval($contents);
49 0 ▶ die "Failed to eval $id: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
50 0 ▶ die "Empty or trashed $id: Returned a false value" unless $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 0 0 0
51 0 $self->{'_ep_data'} = { 'fh' => $fh };
52 0 ▶ bless($self, (ref($proto) || $proto));
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
53 }
54  
55 0 ▶sub Store {
Subroutine Store: not called CC=5 SCAR=34.0
Pod undocumented
56 0 my($self, $ep, $id, $locked) = @_;
57 0 my $data = delete $self->{'_ep_data'};
58 0 my $fh = $data->{'fh'};
59 0 ▶ (seek($fh, 0, 0) and
Branch: 1 branch
BranchTrueFalseTotal
seek $fh, 0, 0 and print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump and truncate $fh, 0 or die "Failed to update ${id}: $!" 0 0 0
Condition0%0/6
seek $fh, 0, 0 and print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump and truncate $fh, 0
!ll&&!rl&&r
000
seek $fh, 0, 0 and print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump
!ll&&!rl&&r
000
MC/DC0%0/3
seek $fh, 0, 0 and print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump and truncate $fh, 0
seek $fh, 0, 0 print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->Dump truncate $fh, 0
Truth table0%0/4
A and B and C
A= seek $fh, 0, 0B= print $fh "Data::Dumper"->new([$self])->Indent(1)->Terse(1)->DumpC= truncate $fh, 0
ABCresult
0XX0
10X0
1100
1111
60 (print $fh (Data::Dumper->new([$self])->Indent(1)->Terse(1)->Dump())) and
61 truncate($fh, 0))
62 or die "Failed to update $id: $!";
63 0 ▶ if ($locked) {
Branch: 1 branch
BranchTrueFalseTotal
if ($locked) 0 0 0
64 0 $self->{'_ep_data'} = $data;
65 }
66 }
67  
68  
69 0 ▶sub Delete {
Subroutine Delete: not called CC=3 SCAR=24.8
Pod undocumented
70 0 my($self, $ep, $id) = @_;
71 0 ▶ if (-f $id) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $id) 0 0 0
72 0 ▶ unlink $id or die "Failed to delete $id: $!";
Branch: 1 branch
BranchTrueFalseTotal
unlink $id or die "Failed to delete ${id}: $!" 0 0 0
73 };
74 }
75  
76  
77 1 1;
78  
« blib/lib/HTML/EP.pm ↑ Summary blib/lib/HTML/EP/Session/Cookie.pm »