blib/lib/Net/ISC/DHCPd/Config/Group.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 35 SCAR 34.0
CC
5
Cov
0%
captured_to_args
12.0
generate
12.0
children
2.0
CRAP 30.0
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 use Moose;
32  
33 with 'Net::ISC::DHCPd::Config::Role';
34  
35 =head2 children
36  
37 See L<Net::ISC::DHCPd::Config::Role/children>.
38  
39 =cut
40 sub children {
41 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 __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 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 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 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 sub captured_to_args {
119 my $name = shift;
120 my $quoted = 0;
121  
122 return if !defined($name);
123  
124 $quoted = 1 if ($name =~ s/^"(.*)"$/$1/g);
125  
126 return {
127 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 sub generate {
139 my $self = shift;
140 if (defined($self->name)) {
141 my $name = $self->name;
142 return 'group ' . ($self->quoted ? qq("$name") : $name) . ' {', $self->_generate_config_from_children, '}';
143 }
144  
145 # default with no name
146 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 __PACKAGE__->meta->make_immutable;
157 1;