| 1 | package Data::Shared::Node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 39 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 39 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 39 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 39 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 39 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 39 | our @CARP_NOT = qw(Data::Shared); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2420 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2420 | my ($class, $root, $components) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2420 | ▶ | return bless { root => $root, components => [ @{ $components || [] } ] }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$components || []
MC/DC0%0/1
$components || []
$components
Truth table50%1/2
A
A= $components
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub CLONE_SKIP { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub root { return $_[0]{root} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | sub components { return [ @{ $_[0]{components} } ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
components: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | sub path { return '/' . join('/', @{ $_[0]{components} }) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 38 | ▶ | sub _abs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_abs: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 38 | my ($self, $rel) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 38 | ▶ | return [ @{ $self->{components} } ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
not defined $rel or not ref $rel and $rel eq "" || $rel eq "/"
not ref $rel and $rel eq "" || $rel eq "/"
$rel eq "" or $rel eq "/"
MC/DC75%3/4
not defined $rel or not ref $rel and $rel eq "" || $rel eq "/"
not defined $rel
not ref $rel
$rel eq ""
$rel eq "/"
Truth table80%4/5
not(A) or not(B) and C or D
A= not defined $relB= not ref $relC= $rel eq ""D= $rel eq "/"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | if !defined $rel || (!ref $rel && ($rel eq '' || $rel eq '/')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 15 | ▶ | Carp::croak('Data::Shared: a Data::Shared::Node is an absolute cursor, not a relative path') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($rel) and $rel->isa("Data::Shared::Node")
MC/DC100%2/2
builtin::blessed($rel) and $rel->isa("Data::Shared::Node")
builtin::blessed($rel)
$rel->isa("Data::Shared::Node")
Truth table100%3/3
A and B
A= builtin::blessed($rel)B= $rel->isa("Data::Shared::Node")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | if blessed($rel) && $rel->isa('Data::Shared::Node'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # Arrayref components are validated there, as $root->node([...]) is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 14 | return [ @{ $self->{components} }, @{ Data::Shared::_rel_components($rel) } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | sub node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | my ($self, $rel) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | return Data::Shared::Node->new($self->{root}, $self->_abs($rel)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # An explicit undef is a path computation that came back empty, not this node; omitted or '' is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 25 | ▶ | sub _rel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 25 | my ($self, $verb, $argc, $rel) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 25 | ▶ | Carp::croak("Data::Shared: node $verb: undef relative path (pass '' for this node)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$argc > 1 and not defined $rel
MC/DC100%2/2
$argc > 1 and not defined $rel
$argc > 1
not defined $rel
Truth table100%3/3
A and not(B)
A= $argc > 1B= not defined $rel
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | if $argc > 1 && !defined $rel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 16 | return $self->_abs($rel); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # _abs has validated the components, so these skip shareda_*. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | ▶ | sub get { my ($s, $rel, @a) = @_; return Data::Shared::_dispatch('get', $s->{root}, $s->_rel('get', scalar @_, $rel), @a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | ▶ | sub set { my ($s, $rel, @a) = @_; return Data::Shared::_dispatch('set', $s->{root}, $s->_rel('set', scalar @_, $rel), @a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | sub delete { my ($s, $rel, @a) = @_; return Data::Shared::_dispatch('delete', $s->{root}, $s->_rel('delete', scalar @_, $rel), @a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | ▶ | sub exists { my ($s, $rel, @a) = @_; return Data::Shared::_dispatch('exists', $s->{root}, $s->_rel('exists', scalar @_, $rel), @a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | sub incr { my ($s, $rel, @a) = @_; return Data::Shared::_dispatch('incr', $s->{root}, $s->_rel('incr', scalar @_, $rel), @a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
incr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | sub push { my ($s, $rel, @a) = @_; return Data::Shared::_dispatch_pushpop('push', $s->{root}, $s->_rel('push', scalar @_, $rel), @a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub pop { my ($s, $rel, @a) = @_; return Data::Shared::_dispatch_pushpop('pop', $s->{root}, $s->_rel('pop', scalar @_, $rel), @a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 18 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 18 | my ($self, $method, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 18 | ▶ | Carp::croak("Data::Shared: node call requires a method name") unless defined $method && length $method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $method and length $method
MC/DC50%1/2
defined $method and length $method
defined $method
length $method
Truth table66%2/3
A and B
A= defined $methodB= length $method
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 17 | return Data::Shared::_dispatch_call($self->{root}, $self->_abs(''), $method, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 7 | ▶ | sub call_at { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call_at: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 7 | my ($self, $rel, $method, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | return Data::Shared::_dispatch_call($self->{root}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 7 | $self->_rel('call_at', scalar @_, $rel), $method, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | sub children { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | my ($self, $rel) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | return $self->{root}->children($self->_abs($rel)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | sub handle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | my ($self, $rel) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | return $self->{root}->handle($self->_abs($rel)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 39 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||