Config-Checker

 view release on metacpan or  search on metacpan

CHANGELOG  view on Meta::CPAN

https://rt.cpan.org/Ticket/Display.html?id=50595
Note dependency on File::Slurp & Module::Load.

= 2009/09/02	0.41

Minor documentation changes.
Fix some regression tests.

= 2009/07/24	0.4

Changed YAML::ConfigFile to Config::YAMLMacros to avoid
a name conflict on CPAN.

MANIFEST  view on Meta::CPAN

CHANGELOG
lib/Config/Checker.pm
lib/Config/YAMLMacros.pm
lib/Config/YAMLMacros/YAML.pm
Makefile.PL
MANIFEST			This list of files
META.yml                                 Module meta-data (added by MakeMaker)
t/checker.t
t/config.t
t/data/config2a.yml
t/data/config2b.yml
t/data/config2c.yml
t/data/config2d.yml
t/data/config2.yml

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


package Config::Checker;

use strict;
use warnings;
use Eval::LineNumbers qw(eval_line_numbers);
require Exporter;
require Config::YAMLMacros::YAML;
require Module::Load;
require Time::ParseDate;
require Carp;
use Config::YAMLMacros::YAML;

our @ISA = qw(Exporter);
our @EXPORT = qw(config_checker_source);
our @EXPORT_OK = (@EXPORT, qw(unique split_listify));
our $VERSION = 0.42;

our %mults = (
	K	=> 1024,
	M	=> 1024**2,
	G	=> 1024**3,

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

sub config_checker_source
{
return eval_line_numbers(<<'END_SOURCE');

	import Config::Checker qw(unique split_listify);
	sub {
		my ($config, $prototype_string, $where) = @_;
		$prototype_string =~ s/^(\t+)/" " x length($1) * 8/e;
		my $proto = ref($prototype_string)
			? $prototype_string
			: Config::YAMLMacros::YAML::Load($prototype_string);

		my %checker;
		my $error;

		local(%Config::Checker::unique);

		my $cleaner = sub {
			my ($spec) = @_;
			Carp::confess if ref($spec);
			my $desc = $spec;

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


package Config::YAMLMacros;

use strict;
use warnings;
use Config::YAMLMacros::YAML qw(Load);
use File::Slurp qw(read_file);
use Carp qw(confess);
use File::Basename qw(basename dirname);
require Hash::Merge;
require Exporter;

our @ISA = qw(Exporter);
our @EXPORT = qw(get_config);
our @EXPORT_OK = (@EXPORT, qw(listify replace));

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

	}
	Hash::Merge::set_behavior($old_behavior) if $old_behavior;
	return $config;
}


__END__

=head1 NAME

Config::YAMLMacros - Include file and string subsitution for YAML configuration files

=head1 SYNOPSIS

use Config::YAMLMacros;

my $config = get_config('/some/file');

=head1 DESCRIPTION

This module is a wrapper around loading YAML configuration files.
It does several things:

=head2 expand tabs

lib/Config/YAMLMacros/YAML.pm  view on Meta::CPAN


package Config::YAMLMacros::YAML;

use strict;
use warnings;
use File::Slurp;
require Exporter;
use YAML::Syck qw(Dump);
use Carp qw(confess);

our @ISA = qw(YAML::Syck);
our @EXPORT = qw(Load Dump LoadFile);

lib/Config/YAMLMacros/YAML.pm  view on Meta::CPAN


	die "YAML INPUT:\n$context\nYAML Error when loading $filename: $error";
}

1;

__END__

=head1 NAME

Config::YAMLMacros::YAML - small wrapper for YAML::Syck to improve error reporting

=head1 SYNOPSIS

 use Config::YAMLMacros::YAML;

 $obj = LoadFile("file");
 @objs = LoadFile("file");

 $obj = Load("--- yaml here");
 @objs = Load("--- yaml here");

=head1 DESCRIPTION

Error reporting from the various YAML modules is worse than

t/config.t  view on Meta::CPAN

#!/usr/bin/perl 

use strict;
use warnings;
use Test::More qw(no_plan);
use Config::YAMLMacros;
use FindBin;

my $finished = 0;

END { ok($finished, 'finished') }

my $path_to_t = $FindBin::Bin;

my $config = get_config("$path_to_t/data/config2.yml", path_to_t => $path_to_t);



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