Config-Scoped

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

- Version synchronize with Precomp.pm
- import override for Parse::RecDescent

0.05 -- Mon Aug  2 17:09:56 CEST 2004
allow lowercase conversion for parameters and declarations 

0.04 -- Mon Aug  2 12:58:11 CEST 2004
test problem's with tar and patched P::RD on Win32 solved

0.03 -- Sun Aug  1 21:32:34 CEST 2004
Macro's expand now in eval blocks unconditionally

0.02 -- Sun Aug  1 15:23:27 CEST 2004
solved problems with permissions and file paths on Win32

0.01 -- Sat Jul 31 22:40:16 CEST 2004
Initial release uploaded to CPAN

META.yml  view on Meta::CPAN

    version: 0.22
  Config::Scoped::Error::Parse:
    file: lib/Config/Scoped/Error.pm
    version: 0.22
  Config::Scoped::Error::Validate:
    file: lib/Config/Scoped/Error.pm
    version: 0.22
  Config::Scoped::Error::Validate::Declaration:
    file: lib/Config/Scoped/Error.pm
    version: 0.22
  Config::Scoped::Error::Validate::Macro:
    file: lib/Config/Scoped/Error.pm
    version: 0.22
  Config::Scoped::Error::Validate::Parameter:
    file: lib/Config/Scoped/Error.pm
    version: 0.22
  Config::Scoped::Error::Validate::Permissions:
    file: lib/Config/Scoped/Error.pm
    version: 0.22
requires:
  Carp: 0

README  view on Meta::CPAN

          eval { 'b' . 'c' } = 1
      }

    parses to

        $cfg_hash = { foo => { bc => 1 } }

DIRECTIVES
    Config::Scoped has three directives: %macro, %warning, and %include.

  Macros
    Config::Scoped supports macros. A macro is defined with

      %macro name value

    Macros may be defined

    *   at file scope

    *   within anonymous blocks

    *   within declaration blocks

    *   within hash blocks

    Macros defined within blocks are lexically scoped to those blocks.

    Macro substitution occurs

    *   within any double-quoted text

    *   within the entirety of Perl eval blocks

    *   nowhere else

  Include files
    Config::Scoped supports include files.

README  view on Meta::CPAN


    *   declaration

    *   eval

    *   hash

    They all look the same, but they aren't, and they have different rules
    and restrictions. See "CONFIG FILE FORMAT" for descriptions of each.

  Macros
    Macros are evil, and Config::Scoped macros are specially evil, because

    *   they don't respect token boundaries

    *   where multiple substitutions are possible, the substitution order is
        undefined

    *   substituted text may or may not be rescanned for further
        substitutions

    Caveat scriptor.

README  view on Meta::CPAN

    the interfaces to the validation methods. Subclasses can override these
    methods to modify or extend the validation checks.

    $macro_value = $cs->macro_validate>(name => $name, value => $value)
        Called for each %macro directive.

        Receives the $name and $value from the directive. The returned
        $macro_value becomes the actual value of the macro.

        If the macro is invalid, throws a
        Config::Scoped::Error::Validate::Macro exception.

    $param_value = $cs->parameter_validate>(name => $name, value => $value)
        Called for each parameter definition.

        Receives the $name and $value from the definition. The returned
        $param_value becomes the actual value of the parameter.

        If the parameter is invalid, throws a
        Config::Scoped::Error::Validate::Parameter exception.

lib/Config/Scoped.pm  view on Meta::CPAN


    Config::Scoped::Error->throw(
        -text => Carp::shortmess("missing parameters") )
      unless ( defined $args{name} && defined $args{value} );

    my $name  = $args{name};
    my $value = $args{value};

    # warnings for macros enabled?
    if ( $thisparser->warnings_on( name => 'macro', ) ) {
        Config::Scoped::Error::Validate::Macro->throw(
            -file => $thisparser->_get_file(%args),
            -line => $thisparser->_get_line(%args),
            -text => "macro redefinition for '$name"
          )
          if exists $thisparser->{local}{macros}{$name};
    }

    # return unchanged, subclass methods may do it different
    return $value;
}

