r14945 - in /branches/upstream/libjson-any-perl/current: Changes META.yml Makefile.PL lib/JSON/Any.pm t/05-JSON-Syck.t

gregoa-guest at users.alioth.debian.org gregoa-guest at users.alioth.debian.org
Thu Feb 14 22:53:56 UTC 2008


Author: gregoa-guest
Date: Thu Feb 14 22:53:55 2008
New Revision: 14945

URL: http://svn.debian.org/wsvn/?sc=1&rev=14945
Log:
[svn-upgrade] Integrating new upstream version, libjson-any-perl (1.16)

Modified:
    branches/upstream/libjson-any-perl/current/Changes
    branches/upstream/libjson-any-perl/current/META.yml
    branches/upstream/libjson-any-perl/current/Makefile.PL
    branches/upstream/libjson-any-perl/current/lib/JSON/Any.pm
    branches/upstream/libjson-any-perl/current/t/05-JSON-Syck.t

Modified: branches/upstream/libjson-any-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libjson-any-perl/current/Changes?rev=14945&op=diff
==============================================================================
--- branches/upstream/libjson-any-perl/current/Changes (original)
+++ branches/upstream/libjson-any-perl/current/Changes Thu Feb 14 22:53:55 2008
@@ -1,4 +1,9 @@
 Revision history for JSON-Any
+1.16    2008-02-13
+        * JSON::Any now compatible with both versions of JSON::XS  (Simon Wistow)
+        * Document that calling 'use JSON::Any ();' is a bad idea
+        * Make JSON.pm required unless a supported JSON package is already installed
+        
 1.15	2008-01-02
 		* Update the config params for JSON and JSON/XS configuration
 		* Update JSON handler to always pass in the -support_by_pp option 

Modified: branches/upstream/libjson-any-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libjson-any-perl/current/META.yml?rev=14945&op=diff
==============================================================================
--- branches/upstream/libjson-any-perl/current/META.yml (original)
+++ branches/upstream/libjson-any-perl/current/META.yml Thu Feb 14 22:53:55 2008
@@ -18,4 +18,4 @@
     - t
 requires: 
   Carp: 0
-version: 1.15
+version: 1.16

Modified: branches/upstream/libjson-any-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libjson-any-perl/current/Makefile.PL?rev=14945&op=diff
==============================================================================
--- branches/upstream/libjson-any-perl/current/Makefile.PL (original)
+++ branches/upstream/libjson-any-perl/current/Makefile.PL Thu Feb 14 22:53:55 2008
@@ -8,13 +8,28 @@
 
 requires 'Carp' => '0';
 
-feature 'JSON',
-  -default => 1,
-  'JSON'   => '2.02';
+sub has_json () {
+    @order = qw(XS JSON DWIW Syck);
+    foreach my $testmod (@order) {
+        $testmod = "JSON::$testmod" unless $testmod eq "JSON";
+        eval "require $testmod";
+        return 1 unless $@;
+    }
+    return 0;
+}
+
+unless (has_json) {
+    requires 'JSON' => '2.02';
+}
+else {
+    feature 'JSON',
+      -default => 0,
+      'JSON'   => '2.02';
+}
 
 feature 'JSON::XS',
   -default   => 0,
-  'JSON::XS' => '2.01';
+  'JSON::XS' => '0';
 
 feature 'JSON::PC',
   -default   => 0,

Modified: branches/upstream/libjson-any-perl/current/lib/JSON/Any.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libjson-any-perl/current/lib/JSON/Any.pm?rev=14945&op=diff
==============================================================================
--- branches/upstream/libjson-any-perl/current/lib/JSON/Any.pm (original)
+++ branches/upstream/libjson-any-perl/current/lib/JSON/Any.pm Thu Feb 14 22:53:55 2008
@@ -1,6 +1,6 @@
 ##############################################################################
 # JSON::Any
-# v1.15
+# v1.16
 # Copyright (c) 2007 Chris Thompson
 ##############################################################################
 
@@ -16,11 +16,11 @@
 
 =head1 VERSION
 
-Version 1.15
-
-=cut
-
-our $VERSION = '1.15';
+Version 1.16
+
+=cut
+
+our $VERSION = '1.16';
 
 our $UTF8;
 
