DHCPd/Config/SubClass.pm

filter: Statementstmt 78.2% 18 / 23 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 2 / 2 totaltotal 72.2% 26 / 36 CC 5 SCAR 18.8
CC
5
Cov
71%
generate
12.0
captured_to_args
3.0
BEGIN
1.0
CRAP 6.6
« DHCPd/OMAPI/Control.pm ↑ Summary DHCPd/Types.pm »
1 package Net::ISC::DHCPd::Config::SubClass;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::Subclass - Subclass config parameter
6  
7 =head1 DESCRIPTION
8  
9 See L<Net::ISC::DHCPd::Config::Role> for methods and attributes without
10 documentation.
11  
12 An instance from this class, comes from / will produce one of the
13 lines below, dependent on L</quoted>.
14  
15 subclass "$name" "$value";
16  
17 =head1 SYNOPSIS
18  
19 See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
20  
21 =cut
22  
23 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 27 with 'Net::ISC::DHCPd::Config::Role';
26  
27 =head1 ATTRIBUTES
28  
29 =head2 name
30  
31 Name of the subclass - See L</DESCRIPTION> for details.
32  
33 =cut
34  
35 27 has name => (
36 is => 'ro',
37 isa => 'Str',
38 );
39  
40 =head2 value
41  
42 Value of the subclass - See L</DESCRIPTION> for details.
43  
44 =cut
45  
46 27 has value => (
47 is => 'ro',
48 isa => 'Str',
49 );
50  
51 =head2 quoted
52  
53 This flag tells if the subclass value should be quoted or not.
54  
55 =cut
56  
57 27 has quoted => (
58 is => 'ro',
59 isa => 'Bool',
60 );
61  
62 =head2 namequoted
63  
64 This flag tells if the subclass name should be quoted or not.
65  
66 =cut
67  
68 27 has namequoted => (
69 is => 'ro',
70 isa => 'Bool',
71 );
72  
73 =head2 regex
74  
75 See L<Net::ISC::DHCPd::Config::Role/regex>.
76  
77 =cut
78  
79 27 our $regex = qr{^\s*subclass \s+ ([\w-]+|".*?") \s+ (.*) ;}x;
80  
81 =head1 METHODS
82  
83 =head2 captured_to_args
84  
85 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
86  
87 =cut
88  
89 6 ▶sub captured_to_args {
Subroutine captured_to_args: called CC=3 SCAR=11.0
Pod documented
90 6 my $name = shift;
91 6 my $value = shift;
92 6 my $quoted = 0;
93 6 my $namequoted = 0;
94  
95 6 ▶ $namequoted = 1 if ($name =~ s/^"(.*)"$/$1/g);
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ s/^"(.*)"$/$1/g 3 3 6
96 6 ▶ $quoted = 1 if($value =~ s/^"(.*)"$/$1/g);
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ s/^"(.*)"$/$1/g 4 2 6
97  
98 return {
99 6 name => $name,
100 value => $value,
101 quoted => $quoted,
102 namequoted => $namequoted,
103 };
104 }
105  
106 =head2 generate
107  
108 See L<Net::ISC::DHCPd::Config::Role/generate>.
109  
110 =cut
111  
112 0 ▶sub generate {
Subroutine generate: not called CC=3 SCAR=24.8
Pod documented
113 0 my $self = shift;
114 0 my $format = "subclass ";
115 0 ▶ $format .= $self->namequoted ? qq("%s" ) : qq(%s );
Branch: 1 branch
BranchTrueFalseTotal
$self->namequoted ? : 0 0 0
116 0 ▶ $format .= $self->quoted ? qq("%s";) : qq(%s;);
Branch: 1 branch
BranchTrueFalseTotal
$self->quoted ? : 0 0 0
117  
118 0 return sprintf $format, $self->name, $self->value;
119 }
120  
121 =head1 COPYRIGHT & LICENSE
122  
123 =head1 AUTHOR
124  
125 See L<Net::ISC::DHCPd>.
126  
127 =cut
128 27 __PACKAGE__->meta->make_immutable;
129 27 1;
« DHCPd/OMAPI/Control.pm ↑ Summary DHCPd/Types.pm »