| 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
| |||||||||||||||||||||||||||||||||
| 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')
MC/DC0%0/1
$args{'-application'} || croak('-application argument missing or undefined')
$args{'-application'}
Truth table0%0/2
A
A= $args{'-application'}
| |||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $self = bless {}, ref($class) || $class; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||
| 27 | 0 | lock_keys(%$self, keys %$self); | |||||||||||||||||||||||||||||||
| 28 | 0 | $singleton = $self; | |||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | croak $@ if $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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')
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
| |||||||||||||||||||||||||||||||||
| 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')
$key || 'UNDEF'
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}
Truth table0%0/2
A
A= $key
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 53 | 0 | $custom_handlers{$args{-system_identifier}} = $args{-handler}; | |||||||||||||||||||||||||||||||
| 54 | }; | ||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ($@ eq $handler_exists_exception) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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")
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
| |||||||||||||||||||||||||||||||||
| 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")
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'}
| |||||||||||||||||||||||||||||||||
| 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')
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'}
| |||||||||||||||||||||||||||||||||
| 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')
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'}
| |||||||||||||||||||||||||||||||||
| 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")
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)
| |||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$@ and $application
MC/DC0%0/2
$@ and $application
$@
$application
Truth table0%0/3
A and B
A= $@B= $application
| |||||||||||||||||||||||||||||||||
| 99 | 0 | $application->Alert("$@"); | |||||||||||||||||||||||||||||||
| 100 | } elsif ($@) { | ||||||||||||||||||||||||||||||||
| 101 | 0 | croak $@; | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | return wantarray ? @return_values : $return_values[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | 0 | }; | |||||||||||||||||||||||||||||||
| 105 | 0 | $self->$method(@args); | |||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | 1 | 1; | |||||||||||||||||||||||||||||||
| 112 | __END__ | ||||||||||||||||||||||||||||||||