line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::TOML; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24365
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
41
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
430
|
use Config::TOML::Parser; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use IO::All qw/io/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Config::TOML - The great new Config::TOML! |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.01 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.01_alpha'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Config::TOML; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $data = Config::TOML->read_file('path/to/file.toml'); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
print "Foo.bar.baz is: ", $data->{foo}{bar}{baz}; |
30
|
|
|
|
|
|
|
... |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 Functions. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
At present the factory methods are meant to be called as class methods on the |
36
|
|
|
|
|
|
|
Config::TOML class. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use IO::All qw/io/; |
40
|
|
|
|
|
|
|
use Carp qw(croak confess); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use Config::TOML::Parser; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 read_file($path): HashRef |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Reads a file given as a path. As we are using IO::All, you can use a variety |
47
|
|
|
|
|
|
|
of different things here. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Returns the parsed data structure. |
50
|
|
|
|
|
|
|
Confesses if it cannot parse the configuration. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub read_file { |
55
|
|
|
|
|
|
|
my ($cls, $path) = @_; |
56
|
|
|
|
|
|
|
my $io = io($path); |
57
|
|
|
|
|
|
|
my $parser = Config::TOML::Parser->new( |
58
|
|
|
|
|
|
|
name => $path, |
59
|
|
|
|
|
|
|
src => sub { $io->getc }, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
my $ret = $parser->parse; |
62
|
|
|
|
|
|
|
$io->close; |
63
|
|
|
|
|
|
|
return $ret; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 parse($text): HashRef |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Reads configuration given as a string. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns the parsed data structure. |
71
|
|
|
|
|
|
|
Confesses if it cannot parse the configuration. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub parse { |
76
|
|
|
|
|
|
|
my ($cls, $text) = @_; |
77
|
|
|
|
|
|
|
my @chars = split '', $text; |
78
|
|
|
|
|
|
|
my $parser = Config::TOML::Parser->new( |
79
|
|
|
|
|
|
|
src => sub { shift @chars }, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
$parser->parse; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Alex Kalderimis, C<< >> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 BUGS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
92
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
93
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SUPPORT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
perldoc Config::TOML |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
You can also look for information at: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=over 4 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * CPAN Ratings |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * Search CPAN |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2013 Alex Kalderimis. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
134
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
135
|
|
|
|
|
|
|
copy of the full license at: |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
140
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
141
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
142
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
145
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
146
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
149
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
152
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
153
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
154
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
155
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
156
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
157
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
158
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
161
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
162
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
163
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
164
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
165
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
166
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
167
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; # End of Config::TOML |