@@ -78,7 +78,6 @@
                 $self->[HANDLER] = $obj;
             },
         },
-
         json_dwiw => {
             encoder       => 'to_json',
             decoder       => 'from_json',
@@ -92,8 +91,36 @@
                   $handler->new( { map { $_ => $conf->{$_} } @params } );
             },
         },
-
-        json_xs => {
+        json_xs_1 => {
+            encoder       => 'to_json',
+            decoder       => 'from_json',
+            create_object => sub {
+                my ( $self, $conf ) = @_;
+
+                my @params = qw(
+                  ascii
+                  utf8
+                  pretty
+                  indent
+                  space_before
+                  space_after
+                  canonical
+                  allow_nonref
+                  shrink
+                  max_depth
+                );
+
+                my $obj = $handler->new;
+                for my $mutator (@params) {
+                    next unless exists $conf->{$mutator};
+                    $obj = $obj->$mutator( $conf->{$mutator} );
+                }
+                $self->[ENCODER] = 'encode';
+                $self->[DECODER] = 'decode';
+                $self->[HANDLER] = $obj;
+            },
+        },
+        json_xs_2 => {
             encoder       => 'encode_json',
             decoder       => 'decode_json',
             create_object => sub {
@@ -149,6 +176,16 @@
     $conf{json_pc} = $conf{json};
 }
 
+sub _make_key {
+    my $handler = shift;
+    ( my $key = lc($handler) ) =~ s/::/_/g;
+    if ( 'json_xs' eq $key ) {
+        no strict 'refs';
+        $key .= "_" . ( split /\./, ${"$handler\::VERSION"} )[0];
+    }
+    return $key;
+}
+
 sub import {
     my $class = shift;
     my @order = @_;
@@ -164,7 +201,7 @@
         eval "require $testmod";
         unless ($@) {
             $handler = $testmod;
-            ( my $key = lc($handler) ) =~ s/::/_/g;
+            my $key = _make_key($handler);
             $encoder = $conf{$key}->{encoder};
             $decoder = $conf{$key}->{decoder};
             last;
@@ -230,6 +267,12 @@
 This will check in that order, and will never attempt to load JSON::Syck. This can also be set via
 the $ENV{JSON_ANY_ORDER} environment variable.
 
+WARNING: If you call JSON::Any with an empty list
+
+    use JSON::Any ();
+    
+It will skip the JSON package detection routines and will die loudly that it couldn't find a package.
+
 =head1 FUNCTIONS
 
 =over
@@ -256,8 +299,8 @@
 
 sub new {
     my $class = shift;
-    my $self = bless [], $class;
-    ( my $key = lc($handler) ) =~ s/::/_/g;
+    my $self  = bless [], $class;
+    my $key   = _make_key($handler);
     if ( my $creator = $conf{$key}->{create_object} ) {
         my @config = @_;
         if ( $ENV{JSON_ANY_CONFIG} ) {
@@ -436,6 +479,9 @@
 In the spirit of Class::Any, JSON::Any was created with the considerable 
 help of Matt 'mst' Trout.
 
+Simon Wistow graciously supplied a patch for backwards compat with JSON::XS 
+versions previous to 2.01
+
 San Dimas High School Football Rules!
 
 =head1 COPYRIGHT & LICENSE

Modified: branches/upstream/libjson-any-perl/current/t/05-JSON-Syck.t
URL: http://svn.debian.org/wsvn/branches/upstream/libjson-any-perl/current/t/05-JSON-Syck.t?rev=14945&op=diff
==============================================================================
--- branches/upstream/libjson-any-perl/current/t/05-JSON-Syck.t (original)
+++ branches/upstream/libjson-any-perl/current/t/05-JSON-Syck.t Thu Feb 14 22:53:55 2008
@@ -11,4 +11,4 @@
 }
 
 ok( JSON::Any->new->objToJson( { foo => 1 } ) );
-ok( JSON::Any->new->objToJson('{ "foo" : 1 }') );
+ok( JSON::Any->new->jsonToObj('{ "foo" : 1 }') );




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