DHCPd/Config/Range.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 100% 29 / 29 CC 3 SCAR 5.1
CC
3
Cov
100%
captured_to_args
2.0
generate
2.0
BEGIN
1.0
CRAP 1.7
« DHCPd/Config/Host.pm ↑ Summary DHCPd/Config/Range6.pm »
1 package Net::ISC::DHCPd::Config::Range;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::Range - Range 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 range $lower_attribute_value $upper_attribute_value;
15  
16 =head1 SYNOPSIS
17  
18 See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
19  
20 =head1 NOTES
21  
22 L</upper> and L</lower> attributes might change from L<NetAddr::IP> to
23 plain strings in the future.
24  
25 =cut
26  
27 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 27 ▶use NetAddr::IP;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 27 with 'Net::ISC::DHCPd::Config::Role';
31  
32 =head1 ATTRIBUTES
33  
34 =head2 upper
35  
36 This attribute holds a L<NetAddr::IP> object, representing the
37 highest IP address in the range.
38  
39 =cut
40  
41 27 has upper => (
42 is => 'ro',
43 isa => 'Object',
44 );
45  
46 =head2 lower
47  
48 This attribute holds a L<NetAddr::IP> object, representing the
49 lowest IP address in the range.
50  
51 =cut
52  
53 27 has lower => (
54 is => 'ro',
55 isa => 'Object',
56 );
57  
58 =head2 regex
59  
60 See L<Net::ISC::DHCPd::Config::Role/regex>.
61  
62 =cut
63  
64 27 our $regex = qr{^\s* range \s+ (\S+) (?:\s+ (\S*))? ;}x;
65  
66 =head1 METHODS
67  
68 =head2 captured_to_args
69  
70 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
71  
72 =cut
73  
74 14 ▶sub captured_to_args {
Subroutine captured_to_args: called CC=2 SCAR=6.9
Pod documented
75  
76 14 ▶ if (!defined($_[1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_[1]) { } 1 13 14
77 1 return { lower => NetAddr::IP->new($_[0]) };
78 } else {
79 return {
80 13 lower => NetAddr::IP->new($_[0]),
81 upper => NetAddr::IP->new($_[1]),
82 };
83 }
84 }
85  
86 =head2 generate
87  
88 See L<Net::ISC::DHCPd::Config::Role/generate>.
89  
90 =cut
91  
92 6 ▶sub generate {
Subroutine generate: called CC=2 SCAR=6.9
Pod documented
93 6 my $self = shift;
94 6 ▶ if (defined($self->upper)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->upper) { } 5 1 6
95 5 return 'range ' .$self->lower->addr .' ' .$self->upper->addr .';';
96 } else {
97 1 return 'range ' .$self->lower->addr.';';
98 }
99 }
100  
101 =head1 COPYRIGHT & LICENSE
102  
103 =head1 AUTHOR
104  
105 See L<Net::ISC::DHCPd>.
106  
107 =cut
108 27 __PACKAGE__->meta->make_immutable;
109 27 1;
« DHCPd/Config/Host.pm ↑ Summary DHCPd/Config/Range6.pm »