summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--php-guzzlehttp-ringphp.spec195
1 files changed, 152 insertions, 43 deletions
diff --git a/php-guzzlehttp-ringphp.spec b/php-guzzlehttp-ringphp.spec
index f6756f6..260bdcc 100644
--- a/php-guzzlehttp-ringphp.spec
+++ b/php-guzzlehttp-ringphp.spec
@@ -1,7 +1,8 @@
+# remirepo spec for php-guzzlehttp-ringphp, from Fedora:
#
# RPM spec file for php-guzzlehttp-ringphp
#
-# Copyright (c) 2014 Shawn Iwinski <shawn.iwinski@gmail.com>
+# Copyright (c) 2014-2015 Shawn Iwinski <shawn.iwinski@gmail.com>
#
# License: MIT
# http://opensource.org/licenses/MIT
@@ -11,8 +12,8 @@
%global github_owner guzzle
%global github_name RingPHP
-%global github_version 1.0.5
-%global github_commit a903f51b692427318bc813217c0e6505287e79a4
+%global github_version 1.1.0
+%global github_commit dbbb91d7f6c191e5e405e900e3102ac7f261bc0b
%global composer_vendor guzzlehttp
%global composer_project ringphp
@@ -20,10 +21,12 @@
# "php": ">=5.4.0"
%global php_min_ver 5.4.0
# "guzzlehttp/streams": "~3.0"
-%global streams_min_ver 3.0
+# Note: Min version not "3.0" because autoloader required
+%global streams_min_ver 3.0.0-3
%global streams_max_ver 4.0
# "react/promise": "~2.0"
-%global promise_min_ver 2.0
+# Note: Min version not "2.0" because autoloader required
+%global promise_min_ver 2.2.0-4
%global promise_max_ver 3.0
%if 0%{?rhel} == 5
@@ -34,49 +37,58 @@
%global with_tests %{?_without_tests:0}%{!?_without_tests:1}
%endif
-%{!?phpdir: %global phpdir %{_datadir}/php}
-%{!?__phpunit: %global __phpunit %{_bindir}/phpunit}
+%{!?phpdir: %global phpdir %{_datadir}/php}
+%{!?testsdir: %global testsdir %{_datadir}/tests}
Name: php-%{composer_vendor}-%{composer_project}
Version: %{github_version}
-Release: 1%{?github_release}%{?dist}
+Release: 3%{?github_release}%{?dist}
Summary: Simple handler system used to power clients and servers in PHP
Group: Development/Libraries
License: MIT
URL: http://ringphp.readthedocs.org
-Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}.tar.gz
+Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
+# Tests
%if %{with_tests}
BuildRequires: nodejs
-BuildRequires: php-phpunit-PHPUnit
-# composer.json
+BuildRequires: %{_bindir}/phpunit
+## composer.json
BuildRequires: php(language) >= %{php_min_ver}
-BuildRequires: php-composer(guzzlehttp/streams) >= %{streams_min_ver}
-BuildRequires: php-composer(guzzlehttp/streams) < %{streams_max_ver}
-BuildRequires: php-composer(react/promise) >= %{promise_min_ver}
-BuildRequires: php-composer(react/promise) < %{promise_max_ver}
+#BuildRequires: php-composer(guzzlehttp/streams) >= %%{streams_min_ver}
+BuildRequires: php-guzzlehttp-streams >= %{streams_min_ver}
+#BuildRequires: php-composer(react/promise) >= %%{promise_min_ver}
+BuildRequires: php-react-promise >= %{promise_min_ver}
BuildRequires: php-curl
-# phpcompatinfo (computed from version 1.0.5)
+## phpcompatinfo (computed from version 1.1.0)
BuildRequires: php-json
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-spl
BuildRequires: php-zlib
+## Autoloader
+BuildRequires: php-composer(symfony/class-loader)
%endif
# composer.json
Requires: php(language) >= %{php_min_ver}
-Requires: php-composer(guzzlehttp/streams) >= %{streams_min_ver}
-Requires: php-composer(guzzlehttp/streams) < %{streams_max_ver}
-Requires: php-composer(react/promise) >= %{promise_min_ver}
-Requires: php-composer(react/promise) < %{promise_max_ver}
+#Requires: php-composer(guzzlehttp/streams) >= %%{streams_min_ver}
+#Requires: php-composer(guzzlehttp/streams) < %%{streams_max_ver}
+Requires: php-guzzlehttp-streams >= %{streams_min_ver}
+Requires: php-guzzlehttp-streams < %{streams_max_ver}
+#Requires: php-composer(react/promise) >= %%{promise_min_ver}
+#Requires: php-composer(react/promise) < %%{promise_max_ver}
+Requires: php-react-promise >= %{promise_min_ver}
+Requires: php-react-promise < %{promise_max_ver}
# composer.json: optional
Requires: php-curl
-# phpcompatinfo (computed from version 1.0.5)
+# phpcompatinfo (computed from version 1.1.0)
Requires: php-spl
+# Autoloader
+Requires: php-composer(symfony/class-loader)
# Composer
Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version}
@@ -94,9 +106,96 @@ clients and servers for both blocking and non-blocking requests.
[2] https://github.com/ring-clojure/ring
+# ------------------------------------------------------------------------------
+
+
+%package tests
+
+Summary: Tests for %{name}
+
+Requires: %{name} = %{version}-%{release}
+Requires: nodejs
+Requires: php-composer(phpunit/phpunit)
+# phpcompatinfo (computed from version 1.1.0)
+Requires: php-json
+Requires: php-pcre
+Requires: php-reflection
+Requires: php-zlib
+
+%description tests
+%{summary}.
+
+
+# ------------------------------------------------------------------------------
+
+
%prep
%setup -qn %{github_name}-%{github_commit}
+: Create library autoloader
+(cat <<'AUTOLOAD'
+<?php
+/**
+ * Autoloader created by %{name}-%{version}-%{release}
+ *
+ * @return \Symfony\Component\ClassLoader\ClassLoader
+ */
+
+if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
+ if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
+ require_once 'Symfony/Component/ClassLoader/ClassLoader.php';
+ }
+
+ $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader();
+ $fedoraClassLoader->register();
+}
+
+require_once 'GuzzleHttp/Stream/autoload.php';
+require_once 'React/Promise/autoload.php';
+
+$fedoraClassLoader->addPrefix('GuzzleHttp\\Ring', dirname(dirname(__DIR__)));
+
+return $fedoraClassLoader;
+AUTOLOAD
+) | tee src/autoload.php
+
+: Create tests autoloader
+(cat <<'AUTOLOAD'
+<?php
+/**
+ * Autoloader created by %{name}-tests-%{version}-%{release}
+ *
+ * @return \Symfony\Component\ClassLoader\ClassLoader
+ */
+
+require_once 'GuzzleHttp/Ring/autoload.php';
+
+$fedoraClassLoader->addPrefix('GuzzleHttp\\Tests\\Ring', __DIR__);
+$fedoraClassLoader->setUseIncludePath(true);
+
+return $fedoraClassLoader;
+AUTOLOAD
+) | tee tests/autoload.php
+
+: Create custom tests PHPUnit config
+rm -f phpunit.xml.dist
+(cat <<'PHPUNIT'
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit bootstrap="./bootstrap.php" colors="true">
+ <testsuites>
+ <testsuite>
+ <directory>.</directory>
+ </testsuite>
+ </testsuites>
+</phpunit>
+PHPUNIT
+) | tee phpunit.xml.dist
+
+: Modify tests bootstrap
+sed -e "s#.*require.*autoload.*#require __DIR__ . '/autoload.php';#" \
+ -e "s#Client/Server.php#GuzzleHttp/Tests/Ring/Client/Server.php#" \
+ -i tests/bootstrap.php
+
%build
# Empty build section, nothing required
@@ -104,32 +203,24 @@ clients and servers for both blocking and non-blocking requests.
%install
rm -rf %{buildroot}
-mkdir -pm 0755 %{buildroot}%{phpdir}/GuzzleHttp/Ring
+
+: Library
+mkdir -p %{buildroot}%{phpdir}/GuzzleHttp/Ring
cp -rp src/* %{buildroot}%{phpdir}/GuzzleHttp/Ring/
+: Tests -- classes must be PSR-0
+mkdir -p %{buildroot}%{testsdir}/%{name}/GuzzleHttp/Tests/Ring
+cp -rp tests/* %{buildroot}%{testsdir}/%{name}/GuzzleHttp/Tests/Ring/
+mv %{buildroot}%{testsdir}/%{name}/GuzzleHttp/Tests/Ring/{autoload,bootstrap}.php \
+ %{buildroot}%{testsdir}/%{name}/
+cp -p phpunit.xml.dist %{buildroot}%{testsdir}/%{name}/
+
%check
%if %{with_tests}
-# Create autoloader
-mkdir vendor
-cat > vendor/autoload.php <<'AUTOLOAD'
-<?php
-
-spl_autoload_register(function ($class) {
- $src = str_replace('\\', '/', $class) . '.php';
-
- if (!@include_once $src) {
- $psr4_class = str_replace('GuzzleHttp\\Tests\\Ring\\', '', $class);
- $psr4_src = str_replace('\\', '/', $psr4_class) . '.php';
-
- @include_once $psr4_src;
- }
-});
-
-require_once '%{phpdir}/React/Promise/functions.php';
-AUTOLOAD
-
-%{__phpunit} --include-path %{buildroot}%{phpdir}:./tests
+%{_bindir}/phpunit -v \
+ --configuration %{buildroot}%{testsdir}/%{name} \
+ --include-path %{buildroot}%{phpdir}
%else
: Tests skipped
%endif
@@ -143,11 +234,29 @@ rm -rf %{buildroot}
%defattr(-,root,root,-)
%{!?_licensedir:%global license %%doc}
%license LICENSE
-%doc *.rst *.md composer.json
+%doc *.md
+%doc *.rst
+%doc composer.json
%{phpdir}/GuzzleHttp/Ring
+%files tests
+%{testsdir}/%{name}
+
%changelog
+* Fri Jun 12 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-3
+- Fix tests' autoload
+
+* Fri Jun 12 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-2
+- Use new $fedoraClassLoader concept in autoloader
+- Remove secondary "tests" directory from tests sub-package
+
+* Mon Jun 01 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-1
+- Updated to 1.1.0
+- Updated source URL
+- Added autoloader
+- Sub-packaged tests
+
* Fri Feb 13 2015 Remi Collet <remi@fedoraproject.org> - 1.0.5-1
- backport for remi repository