|
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 User : jackjohn ( 502) PHP Version : 5.3.17 Disable Function : NONE Directory : /installd/perl588installer/CPAN-1.9301/ |
Upload File : |
#
# $Id: SlayMakefile,v 2.4 2007/10/09 10:14:11 eserte Exp $
#
{
use lib "lib";
use CPAN::Kwalify;
use Data::Dumper;
use Kwalify qw(validate);
use YAML::Syck qw(LoadFile);
}
all:
dd-prefs: { map { s{\.yml$}{.dd}; $_ } glob("distroprefs/*.yml lib/CPAN/Kwalify/distroprefs.yml") }
%.dd: %.yml
{
my($self, $target) = @_;
(my $base = $target) =~ s{\.dd$}{};
my $file = $base . ".yml";
print STDERR "$base...\n";
my @y = LoadFile($file);
open my $ofh, ">", "$target~" or die $!;
print $ofh Data::Dumper->new(\@y)->Indent(1)->Useqq(1)->Purity(1)->Sortkeys(1)->Dump or die $!;
close $ofh or die $!;
rename "$target~", $target or die $!;
return; # note: return value gets printed!
}
validate:
{
my $errors = 0; my $files = 0;
my $distroprefs_path = $INC{"CPAN/Kwalify.pm"};
$distroprefs_path =~ s{\.pm$}{/distroprefs.yml};
my $schema = LoadFile($distroprefs_path);
for my $yml (glob("distroprefs/*.yml")) {
my $data = LoadFile($yml);
$errors++ if (!validate($schema, $data));
$files++;
}
if ($errors) { die "Found $errors errors" }
else { "Validation OK ($files files).\n" }
}