lib/XML/XMetaL.pm

filter: Statementstmt 30.8% 21 / 68 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 41.6% 5 / 12 Podpod 66.6% 2 / 3 totaltotal 20.2% 28 / 138 CC 21 SCAR 37.8
CC
21
Cov
19%
__ANON__
110.0
new
30.0
add_handler
20.0
CRAP 43.6
« lib/XML/XMetaL/Utilities/Iterator.pm ↑ Summary lib/XML/XMetaL/Mock/DOMNodeList.pm »
1 package XML::XMetaL;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Hash::Util qw(lock_keys);
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9
10 1 our $VERSION = '0.52';
11
12 1 our $singleton;
13 1 our $application;
14 1 our %custom_handlers;
15
16 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
17 0 my ($class, %args) = @_;
18 0 my $self;
19 0 eval {
20 0 lock_keys(%args,qw(-application));
21 0 ▶ if ($singleton) {
Branch: 1 branch
BranchTrueFalseTotal
if ($XML::XMetaL::singleton) { } 0 0 0
22 0 $self = $singleton;
23 } else {
24 $application = $args{-application} ||
25 0 ▶ croak "-application argument missing or undefined";
Condition0%0/2
$args{'-application'} || croak('-application argument missing or undefined')
l!l
00
MC/DC0%0/1
$args{'-application'} || croak('-application argument missing or undefined')
$args{'-application'}
Truth table0%0/2
A
A= $args{'-application'}
Aresult
11
00
26 0 ▶ $self = bless {}, ref($class) || $class;
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
27 0 lock_keys(%$self, keys %$self);
28 0 $singleton = $self;
29 }
30 };
31 0 ▶ croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
32 0 return $self;
33 }
34
35 0 ▶sub _get_application {
Subroutine _get_application: not called CC=2 SCAR=17.9
36 0 ▶ return $application ||
Condition0%0/2
$XML::XMetaL::application || croak('Application object does not exist')
l!l
00
MC/DC0%0/1
$XML::XMetaL::application || croak('Application object does not exist')
$XML::XMetaL::application
Truth table0%0/2
A
A= $XML::XMetaL::application
Aresult
11
00
37 croak "Application object does not exist";
38 }
39
40 0 ▶sub get_handler {
Subroutine get_handler: not called CC=3 SCAR=24.8
Pod undocumented
41 0 my ($self, $key) = @_;
42 0 ▶ return $custom_handlers{$key} || croak "Handler ".($key || "UNDEF")." does not exist";
Condition0%0/4
$XML::XMetaL::custom_handlers{$key} || croak('Handler ' . ($key || 'UNDEF') . ' does not exist')
l!l
00
$key || 'UNDEF'
l!l
00
MC/DC0%0/1
$XML::XMetaL::custom_handlers{$key} || croak('Handler ' . ($key || 'UNDEF') . ' does not exist')
$XML::XMetaL::custom_handlers{$key}
MC/DC0%0/1
$key || 'UNDEF'
$key
Truth table0%0/2
A
A= $XML::XMetaL::custom_handlers{$key}
Aresult
11
00
Truth table0%0/2
A
A= $key
Aresult
11
00
43 }
44
45
46 0 ▶sub add_handler {
Subroutine add_handler: not called CC=4 SCAR=30.0
Pod documented
47 0 my ($self, %args) = @_;
48 0 my $handler_exists_exception = "Handler is registered already";
49 0 eval {
50 0 lock_keys(%args, qw(-system_identifier -handler));
51 0 my $dtd_name = $self->_base_path($args{-system_identifier});
52 0 ▶ die $handler_exists_exception if exists $custom_handlers{$dtd_name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $XML::XMetaL::custom_handlers{$dtd_name} 0 0 0
53 0 $custom_handlers{$args{-system_identifier}} = $args{-handler};
54 };
55 0 ▶ if ($@ eq $handler_exists_exception) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@ eq $handler_exists_exception) { } 0 0 0
elsif ($@) { } 0 0 0
56 0 return;
57 } elsif ($@) {
58 0 croak $@;
59 }
60 }
61
62 0 ▶sub _base_path {
Subroutine _base_path: not called CC=1 SCAR=6.9
63 0 my ($self, $system_identifier) = @_;
64 0 my ($base_name) = $system_identifier =~ /([^\\\/]+)$/;
65 0 return $base_name;
66 }
67
68 # ======================================================================
69 # Dispatcher
70 #
71 # The AUTOLOAD method generates dispatch methods automatically,
72 # and installs them in the symbol table
73 # ======================================================================
74
75 1 our $AUTOLOAD;
76 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=16.5
77 0 my ($self, @args) = @_;
78 0 my ($class, $method) = $AUTOLOAD =~ /^(.*)::(.*)$/;
79 0 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 0 0 0
80 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
81 0 ▶ *{$AUTOLOAD} = sub {
Subroutine __ANON__: not called CC=10 SCAR=47.0
82 0 my ($self, @args) = @_;
83 0 my $application;
84 my @return_values;
85 0 eval {
86 0 ▶ $application = $self->_get_application() ||
Condition0%0/2
$self->_get_application || die("Dispatch method $method called, but there is no application object")
l!l
00
MC/DC0%0/1
$self->_get_application || die("Dispatch method $method called, but there is no application object")
$self->_get_application
Truth table0%0/2
A
A= $self->_get_application
Aresult
11
00
87 die "Dispatch method $method called, but there is no application object";
88 my $active_document = $application->{ActiveDocument} ||
89 0 ▶ die "Dispatch method $method called, but there is no active document";
Condition0%0/2
$application->{'ActiveDocument'} || die("Dispatch method $method called, but there is no active document")
l!l
00
MC/DC0%0/1
$application->{'ActiveDocument'} || die("Dispatch method $method called, but there is no active document")
$application->{'ActiveDocument'}
Truth table0%0/2
A
A= $application->{'ActiveDocument'}
Aresult
11
00
90 my $doctype = $active_document->{doctype} ||
91 0 ▶ die "The active document had no doctype";
Condition0%0/2
$active_document->{'doctype'} || die('The active document had no doctype')
l!l
00
MC/DC0%0/1
$active_document->{'doctype'} || die('The active document had no doctype')
$active_document->{'doctype'}
Truth table0%0/2
A
A= $active_document->{'doctype'}
Aresult
11
00
92 my $system_identifier = $doctype->{systemId} ||
93 0 ▶ die "The doctype declaration of the active document had no system identifier";
Condition0%0/2
$doctype->{'systemId'} || die('The doctype declaration of the active document had no system identifier')
l!l
00
MC/DC0%0/1
$doctype->{'systemId'} || die('The doctype declaration of the active document had no system identifier')
$doctype->{'systemId'}
Truth table0%0/2
A
A= $doctype->{'systemId'}
Aresult
11
00
94 0 ▶ my $handler = $self->get_handler($system_identifier) ||
Condition0%0/2
$self->get_handler($system_identifier) || die("Handler for system identifier $system_identifier could not be found")
l!l
00
MC/DC0%0/1
$self->get_handler($system_identifier) || die("Handler for system identifier $system_identifier could not be found")
$self->get_handler($system_identifier)
Truth table0%0/2
A
A= $self->get_handler($system_identifier)
Aresult
11
00
95 die "Handler for system identifier $system_identifier could not be found";
96 0 @return_values = $handler->$method(@args);
97 };
98 0 ▶ if ($@ && $application) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@ and $application) { } 0 0 0
elsif ($@) { } 0 0 0
Condition0%0/3
$@ and $application
!ll&&!rl&&r
000
MC/DC0%0/2
$@ and $application
$@ $application
Truth table0%0/3
A and B
A= $@B= $application
ABresult
0X0
100
111
99 0 $application->Alert("$@");
100 } elsif ($@) {
101 0 croak $@;
102 }
103 0 ▶ return wantarray ? @return_values : $return_values[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
104 0 };
105 0 $self->$method(@args);
106 }
107
108
109
110
111 1 1;
112 __END__
« lib/XML/XMetaL/Utilities/Iterator.pm ↑ Summary lib/XML/XMetaL/Mock/DOMNodeList.pm »