DHCPd/Config/Zone.pm

filter: Statementstmt 87.5% 14 / 16 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 3 / 3 totaltotal 78.7% 26 / 33 CC 6 SCAR 17.9
CC
6
Cov
77%
generate
12.0
slurp
4.0
BEGIN
1.0
CRAP 6.0
« DHCPd/Types.pm ↑ Summary DHCPd/Leases.pm »
1 package Net::ISC::DHCPd::Config::Zone;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::Zone - Server Zone
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 the block below:
13  
14 $name_attribute_value $value_attribute_value;
15  
16 zone $name {
17 primary $primary;
18 key $key;
19 };
20  
21 =head1 SYNOPSIS
22  
23 See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
24  
25 =cut
26  
27 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 27 with 'Net::ISC::DHCPd::Config::Role';
30  
31 =head1 ATTRIBUTES
32  
33 =head2 name
34  
35 Name of the Zone - See L</DESCRIPTION> for details.
36  
37 =head2 primary
38  
39 =head2 key
40  
41 =cut
42  
43 27 has [qw/ name key primary /] => (
44 is => 'rw', # TODO: WILL PROBABLY CHANGE!
45 isa => 'Str',
46 );
47  
48 =head2 regex
49  
50 See L<Net::ISC::DHCPd::Config::Role/regex>.
51  
52 =cut
53  
54 # not sure if this can be quoted or not
55 27 our $regex = qr{^\s* zone \s+ (")?(\S+)(\1|$) }x;
56  
57 =head1 METHODS
58  
59 =head2 slurp
60  
61 This method is used by L<Net::ISC::DHCPd::Config::Role/parse>, and will
62 slurp the content of the function, instead of trying to parse the
63 statements.
64  
65 =cut
66  
67 4 ▶sub slurp {
Subroutine slurp: called CC=4 SCAR=13.9
Pod documented
68 4 my($self, $line) = @_;
69  
70 4 ▶ return 'last' if($line =~ /^\s*}/);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\s*}/ 1 3 4
71 # not sure if these can really be quoted
72 3 ▶ $self->primary($1) if($line =~ /primary \s+ (\S+);/x);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /primary \s+ (\S+);/x 1 2 3
73 3 ▶ $self->key($2) if($line =~ /key \s+ ("?)(\S+)\1;/x);
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /key \s+ ("?)(\S+)\1;/x 1 2 3
74 3 return 'next';
75 }
76  
77 =head2 captured_to_args
78  
79 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
80  
81 =cut
82  
83 1 ▶sub captured_to_args {
Subroutine captured_to_args: called CC=1 SCAR=0.0
Pod documented
84 1 return { name => $_[1] }; # $_[0] == quote or empty string
85 }
86  
87 =head2 generate
88  
89 See L<Net::ISC::DHCPd::Config::Role/generate>.
90  
91 =cut
92  
93 0 ▶sub generate {
Subroutine generate: not called CC=3 SCAR=24.8
Pod documented
94 0 my $self = shift;
95  
96 return(
97 0 ▶ sprintf('zone %s {', $self->name),
Branch: 2 branches
BranchTrueFalseTotal
$self->primary ? : 0 0 0
$self->key ? : 0 0 0
98 $self->primary ? (sprintf ' primary %s;', $self->primary) : (),
99 $self->key ? (sprintf ' key %s;', $self->key) : (),
100 '}',
101 );
102 }
103  
104 =head1 COPYRIGHT & LICENSE
105  
106 =head1 AUTHOR
107  
108 See L<Net::ISC::DHCPd>.
109  
110 =cut
111  
112 27 __PACKAGE__->meta->make_immutable;
113 27 1;
« DHCPd/Types.pm ↑ Summary DHCPd/Leases.pm »