Dropped YAML spec to 1.0
[Data-Peek.git] / sandbox / genMETA.pl
blobf9d90724df18485ce01566e576a4f3fe0bce38d0
1 #!/pro/bin/perl
3 use strict;
4 use warnings;
6 use Getopt::Long qw(:config bundling nopermute);
7 my $check = 0;
8 my $opt_v = 0;
9 GetOptions (
10 "c|check" => \$check,
11 "v|verbose:1" => \$opt_v,
12 ) or die "usage: $0 [--check]\n";
14 my $version;
15 open my $pm, "<", "Peek.pm" or die "Cannot read Peek.pm";
16 while (<$pm>) {
17 m/^.VERSION\s*=\s*"?([-0-9._]+)"?\s*;\s*$/ or next;
18 $version = $1;
19 last;
21 close $pm;
23 my @yml;
24 while (<DATA>) {
25 s/VERSION/$version/o;
26 push @yml, $_;
29 if ($check) {
30 use YAML::Syck;
31 use Test::YAML::Meta::Version;
32 my $h;
33 my $yml = join "", @yml;
34 eval { $h = Load ($yml) };
35 $@ and die "$@\n";
36 $opt_v and print Dump $h;
37 my $t = Test::YAML::Meta::Version->new (yaml => $h);
38 $t->parse () and die join "\n", $t->errors, "";
40 use Parse::CPAN::Meta;
41 eval { Parse::CPAN::Meta::Load ($yml) };
42 $@ and die "$@\n";
44 print "Checking if 5.006 is still OK as minimal version for examples\n";
45 use Test::MinimumVersion;
46 # All other minimum version checks done in xt
47 all_minimum_version_ok ("5.006", { paths => [ "examples" ]});
49 elsif ($opt_v) {
50 print @yml;
52 else {
53 my @my = glob <*/META.yml>;
54 @my == 1 && open my $my, ">", $my[0] or die "Cannot update META.yml\n";
55 print $my @yml;
56 close $my;
57 chmod 0644, glob <*/META.yml>;
60 __END__
61 --- #YAML:1.0
62 name: Data::Peek
63 version: VERSION
64 abstract: Modified and extended debugging facilities
65 license: perl
66 author:
67 - H.Merijn Brand <h.m.brand@xs4all.nl>
68 generated_by: Author
69 distribution_type: module
70 provides:
71 Data::Peek:
72 file: Peek.pm
73 version: VERSION
74 requires:
75 perl: 5.006
76 DynaLoader: 0
77 recommends:
78 perl: 5.010001
79 configure_requires:
80 ExtUtils::MakeMaker: 0
81 build_requires:
82 perl: 5.006
83 Data::Dumper: 0
84 Test::Harness: 0
85 Test::More: 0
86 Test::NoWarnings: 0
87 resources:
88 license: http://dev.perl.org/licenses/
89 repository: http://repo.or.cz/w/Data-Peek.git
90 meta-spec:
91 version: 1.4
92 url: http://module-build.sourceforge.net/META-spec-v1.4.html