DHCPd/Config/Group.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 3 / 3 totaltotal 100% 36 / 36 CC 5 SCAR 9.2
CC
5
Cov
100%
captured_to_args
3.0
generate
3.0
BEGIN
1.0
CRAP 2.5
« DHCPd/Config/Include.pm ↑ Summary DHCPd/Config/SharedNetwork.pm »
1 package Net::ISC::DHCPd::Config::Group;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::Group - Group 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:
13  
14 group $name {
15 $keyvalues_attribute_value
16 $options_attribute_value
17 $hosts_attribute_value
18 $groups_attribute_value
19 $sharednetworks_attribute_value
20 $subnets_attribute_value
21 }
22  
23 Group names are optional.
24  
25 =head1 SYNOPSIS
26  
27 See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
28  
29 =cut
30  
31 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 27 with 'Net::ISC::DHCPd::Config::Role';
34  
35 =head2 children
36  
37 See L<Net::ISC::DHCPd::Config::Role/children>.
38  
39 =cut
40 53 ▶sub children {
Subroutine children: called CC=1 SCAR=0.0
Pod documented
41 53 return qw/
42 Net::ISC::DHCPd::Config::Subnet
43 Net::ISC::DHCPd::Config::Subnet6
44 Net::ISC::DHCPd::Config::SharedNetwork
45 Net::ISC::DHCPd::Config::Group
46 Net::ISC::DHCPd::Config::Host
47 Net::ISC::DHCPd::Config::Option
48 Net::ISC::DHCPd::Config::KeyValue
49 /;
50 }
51 27 __PACKAGE__->create_children(__PACKAGE__->children());
52  
53 =head1 ATTRIBUTES
54  
55 =head2 subnets
56  
57 A list of parsed L<Net::ISC::DHCPd::Config::Subnet> objects.
58  
59 =head2 sharednetworks
60  
61 A list of parsed L<Net::ISC::DHCPd::Config::SharedNetwork> objects.
62  
63 =head2 groups
64  
65 A list of parsed L<Net::ISC::DHCPd::Config::Group> objects.
66  
67 =head2 hosts
68  
69 A list of parsed L<Net::ISC::DHCPd::Config::Host> objects.
70  
71 =head2 options
72  
73 A list of parsed L<Net::ISC::DHCPd::Config::Option> objects.
74  
75 =head2 keyvalues
76  
77 A list of parsed L<Net::ISC::DHCPd::Config::KeyValue> objects.
78  
79 =head2 name
80  
81 Name of the group - See L</DESCRIPTION> for details.
82  
83 =cut
84  
85 27 has name => (
86 is => 'ro',
87 isa => 'Str',
88 );
89  
90 =head2 quoted
91  
92 This flag tells if the group name should be quoted or not.
93  
94 =cut
95  
96 27 has quoted => (
97 is => 'ro',
98 isa => 'Bool',
99 );
100  
101 =head2 regex
102  
103 See L<Net::ISC::DHCPd::Config::Role/regex>.
104  
105 =cut
106  
107  
108 27 our $regex = qr{^ \s* group \s+ ([\w-]+|".*?")? }x;
109  
110 =head1 METHODS
111  
112 =head2 captured_to_args
113  
114 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
115  
116 =cut
117  
118 10 ▶sub captured_to_args {
Subroutine captured_to_args: called CC=3 SCAR=11.0
Pod documented
119 10 my $name = shift;
120 10 my $quoted = 0;
121  
122 10 ▶ return if !defined($name);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 5 5 10
123  
124 5 ▶ $quoted = 1 if ($name =~ s/^"(.*)"$/$1/g);
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ s/^"(.*)"$/$1/g 4 1 5
125  
126 return {
127 5 name => $name,
128 quoted => $quoted,
129 };
130 }
131  
132 =head2 generate
133  
134 See L<Net::ISC::DHCPd::Config::Role/generate>.
135  
136 =cut
137  
138 5 ▶sub generate {
Subroutine generate: called CC=3 SCAR=11.0
Pod documented
139 5 my $self = shift;
140 5 ▶ if (defined($self->name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->name) 3 2 5
141 3 my $name = $self->name;
142 3 ▶ return 'group ' . ($self->quoted ? qq("$name") : $name) . ' {', $self->_generate_config_from_children, '}';
Branch: 1 branch
BranchTrueFalseTotal
$self->quoted ? : 2 1 3
143 }
144  
145 # default with no name
146 2 return 'group {', $self->_generate_config_from_children, '}';
147 }
148  
149 =head1 COPYRIGHT & LICENSE
150  
151 =head1 AUTHOR
152  
153 See L<Net::ISC::DHCPd>.
154  
155 =cut
156 27 __PACKAGE__->meta->make_immutable;
157 27 1;
« DHCPd/Config/Include.pm ↑ Summary DHCPd/Config/SharedNetwork.pm »