blib/lib/Net/ISC/DHCPd/Config/SharedNetwork.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::SharedNetwork;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::SharedNetwork - Shared-network 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 blocks below, dependent on L</name> is set or not.
14  
15 shared-network $name_attribute_value {
16 $keyvalues_attribute_value
17 $subnets_attribute_value
18 }
19  
20 shared-network {
21 $keyvalues_attribute_value
22 $subnets_attribute_value
23 }
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::Host
43 Net::ISC::DHCPd::Config::Subnet
44 Net::ISC::DHCPd::Config::Subnet6
45 Net::ISC::DHCPd::Config::KeyValue
46 /;
47 }
48 __PACKAGE__->create_children(__PACKAGE__->children());
49  
50 =head1 ATTRIBUTES
51  
52 =head2 subnets
53  
54 A list of parsed L<Net::ISC::DHCPd::Config::Subnet> objects.
55  
56 =head2 keyvalues
57  
58 A list of parsed L<Net::ISC::DHCPd::Config::KeyValue> objects.
59  
60 =head2 name
61  
62 Holds a string representing the name of this shared network.
63 Will be omitted if it contains an empty string.
64  
65 =cut
66  
67 has name => (
68 is => 'ro',
69 isa => 'Str',
70 );
71  
72 =head2 quoted
73  
74 This flag tells if the shared-network name should be quoted or not.
75  
76 =cut
77  
78 has quoted => (
79 is => 'ro',
80 isa => 'Bool',
81 );
82  
83 =head2 regex
84  
85 See L<Net::ISC::DHCPd::Config::Role/regex>.
86  
87 =cut
88  
89 our $regex = qr{^\s* shared-network \s+ ([\w-]+|".*?")? }x;
90  
91 =head1 METHODS
92  
93 =head2 captured_to_args
94  
95 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
96  
97 =cut
98  
99 sub captured_to_args {
100 my $name = shift;
101 my $quoted = 0;
102 return if !defined($name);
103  
104 $quoted = 1 if ($name =~ s/^"(.*)"$/$1/g);
105  
106 return {
107 name => $name,
108 quoted => $quoted,
109 };
110 }
111  
112  
113 =head2 generate
114  
115 See L<Net::ISC::DHCPd::Config::Role/generate>.
116  
117 =cut
118  
119 sub generate {
120 my $self = shift;
121  
122 if (defined($self->name)) {
123 my $name = $self->name;
124 return 'shared-network ' . ($self->quoted ? qq("$name") : $self->name) . ' {', $self->_generate_config_from_children, '}';
125 }
126  
127 return 'shared-network {', $self->_generate_config_from_children, '}';
128 }
129  
130 =head1 COPYRIGHT & LICENSE
131  
132 =head1 AUTHOR
133  
134 See L<Net::ISC::DHCPd>.
135  
136 =cut
137 __PACKAGE__->meta->make_immutable;
138 1;