Permalink
Browse files

Preparing for CPAN release

  • Loading branch information...
1 parent 738d829 commit 5d903d54e1bb94c2abbb02b363a91edc4fc51a48 vti committed Apr 27, 2010
Showing with 142 additions and 0 deletions.
  1. +11 −0 .gitignore
  2. +5 −0 MANIFEST.SKIP
  3. +37 −0 Makefile.PL
  4. +56 −0 lib/Mojo/JSON/Any.pm
  5. +33 −0 lib/Mojo/JSON/XS.pm
View
@@ -0,0 +1,11 @@
+.*
+!.gitignore
+!.perltidyrc
+*~
+blib
+Makefile*
+!Makefile.PL
+META.yml
+MANIFEST*
+!MANIFEST.SKIP
+pm_to_blib
View
@@ -0,0 +1,5 @@
+^blib
+^pm_to_blib
+.*\.old$
+^Makefile$
+^\.git
View
@@ -0,0 +1,37 @@
+#!/usr/bin/env perl
+
+use 5.008001;
+
+use strict;
+use warnings;
+
+use ExtUtils::MakeMaker;
+
+my $mm = $ExtUtils::MakeMaker::VERSION;
+
+WriteMakefile(
+ NAME => 'Mojo::JSON::Any',
+ VERSION_FROM => 'lib/Mojo/JSON/Any.pm',
+ ABSTRACT => "Use JSON::XS when it's available",
+ AUTHOR => 'Viacheslav Tykhanovskyi <vti@cpan.org>',
+
+ ($mm < 6.3002 ? () : ('LICENSE' => 'artistic_2')),
+
+ ( $mm < 6.46
+ ? ()
+ : ( META_MERGE => {
+ requires => {perl => '5.008001'},
+ resources =>
+ {repository => 'http://github.com/vti/mojo-json-any'},
+ no_index => {directory => [qw/t/]}
+ },
+ META_ADD => {
+ build_requires => {},
+ configure_requires => {}
+ },
+ )
+ ),
+
+ PREREQ_PM => {},
+ test => {TESTS => 't/*.t t/*/*.t t/*/*/*.t t/*/*/*/*.t'}
+);
View
@@ -3,6 +3,8 @@ package Mojo::JSON::Any;
use strict;
use warnings;
+our $VERSION = '0.990101';
+
use Mojo::JSON;
use constant JSONXS => ($ENV{MOJO_JSON})
@@ -12,3 +14,57 @@ use constant JSONXS => ($ENV{MOJO_JSON})
sub new { shift; JSONXS ? Mojo::JSON::XS->new(@_) : Mojo::JSON->new(@_) }
1;
+__END__
+
+=head1 NAME
+
+Mojo::JSON::Any - Use JSON::XS when it's available
+
+=head1 SYNOPSIS
+
+ use Mojo::JSON::Any;
+
+ my $json = Mojo::JSON::Any->new;
+ my $string = $json->encode({foo => [1, 2], bar => 'hello!'});
+ my $hash = $json->decode('{"foo": [3, -2, 1]}');
+
+=head1 DESCRIPTION
+
+L<Mojo::JSON::Any> is a wrapper over L<Mojo::JSON> and L<JSON::XS>. When the last
+is available it is used.
+
+Interfaces are identical. Encoding parsing is the same as within L<Mojo::JSON>.
+
+When using L<JSON::XS> is undesirable, even if it is available, set
+C<MOJO_JSON> environment variable.
+
+=head1 ATTRIBUTES
+
+See L<Mojo::JSON>.
+
+=head1 METHODS
+
+See L<Mojo::JSON>.
+
+=head1 SEE ALSO
+
+L<MOJO::JSON>, L<JSON::XS>.
+
+=head1 DEVELOPMENT
+
+=head2 Repository
+
+ http://github.com/vti/mojo-json-any
+
+=head1 AUTHOR
+
+Viacheslav Tykhanovskyi, C<vti@cpan.org>.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2010, Viacheslav Tykhanovskyi.
+
+This program is free software, you can redistribute it and/or modify it under
+the terms of the Artistic License version 2.0.
+
+=cut
View
@@ -120,3 +120,36 @@ sub new { shift->SUPER::new(_value => shift) }
sub TO_JSON { $_[0]->{_value} ? JSON::XS::true : JSON::XS::false }
1;
+__END__
+
+=head1 NAME
+
+Mojo::JSON::XS - JSON::XS backend for Mojo::JSON::Any
+
+=head1 SYNOPSIS
+
+ use Mojo::JSON::XS;
+
+ my $json = Mojo::JSON::XS->new;
+ my $string = $json->encode({foo => [1, 2], bar => 'hello!'});
+ my $hash = $json->decode('{"foo": [3, -2, 1]}');
+
+=head1 DESCRIPTION
+
+L<Mojo::JSON::XS> is a wrapper over L<JSON::XS> with a compatible L<Mojo::JSON>
+interface.
+
+=head1 ATTRIBUTES
+
+See L<Mojo::JSON>.
+
+=head1 METHODS
+
+See L<Mojo::JSON>.
+
+=head1 ISSUES
+
+When error occurs error message for obvious reasons is not identical to
+L<Mojo::JSON>.
+
+=cut

0 comments on commit 5d903d5

Please sign in to comment.