Skip to content

Commit 7f6a4f3

Browse files
author
Keith Morgan
committed
Reorganized code to use PHP namespaces with Composer integration.
1 parent 68a63b0 commit 7f6a4f3

16 files changed

Lines changed: 76 additions & 30 deletions

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
*.*~
1+
vendor
2+
composer.phar
3+
phpunit.xml
4+
composer.lock
5+
cov
6+
.DS_Store

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Usage
99
-----------------------------
1010
Sanscript is simple to use:
1111

12+
use Sanskrit\Sanscript;
13+
1214
$sanscript = new Sanscript();
1315
$output = $sanscript->t($input, $from, $to);
1416

@@ -72,3 +74,11 @@ Adding a new scheme is simple:
7274
$sanscript->addRomanScheme($schemeName, $schemeData);
7375

7476
For help in creating `$schemeData`, see the comments on the `addBrahmicScheme` and `addRomanScheme` functions.
77+
78+
Running tests
79+
-----------------------------
80+
Running tests is facilitated with Composer:
81+
82+
1. composer install
83+
2. composer --dev update
84+
3. ./vendor/bin/phpunit

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "sanskrit/sanscript",
3+
"description": "Transliteration library for Sanskrit and other Indian languages",
4+
"keywords": ["transliteration", "romanization", "sanskrit", "devanagari", "itrans", "iast"],
5+
"type": "library",
6+
"homepage": "https://github.com/sanskrit/sanscript.php",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Keith Morgan",
11+
"email": "keith@wellebee.com",
12+
"homepage": "http://wellebee.com"
13+
},
14+
{
15+
"name": "Arun Prasad",
16+
"homepage": "https://github.com/akprasad"
17+
}
18+
],
19+
20+
"require": {
21+
"php": ">=5.4.8"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "~4.0"
25+
},
26+
"autoload": {
27+
"psr-4": {"Sanskrit\\": "src/"}
28+
}
29+
}

phpunit.xml.dist

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit bootstrap="tests/bootstrap.php" colors="true">
4+
<testsuites>
5+
<testsuite name="Sanscript Test Suite">
6+
<file>tests/SanscriptSetup.php</file>
7+
<file>tests/SanscriptTransliteration.php</file>
8+
<file>tests/SanscriptDravidian.php</file>
9+
<file>tests/SanscriptToggle.php</file>
10+
<file>tests/SanscriptOptions.php</file>
11+
<file>tests/SanscriptITRANS.php</file>
12+
</testsuite>
13+
</testsuites>
14+
</phpunit>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Sanskrit;
4+
35
/**
46
* Sanscript
57
*
@@ -726,3 +728,4 @@ public function t($data, $from, $to, $options = NULL) {
726728
}
727729
}
728730
}
731+

test/config.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/run_tests

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3-
abstract class SanscriptBase extends PHPUnit_Framework_TestCase {
3+
namespace Sanskrit\Sanscript\Tests;
4+
use Sanskrit\Sanscript;
5+
6+
abstract class SanscriptBase extends \PHPUnit_Framework_TestCase {
47
protected $sanscript;
58
protected $data;
69

710
protected function setUp() {
8-
include_once '../sanscript/sanscript.php';
911
$this->sanscript = new Sanscript();
1012

1113
$this->data = array(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
include_once './SanscriptBase.php';
3+
use Sanskrit\Sanscript\Tests\SanscriptBase;
44

55
class SanscriptDravidian extends SanscriptBase {
66

0 commit comments

Comments
 (0)