From: H.Merijn Brand - Tux Date: Mon, 21 Jan 2013 16:09:34 +0000 (+0100) Subject: versions X-Git-Tag: v0.39~6 X-Git-Url: https://repo.or.cz/w/Data-Peek.git/commitdiff_plain/7d21aec636f694e5345e1a084f4059df2dc61e63 versions --- diff --git a/sandbox/genMETA.pl b/sandbox/genMETA.pl index deb8c18..d46bb58 100755 --- a/sandbox/genMETA.pl +++ b/sandbox/genMETA.pl @@ -59,8 +59,10 @@ test_requires: Test::More: 0.88 Test::NoWarnings: 0 recommends: - perl: 5.016000 + perl: 5.016002 + Data::Dumper: 2.139 Perl::Tidy: 0 +test_recommends: Test::More: 0.98 resources: license: http://dev.perl.org/licenses/ diff --git a/sandbox/genMETA.pm b/sandbox/genMETA.pm index 490cffd..7df4223 100644 --- a/sandbox/genMETA.pm +++ b/sandbox/genMETA.pm @@ -11,6 +11,7 @@ use Carp; use List::Util qw( first ); use Encode qw( encode decode ); use Test::CPAN::Meta::YAML::Version; +use CPAN::Meta::Converter; use Test::MinimumVersion; use Test::More (); use Parse::CPAN::Meta; @@ -18,7 +19,7 @@ use File::Find; use YAML::Syck; use Data::Peek; use Text::Diff; -use JSON; +use JSON::PP; sub new { @@ -62,7 +63,7 @@ sub version_from my $version; open my $pm, "<", $src or croak "Cannot read $src"; while (<$pm>) { - m/^(?:our\s+)? \$VERSION \s*=\s* "? ([-0-9._]+) "? \s*;\s*$/x or next; + m/^(?:our\s+)? \$VERSION \s*=\s* ["']? ([-0-9._]+) ['"]? \s*;\s*$/x or next; $version = $1; last; } @@ -207,9 +208,9 @@ sub check_yaml $self->{verbose} and print Dump $h; - my $t = Test::CPAN::Meta::YAML::Version->new (yaml => $h); + my $t = Test::CPAN::Meta::YAML::Version->new (data => $h); $t->parse () and - croak join "\n", "Test::YAML::Meta reported failure:", $t->errors, ""; + croak join "\n", "Test::CPAN::Meta::YAML reported failure:", $t->errors, ""; eval { Parse::CPAN::Meta::Load ($yml) }; $@ and croak "$@\n"; @@ -255,23 +256,56 @@ sub fix_meta { my $self = shift; + # Convert to meta-spec version 2 + # licenses are lists now + my $jsn = $self->{h}; + $jsn->{"meta-spec"} = { + version => "2", + url => "https://metacpan.org/module/CPAN::Meta::Spec?#meta-spec", + }; + exists $jsn->{resources}{license} and + $jsn->{resources}{license} = [ $jsn->{resources}{license} ]; + delete $jsn->{distribution_type}; + if (exists $jsn->{license}) { + $jsn->{license} =~ s/^perl$/perl_5/; + $jsn->{license} = [ $jsn->{license} ]; + } + if (exists $jsn->{resources}{repository}) { + my $url = $jsn->{resources}{repository}; + my $web = $url; + $url =~ s{repo.or.cz/w/}{repo.or.cz/r/}; + $web =~ s{repo.or.cz/r/}{repo.or.cz/w/}; + $jsn->{resources}{repository} = { + type => "git", + web => $web, + url => $url, + }; + } + foreach my $sct ("", "configure_", "build_", "test_") { + (my $x = $sct || "runtime") =~ s/_$//; + for (qw( requires recommends suggests )) { + exists $jsn->{"$sct$_"} and + $jsn->{prereqs}{$x}{$_} = delete $jsn->{"$sct$_"}; + } + } + $jsn = CPAN::Meta::Converter->new ($jsn)->convert (version => "2"); + my $yml = CPAN::Meta::Converter->new ($jsn)->convert (version => "1.4"); + $_->{generated_by} = "Author" for $jsn, $yml; + my @my = glob <*/META.yml> or croak "No META files"; my $yf = $my[0]; - @my == 1 && open my $my, ">", $yf or croak "Cannot update $yf\n"; - print $my @{$self->{yml}}; + print $my Dump $yml; # @{$self->{yml}}; close $my; $yf =~ s/yml$/json/; - my $jsn = $self->{h}; - $jsn->{"meta-spec"} = { - version => 2, - url => "https://metacpan.org/module/CPAN::Meta::Spec?#meta-spec", - }; open $my, ">", $yf or croak "Cannot update $yf\n"; - print $my JSON->new->utf8 (1)->pretty (1)->encode ($jsn); + #rint JSON::PP->new->utf8 (1)->pretty (1)->encode ($jsn); + print $my JSON::PP->new->utf8 (1)->pretty (1)->encode ($jsn); + close $my; chmod 0644, glob "*/META.*"; + unlink glob "MYMETA*"; } # fix_meta 1;