blib/lib/Clustericious/Client/Meta.pm

filter: Statementstmt 87.0% 47 / 54 Branchbran 100% 2 / 2 Conditioncond 50.0% 3 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 77.7% 7 / 9 Podpod 100% 7 / 7 totaltotal 82.7% 67 / 81 CC 5 SCAR 9.0
CC
5
Cov
84%
routes
6.0
add_route
3.0
add_object
2.0
CRAP 2.5
« blib/lib/auto/share/dist/Clustericious/tmpl/1.08/app/lib/APPCLASS.pm ↑ Summary blib/lib/Clustericious/Commands.pm »
1 package Clustericious::Client::Meta;
2  
3 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: simple meta object for constructing clients
7 40 our $VERSION = '1.29'; # VERSION
8  
9 40 our %Routes; # hash from class name to array ref of routes.
10 40 our %RouteAttributes; # hash from class name to hash ref of attributes.
11 40 our %Objects; # hash from class name to array ref of objects.
12 40 our @CommonRoutes = ( [ "version" => '' ], [ "status" => '' ], [ "api" => '' ], [ "logtail" => '' ] );
13  
14  
15 34 ▶sub add_route { # Keep track of routes that have are added.
Subroutine add_route: called CC=3 SCAR=11.0
Pod documented
16 34 my $class = shift;
17 34 my $for = shift; # e.g. Restmd::Client
18 34 my $route_name = shift; # same as $subname
19 34 ▶ my $route_doc = shift || '';
Condition100%2/2
shift() || ''
l!l
430
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
20  
21 34 ▶ if (my ($found) = grep { $_->[0] eq $route_name } @{ $Routes{$for} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($found) = grep({$_->[0] eq $route_name;} @{$Clustericious::Client::Meta::Routes{$for};})) 2 32 34
22 2 $found->[1] = $route_doc;
23 2 return;
24 }
25 32 push @{ $Routes{$for} }, [ $route_name => $route_doc ];
26 }
27  
28  
29 2 ▶sub get_route_doc {
Subroutine get_route_doc: called CC=1 SCAR=0.0
Pod documented
30 2 my $class = shift;
31 2 my $for = shift; # e.g. Restmd::Client
32 2 my $route_name = shift; # same as $subname
33 2 my ($found) = grep { $_->[0] eq $route_name } @{ $Routes{$for} };
34 2 return $found->[1];
35 }
36  
37  
38 75 ▶sub add_route_attribute {
Subroutine add_route_attribute: called CC=1 SCAR=0.0
Pod documented
39 75 my $class = shift;
40 75 my $for = shift; # e.g. Restmd::Client
41 75 my $route_name = shift;
42 75 my $attr_name = shift;
43 75 my $attr_value = shift;
44 75 $RouteAttributes{$for}->{$route_name}{$attr_name} = $attr_value;
45 }
46  
47  
48 49 ▶sub get_route_attribute {
Subroutine get_route_attribute: called CC=1 SCAR=0.0
Pod documented
49 49 my $class = shift;
50 49 my $for = shift; # e.g. Restmd::Client
51 49 my $route_name = shift;
52 49 my $attr_name = shift;
53 49 return $RouteAttributes{$for}->{$route_name}{$attr_name};
54 }
55  
56  
57 1 ▶sub add_object {
Subroutine add_object: called CC=2 SCAR=7.0
Pod documented
58 1 my $class = shift;
59 1 my $for = shift;
60 1 my $obj_name = shift;
61 1 ▶ my $obj_doc = shift || '';
Condition50%1/2
shift() || ''
l!l
01
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
62 1 push @{ $Objects{$for} }, [ $obj_name => $obj_doc ];
63 }
64  
65  
66 0 ▶sub routes {
Subroutine routes: not called CC=2 SCAR=17.9
Pod documented
67 0 my $class = shift;
68 0 my $for = shift;
69 0 ▶ return [ @CommonRoutes, @{$Routes{$for} || []}];
Condition0%0/2
$Clustericious::Client::Meta::Routes{$for} || []
l!l
00
MC/DC0%0/1
$Clustericious::Client::Meta::Routes{$for} || []
$Clustericious::Client::Meta::Routes{$for}
Truth table0%0/2
A
A= $Clustericious::Client::Meta::Routes{$for}
Aresult
11
00
70 }
71  
72 0 ▶sub objects {
Subroutine objects: not called CC=1 SCAR=6.9
Pod documented
73 0 my $class = shift;
74 0 my $for = shift;
75 0 return $Objects{$for};
76  
77 }
78  
79 40 1;
80  
81 __END__
« blib/lib/auto/share/dist/Clustericious/tmpl/1.08/app/lib/APPCLASS.pm ↑ Summary blib/lib/Clustericious/Commands.pm »