Radius/Dictionary.pm

filter: Statementstmt 96.2% 51 / 53 Branchbran 65.0% 13 / 20 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 16 / 16 Podpod 10.0% 1 / 10 totaltotal 79.4% 85 / 107 CC 14 SCAR 8.8
CC
14
Cov
86%
_combine_existing_dicts
4.1
from_multiple_files
3.7
value
3.0
CRAP 2.4
« Radius/Util.pm ↑ Summary Radius.pm »
1 package Data::Radius::Dictionary;
2  
3 7 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶use base qw(Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 __PACKAGE__->mk_accessors(qw(attr_id attr_name const_name const_value vnd_name vnd_id));
9  
10 7 ▶use Data::Radius::DictionaryParser ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
13 9 my ($class, %h) = @_;
14 9 return bless({ %h }, $class);
15 }
16  
17 1 ▶sub _combine_existing_dicts {
Subroutine _combine_existing_dicts: called CC=4 SCAR=14.1
18 1 my ($class, @dict_paths) = @_;
19  
20 1 my @existing_paths;
21 1 foreach my $dict_path ( @dict_paths ) {
22 2 ▶ if ( -r $dict_path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-r $dict_path) 2 0 2
23 2 push @existing_paths => $dict_path;
24 }
25 }
26  
27 1 ▶ return @existing_paths ? [ map { '$INCLUDE ' . $_ } @existing_paths ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@existing_paths ? : 1 0 1
28 }
29  
30 1 ▶sub from_multiple_files {
Subroutine from_multiple_files: called CC=3 SCAR=13.0
Pod undocumented
31 1 my ($class, @files) = @_;
32  
33 1 my $arref_of_includes = $class->_combine_existing_dicts(@files);
34 1 ▶ if ( !$arref_of_includes || !@{$arref_of_includes} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($arref_of_includes and @{$arref_of_includes;}) 0 1 1
Condition33%1/3
$arref_of_includes and @{$arref_of_includes;}
!ll&&!rl&&r
001
MC/DC0%0/2
$arref_of_includes and @{$arref_of_includes;}
$arref_of_includes @{$arref_of_includes;}
Truth table33%1/3
A and B
A= $arref_of_includesB= @{$arref_of_includes;}
ABresult
0X0
100
111
35 0 warn 'No usable RADIUS dictionaries was provided';
36 0 return undef;
37 }
38  
39 1 return Data::Radius::DictionaryParser->new()
40 ->parse_str_array($arref_of_includes);
41 }
42  
43 8 ▶sub load_file {
Subroutine load_file: called CC=1 SCAR=0.0
Pod undocumented
44 8 my ($class, $file) = @_;
45 8 return Data::Radius::DictionaryParser->new()->parse_file($file);
46 }
47  
48 30 ▶sub attribute {
Subroutine attribute: called CC=2 SCAR=7.1
Pod undocumented
49 30 my ($self, $attr_name) = @_;
50 30 ▶ return undef if (! $attr_name);
Branch: 1 branch
BranchTrueFalseTotal
unless $attr_name 0 30 30
51 # hash-ref with {id, type, vendor, parent}
52 30 return $self->attr_name()->{ $attr_name };
53 }
54  
55 13 ▶sub attribute_name {
Subroutine attribute_name: called CC=2 SCAR=6.9
Pod undocumented
56 13 my ($self, $vendor_name, $id) = @_;
57 13 ▶ return $self->attr_id()->{ $vendor_name // '' }{$id};
Condition100%2/2
$vendor_name // ""
l!l
112
MC/DC100%1/1
$vendor_name // ""
$vendor_name
Truth table100%2/2
A
A= $vendor_name
Aresult
11
00
58 }
59  
60 3 ▶sub tlv_attribute_name {
Subroutine tlv_attribute_name: called CC=1 SCAR=0.0
Pod undocumented
61 3 my ($self, $parent, $id) = @_;
62 3 return $parent->{tlv_attr_id}{ $id };
63 }
64  
65 14 ▶sub vendor_id {
Subroutine vendor_id: called CC=2 SCAR=6.9
Pod undocumented
66 14 my ($self, $vendor_name) = @_;
67 14 ▶ return undef if (! $vendor_name);
Branch: 1 branch
BranchTrueFalseTotal
unless $vendor_name 12 2 14
68 2 return $self->vnd_name()->{ $vendor_name };
69 }
70  
71 1 ▶sub vendor_name {
Subroutine vendor_name: called CC=2 SCAR=7.1
Pod undocumented
72 1 my ($self, $vendor_id) = @_;
73 1 ▶ return undef if (! $vendor_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $vendor_id 0 1 1
74 1 return $self->vnd_id()->{ $vendor_id };
75 }
76  
77 # VALUE Service-Type Login-User 1
78 # Convert 'Login-User' to 1
79 5 ▶sub value {
Subroutine value: called CC=3 SCAR=11.1
Pod undocumented
80 5 my ($self, $attr_name, $const_name) = @_;
81 5 ▶ return undef if (! defined $const_name);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $const_name 0 5 5
82 5 ▶ return $self->const_value()->{ $attr_name } ? $self->const_value()->{ $attr_name }{ $const_name } : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->const_value->{$attr_name} ? : 4 1 5
83 }
84  
85 5 ▶sub constant {
Subroutine constant: called CC=3 SCAR=11.1
Pod undocumented
86 5 my ($self, $attr_name, $const_value) = @_;
87 5 ▶ return undef if (! defined $const_value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $const_value 0 5 5
88 5 ▶ return $self->const_name()->{ $attr_name } ? $self->const_name()->{ $attr_name }{ $const_value } : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->const_name->{$attr_name} ? : 4 1 5
89 }
90  
91 7 1;
92  
93 __END__
« Radius/Util.pm ↑ Summary Radius.pm »