22c2c66
# remirepo/fedora spec file for php-netresearch-jsonmapper
22c2c66
#
22c2c66
# Copyright (c) 2017-2018 Remi Collet
22c2c66
# License: CC-BY-SA
22c2c66
# http://creativecommons.org/licenses/by-sa/4.0/
22c2c66
#
22c2c66
# Please, preserve the changelog entries
22c2c66
#
00c6131
%global gh_commit    0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06
22c2c66
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
22c2c66
%global gh_owner     cweiske
22c2c66
%global gh_project   jsonmapper
22c2c66
22c2c66
%global pk_vendor    netresearch
22c2c66
%global pk_project   jsonmapper
22c2c66
22c2c66
%global php_home     %{_datadir}/php
22c2c66
%global with_tests   0%{!?_without_tests:1}
22c2c66
22c2c66
Name:           php-%{pk_vendor}-%{pk_project}
00c6131
Version:        1.6.0
22c2c66
Release:        1%{?dist}
22c2c66
Summary:        Map nested JSON structures onto PHP classes
22c2c66
22c2c66
License:        OSL 3.0
22c2c66
URL:            https://github.com/%{gh_owner}/%{gh_project}
22c2c66
Source0:        %{name}-%{version}-%{gh_short}.tgz
22c2c66
# Git snapshot with tests
22c2c66
Source1:        makesrc.sh
22c2c66
22c2c66
BuildArch:      noarch
22c2c66
%if %{with_tests}
22c2c66
# For tests
22c2c66
BuildRequires:  php(language) >= 5.6
22c2c66
BuildRequires:  php-spl
00c6131
BuildRequires:  php-json
00c6131
BuildRequires:  php-pcre
00c6131
BuildRequires:  php-reflection
22c2c66
# From composer.json, "require-dev": {
22c2c66
#        "phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4",
22c2c66
#        "squizlabs/php_codesniffer": "~1.5"
22c2c66
%if 0%{?fedora} >= 26 || 0%{?rhel} >= 8
22c2c66
%global phpunit %{_bindir}/phpunit6
22c2c66
BuildRequires: phpunit6 >= 6.4
22c2c66
%else
22c2c66
%global phpunit %{_bindir}/phpunit
22c2c66
BuildRequires: php-phpunit-PHPUnit >= 4.8.35
22c2c66
%endif
22c2c66
# Required by autoloader
22c2c66
BuildRequires:  php-fedora-autoloader-devel
22c2c66
%endif
22c2c66
22c2c66
# From composer.json, "require": {
00c6131
#        "php": ">=5.6",
00c6131
#        "ext-spl": "*",
00c6131
#        "ext-json": "*",
00c6131
#        "ext-pcre": "*",
00c6131
#        "ext-reflection": "*"
22c2c66
Requires:       php(language) >= 5.6
22c2c66
Requires:       php-spl
00c6131
Requires:       php-json
00c6131
Requires:       php-pcre
00c6131
Requires:       php-reflection
00c6131
# From phpcompatinfo report for version 1.6.0
00c6131
# none
22c2c66
# Required by autoloader
22c2c66
Requires:       php-composer(fedora/autoloader)
22c2c66
22c2c66
Provides:       php-composer(%{pk_vendor}/%{pk_project}) = %{version}
22c2c66
22c2c66
22c2c66
%description
22c2c66
Takes data retrieved from a JSON web service and converts them into nested
22c2c66
object and arrays - using your own model classes.
22c2c66
22c2c66
Starting from a base object, it maps JSON data on class properties, converting
22c2c66
them into the correct simple types or objects.
22c2c66
22c2c66
It's a bit like the native SOAP parameter mapping PHP's SoapClient gives you,
22c2c66
but for JSON. It does not rely on any schema, only your PHP class definitions.
22c2c66
22c2c66
Type detection works by parsing @var docblock annotations of class properties,
22c2c66
as well as type hints in setter methods.
22c2c66
22c2c66
You do not have to modify your model classes by adding JSON specific code;
22c2c66
it works automatically by parsing already-existing docblocks.
22c2c66
22c2c66
Autoloader: %{php_home}/%{pk_vendor}/%{pk_project}/autoload.php
22c2c66
22c2c66
22c2c66
%prep
22c2c66
%setup -q -n %{gh_project}-%{gh_commit}
22c2c66
22c2c66
22c2c66
%build
22c2c66
phpab --template fedora --output src/autoload.php src
22c2c66
22c2c66
22c2c66
%install
22c2c66
: Library
22c2c66
mkdir -p   %{buildroot}%{php_home}/%{pk_vendor}
22c2c66
cp -pr src %{buildroot}%{php_home}/%{pk_vendor}/%{pk_project}
22c2c66
22c2c66
22c2c66
%check
22c2c66
%if %{with_tests}
22c2c66
mkdir vendor
22c2c66
22c2c66
: Run upstream test suite
22c2c66
ret=0
d420494
for cmd in "php %{phpunit}" php71 php72 php73 php74; do
22c2c66
  if which $cmd; then
22c2c66
    set $cmd
22c2c66
    $1 ${2:-%{_bindir}/phpunit6} \
22c2c66
      --bootstrap %{buildroot}%{php_home}/%{pk_vendor}/%{pk_project}/autoload.php \
22c2c66
      --no-coverage \
22c2c66
      --verbose . || ret=1
22c2c66
  fi
22c2c66
done
22c2c66
exit $ret
22c2c66
%else
22c2c66
: Test suite disabled
22c2c66
%endif
22c2c66
22c2c66
22c2c66
%files
22c2c66
%{!?_licensedir:%global license %%doc}
22c2c66
%license LICENSE
22c2c66
%doc composer.json
22c2c66
%doc ChangeLog README.rst
22c2c66
%dir %{php_home}/%{pk_vendor}
22c2c66
     %{php_home}/%{pk_vendor}/%{pk_project}
22c2c66
22c2c66
22c2c66
%changelog
00c6131
* Mon Aug 19 2019 Remi Collet <remi@remirepo.net> - 1.6.0-1
00c6131
- update to 1.6.0
00c6131
- drop patch merged upstream
00c6131
2740b55
* Tue Jul  9 2019 Remi Collet <remi@remirepo.net> - 1.5.1-1
2740b55
- update to 1.5.1
2740b55
d420494
* Mon Jul  8 2019 Remi Collet <remi@remirepo.net> - 1.5.0-1
d420494
- update to 1.5.0
d420494
22c2c66
* Mon Jan 22 2018 Remi Collet <remi@remirepo.net> - 1.4.0-1
22c2c66
- Update to 1.4.0
22c2c66
- use phpunit6 on F26+
22c2c66
- sources from git snapshot
22c2c66
22c2c66
* Sat Oct 21 2017 Remi Collet <remi@remirepo.net> - 1.3.0-1
22c2c66
- initial package, version 1.3.0