Jan Hudec > Config-Maker-0.007 > Config::Maker::Path

Download:
Config-Maker-0.007.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Config::Maker::Path - Selects elements from config.

SYNOPSIS ^

  use Config::Maker

  $path = Config::Maker::Path->new(
    -type => $typepattern,
    -value => $valuepattern,
    -code => $perlcode,
    -tail => $rest);

  $path = Config::Maker::Path::AnyPath->new(
    -tail => $rest);

  $path = Config::Maker::Path::Root->new(
    -tail => $rest);

  $path = Config::Maker::Path::Parent->new(
    -tail => $rest);

  $path = Config::Maker::Path::This->new(
    -tail => $rest);

  $path = Config::Maker::Path->make($pathstring)

  $path->find($config_element);

  $config_element->get($path);
  $config_element->get($pathstring);

DESCRIPTION ^

Paths are used to select config elements to put in a template.

Path is a list of component. Each of them can be either normal (of type Config::Maker::Path), or special (of some subclass type). Each component, when matched from some configuration element, selects some set of matching elemens. From these elements, rest of the path is matched.

A normal component specifies a type pattern, a value pattern and a match code. A config element matches such component if it is a child of staring element, it's type matches given pattern, it's value matches given pattern and the code returns true. All of these have defaults. Default patterns are * and default code is 1. Note, that the code is not a closure, but rather a string, that is wrapped to a closure automagicaly.

The special components are AnyPath, Root, Parent and This.

The AnyPath element matches starting element and all it's descendants (even indirect).

The Root always returns the global $Config::Maker::Eval::config->{root} element, no matter what the starting element was.

The Parent matches parent of starting element.

The This matches the starting element.

Matching is done recursively using the find and match methods. The find method calls match method of given component to get list of matching elements and then recurses to each of them if -tail is defined, and pushes them in the accumulator otherwise. It returns the acumulator (an arrayref).

There are two construcotrs for paths. The new constructor needs parsed specification. It however builds regexes and coderefs from strings itself.

The higher-level make constructor takes a string describing whole path (see configit for grammar description), parses it and builds the path. It uses Config::Maker::Grammar to do the dirty work.

AUTHOR ^

Jan Hudec <bulb@ucw.cz>

COPYRIGHT AND LICENSE ^

Copyright 2004 Jan Hudec. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

configit(1), perl(1), Config::Maker(3pm).

syntax highlighting: