Skip to content

Commit 1687c32

Browse files
committed
Merge pull request #20 from fhasanaj/RCB-230_home_on_github
Rcb 230 home on GitHub
2 parents 0e6b538 + 651f453 commit 1687c32

File tree

7 files changed

+83
-22
lines changed

7 files changed

+83
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PHP client binding for Rosette API
66
Installation
77
------------
88

9-
`composer require "rosette/api: ~0.7.4"`
9+
`composer require "rosette/api: ~0.8.0"`
1010

1111
Basic Usage
1212
-----------

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rosette/api",
3-
"version": "0.7.4",
3+
"version": "0.8.0",
44
"description": "Rosette API PHP client SDK",
55
"license": "Apache",
66
"keywords": [

docker/Dockerfile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
FROM php:5.5-cli
2-
MAINTAINER Sam Hausmann
2+
MAINTAINER Fiona Hasanaj
3+
ENV TZ=America/New_York
34

45
# install necessary software
5-
RUN apt-get -y update && apt-get install -y vim && apt-get install -y git
6+
RUN apt-get -y update && apt-get install -y vim && apt-get install -y git && apt-get install -y libxslt1-dev
67

7-
# clone the Rosette API repo from github
8-
RUN git clone https://github.com/rosette-api/php.git
9-
COPY composer.json /php/examples/composer.json
10-
WORKDIR /php/examples
8+
# copy over the necessary files
9+
COPY composer.json /php-dev/examples/composer.json
10+
COPY composer.json /php-dev/composer.json
11+
WORKDIR /php-dev
1112

1213
# install mbstring
1314
RUN docker-php-ext-install mbstring
1415

16+
#Add xsl in PHP containers image
17+
RUN docker-php-ext-install xsl
18+
1519
# install composer.phar
1620
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
17-
RUN composer install
21+
RUN composer install && cp -r vendor /php-dev/examples
1822

19-
# copy API script
20-
COPY run_php.sh /php/examples/run_php.sh
21-
RUN chmod 755 /php/examples/run_php.sh
23+
# copy over the necessary files
24+
COPY run_php.sh /php-dev/run_php.sh
25+
RUN chmod 755 /php-dev/run_php.sh
2226

2327
# specify docker volume
2428
VOLUME ["/source"]
2529

2630
# allow interactive bash inside docker container
27-
CMD ./run_php.sh $API_KEY $FILENAME $ALT_URL
31+
CMD ./run_php.sh $API_KEY $FILENAME $ALT_URL $GIT_USERNAME $VERSION

docker/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ To simplify the running of the PHP examples, the Dockerfile will build an image
77
### Basic Usage
88
Build the docker image, e.g. `docker build -t basistech/php:1.1 .`
99

10-
Run an example as `docker run -e API_KEY=api-key -v "path-to-example-source:/source" basistech/php:1.1`
10+
Run an example as `docker run -e API_KEY=api-key -v "path-to-php-dir:/source" basistech/php:1.1`
1111

12-
To test against a specific source file, add `-e FILENAME=filename` before the `-v`
13-
14-
Also, to test against an alternate url, add `-e ALT_URL=alternate_url` before the `-v`
12+
To test against a specific source file, add `-e FILENAME=filename` before the `-v`, to test against an alternate url, add `-e ALT_URL=alternate_url`, and optionally if you would like to regenerate gh-pages from the changes made to the development source you can add `-e GIT_USERNAME=git-username -e VERSION=version` before the `-v`. In order to push the gh-pages to git remember to mount .ssh and .gitconfig to the root dir `-v path-to-.ssh-dir:/root/.ssh -v path-to-.gitconfig:/root/.gitconfig`.

docker/composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
{
2+
"name": "rosette/api",
3+
"version": "0.8.0",
4+
"description": "Rosette API PHP client SDK",
5+
"license": "Apache",
6+
"keywords": [
7+
"rosette",
8+
"basis",
9+
"nlp",
10+
"text analytics"
11+
],
12+
"authors": [
13+
{
14+
"name": "Basis Technology Corp",
15+
"homepage": "https://developer.rosette.com"
16+
}
17+
],
18+
"require-dev": {
19+
"phpunit/phpunit": ">=4.6",
20+
"fabpot/php-cs-fixer": ">=1.9",
21+
"phpdocumentor/phpdocumentor": "~2.8"
22+
},
223
"autoload": {
324
"psr-4": {"rosette\\": "/source/source/rosette"}
425
}

docker/run_php.sh

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
#Gets called when the user doesn't provide any args
44
function HELP {
55
echo -e "\nusage: source_file.php --key API_KEY [--url ALT_URL]"
6-
echo " API_KEY - Rosette API key (required)"
7-
echo " FILENAME - PHP source file (optional)"
8-
echo " ALT_URL - Alternate service URL (optional)"
6+
echo " API_KEY - Rosette API key (required)"
7+
echo " FILENAME - PHP source file (optional)"
8+
echo " ALT_URL - Alternate service URL (optional)"
9+
echo " GIT_USERNAME - Git username where you would like to push regenerated gh-pages (optional)"
10+
echo " VERSION - Build version (optional)"
911
echo "Compiles and runs the source file(s) using the local development source."
1012
exit 1
1113
}
1214

13-
#Gets API_KEY, FILENAME and ALT_URL if present
15+
#Gets API_KEY, FILENAME, ALT_URL, GIT_USERNAME and VERSION if present
1416
while getopts ":API_KEY:FILENAME:ALT_URL" arg; do
1517
case "${arg}" in
1618
API_KEY)
@@ -25,6 +27,14 @@ while getopts ":API_KEY:FILENAME:ALT_URL" arg; do
2527
FILENAME=${OPTARG}
2628
usage
2729
;;
30+
GIT_USERNAME)
31+
GIT_USERNAME=${OPTARG}
32+
usage
33+
;;
34+
VERSION)
35+
VERSION={OPTARG}
36+
usage
37+
;;
2838
esac
2939
done
3040

