Initial import (perl-JSON-MaybeXS-1.002002-2)

This module first checks to see if either Cpanel::JSON::XS or JSON::XS
is already loaded, in which case it uses that module. Otherwise it tries
to load Cpanel::JSON::XS, then JSON::XS, then JSON::PP in order, and
either uses the first module it finds or throws an error.

It then exports the "encode_json" and "decode_json" functions from the
loaded module, along with a "JSON" constant that returns the class name
for calling "new" on.

If you're writing fresh code rather than replacing JSON.pm usage, you
might want to pass options as constructor args rather than calling
mutators, so we provide our own "new" method that supports that.
This commit is contained in:
Paul Howarth 2014-05-12 13:49:29 +01:00
parent 895afc7e21
commit e7c970bcac
3 changed files with 91 additions and 0 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
/JSON-MaybeXS-[0-9.]*.tar.gz

89
perl-JSON-MaybeXS.spec Normal file
View File

@ -0,0 +1,89 @@
# Note: this package takes the approach of adding a hard dependency on
# upstream's preferred back-end, Cpanel::JSON::XS, rather than using
# a virtual provides/requires arrangement so that any of the supported
# back-ends could be used. This is not only much simpler and does not
# involve modifications to the back-end packages, but it also makes for
# consistent results as we're always using the same, most-tested
# back-end.
Name: perl-JSON-MaybeXS
Summary: Use Cpanel::JSON::XS with a fallback to JSON::XS and JSON::PP
Version: 1.002002
Release: 2%{?dist}
License: GPL+ or Artistic
URL: http://search.cpan.org/dist/JSON-MaybeXS/
Source0: http://search.cpan.org/CPAN/authors/id/E/ET/ETHER/JSON-MaybeXS-%{version}.tar.gz
BuildArch: noarch
# Module Build
BuildRequires: perl
BuildRequires: perl(ExtUtils::CBuilder) >= 0.27
BuildRequires: perl(ExtUtils::MakeMaker)
BuildRequires: perl(File::Spec)
BuildRequires: perl(File::Temp)
# Module Runtime
BuildRequires: perl(base)
BuildRequires: perl(Cpanel::JSON::XS) >= 2.3310
BuildRequires: perl(Exporter)
BuildRequires: perl(strict)
BuildRequires: perl(warnings)
# Test Suite (wants JSON::PP ≥ 2.27202 really but EL-6 doesn't have that)
BuildRequires: perl(if)
BuildRequires: perl(JSON::PP)
BuildRequires: perl(JSON::XS)
BuildRequires: perl(Test::More) >= 0.88
BuildRequires: perl(Test::Without::Module) >= 0.17
# Runtime
Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
Requires: perl(Cpanel::JSON::XS) >= 2.3310
%description
This module first checks to see if either Cpanel::JSON::XS or JSON::XS
is already loaded, in which case it uses that module. Otherwise it tries
to load Cpanel::JSON::XS, then JSON::XS, then JSON::PP in order, and
either uses the first module it finds or throws an error.
It then exports the "encode_json" and "decode_json" functions from the
loaded module, along with a "JSON" constant that returns the class name
for calling "new" on.
If you're writing fresh code rather than replacing JSON.pm usage, you
might want to pass options as constructor args rather than calling
mutators, so we provide our own "new" method that supports that.
%prep
%setup -q -n JSON-MaybeXS-%{version}
%build
perl Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}
%install
make pure_install DESTDIR=%{buildroot}
find %{buildroot} -type f -name .packlist -exec rm -f {} ';'
%{_fixperms} %{buildroot}
%check
make test
%files
%doc Changes README
%{perl_vendorlib}/JSON/
%{_mandir}/man3/JSON::MaybeXS.3*
%changelog
* Fri May 9 2014 Paul Howarth <paul@city-fan.org> - 1.002002-2
- Sanitize for Fedora submission
* Thu Apr 24 2014 Paul Howarth <paul@city-fan.org> - 1.002002-1
- Update to 1.002002
- More metadata fiddling, to remove the Cpanel::JSON::XS dependency visible
to static analyzers (the prerequisites at install time remain unchanged)
* Wed Apr 23 2014 Paul Howarth <paul@city-fan.org> - 1.002001-1
- Update to 1.002001
- Fix installation on older perls with an older ExtUtils::MakeMaker
(CPAN RT#94964)
- Update patch for building with Test::More < 0.88
* Wed Apr 23 2014 Paul Howarth <paul@city-fan.org> - 1.002000-1
- Initial RPM version

View File

@ -0,0 +1 @@
cb8c66ece7518270ea31ffc4951d5f02 JSON-MaybeXS-1.002002.tar.gz