lib/Lingy/Lang/Namespace.pm

filter: Statementstmt 33.3% 19 / 57 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 46.1% 6 / 13 Podpod 0.0% 0 / 7 totaltotal 25.2% 25 / 99 CC 11 SCAR 24.2
CC
11
Cov
26%
new
24.0
getMappings
20.0
NAME
6.0
CRAP 11.3
« lib/Lingy/Lang/Boolean.pm ↑ Summary lib/Lingy/Lang/Number.pm »
1 34 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Lingy::Lang::Namespace;
3  
4 34 ▶use Lingy::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 34 ▶use Sub::Name 'subname';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub NAME {
9 0 ▶ my ($self) = @_;
Subroutine NAME: not called CC=2 SCAR=17.9
Pod undocumented
10 0 ▶ $self->{' NAME'} // '';
Condition0%0/2
$self->{" NAME"} // ""
l!l
00
MC/DC0%0/1
$self->{" NAME"} // ""
$self->{" NAME"}
Truth table0%0/2
A
A= $self->{" NAME"}
Aresult
11
00
11 }
12  
13 sub new {
14 0 ▶ my ($class, %args) = @_;
Subroutine new: not called CC=6 SCAR=31.8
Pod undocumented
15  
16 0 my $self = bless {}, __PACKAGE__;
17  
18 0 my $name = $self->{' NAME'} = $args{name};
19  
20 0 ▶ if (my $refer_list = $args{refer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $refer_list = $args{"refer"}) 0 0 0
21 0 ▶ $refer_list = [$refer_list]
Branch: 1 branch
BranchTrueFalseTotal
unless ref $refer_list eq "ARRAY" 0 0 0
22 unless ref($refer_list) eq 'ARRAY';
23 0 ▶ my $refer_map = RT->ns_refers->{$name} //= {};
Condition0%0/2
"Lingy::Lang::RT"->ns_refers->{$name} //= {}
l!l
00
MC/DC0%0/1
"Lingy::Lang::RT"->ns_refers->{$name} //= {}
"Lingy::Lang::RT"->ns_refers->{$name}
Truth table0%0/2
A
A= "Lingy::Lang::RT"->ns_refers->{$name}
Aresult
11
00
24 0 for my $ns (@$refer_list) {
25 0 my $ns_name = $ns->NAME;
26 0 map $refer_map->{$_} = $ns_name,
27 grep /^\S/, keys %$ns;
28 }
29 }
30  
31 34 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
32 34 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
33 0 ▶ if (%{"${class}::ns"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (%{"${class}::ns";}) 0 0 0
34 %$self = (
35 %$self,
36 0 %{"${class}::ns"},
37 );
38 }
39  
40 0 RT->namespaces->{$name} = $self;
41  
42 0 return $self;
43 }
44  
45 sub current {
46 0 ▶ my ($self) = @_;
Subroutine current: not called CC=2 SCAR=17.9
Pod undocumented
47 0 ▶ my $name = $self->NAME or die;
Branch: 1 branch
BranchTrueFalseTotal
my $name = $self->NAME or die 0 0 0
48 0 RT->current_ns_name($name);
49 0 RT->namespaces->{$name} = $self;
50 0 RT->env->{space} = $self;
51 0 RT->namespaces->{'lingy.core'}{'*ns*'} = $self;
52 0 return $self;
53 }
54  
55 sub getName {
56 0 ▶ symbol($_[0]->NAME);
Subroutine getName: not called CC=1 SCAR=6.9
Pod undocumented
57 }
58  
59 sub getImports {
60 0 ▶ XXX @_, 'TODO - getImports';
Subroutine getImports: not called CC=1 SCAR=6.9
Pod undocumented
61 }
62  
63 sub getInterns {
64 my $map = {
65 0 ▶ %{$_[0]},
Subroutine getInterns: not called CC=1 SCAR=6.9
Pod undocumented
66 };
67 0 delete $map->{' NAME'};
68 0 HASHMAP->new([ %$map ]);
69 }
70  
71 sub getMappings {
72 my $map = {
73 0 ▶ %{$_[0]},
Subroutine getMappings: not called CC=4 SCAR=30.0
Pod undocumented
74 };
75 0 my $name = delete $map->{' NAME'};
76 0 ▶ my $refer = RT->ns_refers->{$name} // {};
Condition0%0/2
"Lingy::Lang::RT"->ns_refers->{$name} // {}
l!l
00
MC/DC0%0/1
"Lingy::Lang::RT"->ns_refers->{$name} // {}
"Lingy::Lang::RT"->ns_refers->{$name}
Truth table0%0/2
A
A= "Lingy::Lang::RT"->ns_refers->{$name}
Aresult
11
00
77 0 for my $key (keys %$refer) {
78 0 my $ns = $refer->{$key};
79 $map->{$key} =
80 RT->namespaces->{$ns}->{$key} //
81 0 ▶ RT->namespaces->{$key};
Condition0%0/3
"Lingy::Lang::RT"->namespaces->{$ns}{$key} // "Lingy::Lang::RT"->namespaces->{$key}
l!l&&r!l&&!r
000
MC/DC0%0/2
"Lingy::Lang::RT"->namespaces->{$ns}{$key} // "Lingy::Lang::RT"->namespaces->{$key}
"Lingy::Lang::RT"->namespaces->{$ns}{$key} "Lingy::Lang::RT"->namespaces->{$key}
Truth table0%0/3
A // B
A= "Lingy::Lang::RT"->namespaces->{$ns}{$key}B= "Lingy::Lang::RT"->namespaces->{$key}
ABresult
1X1
011
000
82 }
83 0 HASHMAP->new([ %$map ]);
84 }
85  
86 34 1;
« lib/Lingy/Lang/Boolean.pm ↑ Summary lib/Lingy/Lang/Number.pm »