lib/Config/Scoped.pod  view on Meta::CPAN

  }

parses to

    $cfg_hash = { foo => { bc => 1 } }

=head1 DIRECTIVES

B<Config::Scoped> has three directives: B<%macro>, B<%warning>, and B<%include>.

=head2 Macros

B<Config::Scoped> supports macros. A macro is defined with

  %macro name value

Macros may be defined

=over 4

=item *

at file scope

=item *

within anonymous blocks

lib/Config/Scoped.pod  view on Meta::CPAN

=item *

within declaration blocks

=item *

within hash blocks

=back

Macros defined within blocks are lexically scoped to those blocks.

Macro substitution occurs

=over 4

=item *

within B<any> double-quoted text

=item *

within the B<entirety> of Perl B<eval> blocks

lib/Config/Scoped.pod  view on Meta::CPAN

eval

=item *

hash

=back

They all look the same, but they aren't, and they have different rules and restrictions. See L</CONFIG FILE FORMAT> for descriptions of each.

=head2 Macros

Macros are evil, and B<Config::Scoped> macros are specially evil, because

=over 4

=item *

they don't respect token boundaries

=item *

where multiple substitutions are possible, the substitution order is undefined

lib/Config/Scoped.pod  view on Meta::CPAN

B<Config::Scoped> performs validation checks on the elements of configuration files (declarations, parameters, macros, etc). Here are the interfaces to the validation methods. Subclasses can override these methods to modify or extend the validation c...

=over 4

=item B<< $macro_value = $cs->macro_validate>(name => $name, value => $value) >>

Called for each B<%macro> directive.

Receives the B<$name> and B<$value> from the directive. The returned B<$macro_value> becomes the actual value of the macro.

If the macro is invalid, throws a B<Config::Scoped::Error::Validate::Macro> exception.


=item B<< $param_value = $cs->parameter_validate>(name => $name, value => $value) >>

Called for each parameter definition.

Receives the B<$name> and B<$value> from the definition. The returned B<$param_value> becomes the actual value of the parameter.

If the parameter is invalid, throws a B<Config::Scoped::Error::Validate::Parameter> exception.

lib/Config/Scoped/Error.pm  view on Meta::CPAN

        -file => $config_file,
        -line => $thisline,
    );

    Config::Scoped::Error::IO->throw(
        -text => "can't open file: $!",
        -file => $config_file,
        -line => $thisline,
    );

    Config::Scoped::Error::Validate::Macro->throw(
        -text => "macro redefinition: $macro_name",
        -file => $config_file,
        -line => $thisline,
    );

=head1 DESCRIPTION

Config::Scoped::Error is a class hierarchy based on Error.pm. The following Exception class hierarchy is defined:

    Config::Scoped::Error
    
	Config::Scoped::Error::Parse

	Config::Scoped::Error::Validate

	    Config::Scoped::Error::Validate::Macro

	    Config::Scoped::Error::Validate::Parameter

	    Config::Scoped::Error::Validate::Declaration

	    Config::Scoped::Error::Validate::Permissions

	Config::Scoped::Error::IO

=cut

lib/Config/Scoped/Error.pm  view on Meta::CPAN

our $VERSION='0.22';

package Config::Scoped::Error::IO;
use base 'Config::Scoped::Error';
our $VERSION='0.22';

package Config::Scoped::Error::Validate;
use base 'Config::Scoped::Error';
our $VERSION='0.22';

package Config::Scoped::Error::Validate::Macro;
use base 'Config::Scoped::Error::Validate';
our $VERSION='0.22';

package Config::Scoped::Error::Validate::Parameter;
use base 'Config::Scoped::Error::Validate';
our $VERSION='0.22';

package Config::Scoped::Error::Validate::Declaration;
use base 'Config::Scoped::Error::Validate';
our $VERSION='0.22';



( run in 0.553 second using v1.01-cache-2.11-cpan-49f99fa48dc )