summaryrefslogtreecommitdiffstats
path: root/php-PhpCollection.spec
blob: 480193f648488a26d9a7672b7a1fbe3a8f884518 (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
145
146
147
148
149
%global github_owner      schmittjoh
%global github_name       php-collection
%global github_version    0.4.0
%global github_commit     b8bf55a0a929ca43b01232b36719f176f86c7e83

%global lib_name          PhpCollection

%global php_min_ver       5.3.0
# "phpoption/phpoption": "1.*"
%global phpoption_min_ver 1.0
%global phpoption_max_ver 2.0

Name:          php-%{lib_name}
Version:       %{github_version}
Release:       1%{?dist}
Summary:       General purpose collection library for PHP

Group:         Development/Libraries
License:       ASL 2.0
URL:           http://jmsyst.com/libs/%{github_name}
# To create source:
# wget https://github.com/schmittjoh/php-collection/archive/%%{github_commit}.tar.gz
# php-PhpCollection-strip.sh %%{github_version} %%{github_commit}
Source0:       %{name}-%{github_version}-%{github_commit}.tar.gz
Source1:       %{name}-strip.sh

BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:     noarch
# For tests
BuildRequires: php(language) >= %{php_min_ver}
BuildRequires: php-pear(pear.phpunit.de/PHPUnit)
BuildRequires: php-PhpOption >= %{phpoption_min_ver}
BuildRequires: php-PhpOption <  %{phpoption_max_ver}
# For tests: phpcompatinfo (computed from version 0.4.0)
BuildRequires: php-spl

Requires:      php(language) >= %{php_min_ver}
Requires:      php-PhpOption >= %{phpoption_min_ver}
Requires:      php-PhpOption <  %{phpoption_max_ver}
# phpcompatinfo (computed from version 0.4.0)
Requires:      php-spl

%description
This library adds basic collections for PHP.

Collections can be seen as more specialized arrays for which certain contracts
are guaranteed.

Supported Collections:
* Sequences
** Keys: numerical, consequentially increasing, no gaps
** Values: anything, duplicates allowed
** Classes: Sequence, SortedSequence
* Maps
** Keys: strings or objects, duplicate keys not allowed
** Values: anything, duplicates allowed
** Classes: Map, ObjectMap (not yet implemented)
* Sets (not yet implemented)
** Keys: not meaningful
** Values: anything, each value must be unique (===)
** Classes: Set

General Characteristics:
* Collections are mutable (new elements may be added, existing elements may be
  modified or removed). Specialized immutable versions may be added in the
  future though.
* Equality comparison between elements are always performed using the shallow
  comparison operator (===).
* Sorting algorithms are unstable, that means the order for equal elements is
  undefined (the default, and only PHP behavior).


%prep
%setup -q -n %{github_name}-%{github_commit}


%build
# Empty build section, nothing to build


%install
mkdir -p -m 755 %{buildroot}%{_datadir}/php
cp -rp src/%{lib_name} %{buildroot}%{_datadir}/php/


%check
# Rewrite tests' bootstrap
( cat <<'AUTOLOAD'
<?php
spl_autoload_register(function ($class) {
    $src = str_replace('\\', '/', str_replace('_', '/', $class)).'.php';
    @include_once $src;
});
AUTOLOAD
) > tests/bootstrap.php

# Create PHPUnit config w/ colors turned off
cat phpunit.xml.dist \
    | sed 's/colors="true"/colors="false"/' \
    > phpunit.xml

# Skip test known to fail
sed 's/function testMap/function SKIP_testMap/' \
    -i tests/PhpCollection/Tests/SequenceTest.php

%{_bindir}/phpunit --include-path="./src:./tests"


%files
%defattr(-,root,root,-)
%doc LICENSE *.md composer.json
%{_datadir}/php/%{lib_name}


%changelog
* Tue Apr 22 2014 Remi Collet <remi@fedoraproject.org> 0.4.0-1
- backport 0.4.0 for remi repo.

* Mon Apr 21 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 0.4.0-1
- Updated to 0.4.0 (BZ #1078754)

* Mon Dec 30 2013 Remi Collet <remi@fedoraproject.org> 0.3.1-1
- backport 0.3.1 for remi repo.

* Mon Dec 30 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 0.3.1-1
- Updated to 0.3.1 (BZ #1045915)
- Spec cleanup

* Thu Jul 18 2013 Remi Collet <remi@fedoraproject.org> 0.3.0-1
- backport 0.3.0 for remi repo.

* Wed Jul 17 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 0.3.0-1
- Updated to 0.3.0

* Tue Mar 19 2013 Remi Collet <remi@fedoraproject.org> 0.2.0-2
- backport 0.2.0 for remi repo.

* Mon Mar 18 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 0.2.0-2
- Added %%{name}-strip.sh as Source1

* Sat Mar 16 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 0.2.0-1
- Updated to version 0.2.0
- Added phpoption_max_ver global
- Bad licensed files stripped from source
- php-common => php(language)
- Removed tests sub-package

* Wed Jan 23 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 0.1.0-1
- Initial package