summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Changes3
-rw-r--r--Makefile.PL2
-rw-r--r--lib/Config/Parser.pm12
-rw-r--r--lib/Config/Parser/Ini.pm13
4 files changed, 16 insertions, 14 deletions
diff --git a/Changes b/Changes
index 39c85ac..4946431 100644
--- a/Changes
+++ b/Changes
@@ -1,8 +1,11 @@
Revision history for Perl extension Config::Parser
+1.04 Thu Aug 29 08:17:52 2019
+ - use Config::AST 1.05
+
1.03 Fri Aug 23 14:44:18 2019
- implement the BOOLEAN data type
1.02 Thu Aug 22 09:47:42 2019
- use mro to track descendant classes
diff --git a/Makefile.PL b/Makefile.PL
index 366fee2..13a762d 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -13,13 +13,13 @@ WriteMakefile(NAME => 'Config::Parser',
PREREQ_PM => {
'Carp' => 0,
'Text::ParseWords' => '3.26',
'Data::Dumper' => '2.135_06',
'File::Temp' => '0.22',
'Text::Locus' => '1.01',
- 'Config::AST' => '1.01'
+ 'Config::AST' => '1.05'
},
META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
diff --git a/lib/Config/Parser.pm b/lib/Config/Parser.pm
index bd230b5..ee39c2e 100644
--- a/lib/Config/Parser.pm
+++ b/lib/Config/Parser.pm
@@ -4,13 +4,13 @@ use warnings;
use parent 'Config::AST';
use Carp;
use Cwd qw(abs_path);
use Text::ParseWords;
use mro;
-our $VERSION = "1.03";
+our $VERSION = "1.04";
sub new {
my $class = shift;
local %_ = @_;
my $loaded = 0;
@@ -174,13 +174,13 @@ sub check_bool {
Config::Parser - base class for configuration file parsers
=head1 DESCRIPTION
B<Config::Parser> provides a framework for writing configuration file
parsers. It is an intermediate layer between the abstract syntax tree
-(B<Config::AST>) and implementation of a parser for a particular
+(L<Config::AST>) and implementation of a parser for a particular
configuration file format.
It takes a I<define by example> approach. That means that the implementer
creates a derived class that implements a parser on top of B<Config::Parser>.
Application writers write an example of configuration file in the B<__DATA__>
section of their application, which defines the statements that are allowed
@@ -277,13 +277,13 @@ created by using B<open> on the supplied filename.
Valid only together with B<filename>.
=item B<lexicon>
Dictionary of allowed configuration statements in the file. You will not
need this parameter. It is listed here for completeness sake. Refer to
-the B<Config::AST> constructor for details.
+the L<Config::AST> constructor for details.
=back
=head1 USER HOOKS
These are the methods provided for implementers to do any implementation-
@@ -299,13 +299,13 @@ implementation-specific initialization.
Called after successful parsing. It can be used to modify the created
source tree.
=head1 PARSER METHODS
-The following two methods are derived from B<Config::AST>. They are
+The following two methods are derived from L<Config::AST>. They are
called internally by the constructor, if the file name is supplied.
=head2 $cfg->parse($filename, %opts)
Parses the configuration from B<$filename>. Optional arguments are:
@@ -370,13 +370,13 @@ B<no>, B<false>, B<off>, B<nil>, B<0>, for C<false>.
=back
If the data type is omitted, no checking is performed unless specified
otherwise by other options (see the B<:re> and B<:check> options below).
Options are special names prefixed with a colon. Option names follow
-the keywords from the B<Config::AST> keyword lexicon value. An option
+the keywords from the L<Config::AST> keyword lexicon value. An option
can be followed by an equals sign and its value. If an option is used
without arguments, the value B<1> is implied.
Any word not recognized as an option or its value starts the I<default
value>.
@@ -451,11 +451,11 @@ types. If B<$$valref> is one of the valid boolean values (as described
above), it translates it to B<1> or B<0>, stores that value in B<$valref>,
and returns 1. Otherwise, it emits error message using B<$cfg->error> and
returns 0.
=head1 SEE ALSO
-B<Config::AST>(3).
+L<Config::AST>(3).
=cut
diff --git a/lib/Config/Parser/Ini.pm b/lib/Config/Parser/Ini.pm
index 67eaf1f..29923cf 100644
--- a/lib/Config/Parser/Ini.pm
+++ b/lib/Config/Parser/Ini.pm
@@ -59,17 +59,16 @@ sub _readconfig {
@path = parse_line('\s+', 0, $1);
if (@path == 1 && $path[0] eq 'include') {
$include = 1;
} else {
$include = 0;
$self->add_node(\@path,
- new Config::AST::Node::Section(locus => $locus));
+ new Config::AST::Node::Section($self, locus => $locus));
}
} elsif (/([\w_-]+)\s*=\s*(.*)/) {
my ($k, $v) = ($1, $2);
- $k = lc($k) if $self->{_ci}; #FIXME:private member
if ($include) {
if ($k eq 'path') {
$self->_readconfig($v);
} elsif ($k eq 'pathopt') {
$self->_readconfig($v) if -f $v;
@@ -145,13 +144,13 @@ fragment:
use Config::Parser::Ini;
my $cf = new Config::Parser::Ini(filename => "config.ini");
On success, this returns a valid B<Config::Parser::Ini> object. On error,
the diagnostic message is issued using the B<error> method (see the description
-of the method in B<Config::AST>(3)) and the module croaks.
+of the method in L<Config::AST>(3)) and the module croaks.
This usage, although simple, has one major drawback - no checking is performed
on the input file, except for the syntax check. To fix this, you can supply
a dictionary (or I<lexicon>) of allowed keywords along with their values.
Such a dictionary is itself a valid ini file, where the value of each
keyword describes its properties. The dictionary is placed in the B<__DATA__>
@@ -197,13 +196,13 @@ Then, to parse the configuration file, it will suffice to do:
One advantage of this approach is that it will allow you to install
additional validation for the configuration statements using the
B<:check> option. The argument to this option is the name of a
method which will be invoked after parsing the statement in order
to verify its value. It is described in detail below (see the section
-B<SYNTAX DEFINITION> in the documentation of B<Config::Parser>).
+B<SYNTAX DEFINITION> in the documentation of L<Config::Parser>).
For example, if you wish to ensure that the value of the C<root> setting
in C<core> section points to an existing directory, you would do:
package App::MyConf;
use Config::Parser::Ini;
@@ -252,20 +251,20 @@ File handle to read from. If it is not supplied, new handle will be
created by using B<open> on the supplied filename.
=item B<lexicon>
Dictionary of allowed configuration statements in the file. You will not
need this parameter. It is listed here for completeness sake. Refer to
-the B<Config::AST> constructor for details.
+the L<Config::AST> constructor for details.
=back
=head1 METHODS
-All methods are inherited from B<Config::Parser>. Please see its
+All methods are inherited from L<Config::Parser>. Please see its
documentation for details.
=head1 SEE ALSO
-B<Config::Parser>(3), B<Config::AST>(3).
+L<Config::Parser>(3), L<Config::AST>(3).
=cut

Return to:

Send suggestions and report system problems to the System administrator.