From 58890f0efb46f634ad62547ae9cc5d35bbd95659 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 14 Oct 2015 15:43:45 +0200 Subject: php-jsonlint: add an autoloader --- php-jsonlint-autoload.php | 15 ++++++++++ php-jsonlint-bin-without-composer-autoloader.patch | 13 ++------ php-jsonlint.spec | 35 ++++++++++++++-------- 3 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 php-jsonlint-autoload.php diff --git a/php-jsonlint-autoload.php b/php-jsonlint-autoload.php new file mode 100644 index 0000000..53f50f4 --- /dev/null +++ b/php-jsonlint-autoload.php @@ -0,0 +1,15 @@ +register(); +} + +$fedoraClassLoader->addPrefix('Seld\\JsonLint\\', dirname(dirname(__DIR__))); diff --git a/php-jsonlint-bin-without-composer-autoloader.patch b/php-jsonlint-bin-without-composer-autoloader.patch index fdad739..d17357d 100644 --- a/php-jsonlint-bin-without-composer-autoloader.patch +++ b/php-jsonlint-bin-without-composer-autoloader.patch @@ -2,13 +2,7 @@ diff --git a/bin/jsonlint b/bin/jsonlint index 1b9272a..c15cfa6 100755 --- a/bin/jsonlint +++ b/bin/jsonlint -@@ -1,4 +1,4 @@ --#!/usr/bin/env php -+#!/usr/bin/php - # Remi Collet @@ -23,7 +24,7 @@ Name: php-%{github_name} Version: %{github_version} -Release: 1%{?dist} +Release: 3%{?dist} Summary: JSON Lint for PHP Group: Development/Libraries @@ -31,6 +32,9 @@ License: MIT URL: https://github.com/%{github_owner}/%{github_name} Source0: %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz +# Autoloader +Source1: %{name}-autoload.php + # Bin usage without Composer autoloader Patch0: %{name}-bin-without-composer-autoloader.patch @@ -39,14 +43,19 @@ BuildArch: noarch %if %{with_tests} # For tests: composer.json BuildRequires: php(language) >= %{php_min_ver} -BuildRequires: php-phpunit-PHPUnit +BuildRequires: php-composer(phpunit/phpunit) # For tests: phpcompatinfo (computed from version 1.3.1) BuildRequires: php-pcre +# For autoloader +BuildRequires: php-composer(symfony/class-loader) %endif Requires: php(language) >= %{php_min_ver} # phpcompatinfo (computed from version 1.3.1) +Requires: php-cli Requires: php-pcre +# For autoloader +Requires: php-composer(symfony/class-loader) Provides: php-composer(seld/jsonlint) = %{version} @@ -57,10 +66,14 @@ Provides: php-composer(seld/jsonlint) = %{version} This library is a port of the JavaScript jsonlint (https://github.com/zaach/jsonlint) library. +To use this library, you just have to add, in your project: + require_once '%{_datadir}/php/Seld/JsonLint/autoload.php'; + %prep %setup -q -n %{github_name}-%{github_commit} +cp %{SOURCE1} src/Seld/JsonLint/autoload.php %patch0 -p1 @@ -80,16 +93,9 @@ install -pm 0755 bin/jsonlint %{buildroot}%{_bindir}/ %check %if %{with_tests} -# Create autoloader -cat > autoload.php <<'AUTOLOAD' - - 1.3.1-3 +- add autoloader + * Mon Jan 5 2015 Remi Collet - 1.3.1-1 - Updated to 1.3.1 -- cgit