File Coverage

lib/Net/ISC/DHCPd/Config/Range6.pm
Criterion Covered Total %
statement 15 15 100.0
branch 4 4 100.0
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 25 25 100.0


line stmt bran cond sub pod time code
1             package Net::ISC::DHCPd::Config::Range6;
2              
3             =head1 NAME
4              
5             Net::ISC::DHCPd::Config::Range6 - Range6 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             range6 $lower_attribute_value $upper_attribute_value;
15              
16             or
17              
18             range6 $lower_attribute_value temporary;
19              
20             =head1 SYNOPSIS
21              
22             See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
23              
24             =head1 NOTES
25              
26             L</upper> and L</lower> attributes might change from L<NetAddr::IP> to
27             plain strings in the future.
28              
29             =cut
30              
31 25     25   16432 use Moose;
  25         48  
  25         181  
32 25     25   132878 use NetAddr::IP qw(:lower);
  25         21008  
  25         206  
33              
34             with 'Net::ISC::DHCPd::Config::Role';
35              
36             =head1 ATTRIBUTES
37              
38             =head2 upper
39              
40             This attribute holds a L<NetAddr::IP> object, representing the
41             highest IP address in the range.
42              
43             =cut
44              
45             has upper => (
46             is => 'ro',
47             isa => 'Object',
48             );
49              
50             =head2 lower
51              
52             This attribute holds a L<NetAddr::IP> object, representing the
53             lowest IP address in the range.
54              
55             =cut
56              
57             has lower => (
58             is => 'ro',
59             isa => 'Object',
60             );
61              
62             =head2 temporary
63              
64             In place of an upper address range, you can specify that the range is for
65             temporary addresses and it will be used like RFC4941
66              
67             =cut
68              
69             has temporary => (
70             is => 'ro',
71             isa => 'Bool',
72             );
73              
74             =head2 regex
75              
76             See L<Net::ISC::DHCPd::Config::Role/regex>.
77              
78             =cut
79              
80             our $regex = qr{^\s* range6 \s+ (\S+) \s+ (\S*) \s* ;}x;
81              
82             =head1 METHODS
83              
84             =head2 captured_to_args
85              
86             See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
87              
88             =cut
89              
90             sub captured_to_args {
91 2     2 1 3 my $args;
92 2         4 $args->{'temporary'}=0;
93 2 100       11 if ($_[1] eq 'temporary') {
94 1         2 $args->{'temporary'}=1;
95             } else {
96 1         4 $args->{'upper'}=NetAddr::IP->new($_[1]);
97             }
98 2         189 $args->{'lower'}=NetAddr::IP->new($_[0]);
99              
100 2         336 return $args;
101             }
102              
103             =head2 generate
104              
105             See L<Net::ISC::DHCPd::Config::Role/generate>.
106              
107             =cut
108              
109             sub generate {
110 2     2 1 3 my $self = shift;
111 2 100       51 return 'range6 ' .$self->lower->short .' '. ($self->temporary ? 'temporary' : $self->upper->short) .';';
112             }
113              
114             =head1 COPYRIGHT & LICENSE
115              
116             =head1 AUTHOR
117              
118             See L<Net::ISC::DHCPd>.
119              
120             =cut
121              
122             __PACKAGE__->meta->make_immutable;
123              
124             1;