r69218 - in /branches/upstream/libparse-cpan-meta-perl/current: Changes META.yml Makefile.PL lib/Parse/CPAN/Meta.pm t/02_api.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Mon Feb 21 14:26:07 UTC 2011


Author: jawnsy-guest
Date: Mon Feb 21 14:25:55 2011
New Revision: 69218

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=69218
Log:
[svn-upgrade] new version libparse-cpan-meta-perl (1.4401)

Modified:
    branches/upstream/libparse-cpan-meta-perl/current/Changes
    branches/upstream/libparse-cpan-meta-perl/current/META.yml
    branches/upstream/libparse-cpan-meta-perl/current/Makefile.PL
    branches/upstream/libparse-cpan-meta-perl/current/lib/Parse/CPAN/Meta.pm
    branches/upstream/libparse-cpan-meta-perl/current/t/02_api.t

Modified: branches/upstream/libparse-cpan-meta-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-meta-perl/current/Changes?rev=69218&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-meta-perl/current/Changes (original)
+++ branches/upstream/libparse-cpan-meta-perl/current/Changes Mon Feb 21 14:25:55 2011
@@ -1,4 +1,11 @@
 Changes for Perl programming language extension Parse-CPAN-Meta
+
+1.4401 Fri Feb 04 2011
+      - Removed Module::Load::Conditional dependency
+
+1.4400 Fri Feb 04 2011
+      - Added 'json_backend' and 'yaml_backend' methods to provide
+        the names of modules used for deserialization
 
 1.4200 Mon Jan 24 2011
       - No changes from 1.41_04

Modified: branches/upstream/libparse-cpan-meta-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-meta-perl/current/META.yml?rev=69218&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-meta-perl/current/META.yml (original)
+++ branches/upstream/libparse-cpan-meta-perl/current/META.yml Mon Feb 21 14:25:55 2011
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Parse-CPAN-Meta
-version:            1.4200
+version:            1.4401
 abstract:           Parse META.yml and META.json CPAN metadata files
 author:
     - Adam Kennedy <adamk at cpan.org>
@@ -11,11 +11,10 @@
 build_requires:
     ExtUtils::MakeMaker:  0
 requires:
-    CPAN::Meta::YAML:     0.002
-    File::Spec:           0.80
-    JSON::PP:             2.27103
-    Module::Load::Conditional:  0.26
-    Test::More:           0.47
+    CPAN::Meta::YAML:  0.002
+    File::Spec:        0.80
+    JSON::PP:          2.27103
+    Test::More:        0.47
 no_index:
     directory:
         - t

Modified: branches/upstream/libparse-cpan-meta-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-meta-perl/current/Makefile.PL?rev=69218&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-meta-perl/current/Makefile.PL (original)
+++ branches/upstream/libparse-cpan-meta-perl/current/Makefile.PL Mon Feb 21 14:25:55 2011
@@ -9,7 +9,6 @@
 		'Test::More' => '0.47',
 		'JSON::PP'   => 2.27103,
 		'CPAN::Meta::YAML' => '0.002',
-		'Module::Load::Conditional' => '0.26',
 	},
 	($] >= 5.005 ? (
 		AUTHOR  => 'Adam Kennedy <adamk at cpan.org>',

Modified: branches/upstream/libparse-cpan-meta-perl/current/lib/Parse/CPAN/Meta.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-meta-perl/current/lib/Parse/CPAN/Meta.pm?rev=69218&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-meta-perl/current/lib/Parse/CPAN/Meta.pm (original)
+++ branches/upstream/libparse-cpan-meta-perl/current/lib/Parse/CPAN/Meta.pm Mon Feb 21 14:25:55 2011
@@ -2,7 +2,6 @@
 
 use strict;
 use Carp 'croak';
-use Module::Load::Conditional qw/can_load/;
 
 # UTF Support?
 sub HAVE_UTF8 () { $] >= 5.007003 }
@@ -18,7 +17,7 @@
 	# Class structure
 	require 5.004;
 	require Exporter;
-	$Parse::CPAN::Meta::VERSION   = '1.4200';
+	$Parse::CPAN::Meta::VERSION   = '1.4401';
 	@Parse::CPAN::Meta::ISA       = qw{ Exporter      };
 	@Parse::CPAN::Meta::EXPORT_OK = qw{ Load LoadFile };
 }
