# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

EGIT_REPO_URI="https://github.com/phar-io/version.git"

inherit git-r3

DESCRIPTION="Library for handling version information and constraints"
HOMEPAGE="https://github.com/phar-io/version"

LICENSE="BSD"
SLOT="0"
IUSE="test"
RESTRICT="!test? ( test )"

RDEPEND="dev-lang/php:*
	dev-php/fedora-autoloader"
BDEPEND="dev-php/theseer-Autoload
	test? ( dev-php/phpunit )"

DOCS=( {CHANGELOG,README}.md )

src_prepare() {
	default

	# remove failed tests (Version string '1' does not follow SemVer semantics)
	sed -i '/testReturnsExpectedConstraint/,+5d' \
		tests/Integration/VersionConstraintParserTest.php \
		|| die "sed failed for VersionConstraintParserTest.php"
	sed -i -e '/testOrigionalStringReturnsExceptedVersionString/,+6d' \
		-e '/testAsStringReturnsExceptedVersionString/,+6d' \
		tests/Unit/VersionTest.php \
		|| die "sed failed for VersionTest.php"
	phpab -q -o src/autoload.php -t fedora2 src || die "phpab failed"
}

src_test() {
	phpunit --testdox || die "phpunit failed"
}

src_install() {
	einstalldocs
	insinto /usr/share/php/PharIo/Version
	doins -r src/.
}