diff options
author | Remi Collet <remi@remirepo.net> | 2017-09-04 12:18:56 +0200 |
---|---|---|
committer | Remi Collet <remi@remirepo.net> | 2017-09-04 12:18:56 +0200 |
commit | 71881712c325f047fb1bb8dbbf7a31da85d7f06c (patch) | |
tree | 0249981e960b2e018274f463d7de2092320ed626 |
import from Fedora
-rw-r--r-- | php-flow-jsonpath-add-license-file.patch | 35 | ||||
-rw-r--r-- | php-flow-jsonpath.spec | 155 |
2 files changed, 190 insertions, 0 deletions
diff --git a/php-flow-jsonpath-add-license-file.patch b/php-flow-jsonpath-add-license-file.patch new file mode 100644 index 0000000..825ef85 --- /dev/null +++ b/php-flow-jsonpath-add-license-file.patch @@ -0,0 +1,35 @@ +From 85bd143727b0fb063f03902aef39112ae37deaf2 Mon Sep 17 00:00:00 2001 +From: Shawn Iwinski <siwinski@redhat.com> +Date: Sun, 20 Aug 2017 21:13:06 -0400 +Subject: [PATCH] Add LICENSE file + +--- + LICENSE | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + create mode 100644 LICENSE + +diff --git a/LICENSE b/LICENSE +new file mode 100644 +index 0000000..d9fd9c2 +--- /dev/null ++++ b/LICENSE +@@ -0,0 +1,19 @@ ++Copyright (c) 2014-2017 Stephen Frank ++ ++Permission is hereby granted, free of charge, to any person obtaining a copy ++of this software and associated documentation files (the "Software"), to deal ++in the Software without restriction, including without limitation the rights ++to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++copies of the Software, and to permit persons to whom the Software is furnished ++to do so, subject to the following conditions: ++ ++The above copyright notice and this permission notice shall be included in all ++copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ++THE SOFTWARE. diff --git a/php-flow-jsonpath.spec b/php-flow-jsonpath.spec new file mode 100644 index 0000000..44617de --- /dev/null +++ b/php-flow-jsonpath.spec @@ -0,0 +1,155 @@ +# +# Fedora spec file for php-flow-jsonpath +# +# Copyright (c) 2017 Shawn Iwinski <shawn@iwin.ski> +# +# License: MIT +# http://opensource.org/licenses/MIT +# +# Please preserve changelog entries +# + +%global github_owner FlowCommunications +%global github_name JSONPath +%global github_version 0.3.4 +%global github_commit 00aa9c361e4d0a210dd95f3c917a1e0dde3a957f + +%global composer_vendor flow +%global composer_project jsonpath + +# "php": ">=5.4.0" +%global php_min_ver 5.4.0 + +# Build using "--without tests" to disable tests +%global with_tests 0%{!?_without_tests:1} + +%{!?phpdir: %global phpdir %{_datadir}/php} + +Name: php-%{composer_vendor}-%{composer_project} +Version: %{github_version} +Release: 1%{?github_release}%{?dist} +Summary: JSONPath implementation for parsing, searching and flattening arrays + +Group: Development/Libraries +License: MIT +URL: https://github.com/%{github_owner}/%{github_name} +Source0: %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz + +# Add LICENSE file +# https://github.com/FlowCommunications/JSONPath/pull/20 +Patch0: %{name}-add-license-file.patch + +BuildArch: noarch +# Tests +%if %{with_tests} +## composer.json +BuildRequires: php(language) >= %{php_min_ver} +BuildRequires: php-composer(phpunit/phpunit) +## phpcompatinfo (computed from version 0.3.4) +BuildRequires: php-json +BuildRequires: php-pcre +BuildRequires: php-spl +## Autoloader +BuildRequires: php-composer(fedora/autoloader) +%endif + +# composer.json +Requires: php(language) >= %{php_min_ver} +# phpcompatinfo (computed from version 0.3.4) +Requires: php-json +Requires: php-pcre +Requires: php-spl +# Autoloader +Requires: php-composer(fedora/autoloader) + +# Composer +Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} + +%description +This is a JSONPath [1] implementation for PHP based on Stefan Goessner's +JSONPath script. + +JSONPath is an XPath-like expression language for filtering, flattening and +extracting data. + +I believe that is improves on the original script (which was last updated in +2007) by doing a few things: +* Object-oriented code (should be easier to manage or extend in future) +* Expressions are parsed into tokens using some code cribbed from Doctrine + Lexer and cached +* There is no eval() in use +* Performance is pretty much the same +* Any combination of objects/arrays/ArrayAccess-objects can be used as the data + input which is great if you're de-serializing JSON in to objects or if you + want to process your own data structures. + +Autoloader: %{phpdir}/Flow/JSONPath/autoload.php + +[1] http://goessner.net/articles/JsonPath/ + + +%prep +%setup -qn %{github_name}-%{github_commit} + +: Add LICENSE file +%patch0 -p1 + + +%build +: Create autoloader +cat <<'AUTOLOAD' | tee src/Flow/JSONPath/autoload.php +<?php +/** + * Autoloader for %{name} and its' dependencies + * (created by %{name}-%{version}-%{release}). + */ +require_once '%{phpdir}/Fedora/Autoloader/autoload.php'; + +\Fedora\Autoloader\Autoload::addPsr4('Flow\\JSONPath\\', __DIR__); +AUTOLOAD + + +%install +mkdir -p %{buildroot}%{phpdir}/Flow +cp -rp src/Flow/JSONPath %{buildroot}%{phpdir}/Flow/ + + +%check +%if %{with_tests} +: Create tests bootstrap +cat <<'BOOTSTRAP' | tee bootstrap.php +<?php +require '%{buildroot}%{phpdir}/Flow/JSONPath/autoload.php'; +\Fedora\Autoloader\Autoload::addPsr4('Flow\\JSONPath\\Test\\', __DIR__.'/tests/Flow/JSONPath/Test'); +BOOTSTRAP + +: Mock Composer autoloader +mkdir vendor +ln -s %{buildroot}%{phpdir}/Flow/JSONPath/autoload.php vendor/autoload.php + +: Upstream tests +RETURN_CODE=0 +PHPUNIT=$(which phpunit) +for PHP_EXEC in php %{?rhel:php55} php56 php70 php71 php72; do + if [ "php" == "$PHP_EXEC" ] || which $PHP_EXEC; then + $PHP_EXEC $PHPUNIT --verbose --bootstrap bootstrap.php || RETURN_CODE=1 + fi +done +exit $RETURN_CODE +%else +: Tests skipped +%endif + + +%files +%{!?_licensedir:%global license %%doc} +%license LICENSE +%doc *.md +%doc composer.json +%dir %{phpdir}/Flow + %{phpdir}/Flow/JSONPath + + +%changelog +* Sun Aug 20 2017 Shawn Iwinski <shawn@iwin.ski> - 0.3.4-1 +- Initial package |