Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (49 sloc) 1.401 kB
#
# $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::XS 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 $perrors = 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")) {
$files++;
my $data = eval { LoadFile($yml) };
if (!$data or $@) {
$perrors++;
warn "Parse error in $yml: '$@'\n";
next;
}
$errors++ if (!validate($schema, $data));
}
if ($perrors||$errors) { die "Found $perrors parse errors and $errors validate errors in $files files" }
else { "Validation OK ($files files).\n" }
}
# Local Variables:
# mode: cperl
# cperl-indent-level: 8
# indent-tabs-mode: t
# End:
Jump to Line
Something went wrong with that request. Please try again.