r5258 - in /packages/libjson-any-perl: ./ branches/
branches/upstream/
branches/upstream/current/ branches/upstream/current/lib/
branches/upstream/current/lib/JSON/ branches/upstream/current/t/ tags/
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Fri Apr 20 15:03:33 UTC 2007
Author: eloy
Date: Fri Apr 20 15:03:32 2007
New Revision: 5258
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=5258
Log:
[svn-inject] Installing original source of libjson-any-perl
Added:
packages/libjson-any-perl/
packages/libjson-any-perl/branches/
packages/libjson-any-perl/branches/upstream/
packages/libjson-any-perl/branches/upstream/current/
packages/libjson-any-perl/branches/upstream/current/Changes (with props)
packages/libjson-any-perl/branches/upstream/current/MANIFEST
packages/libjson-any-perl/branches/upstream/current/META.yml
packages/libjson-any-perl/branches/upstream/current/Makefile.PL
packages/libjson-any-perl/branches/upstream/current/README
packages/libjson-any-perl/branches/upstream/current/lib/
packages/libjson-any-perl/branches/upstream/current/lib/JSON/
packages/libjson-any-perl/branches/upstream/current/lib/JSON/Any.pm (with props)
packages/libjson-any-perl/branches/upstream/current/t/
packages/libjson-any-perl/branches/upstream/current/t/00-load.t
packages/libjson-any-perl/branches/upstream/current/t/pod-coverage.t
packages/libjson-any-perl/branches/upstream/current/t/pod.t
packages/libjson-any-perl/tags/
Added: packages/libjson-any-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/Changes?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/Changes (added)
+++ packages/libjson-any-perl/branches/upstream/current/Changes Fri Apr 20 15:03:32 2007
@@ -1,0 +1,24 @@
+Revision history for JSON-Any
+
+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
+
Propchange: packages/libjson-any-perl/branches/upstream/current/Changes
------------------------------------------------------------------------------
svn:executable =
Added: packages/libjson-any-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/MANIFEST?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/MANIFEST (added)
+++ packages/libjson-any-perl/branches/upstream/current/MANIFEST Fri Apr 20 15:03:32 2007
@@ -1,0 +1,9 @@
+Changes
+MANIFEST
+META.yml
+Makefile.PL
+README
+lib/JSON/Any.pm
+t/00-load.t
+t/pod-coverage.t
+t/pod.t
Added: packages/libjson-any-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/META.yml?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/META.yml (added)
+++ packages/libjson-any-perl/branches/upstream/current/META.yml Fri Apr 20 15:03:32 2007
@@ -1,0 +1,11 @@
+# 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.03
+version_from: lib/JSON/Any.pm
+installdirs: site
+requires:
+ Test::More: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
Added: packages/libjson-any-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/Makefile.PL?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/Makefile.PL (added)
+++ packages/libjson-any-perl/branches/upstream/current/Makefile.PL Fri Apr 20 15:03:32 2007
@@ -1,0 +1,16 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+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-*' },
+);
Added: packages/libjson-any-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/README?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/README (added)
+++ packages/libjson-any-perl/branches/upstream/current/README Fri Apr 20 15:03:32 2007
@@ -1,0 +1,126 @@
+NAME
+ JSON::Any - Wrapper Class for the various JSON classes.
+
+VERSION
+ Version 1.01
+
+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.
+
+ 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);
+
+ On load, JSON::Any will find a valid JSON module in your @INC by looking
+ for them in this order:
+
+ JSON::XS
+ JSON
+ JSON::DWIW
+ JSON::Syck
+
+ And loading the first one it finds.
+
+ 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:
+
+ use JSON::Any qw(DWIW XS JSON);
+
+ This will check in that order, and will never attempt to load
+ JSON::Syck.
+
+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.
+
+ "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.
+
+ "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.
+
+ "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.
+
+AUTHOR
+ Chris Thompson, "<cthom at cpan.org>"
+
+BUGS
+ Please report any bugs or feature requests to "bug-json-any at
+ rt.cpan.org", or through the web interface at
+ <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=JSON-Any>. I will be
+ notified, and then you'll automatically be notified of progress on your
+ bug as I make changes.
+
+ACKNOWLEDGEMENTS
+ This module came about after discussions on irc.perl.org about the fact
+ 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!
+
+COPYRIGHT & LICENSE
+ Copyright 2007 Chris Thompson, all rights reserved.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
Added: packages/libjson-any-perl/branches/upstream/current/lib/JSON/Any.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/lib/JSON/Any.pm?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/lib/JSON/Any.pm (added)
+++ packages/libjson-any-perl/branches/upstream/current/lib/JSON/Any.pm Fri Apr 20 15:03:32 2007
@@ -1,0 +1,360 @@
+##############################################################################
+# JSON::Any
+# v1.03
+# Copyright (c) 2007 Chris Thompson
+##############################################################################
+
+package JSON::Any;
+
+use warnings;
+use strict;
+use Carp;
+
+my ( %conf, $handler, $encoder, $decoder );
+
+BEGIN {
+ %conf = (
+ json => {
+ encoder => 'objToJson',
+ decoder => 'jsonToObj',
+ create_object => sub {
+ my ($self) = @_;
+ my @params = qw(
+ autoconv
+ skipinvalid
+ execcoderef
+ pretty
+ indent
+ delimiter
+ keysort
+ convblessed
+ selfconvert
+ singlequote
+ );
+ return $handler->new( map { $_ => $self->{$_} } @params );
+ },
+ },
+
+ json_dwiw => {
+ encoder => 'to_json',
+ decoder => 'from_json',
+ create_object => sub {
+ my ($self) = @_;
+ my @params = qw(bare_keys);
+ return $handler->new( { map { $_ => $self->{$_} } @params } );
+ },
+ },
+
+ json_xs => {
+ encoder => 'to_json',
+ decoder => 'from_json',
+ create_object => sub {
+ my ($self) = @_;
+
+ 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 $self->{$mutator};
+ $obj = $obj->$mutator( $self->{$mutator} );
+ }
+ $encoder = 'encode';
+ $decoder = 'decode';
+ return $obj;
+ },
+ },
+ json_syck => {
+ encoder => 'Dump',
+ decoder => 'Load',
+ },
+ );
+
+ # JSON::PC claims it has the same API as JSON
+ $conf{json_pc} = $conf{json};
+}
+
+sub import {
+ my $class = shift;
+ my @order = @_;
+
+ ( $handler, $encoder, $decoder ) = ();
+
+ @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;
+ ( my $key = lc($handler) ) =~ s/::/_/g;
+ $encoder = $conf{$key}->{encoder};
+ $decoder = $conf{$key}->{decoder};
+ last;
+ }
+ }
+
+ 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.03
+
+=cut
+
+our $VERSION = '1.03';
+
+=head1 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.
+
+ 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);
+
+On load, JSON::Any will find a valid JSON module in your @INC by looking
+for them in this order:
+
+ JSON::XS
+ JSON
+ JSON::DWIW
+ JSON::Syck
+
+And loading the first one it finds.
+
+You may change the order by specifying it on the C<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:
+
+ use JSON::Any qw(DWIW XS JSON);
+
+This will check in that order, and will never attempt to load JSON::Syck.
+
+=head1 FUNCTIONS
+
+=over
+
+=item C<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.
+
+=back
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $self = bless [], $class;
+ ( my $key = lc($handler) ) =~ s/::/_/g;
+ if ( my $creator = $conf{$key}->{create_object} ) {
+ $self->[0] = $creator->(@_);
+ }
+ return $self;
+}
+
+=over
+
+=item C<handlerType>
+
+Takes no arguments, returns a string indicating which JSON Module is in use.
+
+=back
+
+=cut
+
+sub handlerType {
+ my $class = shift;
+ $handler;
+}
+
+=over
+
+=item C<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.
+
+=back
+
+=cut
+
+sub handler {
+ my $self = shift;
+ if ( ref $self ) {
+ return $self->[0];
+ }
+ return $handler;
+}
+
+=over
+
+=item C<objToJson>
+
+Takes a single argument, a hashref to be converted into JSON.
+It returns the JSON text in a scalar.
+
+=back
+
+=cut
+
+sub objToJson {
+ 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 "$handler can't execute $encoder" unless $method;
+ return $self->[0]->$method($obj);
+ }
+ return $handler->can($encoder)->($obj);
+}
+
+=over
+
+=item C<to_json>
+
+=item C<Dump>
+
+=item C<encode>
+
+Aliases for objToJson, can be used interchangeably, regardless of the
+underlying JSON module.
+
+=back
+
+=cut
+
+{
+ no strict "refs";
+ *to_json = \&objToJson;
+ *Dump = \&objToJson;
+ *encode = \&objToJson;
+}
+
+=over
+
+=item C<jsonToObj>
+
+Takes a single argument, a string of JSON text to be converted
+back into a hashref.
+
+=back
+
+=cut
+
+sub jsonToObj {
+ my $self = shift;
+ my $obj = shift;
+ if ( ref $self ) {
+ croak "No $handler Object created!" unless exists $self->{[0]};
+ my $method = $self->[0]->can($decoder);
+ croak "$handler can't execute $encoder" unless $method;
+ return $self->[0]->$method($obj);
+ }
+ $handler->can($decoder)->($obj);
+}
+
+=over
+
+=item C<from_json>
+
+=item C<Load>
+
+=item C<decode>
+
+Aliases for jsonToObj, can be used interchangeably, regardless of the
+underlying JSON module.
+
+=back
+
+=cut
+
+{
+ no strict "refs";
+ *from_json = \&jsonToObj;
+ *Load = \&jsonToObj;
+ *decode = \&jsonToObj;
+}
+
+=head1 AUTHOR
+
+Chris Thompson, C<< <cthom at cpan.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+C<bug-json-any at rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=JSON-Any>.
+I will be notified, and then you'll automatically be notified of progress on
+your bug as I make changes.
+
+=head1 ACKNOWLEDGEMENTS
+
+This module came about after discussions on irc.perl.org about the fact
+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!
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2007 Chris Thompson, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1; # End of JSON::Any
Propchange: packages/libjson-any-perl/branches/upstream/current/lib/JSON/Any.pm
------------------------------------------------------------------------------
svn:executable =
Added: packages/libjson-any-perl/branches/upstream/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/t/00-load.t?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/t/00-load.t (added)
+++ packages/libjson-any-perl/branches/upstream/current/t/00-load.t Fri Apr 20 15:03:32 2007
@@ -1,0 +1,16 @@
+#!perl -T
+
+use Test::More tests => 7;
+
+BEGIN {
+ use_ok('JSON::Any');
+}
+
+diag("Testing JSON::Any $JSON::Any::VERSION, Perl $], $^X");
+can_ok( JSON::Any, qw(new) );
+can_ok( JSON::Any, qw(objToJson jsonToObj) );
+can_ok( JSON::Any, qw(to_json from_json ) );
+can_ok( JSON::Any, qw(Dump Load ) );
+can_ok( JSON::Any, qw(encode decode ) );
+
+is(JSON::Any->objToJson({ foo => 'bar'}), q[{"foo":"bar"}]);
Added: packages/libjson-any-perl/branches/upstream/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/t/pod-coverage.t?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/t/pod-coverage.t (added)
+++ packages/libjson-any-perl/branches/upstream/current/t/pod-coverage.t Fri Apr 20 15:03:32 2007
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
Added: packages/libjson-any-perl/branches/upstream/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libjson-any-perl/branches/upstream/current/t/pod.t?rev=5258&op=file
==============================================================================
--- packages/libjson-any-perl/branches/upstream/current/t/pod.t (added)
+++ packages/libjson-any-perl/branches/upstream/current/t/pod.t Fri Apr 20 15:03:32 2007
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
More information about the Pkg-perl-cvs-commits
mailing list