r5421 - in /packages/libjson-any-perl/trunk: Changes MANIFEST META.yml Makefile.PL README debian/changelog debian/control debian/watch inc/ lib/JSON/Any.pm t/01-JSON.t t/02-JSON-XS.t t/03-JSON-DWIW.t t/04-ENV.t t/kwalitee.t
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Wed May 16 14:32:38 UTC 2007
Author: eloy
Date: Wed May 16 14:32:38 2007
New Revision: 5421
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=5421
Log:
new upstream version
Added:
packages/libjson-any-perl/trunk/inc/
- copied from r5420, packages/libjson-any-perl/branches/upstream/current/inc/
packages/libjson-any-perl/trunk/t/01-JSON.t
- copied unchanged from r5420, packages/libjson-any-perl/branches/upstream/current/t/01-JSON.t
packages/libjson-any-perl/trunk/t/02-JSON-XS.t
- copied unchanged from r5420, packages/libjson-any-perl/branches/upstream/current/t/02-JSON-XS.t
packages/libjson-any-perl/trunk/t/03-JSON-DWIW.t
- copied unchanged from r5420, packages/libjson-any-perl/branches/upstream/current/t/03-JSON-DWIW.t
packages/libjson-any-perl/trunk/t/kwalitee.t
- copied unchanged from r5420, packages/libjson-any-perl/branches/upstream/current/t/kwalitee.t
Modified:
packages/libjson-any-perl/trunk/Changes
packages/libjson-any-perl/trunk/MANIFEST
packages/libjson-any-perl/trunk/META.yml
packages/libjson-any-perl/trunk/Makefile.PL
packages/libjson-any-perl/trunk/README
packages/libjson-any-perl/trunk/debian/changelog
packages/libjson-any-perl/trunk/debian/control
packages/libjson-any-perl/trunk/debian/watch
packages/libjson-any-perl/trunk/lib/JSON/Any.pm
packages/libjson-any-perl/trunk/t/04-ENV.t
Modified: packages/libjson-any-perl/trunk/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/Changes?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/Changes (original)
+++ packages/libjson-any-perl/trunk/Changes Wed May 16 14:32:38 2007
@@ -1,27 +1,5 @@
Revision history for JSON-Any
-
-1.04 Tue Apr 24 12:46:17 EDT 2007
- o Oops, 1.03 released with a bug in it's object creation.
-
-1.03 Thu Apr 05 15:30:47 EDT 2007
- o Oops, 1.02 released with a bug. from the array based object.
-
-1.02 Thu Apr 05 15:02:47 EDT 2007
- o Changed object to be array based, for speed, at request
- of xantus for POE::Filter::JSON.
- 0 POD fixes, per http://rt.cpan.org/Public/Bug/Display.html?id=25991
-
-1.01 Thu Apr 05 13:06:17 EDT 2007
- o Extensive code from Chris 'Perigrin' Prather, to extend
- the API to include aliases for other JSON modules. It is
- now possible to use the API for any underlying JSON module
- transparently.
- o Added ->handler() to return the underlying JSON object.
- o new() changed to allow configuration args to be passed to the
- underlying JSON object. These values are not universal, and so
- are do not work across different JSON engines.
1.00 Fri Mar 23 10:24:50 EDT 2007
o Initial Release
o Currently only supports objToJson and jsonToObj
-
Modified: packages/libjson-any-perl/trunk/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/MANIFEST?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/MANIFEST (original)
+++ packages/libjson-any-perl/trunk/MANIFEST Wed May 16 14:32:38 2007
@@ -1,10 +1,25 @@
Changes
+inc/Module/AutoInstall.pm
+inc/Module/Install.pm
+inc/Module/Install/AutoInstall.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Include.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+lib/JSON/Any.pm
+Makefile.PL
MANIFEST
META.yml
-Makefile.PL
README
-lib/JSON/Any.pm
t/00-load.t
+t/01-JSON.t
+t/02-JSON-XS.t
+t/03-JSON-DWIW.t
+t/04-ENV.t
+t/kwalitee.t
t/pod-coverage.t
t/pod.t
-t/04-ENV.t
Modified: packages/libjson-any-perl/trunk/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/META.yml?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/META.yml (original)
+++ packages/libjson-any-perl/trunk/META.yml Wed May 16 14:32:38 2007
@@ -1,11 +1,20 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: JSON-Any
-version: 1.05
-version_from: lib/JSON/Any.pm
-installdirs: site
-requires:
- Test::More: 0
-
+---
+abstract: Wrapper Class for the various JSON classes.
+author: Chris Thompson, C<< <cthom at cpan.org> >>
+build_requires:
+ Test::More: 0
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.30_01
+generated_by: Module::Install version 0.65
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
+name: JSON-Any
+no_index:
+ directory:
+ - ex
+ - inc
+ - t
+requires:
+ Carp: 0
+version: 1.07
Modified: packages/libjson-any-perl/trunk/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/Makefile.PL?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/Makefile.PL (original)
+++ packages/libjson-any-perl/trunk/Makefile.PL Wed May 16 14:32:38 2007
@@ -1,16 +1,35 @@
-use strict;
-use warnings;
-use ExtUtils::MakeMaker;
+# Drop-in replacement to ExtUtils::MakeMaker
+use inc::Module::Install;
-WriteMakefile(
- NAME => 'JSON::Any',
- AUTHOR => 'Chris Thompson <cthom at cpan.org>',
- VERSION_FROM => 'lib/JSON/Any.pm',
- ABSTRACT_FROM => 'lib/JSON/Any.pm',
- PL_FILES => {},
- PREREQ_PM => {
- 'Test::More' => 0,
- },
- dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
- clean => { FILES => 'JSON-Any-*' },
-);
+# Define metadata
+name 'JSON-Any';
+all_from 'lib/JSON/Any.pm';
+
+requires 'Carp' => '0';
+
+feature 'JSON',
+ -default => 1,
+ 'JSON' => '0';
+
+feature 'JSON::XS',
+ -default => 0,
+ 'JSON::XS' => '0';
+
+feature 'JSON::PC',
+ -default => 0,
+ 'JSON::PC' => '0';
+
+feature 'JSON::DWIW',
+ -default => 0,
+ 'JSON::DWIW' => '0';
+
+feature 'JSON::Syck',
+ -default => 0,
+ 'JSON::Syck' => '0';
+
+# Specific dependencies
+build_requires 'Test::More' => '0';
+no_index 'directory' => 'ex';
+
+auto_install;
+WriteAll;
Modified: packages/libjson-any-perl/trunk/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/README?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/README (original)
+++ packages/libjson-any-perl/trunk/README Wed May 16 14:32:38 2007
@@ -1,41 +1,31 @@
NAME
- JSON::Any - Wrapper Class for the various JSON classes.
+ JSON::Any - Wrapper Class for the myriad JSON classes.
VERSION
- Version 1.05
+ Version 1.00
SYNOPSIS
This module will provide a coherent API to bring together the various
- JSON modules currently on CPAN. This module will allow you to code to
- any JSON API and have it work regardless of which JSON module is
- actually installed.
+ JSON modules currently on CPAN.
- use JSON::Any;
+ use JSON::Any;
my $j = JSON::Any->new;
$json = $j->objToJson({foo=>'bar', baz=>'quux'});
+
$obj = $j->jsonToObj($json);
-
- or
-
- $json = $j->encode({foo=>'bar', baz=>'quux'});
- $obj = $j->decode($json);
-
- or
-
- $json = $j->Dump({foo=>'bar', baz=>'quux'});
- $obj = $j->Load($json);
-
- or
-
- $json = $j->to_json({foo=>'bar', baz=>'quux'});
- $obj = $j->from_json($json);
or without creating an object:
$json = JSON::Any->objToJson({foo=>'bar', baz=>'quux'});
+
$obj = JSON::Any->jsonToObj($json);
+
+ JSON::Any currently only implements converting back and forth between
+ JSON and hashrefs. There is considerably more functionality in many of
+ the JSON modules. Ability to access these will be provided in subsequent
+ versions of JSON::Any.
On load, JSON::Any will find a valid JSON module in your @INC by looking
for them in this order:
@@ -50,7 +40,7 @@
You may change the order by specifying it on the "use JSON::Any" line:
use JSON::Any qw(DWIW Syck XS JSON);
-
+
Specifying an order that is missing one of the modules will prevent that
module from being used:
@@ -61,40 +51,19 @@
FUNCTIONS
"new"
- Will take any of the parameters for the underlying system and pass
- them through. However these values don't map between JSON modules,
- so, from a portability standpoint this is really only helpful for
- those paramters that happen to have the same name. This will be
- addressed in a future release.
+ There are currently no arguments to "new"
"handlerType"
- Takes no arguments, returns a string indicating which JSON Module is
- in use.
-
- "handler"
- Takes no arguments, if called on an object returns the internal
- JSON::* object in use. Otherwise returns the JSON::* package we are
- using for class methods.
+ Takes no arguments, returns a string indicating which JSON Module is in
+ use.
"objToJson"
- Takes a single argument, a hashref to be converted into JSON. It
- returns the JSON text in a scalar.
-
- "to_json"
- "Dump"
- "encode"
- Aliases for objToJson, can be used interchangeably, regardless of
- the underlying JSON module.
+ Takes a single argument, a hashref to be converted into JSON. It returns
+ the JSON text in a scalar.
"jsonToObj"
- Takes a single argument, a string of JSON text to be converted back
- into a hashref.
-
- "from_json"
- "Load"
- "decode"
- Aliases for jsonToObj, can be used interchangeably, regardless of
- the underlying JSON module.
+ Takes a single argument, a string of JSON text to be converted back into
+ a hashref.
AUTHOR
Chris Thompson, "<cthom at cpan.org>"
@@ -111,12 +80,8 @@
that there were now six separate JSON perl modules with different
interfaces.
- In the spirit of Class::Any, JSON::Any was created with the considerable
- help of Chris 'perigrin' Prather, and Matt 'mst' Trout.
-
- JSON::Any 1.01 was written almost entirely by Chris Prather.
-
- San Dimas High School Football Rules!
+ In the spirit of Class::Any, I have created JSON::Any with the
+ considerable help of Chris 'Perigrin' Prather, and Matt 'mst' Trout.
COPYRIGHT & LICENSE
Copyright 2007 Chris Thompson, all rights reserved.
Modified: packages/libjson-any-perl/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/debian/changelog?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/debian/changelog (original)
+++ packages/libjson-any-perl/trunk/debian/changelog Wed May 16 14:32:38 2007
@@ -1,4 +1,11 @@
-libjson-any-perl (1.05-1) UNRELEASED; urgency=low
+libjson-any-perl (1.07-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/control: libjson-perl added to build depends (closes: #424447)
+
+ -- Krzysztof Krzyzaniak (eloy) <eloy at debian.org> Wed, 16 May 2007 16:31:45 +0200
+
+libjson-any-perl (1.05-1) unstable; urgency=low
* New upstream release
Modified: packages/libjson-any-perl/trunk/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/debian/control?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/debian/control (original)
+++ packages/libjson-any-perl/trunk/debian/control Wed May 16 14:32:38 2007
@@ -2,7 +2,7 @@
Section: perl
Priority: optional
Build-Depends: debhelper (>= 5.0.0)
-Build-Depends-Indep: perl (>= 5.8.8-7)
+Build-Depends-Indep: perl (>= 5.8.8-7), libjson-perl
Uploaders: Krzysztof Krzyzaniak (eloy) <eloy at debian.org>
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Standards-Version: 3.7.2
Modified: packages/libjson-any-perl/trunk/debian/watch
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/debian/watch?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/debian/watch (original)
+++ packages/libjson-any-perl/trunk/debian/watch Wed May 16 14:32:38 2007
@@ -1,4 +1,4 @@
# format version number, currently 2; this line is compulsory!
version=2
-http://www.cpan.org/modules/by-module/Net/CTHOM/JSON-Any-(.*).(tar.gz|tar|tgz)
+http://www.cpan.org/modules/by-module/Bundle/PERIGRIN/JSON-Any-(.*)\.tar\.gz
Modified: packages/libjson-any-perl/trunk/lib/JSON/Any.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/lib/JSON/Any.pm?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/lib/JSON/Any.pm (original)
+++ packages/libjson-any-perl/trunk/lib/JSON/Any.pm Wed May 16 14:32:38 2007
@@ -1,6 +1,6 @@
##############################################################################
# JSON::Any
-# v1.05
+# v1.07
# Copyright (c) 2007 Chris Thompson
##############################################################################
@@ -10,15 +10,29 @@
use strict;
use Carp;
+=head1 NAME
+
+JSON::Any - Wrapper Class for the various JSON classes.
+
+=head1 VERSION
+
+Version 1.07
+
+=cut
+
+our $VERSION = '1.07';
+
my ( %conf, $handler, $encoder, $decoder );
-
+use constant HANDLER => 0;
+use constant ENCODER => 1;
+use constant DECODER => 2;
BEGIN {
%conf = (
json => {
encoder => 'objToJson',
decoder => 'jsonToObj',
create_object => sub {
- my ($self) = @_;
+ my ($self, $conf) = @_;
my @params = qw(
autoconv
skipinvalid
@@ -31,7 +45,9 @@
selfconvert
singlequote
);
- return $handler->new( map { $_ => $self->{$_} } @params );
+ $self->[ENCODER] = 'objToJson';
+ $self->[DECODER] = 'jsonToObj',
+ $self->[HANDLER] = $handler->new( map { $_ => $conf->{$_} } @params );
},
},
@@ -39,9 +55,11 @@
encoder => 'to_json',
decoder => 'from_json',
create_object => sub {
- my ($self) = @_;
+ my ($self, $conf) = @_;
my @params = qw(bare_keys);
- return $handler->new( { map { $_ => $self->{$_} } @params } );
+ $self->[ENCODER] = 'to_json';
+ $self->[DECODER] = 'from_json',
+ $self->[HANDLER] = $handler->new( { map { $_ => $conf->{$_} } @params } );
},
},
@@ -49,7 +67,7 @@
encoder => 'to_json',
decoder => 'from_json',
create_object => sub {
- my ($self) = @_;
+ my ($self, $conf) = @_;
my @params = qw(
ascii
@@ -63,15 +81,15 @@
shrink
max_depth
);
-
- my $obj = $handler->new;
+
+ my $obj = $handler->new;
for my $mutator (@params) {
- next unless exists $self->{$mutator};
- $obj = $obj->$mutator( $self->{$mutator} );
- }
- $encoder = 'encode';
- $decoder = 'decode';
- return $obj;
+ next unless exists $conf->{$mutator};
+ $obj = $obj->$mutator( $conf->{$mutator} );
+ }
+ $self->[ENCODER] = 'encode';
+ $self->[DECODER] = 'decode',
+ $self->[HANDLER] = $obj;
},
},
json_syck => {
@@ -90,14 +108,17 @@
( $handler, $encoder, $decoder ) = ();
- @order = split /\s/, $ENV{JSON_ANY_ORDER} unless @order;
+ if ( $ENV{JSON_ANY_ORDER} ) {
+ next if @order;
+ @order = split /\s/, $ENV{JSON_ANY_ORDER};
+ }
@order = qw(XS JSON DWIW Syck) unless @order;
foreach my $testmod (@order) {
$testmod = "JSON::$testmod" unless $testmod eq "JSON";
eval "require $testmod";
unless ($@) {
- $handler = $testmod;
+ $handler = $testmod;
( my $key = lc($handler) ) =~ s/::/_/g;
$encoder = $conf{$key}->{encoder};
$decoder = $conf{$key}->{decoder};
@@ -105,22 +126,10 @@
}
}
- croak "Couldn't find a JSON Package." unless $handler;
+ croak "Couldn't find a JSON Package." unless $handler;
croak "Couldn't find a decoder method." unless $decoder;
croak "Couldn't find a encoder method." unless $encoder;
}
-
-=head1 NAME
-
-JSON::Any - Wrapper Class for the various JSON classes.
-
-=head1 VERSION
-
-Version 1.05
-
-=cut
-
-our $VERSION = '1.05';
=head1 SYNOPSIS
@@ -173,7 +182,8 @@
use JSON::Any qw(DWIW XS JSON);
-This will check in that order, and will never attempt to load JSON::Syck.
+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.
=head1 FUNCTIONS
@@ -192,12 +202,15 @@
sub new {
my $class = shift;
- my $self = bless [], $class;
+ my $self = bless [], $class;
( my $key = lc($handler) ) =~ s/::/_/g;
if ( my $creator = $conf{$key}->{create_object} ) {
my @config = @_;
- push @config, map { split /=/, $_ } split /,\s*/, $ENV{JSON_ANY_CONFIG};
- $self->[0] = $creator->({@config});
+ if ( $ENV{JSON_ANY_CONFIG} ) {
+ push @config, map { split /=/, $_ } split /,\s*/,
+ $ENV{JSON_ANY_CONFIG};
+ }
+ $creator->( $self, {@config} );
}
return $self;
}
@@ -232,7 +245,7 @@
sub handler {
my $self = shift;
if ( ref $self ) {
- return $self->[0];
+ return $self->[HANDLER];
}
return $handler;
}
@@ -252,10 +265,10 @@
my $self = shift;
my $obj = shift;
if ( ref $self ) {
- croak "No $handler Object created!" unless exists $self->[0];
- my $method = $self->[0]->can($encoder);
+ croak "No $handler Object created!" unless exists $self->[HANDLER];
+ my $method = $self->[HANDLER]->can($self->[ENCODER]);
croak "$handler can't execute $encoder" unless $method;
- return $self->[0]->$method($obj);
+ return $self->[HANDLER]->$method($obj);
}
return $handler->can($encoder)->($obj);
}
@@ -295,12 +308,12 @@
sub jsonToObj {
my $self = shift;
- my $obj = shift;
+ my $obj = shift;
if ( ref $self ) {
- croak "No $handler Object created!" unless exists $self->[0];
- my $method = $self->[0]->can($decoder);
+ croak "No $handler Object created!" unless exists $self->[HANDLER];
+ my $method = $self->[HANDLER]->can($self->[ENCODER]);
croak "$handler can't execute $encoder" unless $method;
- return $self->[0]->$method($obj);
+ return $self->[HANDLER]->$method($obj);
}
$handler->can($decoder)->($obj);
}
@@ -330,6 +343,7 @@
=head1 AUTHOR
Chris Thompson, C<< <cthom at cpan.org> >>
+Chris Prather, C<< <perigrin at cpan.org> >>
=head1 BUGS
@@ -345,9 +359,7 @@
that there were now six separate JSON perl modules with different interfaces.
In the spirit of Class::Any, JSON::Any was created with the considerable
-help of Chris 'perigrin' Prather, and Matt 'mst' Trout.
-
-JSON::Any 1.01 was written almost entirely by Chris Prather.
+help of Matt 'mst' Trout.
San Dimas High School Football Rules!
Modified: packages/libjson-any-perl/trunk/t/04-ENV.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/trunk/t/04-ENV.t?rev=5421&op=diff
==============================================================================
--- packages/libjson-any-perl/trunk/t/04-ENV.t (original)
+++ packages/libjson-any-perl/trunk/t/04-ENV.t Wed May 16 14:32:38 2007
@@ -1,26 +1,36 @@
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 8;
+use Test::More no_plan => 1;
+use JSON::Any;
-BEGIN {
+SKIP: {
+ eval { require JSON; };
+ skip "JSON not installed: $@", 1 if $@;
+
$ENV{JSON_ANY_ORDER} = qw(JSON);
+ JSON::Any->import();
+ skip "JSON not installed: $@", 1 if $@;
+ is_deeply( $ENV{JSON_ANY_ORDER}, qw(JSON) );
+ is( JSON::Any->handlerType, 'JSON' );
}
-use JSON::Any;
-is_deeply( $ENV{JSON_ANY_ORDER}, qw(JSON) );
-is( JSON::Any->handlerType, 'JSON' );
-$ENV{JSON_ANY_ORDER} = qw(XS);
-JSON::Any->import();
-is(JSON::Any->handlerType, 'JSON::XS');
+SKIP: {
+ eval { require JSON::XS; };
+ skip "JSON::XS not installed: $@", 1 if $@;
-my ($json);
-ok( $json = JSON::Any->new() );
-eval{ $json->encode("ü"), qq["ü"] };
-ok($@, 'trapped a failure');
-undef $@;
-$ENV{JSON_ANY_CONFIG} = 'allow_nonref=1';
-ok( $json = JSON::Any->new() );
-ok($json->encode("ü"), qq["ü"]);
-ok($@ == undef, 'no failure');
+ $ENV{JSON_ANY_ORDER} = qw(XS);
+ JSON::Any->import();
+ is( JSON::Any->handlerType, 'JSON::XS' );
+
+ my ($json);
+ ok( $json = JSON::Any->new() );
+ eval { $json->encode("ü") };
+ ok( $@, 'trapped a failure' );
+ undef $@;
+ $ENV{JSON_ANY_CONFIG} = 'allow_nonref=1';
+ ok( $json = JSON::Any->new() );
+ ok( $json->encode("dahut"), qq["dahut"] );
+ is( $@, undef, 'no failure' );
+}
More information about the Pkg-perl-cvs-commits
mailing list