@@ -37,9 +47,13 @@ function checkAPI {
3747
fi
3848
}
3949

50+
#Copy the mounted content in /source to current WORKDIR
51+
cp -r -n /source/* .
52+
4053
#Run the examples
4154
if [ ! -z ${API_KEY} ]; then
4255
checkAPI
56+
cd /php-dev/examples
4357
if [ ! -z ${FILENAME} ]; then
4458
if [ ! -z ${ALT_URL} ]; then
4559
php ${FILENAME} --key ${API_KEY} --url=${ALT_URL}
@@ -53,4 +67,28 @@ if [ ! -z ${API_KEY} ]; then
5367
fi
5468
else
5569
HELP
70+
fi
71+
72+
#Run unit tests
73+
cd /php-dev && ./vendor/bin/phpunit -v --bootstrap ./vendor/autoload.php ./tests/rosette/api/ApiTest.php
74+
75+
#Run php-cs-fixer
76+
./vendor/bin/php-cs-fixer fix . --dry-run --diff
77+
78+
#Generate gh-pages and push them to git account (if git username is provided)
79+
if [ ! -z ${GIT_USERNAME} ] && [ ! -z ${VERSION} ]; then
80+
#clone php git repo to the root dir
81+
cd /
82+
git clone [email protected]:${GIT_USERNAME}/php.git
83+
cd php
84+
git checkout origin/gh-pages -b gh-pages
85+
git branch -d develop
86+
#generate gh-pages from development source and output the contents to php repo
87+
cd /php-dev
88+
./vendor/bin/phpdoc -d ./source/rosette/api -t /php
89+
cd /php
90+
find -name 'phpdoc-cache-*' -exec rm -rf {} \;
91+
git add .
92+
git commit -a -m "publish php apidocs ${VERSION}"
93+
git push
5694
fi

examples/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"require": {
3-
"rosette/api": "0.7.*"
3+
"rosette/api": "0.8.*"
44
}
55
}

0 commit comments

Comments
 (0)