DHCPd/Config/Host.pm

filter: Statementstmt 88.8% 24 / 27 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 5 / 5 totaltotal 87.2% 41 / 47 CC 4 SCAR 5.1
CC
4
Cov
85%
__ANON__
2.3
__ANON__
2.3
__ANON__
2.0
CRAP 1.7
« DHCPd/Config/Option.pm ↑ Summary DHCPd/Config/Range.pm »
1 package Net::ISC::DHCPd::Config::Host;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::Host - Host 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 host $name_attribute_value {
15 $keyvalues_attribute_value
16 $filenames_attribute_value
17 $options_attribute_value
18 }
19  
20 =head1 SYNOPSIS
21  
22 See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
23  
24 =cut
25  
26 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 27 with 'Net::ISC::DHCPd::Config::Role';
29  
30 =head2 children
31  
32 See L<Net::ISC::DHCPd::Config::Role/children>.
33  
34 =cut
35  
36 82 ▶sub children {
Subroutine children: called CC=1 SCAR=0.0
Pod documented
37 82 return qw/
38 Net::ISC::DHCPd::Config::Host::FixedAddress
39 Net::ISC::DHCPd::Config::Host::HardwareEthernet
40 Net::ISC::DHCPd::Config::Option
41 Net::ISC::DHCPd::Config::Filename
42 Net::ISC::DHCPd::Config::KeyValue
43 /;
44 }
45 27 __PACKAGE__->create_children(__PACKAGE__->children());
46  
47 =head1 ATTRIBUTES
48  
49 =head2 fixedaddress
50  
51 Convienence method that wraps shift->fixedaddresses->[0]
52  
53 =head2 options
54  
55 A list of parsed L<Net::ISC::DHCPd::Config::Option> objects.
56  
57 =head2 filenames
58  
59 A list of parsed L<Net::ISC::DHCPd::Config::Filename> objects. There can
60 be only one element in this list.
61  
62 =cut
63  
64 6 ▶before add_filename => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
65 6 ▶ if(0 < int @{ $_[0]->filenames }) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 < int @{$_[0]->filenames;}) 1 5 6
66 1 confess 'Host cannot have more than one filename';
67 }
68 27 };
69  
70 13 ▶before add_fixedaddress => sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
71 13 ▶ if(0 < int @{ $_[0]->fixedaddresses }) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 < int @{$_[0]->fixedaddresses;}) 0 13 13
72 0 confess 'Host cannot have more than one ip address';
73 }
74 27 };
75  
76 11 ▶before add_hardwareethernet => sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
77 11 ▶ if(0 < int @{ $_[0]->hardwareethernets }) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 < int @{$_[0]->hardwareethernets;}) 0 11 11
78 0 confess 'Host cannot have more than one mac address';
79 }
80 27 };
81  
82 0 ▶sub fixedaddress {
Subroutine fixedaddress: not called CC=1 SCAR=6.9
Pod documented
83 0 shift->fixedaddresses->[0];
84 }
85  
86 =head2 hardwareethernet
87  
88 Convienence method that wraps shift->hardwareethernets->[0]
89  
90 =cut
91 2 ▶sub hardwareethernet {
Subroutine hardwareethernet: called CC=1 SCAR=0.0
Pod documented
92 2 shift->hardwareethernets->[0];
93 }
94  
95 =head2 keyvalues
96  
97 A list of parsed L<Net::ISC::DHCPd::Config::KeyValue> objects.
98  
99 =head2 name
100  
101 This attribute holds a string describing the host.
102  
103 =cut
104  
105 27 has name => (
106 is => 'ro',
107 isa => 'Str',
108 );
109  
110 =head2 regex
111  
112 See L<Net::ISC::DHCPd::Config::Role/regex>.
113  
114 =cut
115  
116 27 our $regex = qr{^ \s* host \s+ (\S+)}x;
117  
118 =head1 METHODS
119  
120 =head2 captured_to_args
121  
122 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
123  
124 =cut
125  
126 17 ▶sub captured_to_args {
Subroutine captured_to_args: called CC=1 SCAR=0.0
Pod documented
127 17 return { name => $_[0] };
128 }
129  
130 =head2 generate
131  
132 See L<Net::ISC::DHCPd::Config::Role/generate>.
133  
134 =cut
135  
136 4 ▶sub generate {
Subroutine generate: called CC=1 SCAR=0.0
Pod documented
137 4 my $self = shift;
138  
139 return(
140 4 'host ' .$self->name .' {',
141 $self->_generate_config_from_children,
142 '}',
143 );
144 }
145  
146 =head1 COPYRIGHT & LICENSE
147  
148 =head1 AUTHOR
149  
150 See L<Net::ISC::DHCPd>.
151  
152 =cut
153 27 __PACKAGE__->meta->make_immutable;
154 27 1;
« DHCPd/Config/Option.pm ↑ Summary DHCPd/Config/Range.pm »