line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::ISC::DHCPd::Config::Include; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Include - Hold content of included file |
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
|
|
|
|
|
|
|
include "$file_attribute_value"; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Example: |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $include = $config->includes->[0]; |
19
|
|
|
|
|
|
|
$include->parse; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config/SYNOPSIS>. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
24
|
|
|
24
|
|
31747
|
use Moose; |
|
24
|
|
|
|
|
61
|
|
|
24
|
|
|
|
|
224
|
|
28
|
24
|
|
|
24
|
|
165601
|
use Path::Class::File; |
|
24
|
|
|
|
|
81
|
|
|
24
|
|
|
|
|
15029
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
with 'Net::ISC::DHCPd::Config::Root'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 children |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/children>. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub children { |
39
|
|
|
|
|
|
|
|
40
|
36
|
|
|
36
|
1
|
1110
|
return qw/ |
41
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Authoritative |
42
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Include |
43
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Conditional |
44
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::FailoverPeer |
45
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Class |
46
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::SubClass |
47
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Host |
48
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Subnet |
49
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Subnet6 |
50
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::SharedNetwork |
51
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Function |
52
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::OptionSpace |
53
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::OptionCode |
54
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Option |
55
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Key |
56
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Zone |
57
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Group |
58
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::Block |
59
|
|
|
|
|
|
|
Net::ISC::DHCPd::Config::KeyValue |
60
|
|
|
|
|
|
|
/; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__PACKAGE__->create_children(__PACKAGE__->children()); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 generate_with_include |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This attribute holds a boolean value. L</generate> will result in |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
include "path/from/file/attribute"; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
when false, and the included config if true. This attribute is false |
74
|
|
|
|
|
|
|
by default. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Example: |
77
|
|
|
|
|
|
|
$include->generate_with_include(1); |
78
|
|
|
|
|
|
|
$include->generate; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has generate_with_include => ( |
83
|
|
|
|
|
|
|
is => 'rw', |
84
|
|
|
|
|
|
|
isa => 'Bool', |
85
|
|
|
|
|
|
|
default => 0, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 regex |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/regex>. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
101
|
|
|
101
|
1
|
739
|
sub regex { qr{^\s* include \s+ "([^"]+)" ;}x } |
94
|
6
|
|
|
6
|
|
231
|
sub _build_root { shift->parent } |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _build__filehandle { |
97
|
6
|
|
|
6
|
|
12
|
my $self = shift; |
98
|
6
|
|
|
|
|
232
|
my $file = $self->file; |
99
|
|
|
|
|
|
|
|
100
|
6
|
100
|
|
|
|
293
|
if ($self->root->filename_callback) { |
101
|
1
|
|
|
|
|
5
|
$file = Path::Class::File->new(&{$self->root->filename_callback}($file)); |
|
1
|
|
|
|
|
37
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
6
|
100
|
66
|
|
|
192
|
if($file->is_relative and !-e $file) { |
105
|
5
|
|
|
|
|
564
|
$file = Path::Class::File->new($self->root->file->dir, $file); |
106
|
5
|
|
|
|
|
855
|
$self->file($file); # needed so dir stays updated with recursive includes |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
6
|
|
|
|
|
143
|
return $file->openr; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 parse |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This around method modifier will stop the parser when parsing |
117
|
|
|
|
|
|
|
recursively, which will require the user to manually parse the |
118
|
|
|
|
|
|
|
included files from the config. Reason for this is that the |
119
|
|
|
|
|
|
|
C<parse()> method returns the number of lines in a single file. |
120
|
|
|
|
|
|
|
and counting lines from included files will break this behaviour. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
See also L<Net::ISC::DHCPd::Config::Role/parse> and |
123
|
|
|
|
|
|
|
L<Net::ISC::DHCPd::Config/SYNOPSIS>. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
around parse => sub { |
128
|
|
|
|
|
|
|
my $next = shift; |
129
|
|
|
|
|
|
|
my $self = shift; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
if($_[0] and $_[0] eq 'recursive') { |
132
|
|
|
|
|
|
|
return '0e0'; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
return $self->$next(@_); |
136
|
|
|
|
|
|
|
}; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 captured_to_args |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd::Config::Role/captured_to_args>. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub captured_to_args { |
145
|
6
|
|
|
6
|
1
|
30
|
return { file => $_[0] }; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 generate |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This method can either result in C<include ...;> line or the whole |
151
|
|
|
|
|
|
|
config of the included file. See L</generate_with_include> for how |
152
|
|
|
|
|
|
|
to control the behaviour. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
See also L<Net::ISC::DHCPd::Config::Role/generate>. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub generate { |
159
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
160
|
|
|
|
|
|
|
|
161
|
4
|
100
|
|
|
|
125
|
if($self->generate_with_include) { |
162
|
2
|
|
|
|
|
8
|
my $text = $self->generate_config_from_children; |
163
|
2
|
100
|
|
|
|
28
|
return $text ? $text : "# forgot to parse " .$self->file ."?"; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
else { |
167
|
2
|
|
|
|
|
55
|
return qq(include ") .$self->file .qq(";); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 AUTHOR |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
See L<Net::ISC::DHCPd>. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
179
|
|
|
|
|
|
|
1; |