| 1 | package Statistics::R::REXP::Environment; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: an R environment | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | $Statistics::R::REXP::Environment::VERSION = '1.0002'; | |||||||||||||||||||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use Scalar::Util qw(refaddr blessed); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use Class::Tiny::Antlers qw(-default around); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 17 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 17 | extends 'Statistics::R::REXP'; | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 17 | ▶ | use constant sexptype => 'ENVSXP'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | has frame => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 344 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | { } | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 344 | }, | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 17 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 17 | has enclosure => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | use overload | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 17 | ▶ | '""' => sub { 'environment '. shift->name }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 475 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 475 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 475 | ▶ | if ( scalar @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | if ( ref $_[0] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | ▶ | } elsif ( blessed $_[0] && $_[0]->isa('Statistics::R::REXP::Environment') ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($_[0]) and $_[0]->isa("Statistics::R::REXP::Environment")
MC/DC50%1/2
builtin::blessed($_[0]) and $_[0]->isa("Statistics::R::REXP::Environment")
builtin::blessed($_[0])
$_[0]->isa("Statistics::R::REXP::Environment")
Truth table66%2/3
A and B
A= builtin::blessed($_[0])B= $_[0]->isa("Statistics::R::REXP::Environment")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # copy constructor from another environment | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | return { frame => $_[0]->frame, | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | enclosure => $_[0]->enclosure }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | die "Single parameters to new() must be a HASH data" | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | ." or a Statistics::R::REXP::Environment object => ". $_[0] ."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | elsif ( @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | die "The new() method for $class expects a hash reference or a key/value list." | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | . " You passed an odd number of arguments\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 472 | return {@_}; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 472 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 472 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Required attribute type | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | die "Attribute 'frame' must be a reference to a hash of REXPs" if ref($self->frame) ne 'HASH' || | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 472 | ▶ | grep { ! (blessed($_) && $_->isa('Statistics::R::REXP')) } values(%{$self->frame}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
ref $self->frame ne "HASH" or grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;}
builtin::blessed($_) && $_->isa('Statistics::R::REXP')
MC/DC50%1/2
ref $self->frame ne "HASH" or grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;}
ref $self->frame ne "HASH"
grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;}
MC/DC50%1/2
builtin::blessed($_) && $_->isa('Statistics::R::REXP')
builtin::blessed($_)
$_->isa('Statistics::R::REXP')
Truth table66%2/3
A or B
A= ref $self->frame ne "HASH"B= grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;}
Truth table66%2/3
A && B
A= builtin::blessed($_)B= $_->isa('Statistics::R::REXP')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 471 | ▶ | die "Attribute 'enclosure' must be an instance of Environment" if defined $self->enclosure && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $self->enclosure and not builtin::blessed($self->enclosure) && $self->enclosure->isa("Statistics::R::REXP::Environment")
builtin::blessed($self->enclosure) && $self->enclosure->isa('Statistics::R::REXP::Environment')
MC/DC66%2/3
defined $self->enclosure and not builtin::blessed($self->enclosure) && $self->enclosure->isa("Statistics::R::REXP::Environment")
defined $self->enclosure
builtin::blessed($self->enclosure)
$self->enclosure->isa('Statistics::R::REXP::Environment')
Truth table75%3/4
A and not(B && C)
A= defined $self->enclosureB= builtin::blessed($self->enclosure)C= $self->enclosure->isa('Statistics::R::REXP::Environment')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | !(blessed($self->enclosure) && $self->enclosure->isa('Statistics::R::REXP::Environment')); | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 252 | ▶ | around _eq => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 252 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 252 | ▶ | return unless $orig->(@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 235 | my ($self, $obj) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | 235 | ▶ | Statistics::R::REXP::_compare_deeply($self->frame, $obj->frame) && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | Statistics::R::REXP::_compare_deeply($self->enclosure, $obj->enclosure) | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | sub name { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | ($self->attributes && exists $self->attributes->{name}) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | $self->attributes->{name} : | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | '0x' . sprintf('%x', refaddr $self) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->attributes and exists $self->attributes->{"name"}
MC/DC0%0/2
$self->attributes and exists $self->attributes->{"name"}
$self->attributes
exists $self->attributes->{"name"}
Truth table33%1/3
A and B
A= $self->attributesB= exists $self->attributes->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | sub to_pl { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_pl: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | die "Environments do not have a native Perl representation" | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 17 | 1; # End of Statistics::R::REXP::Environment | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||