@@ -39,7 +38,7 @@
 
 sub load_yaml_string {
   my ($class, $string) = @_;
-  my $backend = _choose_yaml_backend();
+  my $backend = $class->yaml_backend();
   my $data = eval { no strict 'refs'; &{"$backend\::Load"}($string) };
   if ( $@ ) { 
     croak $backend->can('errstr') ? $backend->errstr : $@
@@ -49,19 +48,19 @@
 
 sub load_json_string {
   my ($class, $string) = @_;
-  return _choose_json_backend()->new->decode($string);
-}
-
-sub _choose_yaml_backend {
+  return $class->json_backend()->new->decode($string);
+}
+
+sub yaml_backend {
   local $Module::Load::Conditional::CHECK_INC_HASH = 1;
   if (! defined $ENV{PERL_YAML_BACKEND} ) {
-    can_load( modules => {'CPAN::Meta::YAML' => 0.002}, verbose => 0 )
+    _can_load( 'CPAN::Meta::YAML', 0.002 )
       or croak "CPAN::Meta::YAML 0.002 is not available\n";
     return "CPAN::Meta::YAML";
   }
   else {
     my $backend = $ENV{PERL_YAML_BACKEND};
-    can_load( modules => {$backend => undef}, verbose => 0 )
+    _can_load( $backend )
       or croak "Could not load PERL_YAML_BACKEND '$backend'\n";
     $backend->can("Load")
       or croak "PERL_YAML_BACKEND '$backend' does not implement Load()\n";
@@ -69,15 +68,15 @@
   }
 }
 
-sub _choose_json_backend {
+sub 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 )
+    _can_load( 'JSON::PP' => 2.27103 )
       or croak "JSON::PP 2.27103 is not available\n";
     return 'JSON::PP';
   }
   else {
-    can_load( modules => {'JSON' => 2.5}, verbose => 0 )
+    _can_load( 'JSON' => 2.5 )
       or croak  "JSON 2.5 is required for " .
                 "\$ENV{PERL_JSON_BACKEND} = '$ENV{PERL_JSON_BACKEND}'\n";
     return "JSON";
@@ -90,6 +89,21 @@
   return do { local $/; <$fh> };
 }
   
+sub _can_load {
+  my ($module, $version) = @_;
+  (my $file = $module) =~ s{::}{/}g;
+  $file .= ".pm";
+  return 1 if $INC{$file};
+  return 0 if exists $INC{$file}; # prior load failed
+  eval { require $file; 1 }
+    or return 0;
+  if ( defined $version ) {
+    eval { $module->VERSION($version); 1 }
+      or return 0;
+  }
+  return 1;
+}
+
 # Kept for backwards compatibility only
 # Create an object from a file
 sub LoadFile ($) {
@@ -186,6 +200,22 @@
 If the source was UTF-8 encoded, the string must be decoded before calling
 C<load_json_string>.
 
+=head2 yaml_backend
+
+  my $backend = Parse::CPAN::Meta->yaml_backend;
+
+Returns the module name of the YAML serializer. See L</ENVIRONMENT>
+for details.
+
+=head2 json_backend
+
+  my $backend = Parse::CPAN::Meta->json_backend;
+
+Returns the module name of the JSON serializer.  This will either
+be L<JSON::PP> or L<JSON>.  Even if C<PERL_JSON_BACKEND> is set,
+this will return L<JSON> as further delegation is handled by
+the L<JSON> module.  See L</ENVIRONMENT> for details.
+
 =head1 FUNCTIONS
 
 For maintenance clarity, no functions are exported.  These functions are

Modified: branches/upstream/libparse-cpan-meta-perl/current/t/02_api.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-meta-perl/current/t/02_api.t?rev=69218&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-meta-perl/current/t/02_api.t (original)
+++ branches/upstream/libparse-cpan-meta-perl/current/t/02_api.t Mon Feb 21 14:25:55 2011
@@ -62,6 +62,7 @@
 {
   local $ENV{PERL_YAML_BACKEND}; # ensure we get CPAN::META::YAML
 
+  is(Parse::CPAN::Meta->yaml_backend(), 'CPAN::Meta::YAML', 'yaml_backend()');
   my $from_yaml = Parse::CPAN::Meta->load_file( $meta_yaml );
   is_deeply($from_yaml, $want, "load from YAML file results in expected data");
 }
@@ -79,6 +80,7 @@
     unless eval "require YAML; 1";
   local $ENV{PERL_YAML_BACKEND} = 'YAML';
 
+  is(Parse::CPAN::Meta->yaml_backend(), 'YAML', 'yaml_backend()');
   my $yaml   = load_ok( 'VR-META.yml', $meta_yaml, 100);
   my $from_yaml = Parse::CPAN::Meta->load_yaml_string( $yaml );
   is_deeply($from_yaml, $want, "load_yaml_string using PERL_YAML_BACKEND");
@@ -89,6 +91,7 @@
   # JSON tests with JSON::PP
   local $ENV{PERL_JSON_BACKEND}; # ensure we get JSON::PP
 
+  is(Parse::CPAN::Meta->json_backend(), 'JSON::PP', 'json_backend()');
   my $from_json = Parse::CPAN::Meta->load_file( $meta_json );
   is_deeply($from_json, $want, "load from JSON file results in expected data");
 }
@@ -125,6 +128,7 @@
     unless eval "require JSON; JSON->VERSION(2.5); 1";
   local $ENV{PERL_JSON_BACKEND} = 1;
 
+  is(Parse::CPAN::Meta->json_backend(), 'JSON', 'json_backend()');
   my $json   = load_ok( 'VR-META.json', $meta_json, 100);
   my $from_json = Parse::CPAN::Meta->load_json_string( $json );
   is_deeply($from_json, $want, "load_json_string with PERL_JSON_BACKEND = 1");




More information about the Pkg-perl-cvs-commits mailing list