r69199 - in /branches/upstream/libcpan-meta-perl/current: ./ lib/CPAN/ lib/CPAN/Meta/ t/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Mon Feb 21 03:47:45 UTC 2011
Author: jawnsy-guest
Date: Mon Feb 21 03:47:33 2011
New Revision: 69199
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=69199
Log:
[svn-upgrade] new version libcpan-meta-perl (2.110440)
Modified:
branches/upstream/libcpan-meta-perl/current/Changes
branches/upstream/libcpan-meta-perl/current/META.json
branches/upstream/libcpan-meta-perl/current/META.yml
branches/upstream/libcpan-meta-perl/current/Makefile.PL
branches/upstream/libcpan-meta-perl/current/README
branches/upstream/libcpan-meta-perl/current/dist.ini
branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta.pm
branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Converter.pm
branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Feature.pm
branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/History.pm
branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Prereqs.pm
branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Spec.pm
branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Validator.pm
branches/upstream/libcpan-meta-perl/current/t/converter-bad.t
branches/upstream/libcpan-meta-perl/current/t/converter-fail.t
branches/upstream/libcpan-meta-perl/current/t/converter.t
branches/upstream/libcpan-meta-perl/current/t/meta-obj.t
branches/upstream/libcpan-meta-perl/current/t/save-load.t
branches/upstream/libcpan-meta-perl/current/t/validator.t
Modified: branches/upstream/libcpan-meta-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/Changes?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/Changes (original)
+++ branches/upstream/libcpan-meta-perl/current/Changes Mon Feb 21 03:47:33 2011
@@ -1,4 +1,65 @@
Revision history for CPAN-Meta
+
+2.110440 2011-02-12 22:55:28 EST5EDT
+
+ [BUGFIX]
+
+ - Bump Parse::CPAN::Meta prereq to 1.44, as 1.43 was never released
+
+2.110420 2011-02-11 15:40:36 EST5EDT
+
+ [BUG FIXES]
+
+ - The as_string() method now always returns a character string;
+ previously, JSON strings were UTF-8 encoded.
+
+ - The save() method now always saves with UTF-8 encoding for
+ Perl 5.8.1 or greater; previously, YAML was not encoded
+
+2.110390 2011-02-07 21:00:47 EST5EDT
+
+ [BUG FIXES]
+
+ - Release 2.110360 had a regression where the save() method would no
+ longer return true on success. That has been fixed.
+
+2.110360 2011-02-04 19:46:21 America/New_York
+
+ [OTHER]
+
+ - Remove autodie dependency so CPAN::Meta can be used on older Perls
+
+ - Remove unused Data::Dumper dependency
+
+2.110350 2011-02-03 19:57:32 America/New_York
+
+ [ENHANCEMENTS]
+
+ - Added "as_string" method similar to "as_struct"
+
+ [OTHER]
+
+ - Bumped Parse::CPAN::Meta prereq to 1.43 and uses that to
+ determine proper YAML/JSON backends
+
+ - Removed unused prereqs
+
+2.110330 2011-02-02 09:42:57 EST5EDT
+
+ [ENHANCEMENTS]
+
+ - Saved META.json files are now sorted by key
+
+ - as_struct() method takes an optional "version" argument to return
+ a down-converted metadata hashref
+
+2.110320 2011-01-31 23:14:30 EST5EDT
+
+ [ENHANCEMENTS]
+
+ - The 'save' method now allows an optional hashref argument, which can be
+ used to set the desired meta spec version. Metadata is automatically
+ converted to the specified output.
2.110240 2011-01-24 16:28:25 EST5EDT
Modified: branches/upstream/libcpan-meta-perl/current/META.json
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/META.json?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/META.json (original)
+++ branches/upstream/libcpan-meta-perl/current/META.json Mon Feb 21 03:47:33 2011
@@ -5,7 +5,7 @@
"Ricardo Signes <rjbs at cpan.org>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 4.200001, CPAN::Meta::Converter version 2.102400",
+ "generated_by" : "Dist::Zilla version 4.200002, CPAN::Meta::Converter version 2.110420",
"license" : [
"perl_5"
],
@@ -28,13 +28,10 @@
"runtime" : {
"requires" : {
"Carp" : 0,
- "JSON::PP" : "2.27103",
- "Module::Load::Conditional" : 0,
- "Parse::CPAN::Meta" : "1.4200",
+ "Parse::CPAN::Meta" : "1.44",
"Scalar::Util" : 0,
"Storable" : 0,
"Version::Requirements" : "0.101020",
- "autodie" : 0,
"perl" : "5.006",
"version" : "0.82"
}
@@ -45,7 +42,7 @@
"File::Spec" : 0,
"File::Temp" : "0.20",
"IO::Dir" : 0,
- "Parse::CPAN::Meta" : "1.4200",
+ "Parse::CPAN::Meta" : "1.4400",
"Test::More" : "0.96"
}
}
@@ -58,7 +55,7 @@
"web" : "http://github.com/dagolden/cpan-meta"
}
},
- "version" : "2.110240",
+ "version" : "2.110440",
"x_Dist_Zilla" : {
"plugins" : [
{
@@ -79,97 +76,97 @@
{
"class" : "Dist::Zilla::Plugin::GatherDir",
"name" : "@Filter/@Basic/GatherDir",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::PruneCruft",
"name" : "@Filter/@Basic/PruneCruft",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::ManifestSkip",
"name" : "@Filter/@Basic/ManifestSkip",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::MetaYAML",
"name" : "@Filter/@Basic/MetaYAML",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::License",
"name" : "@Filter/@Basic/License",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::Readme",
"name" : "@Filter/@Basic/Readme",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::ExecDir",
"name" : "@Filter/@Basic/ExecDir",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::ShareDir",
"name" : "@Filter/@Basic/ShareDir",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::MakeMaker",
"name" : "@Filter/@Basic/MakeMaker",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::Manifest",
"name" : "@Filter/@Basic/Manifest",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::TestRelease",
"name" : "@Filter/@Basic/TestRelease",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::ConfirmRelease",
"name" : "@Filter/@Basic/ConfirmRelease",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::UploadToCPAN",
"name" : "@Filter/@Basic/UploadToCPAN",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::AutoPrereqs",
"name" : "@Filter/AutoPrereqs",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::PkgVersion",
"name" : "@Filter/PkgVersion",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::MetaConfig",
"name" : "@Filter/MetaConfig",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::MetaJSON",
"name" : "@Filter/MetaJSON",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::NextRelease",
"name" : "@Filter/NextRelease",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::PodSyntaxTests",
"name" : "@Filter/PodSyntaxTests",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::Repository",
@@ -185,7 +182,7 @@
}
},
"name" : "@Filter/TestMoreWithSubtests",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::PodWeaver",
@@ -213,20 +210,9 @@
"version" : "1.103520"
},
{
- "class" : "Dist::Zilla::Plugin::Prereqs",
- "config" : {
- "Dist::Zilla::Plugin::Prereqs" : {
- "phase" : "runtime",
- "type" : "requires"
- }
- },
- "name" : "Prereqs",
- "version" : "4.200001"
- },
- {
"class" : "Dist::Zilla::Plugin::AutoVersion",
"name" : "AutoVersion",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::Git::Push",
@@ -236,27 +222,27 @@
{
"class" : "Dist::Zilla::Plugin::MetaResources",
"name" : "MetaResources",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":InstallModules",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":TestFiles",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":ExecFiles",
- "version" : "4.200001"
+ "version" : "4.200002"
},
{
"class" : "Dist::Zilla::Plugin::FinderCode",
"name" : ":ShareFiles",
- "version" : "4.200001"
+ "version" : "4.200002"
}
],
"zilla" : {
@@ -264,7 +250,7 @@
"config" : {
"is_trial" : 0
},
- "version" : "4.200001"
+ "version" : "4.200002"
}
}
}
Modified: branches/upstream/libcpan-meta-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/META.yml?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/META.yml (original)
+++ branches/upstream/libcpan-meta-perl/current/META.yml Mon Feb 21 03:47:33 2011
@@ -8,12 +8,12 @@
File::Spec: 0
File::Temp: 0.20
IO::Dir: 0
- Parse::CPAN::Meta: 1.4200
+ Parse::CPAN::Meta: 1.4400
Test::More: 0.96
configure_requires:
ExtUtils::MakeMaker: 6.31
dynamic_config: 0
-generated_by: 'Dist::Zilla version 4.200001, CPAN::Meta::Converter version 2.102400'
+generated_by: 'Dist::Zilla version 4.200002, CPAN::Meta::Converter version 2.110420'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -24,18 +24,15 @@
- history
requires:
Carp: 0
- JSON::PP: 2.27103
- Module::Load::Conditional: 0
- Parse::CPAN::Meta: 1.4200
+ Parse::CPAN::Meta: 1.44
Scalar::Util: 0
Storable: 0
Version::Requirements: 0.101020
- autodie: 0
perl: 5.006
version: 0.82
resources:
repository: http://github.com/dagolden/cpan-meta.git
-version: 2.110240
+version: 2.110440
x_Dist_Zilla:
plugins:
-
@@ -53,79 +50,79 @@
-
class: Dist::Zilla::Plugin::GatherDir
name: '@Filter/@Basic/GatherDir'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::PruneCruft
name: '@Filter/@Basic/PruneCruft'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::ManifestSkip
name: '@Filter/@Basic/ManifestSkip'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::MetaYAML
name: '@Filter/@Basic/MetaYAML'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::License
name: '@Filter/@Basic/License'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::Readme
name: '@Filter/@Basic/Readme'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::ExecDir
name: '@Filter/@Basic/ExecDir'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::ShareDir
name: '@Filter/@Basic/ShareDir'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::MakeMaker
name: '@Filter/@Basic/MakeMaker'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::Manifest
name: '@Filter/@Basic/Manifest'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::TestRelease
name: '@Filter/@Basic/TestRelease'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::ConfirmRelease
name: '@Filter/@Basic/ConfirmRelease'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::UploadToCPAN
name: '@Filter/@Basic/UploadToCPAN'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::AutoPrereqs
name: '@Filter/AutoPrereqs'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::PkgVersion
name: '@Filter/PkgVersion'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::MetaConfig
name: '@Filter/MetaConfig'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::MetaJSON
name: '@Filter/MetaJSON'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::NextRelease
name: '@Filter/NextRelease'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::PodSyntaxTests
name: '@Filter/PodSyntaxTests'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::Repository
name: '@Filter/Repository'
@@ -137,7 +134,7 @@
phase: test
type: requires
name: '@Filter/TestMoreWithSubtests'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::PodWeaver
name: '@Filter/PodWeaver'
@@ -159,17 +156,9 @@
name: '@Filter/@Git/Push'
version: 1.103520
-
- class: Dist::Zilla::Plugin::Prereqs
- config:
- Dist::Zilla::Plugin::Prereqs:
- phase: runtime
- type: requires
- name: Prereqs
- version: 4.200001
- -
class: Dist::Zilla::Plugin::AutoVersion
name: AutoVersion
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::Git::Push
name: Git::Push
@@ -177,25 +166,25 @@
-
class: Dist::Zilla::Plugin::MetaResources
name: MetaResources
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::FinderCode
name: ':InstallModules'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::FinderCode
name: ':TestFiles'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::FinderCode
name: ':ExecFiles'
- version: 4.200001
+ version: 4.200002
-
class: Dist::Zilla::Plugin::FinderCode
name: ':ShareFiles'
- version: 4.200001
+ version: 4.200002
zilla:
class: Dist::Zilla::Dist::Builder
config:
is_trial: 0
- version: 4.200001
+ version: 4.200002
Modified: branches/upstream/libcpan-meta-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/Makefile.PL?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/Makefile.PL (original)
+++ branches/upstream/libcpan-meta-perl/current/Makefile.PL Mon Feb 21 03:47:33 2011
@@ -16,7 +16,7 @@
'File::Spec' => '0',
'File::Temp' => '0.20',
'IO::Dir' => '0',
- 'Parse::CPAN::Meta' => '1.4200',
+ 'Parse::CPAN::Meta' => '1.4400',
'Test::More' => '0.96'
},
'CONFIGURE_REQUIRES' => {
@@ -28,16 +28,13 @@
'NAME' => 'CPAN::Meta',
'PREREQ_PM' => {
'Carp' => '0',
- 'JSON::PP' => '2.27103',
- 'Module::Load::Conditional' => '0',
- 'Parse::CPAN::Meta' => '1.4200',
+ 'Parse::CPAN::Meta' => '1.44',
'Scalar::Util' => '0',
'Storable' => '0',
'Version::Requirements' => '0.101020',
- 'autodie' => '0',
'version' => '0.82'
},
- 'VERSION' => '2.110240',
+ 'VERSION' => '2.110440',
'test' => {
'TESTS' => 't/*.t'
}
Modified: branches/upstream/libcpan-meta-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/README?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/README (original)
+++ branches/upstream/libcpan-meta-perl/current/README Mon Feb 21 03:47:33 2011
@@ -1,7 +1,7 @@
This archive contains the distribution CPAN-Meta,
-version 2.110240:
+version 2.110440:
the distribution metadata for a CPAN dist
Modified: branches/upstream/libcpan-meta-perl/current/dist.ini
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/dist.ini?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/dist.ini (original)
+++ branches/upstream/libcpan-meta-perl/current/dist.ini Mon Feb 21 03:47:33 2011
@@ -17,10 +17,6 @@
-remove = AutoVersion
-remove = Git::NextVersion
-[Prereqs]
-Parse::CPAN::Meta = 1.4200
-JSON::PP = 2.27103
-
[AutoVersion]
major = 2
Modified: branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta.pm?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta.pm (original)
+++ branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta.pm Mon Feb 21 03:47:33 2011
@@ -1,10 +1,9 @@
use 5.006;
use strict;
use warnings;
-use autodie;
package CPAN::Meta;
BEGIN {
- $CPAN::Meta::VERSION = '2.110240';
+ $CPAN::Meta::VERSION = '2.110440';
}
# ABSTRACT: the distribution metadata for a CPAN dist
@@ -14,8 +13,7 @@
use CPAN::Meta::Prereqs;
use CPAN::Meta::Converter;
use CPAN::Meta::Validator;
-use Module::Load::Conditional qw(can_load);
-use Storable ();
+use Parse::CPAN::Meta 1.44 ();
BEGIN {
@@ -149,10 +147,6 @@
my ($class, $file, $options) = @_;
$options->{lazy_validation} = 1 unless exists $options->{lazy_validation};
- local $Module::Load::Conditional::CHECK_INC_HASH = 1;
- can_load( modules => { 'Parse::CPAN::Meta' => 1.4200 } )
- or croak "CPAN::Meta requires Parse::CPAN::Meta 1.4200 or later\n";
-
croak "load_file() requires a valid, readable filename"
unless -r $file;
@@ -195,29 +189,29 @@
sub save {
- my ($self, $file) = @_;
-
- carp "'$file' should end in '.json'"
- unless $file =~ m{\.json$};
-
- open my $fh, ">", $file;
- print {$fh} _choose_json_backend()->new->utf8->pretty->encode({%$self});
-}
-
-# Copied from Parse::CPAN::Meta
-sub _choose_json_backend {
- local $Module::Load::Conditional::CHECK_INC_HASH = 1;
- if (! $ENV{PERL_JSON_BACKEND} or $ENV{PERL_JSON_BACKEND} eq 'JSON::PP') {
- can_load( modules => {'JSON::PP' => 2.27103}, verbose => 0 )
- or croak "JSON::PP 2.27103 is not available\n";
- return 'JSON::PP';
+ my ($self, $file, $options) = @_;
+
+ my $version = $options->{version} || '2';
+ my $layer = $] ge '5.008001' ? ':utf8' : '';
+
+ if ( $version ge '2' ) {
+ carp "'$file' should end in '.json'"
+ unless $file =~ m{\.json$};
}
else {
- can_load( modules => {'JSON' => 2.5}, verbose => 0 )
- or croak "JSON 2.5 is required for " .
- "\$ENV{PERL_JSON_BACKEND} = '$ENV{PERL_JSON_BACKEND}'\n";
- return "JSON";
- }
+ carp "'$file' should end in '.yml'"
+ unless $file =~ m{\.yml$};
+ }
+
+ my $data = $self->as_string( $options );
+ open my $fh, ">$layer", $file
+ or die "Error opening '$file' for writing: $!\n";
+
+ print {$fh} $data;
+ close $fh
+ or die "Error closing '$file': $!\n";
+
+ return 1;
}
@@ -295,9 +289,47 @@
sub as_struct {
- my ($self) = @_;
- my $json = _choose_json_backend();
- return $json->new->decode( $json->new->convert_blessed->encode( $self ) )
+ my ($self, $options) = @_;
+ my $backend = Parse::CPAN::Meta->json_backend();
+ my $struct = $backend->new->decode(
+ $backend->new->convert_blessed->encode($self)
+ );
+ if ( $options->{version} ) {
+ my $cmc = CPAN::Meta::Converter->new( $struct );
+ $struct = $cmc->convert( version => $options->{version} );
+ }
+ return $struct;
+}
+
+
+sub as_string {
+ my ($self, $options) = @_;
+
+ my $version = $options->{version} || '2';
+
+ my $struct;
+ if ( $self->version ne $version ) {
+ my $cmc = CPAN::Meta::Converter->new( $self->as_struct );
+ $struct = $cmc->convert( version => $version );
+ }
+ else {
+ $struct = $self->as_struct;
+ }
+
+ my ($data, $backend);
+ if ( $version ge '2' ) {
+ $backend = Parse::CPAN::Meta->json_backend();
+ $data = $backend->new->pretty->canonical->encode($struct);
+ }
+ else {
+ $backend = Parse::CPAN::Meta->yaml_backend();
+ $data = eval { no strict 'refs'; &{"$backend\::Dump"}($struct) };
+ if ( $@ ) {
+ croak $backend->can('errstr') ? $backend->errstr : $@
+ }
+ }
+
+ return $data;
}
# Used by JSON::PP, etc. for "convert_blessed"
@@ -317,7 +349,7 @@
=head1 VERSION
-version 2.110240
+version 2.110440
=head1 SYNOPSIS
@@ -361,7 +393,7 @@
reference fails to validate. Older-format metadata will be up-converted to
version 2 if they validate against the original stated specification.
-Valid options include:
+It takes an optional hashref of options. Valid options include:
=over
@@ -377,7 +409,7 @@
=head2 create
- my $meta = CPAN::Meta->create($distmeta_struct);
+ my $meta = CPAN::Meta->create($distmeta_struct, \%options);
This is same as C<new()>, except that C<generated_by> and C<meta-spec> fields
will be generated if not provided. This means the metadata structure is
@@ -411,12 +443,23 @@
=head2 save
- $meta->save($distmeta_file);
-
-Serializes the object as JSON and writes it to the given file. The filename
-should end in '.json'. L<JSON::PP> is the default JSON backend. Using another
-JSON backend requires L<JSON> 2.5 or later and you must set the
-C<$ENV{PERL_JSON_BACKEND}> to a supported alternate backend like L<JSON::XS>.
+ $meta->save($distmeta_file, \%options);
+
+Serializes the object as JSON and writes it to the given file. The only valid
+option is C<version>, which defaults to '2'. On Perl 5.8.1 or later, the file
+is saved with UTF-8 encoding.
+
+For C<version> 2 (or higher), the filename should end in '.json'. L<JSON::PP>
+is the default JSON backend. Using another JSON backend requires L<JSON> 2.5 or
+later and you must set the C<$ENV{PERL_JSON_BACKEND}> to a supported alternate
+backend like L<JSON::XS>.
+
+For C<version> less than 2, the filename should end in '.yml'.
+L<CPAN::Meta::Converter> is used to generate an older metadata structure, which
+is serialized to YAML. CPAN::Meta::YAML is the default YAML backend. You may
+set the C<$ENV{PERL_YAML_BACKEND}> to a supported alternative backend, though
+this is not recommended due to subtle incompatibilities between YAML parsers on
+CPAN.
=head2 meta_spec_version
@@ -471,14 +514,31 @@
=head2 as_struct
- my $copy = $meta->as_struct;
+ my $copy = $meta->as_struct( \%options );
This method returns a deep copy of the object's metadata as an unblessed has
-reference. This is useful for raw analysis or for passing to a converter
-object. For example:
-
- my $cmc = CPAN::Meta::Converter->new( $meta->as_struct );
- my $meta_1_4 = $cmc->convert( version => "1.4" );
+reference. It takes an optional hashref of options. If the hashref contains
+a C<version> argument, the copied metadata will be converted to the version
+of the specification and returned. For example:
+
+ my $old_spec = $meta->as_struct( {version => "1.4"} );
+
+=head2 as_string
+
+ my $string = $meta->as_string( \%options );
+
+This method returns a serialized copy of the object's metadata as a character
+string. (The strings are B<not> UTF-8 encoded.) It takes an optional hashref
+of options. If the hashref contains a C<version> argument, the copied metadata
+will be converted to the version of the specification and returned. For
+example:
+
+ my $string = $meta->as_struct( {version => "1.4"} );
+
+For C<version> greater than or equal to 2, the string will be serialized as
+JSON. For C<version> less than 2, the string will be serialized as YAML. In
+both cases, the same rules are followed as in the C<save()> method for choosing
+a serialization backend.
=head1 STRING DATA
Modified: branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Converter.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Converter.pm?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Converter.pm (original)
+++ branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Converter.pm Mon Feb 21 03:47:33 2011
@@ -1,10 +1,9 @@
use 5.006;
use strict;
use warnings;
-use autodie;
package CPAN::Meta::Converter;
BEGIN {
- $CPAN::Meta::Converter::VERSION = '2.110240';
+ $CPAN::Meta::Converter::VERSION = '2.110440';
}
# ABSTRACT: Convert CPAN distribution metadata structures
@@ -1243,7 +1242,7 @@
=head1 VERSION
-version 2.110240
+version 2.110440
=head1 SYNOPSIS
Modified: branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Feature.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Feature.pm?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Feature.pm (original)
+++ branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Feature.pm Mon Feb 21 03:47:33 2011
@@ -1,10 +1,9 @@
use 5.006;
use strict;
use warnings;
-use autodie;
package CPAN::Meta::Feature;
BEGIN {
- $CPAN::Meta::Feature::VERSION = '2.110240';
+ $CPAN::Meta::Feature::VERSION = '2.110440';
}
# ABSTRACT: an optional feature provided by a CPAN distribution
@@ -44,7 +43,7 @@
=head1 VERSION
-version 2.110240
+version 2.110440
=head1 DESCRIPTION
Modified: branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/History.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/History.pm?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/History.pm (original)
+++ branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/History.pm Mon Feb 21 03:47:33 2011
@@ -2,10 +2,9 @@
use 5.006;
use strict;
use warnings;
-use autodie;
package CPAN::Meta::History;
BEGIN {
- $CPAN::Meta::History::VERSION = '2.110240';
+ $CPAN::Meta::History::VERSION = '2.110440';
}
# ABSTRACT: history of CPAN Meta Spec changes
1;
@@ -21,7 +20,7 @@
=head1 VERSION
-version 2.110240
+version 2.110440
=head1 DESCRIPTION
Modified: branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Prereqs.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Prereqs.pm?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Prereqs.pm (original)
+++ branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Prereqs.pm Mon Feb 21 03:47:33 2011
@@ -1,10 +1,9 @@
use 5.006;
use strict;
use warnings;
-use autodie;
package CPAN::Meta::Prereqs;
BEGIN {
- $CPAN::Meta::Prereqs::VERSION = '2.110240';
+ $CPAN::Meta::Prereqs::VERSION = '2.110440';
}
# ABSTRACT: a set of distribution prerequisites by phase and type
@@ -151,7 +150,7 @@
=head1 VERSION
-version 2.110240
+version 2.110440
=head1 DESCRIPTION
Modified: branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Spec.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Spec.pm?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Spec.pm (original)
+++ branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Spec.pm Mon Feb 21 03:47:33 2011
@@ -2,10 +2,9 @@
use 5.006;
use strict;
use warnings;
-use autodie;
package CPAN::Meta::Spec;
BEGIN {
- $CPAN::Meta::Spec::VERSION = '2.110240';
+ $CPAN::Meta::Spec::VERSION = '2.110440';
}
# ABSTRACT: specification for CPAN distribution metadata
1;
@@ -21,7 +20,7 @@
=head1 VERSION
-version 2.110240
+version 2.110440
=head1 SYNOPSIS
Modified: branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Validator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Validator.pm?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Validator.pm (original)
+++ branches/upstream/libcpan-meta-perl/current/lib/CPAN/Meta/Validator.pm Mon Feb 21 03:47:33 2011
@@ -1,10 +1,9 @@
use 5.006;
use strict;
use warnings;
-use autodie;
package CPAN::Meta::Validator;
BEGIN {
- $CPAN::Meta::Validator::VERSION = '2.110240';
+ $CPAN::Meta::Validator::VERSION = '2.110440';
}
# ABSTRACT: validate CPAN distribution metadata structures
@@ -840,7 +839,7 @@
=head1 VERSION
-version 2.110240
+version 2.110440
=head1 SYNOPSIS
Modified: branches/upstream/libcpan-meta-perl/current/t/converter-bad.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/t/converter-bad.t?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/t/converter-bad.t (original)
+++ branches/upstream/libcpan-meta-perl/current/t/converter-bad.t Mon Feb 21 03:47:33 2011
@@ -7,14 +7,14 @@
use CPAN::Meta::Converter;
use File::Spec;
use IO::Dir;
-use Parse::CPAN::Meta 1.4200;
+use Parse::CPAN::Meta 1.4400;
my $data_dir = IO::Dir->new( 't/data-bad' );
my @files = sort grep { /^\w/ } $data_dir->read;
sub _spec_version { return $_[0]->{'meta-spec'}{version} || "1.0" }
-use Data::Dumper;
+#use Data::Dumper;
for my $f ( reverse sort @files ) {
my $path = File::Spec->catfile('t','data-bad',$f);
Modified: branches/upstream/libcpan-meta-perl/current/t/converter-fail.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/t/converter-fail.t?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/t/converter-fail.t (original)
+++ branches/upstream/libcpan-meta-perl/current/t/converter-fail.t Mon Feb 21 03:47:33 2011
@@ -7,7 +7,7 @@
use CPAN::Meta::Converter;
use File::Spec;
use IO::Dir;
-use Parse::CPAN::Meta 1.4200;
+use Parse::CPAN::Meta 1.4400;
my $data_dir = IO::Dir->new( 't/data-fail' );
my @files = sort grep { /^\w/ } $data_dir->read;
Modified: branches/upstream/libcpan-meta-perl/current/t/converter.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/t/converter.t?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/t/converter.t (original)
+++ branches/upstream/libcpan-meta-perl/current/t/converter.t Mon Feb 21 03:47:33 2011
@@ -7,14 +7,14 @@
use CPAN::Meta::Converter;
use File::Spec;
use IO::Dir;
-use Parse::CPAN::Meta 1.4200;
+use Parse::CPAN::Meta 1.4400;
my $data_dir = IO::Dir->new( 't/data' );
my @files = sort grep { /^\w/ } $data_dir->read;
sub _spec_version { return $_[0]->{'meta-spec'}{version} || "1.0" }
-use Data::Dumper;
+#use Data::Dumper;
for my $f ( reverse sort @files ) {
my $path = File::Spec->catfile('t','data',$f);
Modified: branches/upstream/libcpan-meta-perl/current/t/meta-obj.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/t/meta-obj.t?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/t/meta-obj.t (original)
+++ branches/upstream/libcpan-meta-perl/current/t/meta-obj.t Mon Feb 21 03:47:33 2011
@@ -83,6 +83,9 @@
is_deeply( $meta->as_struct, $distmeta, "->as_struct (deep comparison)" );
isnt( $meta->as_struct, $distmeta, "->as_struct (is a deep clone)" );
+my $old_copy = $meta->as_struct( {version => "1.4"} );
+is( $old_copy->{'meta-spec'}{version}, "1.4", "->as_struct (downconversion)" );
+
isnt( $meta->resources, $meta->{resources}, "->resource (map values are deep cloned)");
is($meta->name, 'Module-Build', '->name');
Modified: branches/upstream/libcpan-meta-perl/current/t/save-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/t/save-load.t?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/t/save-load.t (original)
+++ branches/upstream/libcpan-meta-perl/current/t/save-load.t Mon Feb 21 03:47:33 2011
@@ -4,7 +4,7 @@
use CPAN::Meta;
use File::Temp 0.20 ();
-use Parse::CPAN::Meta 1.4200;
+use Parse::CPAN::Meta 1.4400;
my $distmeta = {
name => 'Module-Build',
@@ -75,14 +75,25 @@
my $tmpdir = File::Temp->newdir();
my $metafile = File::Spec->catfile( $tmpdir, 'META.json' );
-$meta->save($metafile);
+ok( $meta->save($metafile), "save returns true" );
ok( -f $metafile, "save meta to file" );
-ok( $meta = Parse::CPAN::Meta->load_file($metafile), 'load saved file' );
-is($meta->{name}, 'Module-Build', 'name correct');
+ok( my $loaded = Parse::CPAN::Meta->load_file($metafile), 'load saved file' );
+is($loaded->{name}, 'Module-Build', 'name correct');
-ok( $meta = Parse::CPAN::Meta->load_file('t/data/META-1_4.yml'), 'load META-1.4' );
-is($meta->{name}, 'Module-Build', 'name correct');
+ok( $loaded = Parse::CPAN::Meta->load_file('t/data/META-1_4.yml'), 'load META-1.4' );
+is($loaded->{name}, 'Module-Build', 'name correct');
+
+# Test saving with conversion
+
+my $metayml = File::Spec->catfile( $tmpdir, 'META.yml' );
+
+$meta->save($metayml, {version => "1.4"});
+ok( -f $metayml, "save meta to META.yml with conversion" );
+
+ok( $loaded = Parse::CPAN::Meta->load_file($metayml), 'load saved file' );
+is( $loaded->{name}, 'Module-Build', 'name correct');
+is( $loaded->{requires}{perl}, "5.006", 'prereq correct' );
done_testing;
Modified: branches/upstream/libcpan-meta-perl/current/t/validator.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-meta-perl/current/t/validator.t?rev=69199&op=diff
==============================================================================
--- branches/upstream/libcpan-meta-perl/current/t/validator.t (original)
+++ branches/upstream/libcpan-meta-perl/current/t/validator.t Mon Feb 21 03:47:33 2011
@@ -6,7 +6,7 @@
use CPAN::Meta::Validator;
use File::Spec;
use IO::Dir;
-use Parse::CPAN::Meta 1.4200;
+use Parse::CPAN::Meta 1.4400;
{
my $data_dir = IO::Dir->new( 't/data' );
More information about the Pkg-perl-cvs-commits
mailing list