DHCPd/Config/KeyValue.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 2 / 2 totaltotal 100% 27 / 27 CC 3 SCAR 5.9
CC
3
Cov
100%
captured_to_args
2.0
generate
2.0
BEGIN
1.0
CRAP 1.8
« DHCPd/Config/OptionCode.pm ↑ Summary DHCPd/Config/Option.pm »
1 package Net::ISC::DHCPd::Config::KeyValue;
2  
3 =head1 NAME
4  
5 Net::ISC::DHCPd::Config::KeyValue - Misc option 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 one of the
13 lines below, dependent on L</quoted>.
14  
15 $name_attribute_value "$value_attribute_value";
16 $name_attribute_value $value_attribute_value;
17  
18 This means that this class represents "anything" that does not
19 fall into any of the other categories and can be expressed as a
20 key-value pair.
21  
22 =head1 SYNOPSIS
23  
24 See L<Net::ISC::DHCPd::Config/SYNOPSIS>.
25  
26 =cut
27  
28 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 27 with 'Net::ISC::DHCPd::Config::Role';
31  
32 =head1 ATTRIBUTES
33  
34 =head2 name
35  
36 Name of the option - See L</DESCRIPTION> for details.
37  
38 =cut
39  
40 27 has name => (
41 is => 'ro',
42 isa => 'Str',
43 );
44  
45 =head2 value
46  
47 Value of the option - See L</DESCRIPTION> for details.
48  
49 =cut
50  
51 27 has value => (
52 is => 'ro',
53 isa => 'Str',
54 );
55  
56 =head2 quoted
57  
58 This flag tells if the option value should be quoted or not.
59  
60 =cut
61  
62 27 has quoted => (
63 is => 'ro',
64 isa => 'Bool',
65 );
66  
67 =head2 regex
68  
69 See L<Net::ISC::DHCPd::Config::Role/regex>.
70  
71 =cut
72  
73 27 our $regex = qr{^\s* ([\w-]+) \s+ (.*) ;}x;
74  
75 =head1 METHODS
76  
77 =head2 captured_to_args
78  
79 See L<Net::ISC::DHCPd::Config::Role/captured_to_args>.
80  
81 =cut
82  
83 61 ▶sub captured_to_args {
Subroutine captured_to_args: called CC=2 SCAR=6.9
Pod documented
84 61 my $name = shift;
85 61 my $value = shift;
86 61 my $quoted = 0;
87  
88 61 ▶ $quoted = 1 if($value =~ s/^"(.*)"$/$1/g);
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ s/^"(.*)"$/$1/g 5 56 61
89  
90 return {
91 61 name => $name,
92 value => $value,
93 quoted => $quoted,
94 };
95 }
96  
97 =head2 generate
98  
99 See L<Net::ISC::DHCPd::Config::Role/generate>.
100  
101 =cut
102  
103 37 ▶sub generate {
Subroutine generate: called CC=2 SCAR=6.9
Pod documented
104 37 my $self = shift;
105 37 ▶ my $format = $self->quoted ? qq(%s "%s";) : qq(%s %s;);
Branch: 1 branch
BranchTrueFalseTotal
$self->quoted ? : 4 33 37
106  
107 37 return sprintf $format, $self->name, $self->value;
108 }
109  
110 =head1 COPYRIGHT & LICENSE
111  
112 =head1 AUTHOR
113  
114 See L<Net::ISC::DHCPd>.
115  
116 =cut
117 27 __PACKAGE__->meta->make_immutable;
118 27 1;
« DHCPd/Config/OptionCode.pm ↑ Summary DHCPd/Config/Option.pm »