summaryrefslogtreecommitdiffstats
path: root/php-jeremeamia-superclosure.spec
blob: e4c8b595b7454e39c7cabb8faa5c295a5cebd1de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# remirepo/fedora spec file for php-jeremeamia-superclosure
#
# Copyright (c) 2015-2016 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#
# Github
%global gh_commit    443c3df3207f176a1b41576ee2a66968a507b3db
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     jeremeamia
%global gh_project   super_closure
# Packagist
%global pk_vendor    jeremeamia
%global pk_name      superclosure
# PSR-0 namespace
%global namespace    SuperClosure

Name:           php-%{pk_vendor}-%{pk_name}
Version:        2.3.0
Release:        1%{?dist}
Summary:        Serialize Closure objects, including their context and binding

Group:          Development/Libraries
License:        MIT
URL:            https://github.com/%{gh_owner}/%{gh_project}
Source0:        %{name}-%{version}-%{gh_short}.tgz
# Create git snapshot as tests are excluded from official tarball
Source1:        makesrc.sh
# Autoloader
Source2:        %{name}-autoload.php

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:      noarch
BuildRequires:  php(language) >= 5.4
BuildRequires:  php-composer(nikic/php-parser) >= 1.4
BuildRequires:  php-composer(symfony/polyfill-php56) >= 1.0
# From composer.json, "require-dev": {
#        "phpunit/phpunit": "^4.0|^5.0",
BuildRequires:  php-composer(phpunit/phpunit)  >= 4.0
# Autoloader
BuildRequires:  php-composer(fedora/autoloader)

# From composer.json, "require": {
#        "php": ">=5.4",
#        "nikic/php-parser": "^1.2|^2.0|^3.0",
#        "symfony/polyfill-php56": "^1.0"
# php-parser 1.4 for autoloader
Requires:       php(language) >= 5.4
Requires:       php-composer(nikic/php-parser) >= 1.4
Requires:       php-composer(nikic/php-parser) <  4
Requires:       php-composer(symfony/polyfill-php56) >= 1.0
Requires:       php-composer(symfony/polyfill-php56) <  2
# From phpcompatifo report for 2.1.0
Requires:       php-hash
Requires:       php-reflection
Requires:       php-spl
Requires:       php-tokenizer
# Autoloader
Requires:       php-composer(fedora/autoloader)

Provides:       php-composer(%{pk_vendor}/%{pk_name}) = %{version}


%description
Even though serializing closures is "not allowed" by PHP,
the SuperClosure library makes it possible

To use this library, you just have to add, in your project:
  require-once '%{_datadir}/php/%{namespace}/autoload.php';


%prep
%setup -q -n %{gh_project}-%{gh_commit}
install -pm 644 %{SOURCE2} src/autoload.php


%build
# Nothing


%install
rm -rf     %{buildroot}
# Restore PSR-0 tree
mkdir -p   %{buildroot}%{_datadir}/php
cp -pr src %{buildroot}%{_datadir}/php/%{namespace}


%check
mkdir vendor
cat << 'EOF' | tee vendor/autoload.php
<?php
require '%{buildroot}%{_datadir}/php/%{namespace}/autoload.php';
require dirname(__DIR__) . '/tests/Integ/Fixture/Collection.php';
require dirname(__DIR__) . '/tests/Integ/Fixture/Foo.php';
EOF

: Run the test suite
# remirepo:10
ret=0
run=0
if which php56; then
  php56 %{_bindir}/phpunit || ret=1
  run=1
fi
if which php71; then
  php71 %{_bindir}/phpunit || ret=1
  run=1
fi
if [ $run -eq 0 ]; then
%{_bindir}/phpunit --verbose
# remirepo:1
fi


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%{!?_licensedir:%global license %%doc}
%license LICENSE.md
%doc README.md composer.json
%{_datadir}/php/%{namespace}


%changelog
* Wed Dec  7 2016 Remi Collet <remi@fedoraproject.org> - 2.3.0-1
- update to 2.3.0
- switch to fedora/autoloader
- allow nikic/php-parser v3

* Sat May 21 2016 Remi Collet <remi@fedoraproject.org> - 2.2.0-3
- use nikic/php-parser v2 when available

* Sun Dec  6 2015 Remi Collet <remi@fedoraproject.org> - 2.2.0-1
- update to 2.2.0
- run test suite with both php 5 and 7 when available
- add dependency on symfony/polyfill-php56

* Tue Sep  1 2015 Remi Collet <remi@fedoraproject.org> - 2.1.0-1
- initial package