summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2018-07-10 09:55:54 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2018-07-10 09:55:54 (GMT)
commitcc81fa13ff5a8402457a860a0e64d76d3d89b8d9 (patch) (side-by-side diff)
treee287607491077d0946868ec26a7d236a9a56ec1d
parent90d7ba0cd178ca223355c8bcb1cf6c1174bee794 (diff)
downloadconfig-ast-cc81fa13ff5a8402457a860a0e64d76d3d89b8d9.tar.gz
config-ast-cc81fa13ff5a8402457a860a0e64d76d3d89b8d9.tar.bz2
Rename to Config::AST
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile.PL6
-rw-r--r--lib/Config/AST.pm (renamed from lib/Config/Tree.pm)248
-rw-r--r--lib/Config/AST/Node.pm (renamed from lib/Config/Tree/Node.pm)14
-rw-r--r--lib/Config/AST/Node/Null.pm (renamed from lib/Config/Tree/Node/Null.pm)4
-rw-r--r--lib/Config/AST/Node/Section.pm (renamed from lib/Config/Tree/Node/Section.pm)8
-rw-r--r--lib/Config/AST/Node/Value.pm (renamed from lib/Config/Tree/Node/Value.pm)4
-rw-r--r--t/01conf03.t2
-rw-r--r--t/01conf04.t2
-rw-r--r--t/01conf05.t2
-rw-r--r--t/01conf06.t2
-rw-r--r--t/01conf07.t2
-rw-r--r--t/01conf08.t2
-rw-r--r--t/01conf09.t2
-rw-r--r--t/01conf10.t2
-rw-r--r--t/01conf13.t4
-rw-r--r--t/01conf14.t4
-rw-r--r--t/01conf15.t4
-rw-r--r--t/02merge.t18
-rw-r--r--t/TestConfig.pm6
19 files changed, 219 insertions, 117 deletions
diff --git a/Makefile.PL b/Makefile.PL
index cedef68..80b1928 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,9 +4,9 @@ use warnings;
use ExtUtils::MakeMaker;
use Module::Metadata;
-WriteMakefile(NAME => 'Config::Tree',
- ABSTRACT_FROM => 'lib/Config/Tree.pm',
- VERSION_FROM => 'lib/Config/Tree.pm',
+WriteMakefile(NAME => 'Config::AST',
+ ABSTRACT_FROM => 'lib/Config/AST.pm',
+ VERSION_FROM => 'lib/Config/AST.pm',
AUTHOR => 'Sergey Poznyakoff <gray@gnu.org>',
LICENSE => 'gpl_3',
MIN_PERL_VERSION => 5.016001,
diff --git a/lib/Config/Tree.pm b/lib/Config/AST.pm
index b4d2728..5774865 100644
--- a/lib/Config/Tree.pm
+++ b/lib/Config/AST.pm
@@ -14,15 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-package Config::Tree;
+package Config::AST;
use strict;
use warnings;
use Carp;
use Text::Locus;
-use Config::Tree::Node qw(:sort);
-use Config::Tree::Node::Section;
-use Config::Tree::Node::Value;
+use Config::AST::Node qw(:sort);
+use Config::AST::Node::Section;
+use Config::AST::Node::Value;
use Data::Dumper;
require Exporter;
@@ -34,11 +34,11 @@ our $VERSION = "1.00";
=head1 NAME
-Config::Tree - generalized configuration file parser
+Config::AST - abstract syntax tree for configuration files
=head1 SYNOPSIS
- my $cfg = new Config::Tree($filename, %opts);
+ my $cfg = new Config::AST($filename, %opts);
$cfg->parse() or die;
if ($cfg->is_set('core', 'variable')) {
@@ -53,45 +53,97 @@ Config::Tree - generalized configuration file parser
=head1 DESCRIPTION
-Configuration file handling. Features:
+This module aims to provide a generalized implementation of parse tree
+for various configuration files. It does not implement parser for any existing
+configuration file format. Instead, it provides an API that can be used by
+parsers to build internal representation for the particular configuration file
+format.
+
+A configuration file in general is supposed to consist of statements of two
+kinds: simple statements, and sections. A simple statement declares or sets
+a configuration parameter. Examples of simple statements are:
+
+ # Bind configuration file:
+ file "cache/named.root";
+
+ # Apache configuration file:
+ ServerName example.com
+
+ # Git configuration file:
+ logallrefupdates = true
+
+A section statement groups together a number of another statements. These
+can be simple statements, as well as another sections. Examples of sections
+are (with subordinate statements replaced with ellipsis):
+
+ # Bind configuration file:
+ zone "." {
+ ...
+ };
+
+ # Apache configuration file:
+ <VirtualHost *:80>
+ ...
+ </VirtualHost>
+
+ # Git configuration file:
+ [core]
+ ...
+
+Syntax of Git configuration file being one of the simplest, we will use
+it in the discussion below to illustrate various concepts.
+
+The abstract syntax tree (AST) for configuration file consists of nodes.
+Each node represents a single statement and carries detailed information
+about that statement, in particular:
=over 4
-=item 1
-
-Handles I<git>-format configuration files.
+=item B<locus>
-=item 2
+Location of the statement in the configuration. It is represented by an
+object of class B<Text::Locus>.
-Table-driven syntax checking and validation.
+=item order
-=item 3
+0-based number reflecting position of this node in the parent section
+node.
-Optional caching facility allows for faster loading. This is especially
-useful for big configurations.
+=item value
-=item 4
+For simple statements - the value of this statement.
-Built-in B<lint> facility.
+=item subtree
-=item 5
+For sections - the subtree below this section.
-Location tracking.
+=back
-=item 6
+The type of each node can be determined using the following node attributes:
-Dump facility. The parsed configuration can be output to the given file
-handler in a standardized form.
+=over 4
+
+=item is_section
-=item 7
+True if node is a section node.
-Both random access and iteration over all settings is possible.
+=item is_value
+
+True if node is a simple statement.
=back
-=head1 METHODS
+To retrieve a node, address it using its I<full path>, i.e. list of statement
+names that lead to this node. For example, in this simple configuration file:
+
+ [core]
+ filemode = true
+
+the path of the C<filemode> statement is C<qw(core filemode)>.
+
+=head1 CONSTRUCTOR
-=head2 $cfg = new Config::Tree($filename, %opts);
+ $cfg = new Config::AST($filename, %opts);
Creates new configuration object for file B<$filename>. Valid
options are:
@@ -107,15 +159,15 @@ Sets debug verbosity level.
If B<1>, enables case-insensitive keyword matching. Default is B<0>,
i.e. the keywords are case-sensitive.
-=item B<parameters> => \%hash
+=item B<lexicon> => \%hash
-Defines the syntax table. See below for a description of B<%hash>.
+Defines the keywords lexicon. See below for a description of B<%hash>.
=back
-=head3 Syntax hash
+=head3 Keywords lexicon
-The hash reference passed via the B<parameters> keyword defines the keywords
+The hash reference passed via the B<lexicon> keyword defines the keywords
and sections allowed within a configuration file. In a simplest case, a
keyword is described as
@@ -135,13 +187,13 @@ Whether or not this setting is mandatory.
=item default => I<VALUE>
Default value for the setting. This value will be assigned if that particular
-variable is not explicilty assigned in the configuration file. If I<VALUE>
+statement is not explicilty used in the configuration file. If I<VALUE>
is a CODE reference, it will be invoked as a method each time the value is
accessed.
Default values must be pure Perl values (not the values that should appear
in the configuration file). They are not processed using the B<check>
-callbacks.
+callbacks (see below).
=item array => 0 | 1
@@ -161,7 +213,7 @@ called as
$self->$coderef($node, @path)
-where $node is the B<Config::Tree::Node::Value> object (use
+where $node is the B<Config::AST::Node::Value> object (use
B<$vref-E<gt>value>, to obtain the actual value), and B<@path> is its patname.
=item check => I<coderef>
@@ -196,12 +248,16 @@ To define a section, use the B<section> keyword, e.g.:
}
}
-This says that the section B<[core]> can have two variables: B<pidfile>, which
-is mandatory, and B<verbose>, whose value must be B<on>, or B<off> (case-
-insensitive).
+This says that the section named B<core> can have two variables: B<pidfile>,
+which is mandatory, and B<verbose>, whose value must be B<on>, or B<off>
+(case-insensitive). E.g.:
+
+ [core]
+ pidfile = /run/ast.pid
+ verbose = off
To accept arbitrary keywords, use B<*>. For example, the following
-declares the B<[code]> section, which must have the B<pidfile> setting
+declares B<code> section, which must have the B<pidfile> setting
and is allowed to have any other settings as well.
code => {
@@ -212,7 +268,7 @@ and is allowed to have any other settings as well.
}
Everything said above applies to the B<'*'> as well. E.g. the following
-example declares the B<[code]> section, which must have the B<pidfile>
+example declares the B<code> section, which must have the B<pidfile>
setting and is allowed to have I<subsections> with arbitrary settings.
code => {
@@ -230,7 +286,7 @@ The special entry
'*' => '*'
-means "any settings and any subsections".
+means "any settings and any subsections are allowed".
=cut
@@ -244,11 +300,11 @@ sub new {
$self->{_debug} = delete $_{debug} || 0;
$self->{_ci} = delete $_{ci} || 0;
- if (defined($v = delete $_{parameters})) {
+ if (defined($v = delete $_{lexicon})) {
if (ref($v) eq 'HASH') {
- $self->{_parameters} = $v;
+ $self->{_lexicon} = $v;
} else {
- carp "parameters must refer to a HASH";
+ carp "lexicon must refer to a HASH";
++$err;
}
}
@@ -264,6 +320,14 @@ sub new {
return $self;
}
+=head1 METHODS
+
+=head2 $cfg->reset;
+
+Resets the parse tree.
+
+=cut
+
sub reset {
my $self = shift;
$self->{_error_count} = 0;
@@ -318,12 +382,12 @@ sub _fixup {
? sub { $self->${ \ $d->{default} } }
: $d->{default};
if (exists($d->{section})) {
- $n = new Config::Tree::Node::Section(
+ $n = new Config::AST::Node::Section(
default => 1,
subtree => $dfl
);
} else {
- $n = new Config::Tree::Node::Value(
+ $n = new Config::AST::Node::Value(
default => 1,
value => $dfl
);
@@ -344,7 +408,7 @@ sub _fixup {
}
}
} else {
- my $node = new Config::Tree::Node::Section;
+ my $node = new Config::AST::Node::Section;
$self->_fixup($node, $d->{section}, @path, $k);
if ($node->keys > 0) {
# If the newly created node contains any subnodes
@@ -369,7 +433,7 @@ sub _fixup {
my $node;
unless ($node = $section->subtree($k)) {
- $node = new Config::Tree::Node::Section;
+ $node = new Config::AST::Node::Section;
}
if ((!exists($d->{select})
|| $self->${ \ $d->{select} }($node, @path, $k))) {
@@ -397,9 +461,11 @@ sub _fixup {
=head2 $cfg->parse(...)
-Parses the configuration file and stores the data in the object. Returns
-true on success and false on failure. Eventual errors in the configuration
-are reported using B<error>.
+Abstract method that is supposed to actually parse the configuration file
+and build the parse tree from it. Derived classes must overload it.
+
+The must return true on success and false on failure. Eventual errors in
+the configuration should be reported using B<error>.
=cut
@@ -408,6 +474,22 @@ sub parse {
croak "call to abstract method"
}
+=head2 $cfg->commit
+
+Must be called after B<parse> to finalize the parse tree. This function
+does the actual syntax checking and applied default values to the statements
+where such are defined. Returns true on success.
+
+=cut
+
+sub commit {
+ my ($self) = @_;
+ # FIXME
+ $self->_fixup($self->tree, $self->{_lexicon})
+ if exists $self->{_lexicon};
+ return $self->{_error_count} == 0;
+}
+
sub getnode {
my $self = shift;
@@ -419,9 +501,11 @@ sub getnode {
return $node;
}
+=head1 NODE RETRIEVAL
+
=head2 $var = $cfg->get(@path);
-Returns the B<Config::Tree::Node::Value>(3) corresponding to the
+Returns the B<Config::AST::Node::Value>(3) corresponding to the
configuration variable represented by its I<path>, or B<undef> if the
variable is not set. The path is a list of configuration variables leading
to the value in question. For example, the following statement:
@@ -475,7 +559,7 @@ sub is_set {
=head2 $cfg->is_section(@path)
Returns true if the configuration section addressed by B<@path> is
-set.
+defined.
=cut
@@ -488,7 +572,7 @@ sub is_section {
=head2 $cfg->is_variable(@path)
Returns true if the configuration setting addressed by B<@path>
-is set and is a variable.
+is set and is a simple statement.
=cut
@@ -498,17 +582,30 @@ sub is_variable {
return defined($node) && $node->is_value;
}
+=head2 $cfg->tree
+
+ Returns the parse tree.
+
+=cut
+
sub tree {
my $self = shift;
- return $self->{_tree} //= new Config::Tree::Node::Section(locus => new Text::Locus);
+ return $self->{_tree} //= new Config::AST::Node::Section(locus => new Text::Locus);
}
+=head2 $cfg->subtree(@path)
+
+Returns the configuration subtree associated with the statement indicated by
+B<@path>.
+
+=cut
+
sub subtree {
my $self = shift;
return $self->tree->subtree(@_);
}
-sub _get_section_synt {
+sub _section_lexicon {
my ($self, $kw, $name) = @_;
if (defined($kw)) {
@@ -535,9 +632,15 @@ sub _get_section_synt {
use constant TAINT => eval '${^TAINT}';
use constant TESTS => TAINT && defined eval 'require Taint::Util';
-=head2 add_node($path, $node)
+=head2 $cfg->add_node($path, $node)
+
+Adds the node in the node corresponding to B<$path>. B<$path> can be
+either a list of keyword names, or its string representation, where
+names are separated by dots. I.e., the following two calls are equivalent:
- FIXME
+ $cfg->add_node(qw(core pidfile), $node)
+
+ $cfg->add_node('core.pidfile', $node)
=cut
@@ -548,7 +651,7 @@ sub add_node {
$path = [ split(/\./, $path) ]
}
- my $kw = $self->{_parameters} // { '*' => '*' };
+ my $kw = $self->{_lexicon} // { '*' => '*' };
my $tree = $self->tree;
my $pn = $#{$path};
my $name;
@@ -562,7 +665,7 @@ sub add_node {
return;
}
- $kw = $self->_get_section_synt($kw, $name);
+ $kw = $self->_section_lexicon($kw, $name);
unless ($kw) {
$self->error(join('.', @{$path}[0..$i]) . ": unknown section");
$self->{_error_count}++;
@@ -573,7 +676,7 @@ sub add_node {
$tree = $subtree;
} else {
$tree = $tree->subtree(
- $name => new Config::Tree::Node::Section(
+ $name => new Config::AST::Node::Section(
order => $self->{_order}++,
locus => $locus->clone)
);
@@ -659,20 +762,19 @@ sub add_node {
return $newnode;
}
+=head2 $cfg->add_value($path, $value, $locus)
+
+Adds a statement node with the given B<$value> and B<$locus> in position,
+indicated by $path.
+
+=cut
+
sub add_value {
my ($self, $path, $value, $locus) = @_;
- $self->add_node($path, new Config::Tree::Node::Value(value => $value,
+ $self->add_node($path, new Config::AST::Node::Value(value => $value,
locus => $locus));
}
-sub commit {
- my ($self) = @_;
- # FIXME
- $self->_fixup($self->tree, $self->{_parameters})
- if exists $self->{_parameters};
- return $self->{_error_count} == 0;
-}
-
=head2 $cfg->set(@path, $value)
Sets the configuration variable B<@path> to B<$value>.
@@ -690,13 +792,13 @@ sub set {
$node = $n;
} else {
$node = $node->subtree(
- $arg => new Config::Tree::Node::Section
+ $arg => new Config::AST::Node::Section
);
}
}
my $v = $node->subtree($_[0]) ||
- $node->subtree($_[0] => new Config::Tree::Node::Value(
+ $node->subtree($_[0] => new Config::AST::Node::Value(
order => $self->{_order}++
));
@@ -767,7 +869,7 @@ sub names_of {
Returns a I<flattened> representation of the configuration, as a
list of pairs B<[ $path, $value ]>, where B<$path> is a reference
to the variable pathname, and B<$value> is a
-B<Config::Tree::Node::Value> object.
+B<Config::AST::Node::Value> object.
The I<$sort> argument controls the ordering of the entries in the returned
B<@array>. It is either a code reference suitable to pass to the Perl B<sort>
@@ -795,7 +897,7 @@ Sort by pathname.
These constants are not exported by default. You can either import the
ones you need, or use the B<:sort> keyword to import them all, e.g.:
- use Config::Tree qw(:sort);
+ use Config::AST qw(:sort);
@array = $cfg->flatten(sort => SORT_PATH);
=cut
@@ -846,7 +948,7 @@ sub as_hash {
Returns the canonical string representation of the configuration tree.
For details, please refer to the documentation of the eponymous method
-in class B<Config::Tree::Node>.
+in class B<Config::AST::Node>.
=cut
diff --git a/lib/Config/Tree/Node.pm b/lib/Config/AST/Node.pm
index 24fca30..ba0d279 100644
--- a/lib/Config/Tree/Node.pm
+++ b/lib/Config/AST/Node.pm
@@ -1,4 +1,4 @@
-package Config::Tree::Node;
+package Config::AST::Node;
use strict;
use warnings;
@@ -13,11 +13,11 @@ our @EXPORT_OK = qw(NO_SORT SORT_NATURAL SORT_PATH);
=head1 NAME
-Config::Tree::Node - generic configuration node
+Config::AST::Node - generic configuration node
=head1 SYNOPSIS
-use parent 'Config::Tree::Node';
+use parent 'Config::AST::Node';
=head1 DESCRIPTION
@@ -35,7 +35,7 @@ Creates new object. Recognized arguments are:
=item B<clone =E<gt>> I<OBJ>
-Clone object I<OBJ>, which must be an instance of B<Config::Tree::Node>
+Clone object I<OBJ>, which must be an instance of B<Config::AST::Node>
or its derived class.
=item B<default =E<gt>> I<VAL>
@@ -185,7 +185,7 @@ use constant {
Returns a I<flattened> representation of the configuration, as a
list of pairs B<[ $path, $value ]>, where B<$path> is a reference
to the variable pathname, and B<$value> is a
-B<Config::Tree::Node::Value> object.
+B<Config::AST::Node::Value> object.
The I<$sort> argument controls the ordering of the entries in the returned
B<@array>. It is either a code reference suitable to pass to the Perl B<sort>
@@ -213,7 +213,7 @@ Sort by pathname.
These constants are not exported by default. You can either import the
ones you need, or use the B<:sort> keyword to import them all, e.g.:
- use Config::Tree::Node qw(:sort);
+ use Config::AST::Node qw(:sort);
@array = $node->flatten(sort => SORT_PATH);
=cut
@@ -282,7 +282,7 @@ sub canonical {
$delim = "\n";
}
my $prloc = delete $_{locus};
- carp "unknown parameters: " . join(', ', keys(%_)) if (keys(%_));
+ carp "unrecognized parameters: " . join(', ', keys(%_)) if (keys(%_));
return join $delim, map {
($prloc ? '[' . $_->[1]->locus . ']: ' : '')
diff --git a/lib/Config/Tree/Node/Null.pm b/lib/Config/AST/Node/Null.pm
index edf3aad..66986d2 100644
--- a/lib/Config/Tree/Node/Null.pm
+++ b/lib/Config/AST/Node/Null.pm
@@ -1,5 +1,5 @@
-package Config::Tree::Node::Null;
-use parent 'Config::Tree::Node';
+package Config::AST::Node::Null;
+use parent 'Config::AST::Node';
use strict;
use warnings;
use Carp;
diff --git a/lib/Config/Tree/Node/Section.pm b/lib/Config/AST/Node/Section.pm
index 340bdee..47668fc 100644
--- a/lib/Config/Tree/Node/Section.pm
+++ b/lib/Config/AST/Node/Section.pm
@@ -1,9 +1,9 @@
-package Config::Tree::Node::Section;
-use parent 'Config::Tree::Node';
+package Config::AST::Node::Section;
+use parent 'Config::AST::Node';
use strict;
use warnings;
use Carp;
-use Config::Tree::Node::Null;
+use Config::AST::Node::Null;
sub new {
my $class = shift;
@@ -123,7 +123,7 @@ sub AUTOLOAD {
if ($key =~ s/^([A-Z])(.*)/\l$1$2/) {
$key =~ s/__/-/g;
return $self->subtree($self->{_ci} ? lc($key) : $key)
- // new Config::Tree::Node::Null;
+ // new Config::AST::Node::Null;
}
confess "Can't locate method $AUTOLOAD";
}
diff --git a/lib/Config/Tree/Node/Value.pm b/lib/Config/AST/Node/Value.pm
index d9961c0..24dd18d 100644
--- a/lib/Config/Tree/Node/Value.pm
+++ b/lib/Config/AST/Node/Value.pm
@@ -1,5 +1,5 @@
-package Config::Tree::Node::Value;
-use parent 'Config::Tree::Node';
+package Config::AST::Node::Value;
+use parent 'Config::AST::Node';
use strict;
use warnings;
diff --git a/t/01conf03.t b/t/01conf03.t
index b887995..87444d8 100644
--- a/t/01conf03.t
+++ b/t/01conf03.t
@@ -24,6 +24,6 @@ my $cfg = new TestConfig(
'core.tempdir' => '/tmp',
'core.output' => 'file'
],
- parameters => \%keywords,
+ lexicon => \%keywords,
expect => [ 'keyword "output" is unknown' ]);
ok($cfg->errors() == 1);
diff --git a/t/01conf04.t b/t/01conf04.t
index 0ad4b64..dcce2a4 100644
--- a/t/01conf04.t
+++ b/t/01conf04.t
@@ -31,7 +31,7 @@ my $cfg = new TestConfig(
'core.tempdir' => '/tmp',
'backend.file.local' => 1
],
- parameters => \%keywords,
+ lexicon => \%keywords,
expect => [ 'mandatory variable "core.retain-interval" not set',
'mandatory variable "backend.file.name" not set' ]);
ok($cfg->errors()==2);
diff --git a/t/01conf05.t b/t/01conf05.t
index 4cb7942..6b03cf8 100644
--- a/t/01conf05.t
+++ b/t/01conf05.t
@@ -26,5 +26,5 @@ my $cfg = new TestConfig(
'core.pidfile' => 'file1',
'core.pidfile' => 'file2'
],
- parameters => \%keywords);
+ lexicon => \%keywords);
ok($cfg->canonical(),'core.list=["en","to",5] core.pidfile="file2"');
diff --git a/t/01conf06.t b/t/01conf06.t
index 1d04c8e..b3f58ca 100644
--- a/t/01conf06.t
+++ b/t/01conf06.t
@@ -25,7 +25,7 @@ my $cfg = new TestConfig(
'backend.file.local' => 1,
'backend.file.level' => 3
],
- parameters => \%keywords);
+ lexicon => \%keywords);
ok($cfg->canonical, 'backend.file.level=3 backend.file.local=1 core.retain-interval=10 core.tempdir="/tmp"');
diff --git a/t/01conf07.t b/t/01conf07.t
index ba28872..8e6b62d 100644
--- a/t/01conf07.t
+++ b/t/01conf07.t
@@ -26,7 +26,7 @@ my $cfg = new TestConfig(
'item.bar.backend' => 'mysql',
'item.bar.database' => 'quux'
],
- parameters => \%keywords
+ lexicon => \%keywords
);
ok($cfg->canonical, 'core.retain-interval=10 item.bar.backend="mysql" item.bar.database="quux" item.foo.backend="tar" item.foo.directory="baz"');
diff --git a/t/01conf08.t b/t/01conf08.t
index 8068de2..8e36a1d 100644
--- a/t/01conf08.t
+++ b/t/01conf08.t
@@ -28,7 +28,7 @@ ok(new TestConfig(
config => [
'core.name' => 'foo'
],
- parameters => \%keywords,
+ lexicon => \%keywords,
expect => [ "must start with a capital letter" ]));
diff --git a/t/01conf09.t b/t/01conf09.t
index cbe5536..b188617 100644
--- a/t/01conf09.t
+++ b/t/01conf09.t
@@ -20,7 +20,7 @@ my %keywords = (
}
);
-my $cfg = new TestConfig(parameters => \%keywords);
+my $cfg = new TestConfig(lexicon => \%keywords);
ok($cfg);
ok($cfg->canonical, q{core.backend="file"});
diff --git a/t/01conf10.t b/t/01conf10.t
index 91fcb25..a30f784 100644
--- a/t/01conf10.t
+++ b/t/01conf10.t
@@ -22,7 +22,7 @@ my $t = new TestConfig(
config => [
base => '/etc'
],
- parameters => \%keywords);
+ lexicon => \%keywords);
ok($t->get('file'), '/etc/passwd');
ok($t->get('index'), 0);
diff --git a/t/01conf13.t b/t/01conf13.t
index 2807d92..8913fd4 100644
--- a/t/01conf13.t
+++ b/t/01conf13.t
@@ -30,10 +30,10 @@ my %syntax = (
);
-my $t = new TestConfig(parameters => \%syntax,
+my $t = new TestConfig(lexicon => \%syntax,
expect => ['mandatory section [load * param] not present']);
ok($t->errors,1);
-$t = new TestConfig(parameters => \%syntax,
+$t = new TestConfig(lexicon => \%syntax,
config => [
'load.foo.param.mode' => 'rw'
]);
diff --git a/t/01conf14.t b/t/01conf14.t
index 1f69a8a..55f9b3a 100644
--- a/t/01conf14.t
+++ b/t/01conf14.t
@@ -30,10 +30,10 @@ my %syntax = (
);
-my $t = new TestConfig(parameters => \%syntax,
+my $t = new TestConfig(lexicon => \%syntax,
expect => ['no section matches mandatory [load * param]']);
ok($t->errors,1);
-$t = new TestConfig(parameters => \%syntax,
+$t = new TestConfig(lexicon => \%syntax,
config => [
'load.foo.param.mode' => 'rw'
]);
diff --git a/t/01conf15.t b/t/01conf15.t
index 8593ff4..da60203 100644
--- a/t/01conf15.t
+++ b/t/01conf15.t
@@ -7,7 +7,7 @@ use TestConfig;
plan(tests => 2);
my $t = new TestConfig(
- parameters => {
+ lexicon => {
load => {
section => {
'*' => {
@@ -26,7 +26,7 @@ my $t = new TestConfig(
ok($t->errors,1);
my $t = new TestConfig(
- parameters => {
+ lexicon => {
load => 1
},
config => [
diff --git a/t/02merge.t b/t/02merge.t
index 77bf705..024f7d8 100644
--- a/t/02merge.t
+++ b/t/02merge.t
@@ -2,13 +2,13 @@
use lib qw(t lib);
use strict;
use Test;
-use Config::Tree qw(:sort);
+use Config::AST qw(:sort);
use Data::Dumper;
plan(tests => 1);
-my $t = new Config::Tree(
- parameters => {
+my $t = new Config::AST(
+ lexicon => {
x => {
section => {
number => { array => 1 },
@@ -17,20 +17,20 @@ my $t = new Config::Tree(
}
});
-my $node = new Config::Tree::Node::Section;
-$node->subtree(number => new Config::Tree::Node::Value(
+my $node = new Config::AST::Node::Section;
+$node->subtree(number => new Config::AST::Node::Value(
value => [1],
locus => new Text::Locus('input',1)));
-$node->subtree(name => new Config::Tree::Node::Value(
+$node->subtree(name => new Config::AST::Node::Value(
value => 'foo',
locus => new Text::Locus('input',2)));
$t->add_node(x => $node);
-$node = new Config::Tree::Node::Section;
-$node->subtree(number => new Config::Tree::Node::Value(
+$node = new Config::AST::Node::Section;
+$node->subtree(number => new Config::AST::Node::Value(
value => 2,
locus => new Text::Locus('input',3)));
-$node->subtree(name => new Config::Tree::Node::Value(
+$node->subtree(name => new Config::AST::Node::Value(
value => 'bar',
locus => new Text::Locus('input',4)));
$t->add_node(x => $node);
diff --git a/t/TestConfig.pm b/t/TestConfig.pm
index 55a0aee..be7c038 100644
--- a/t/TestConfig.pm
+++ b/t/TestConfig.pm
@@ -4,8 +4,8 @@ use strict;
use Carp;
use File::Temp;
-use Config::Tree qw(:sort);
-use parent 'Config::Tree';
+use Config::AST qw(:sort);
+use parent 'Config::AST';
sub new {
my $class = shift;
@@ -80,7 +80,7 @@ sub lint {
my $synt = shift;
local %_ = @_;
my $exp = $self->{_expected_errors} = delete $_{expect};
- carp "unknown parameters: " . join(', ', keys(%_)) if (keys(%_));
+ carp "unrecognized parameters: " . join(', ', keys(%_)) if (keys(%_));
my $ret = $self->SUPER::lint($synt);

Return to:

Send suggestions and report system problems to the System administrator.