Renamed DDumper to Data::Peek
[Data-Peek.git] / sandbox / genMETA.pl
blobeef4e4c8a96e3d22bb2fefa38196a4267f8e6b8a
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 eval { $h = Load (join "", @yml) };
34 $@ and die "$@\n";
35 $opt_v and print Dump $h;
36 my $t = Test::YAML::Meta::Version->new (yaml => $h);
37 $t->parse () and die join "\n", $t->errors, "";
39 print "Checking if 5.006 is still OK as minimal version for examples\n";
40 use Test::MinimumVersion;
41 # All other minimum version checks done in xt
42 all_minimum_version_ok ("5.006", { paths => [ "examples" ]});
44 elsif ($opt_v) {
45 print @yml;
47 else {
48 my @my = glob <*/META.yml>;
49 @my == 1 && open my $my, ">", $my[0] or die "Cannot update META.yml|n";
50 print $my @yml;
51 close $my;
52 chmod 0644, glob <*/META.yml>;
55 __END__
56 --- #YAML:1.4
57 name: Data::Peek
58 version: VERSION
59 abstract: Modified and extended debugging facilities
60 license: perl
61 author:
62 - H.Merijn Brand <h.merijn@xs4all.nl>
63 generated_by: Author
64 distribution_type: module
65 provides:
66 Data::Peek:
67 file: Peek.pm
68 version: VERSION
69 requires:
70 perl: 5.006
71 DynaLoader: 0
72 build_requires:
73 perl: 5.006
74 Data::Dumper: 0
75 Test::Harness: 0
76 Test::More: 0
77 resources:
78 license: http://dev.perl.org/licenses/
79 meta-spec:
80 version: 1.4
81 url: http://module-build.sourceforge.net/META-spec-v1.4.html