Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Clean up scripts and add README
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodacious committed Nov 10, 2020
1 parent 637708f commit a1af349
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Boxt API Documentation buildpack

This buildpack should be included as part of Heroku apps that host API documentation.

For more info on how buildpacks work, read the Heroku Buildpacks API: https://devcenter.heroku.com/articles/buildpack-api

## Detect

The detect script in `./bin/detect` will test for the existence of the **boxt_documentation** gem on the system. If it's not found, the buildpack will exit, otherwise it will run the script in `./bin/compile`.

## Compile

The compile script will run the requisite rake tasks on the **boxt_documentation** gem to build the API documentation.
10 changes: 5 additions & 5 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#!/bin/sh

# bin/compile BUILD_DIR CACHE_DIR ENV_DIR

BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3

echo `which gem`
echo `which bundle`

cd $BUILD_DIR

echo "DATABASE_URL:$DATABASE_URL"
# Set ENV vars
export DATABASE_URL=`cat $ENV_DIR/DATABASE_URL`
export RAILS_ENV=`cat $ENV_DIR/RAILS_ENV`
export RACK_ENV=`cat $ENV_DIR/RACK_ENV`

# Stash the database file over
# Stash the database file before replacing it...
cp config/database.yml config/database.yml.stash

# Rewrite the database file to use the DATABASE_URL. This emulates Heroku's own buildpack
Expand All @@ -28,10 +26,12 @@ YAML

echo $DATABASE_FILE_CONTENT >> config/database.yml

Run the rake task
bin/rake docs:api:build -- --api-class-name=V2::API --base-dir="$BUILD_DIR/public/api-docs"

# Put database.yml back where it was
rm config/database.yml
cp config/database.yml.stash config/database.yml

# Exit 0—success
exit 0
4 changes: 1 addition & 3 deletions bin/detect
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
BUILD_DIR=$1
cd $BUILD_DIR

export PATH="$BUILD_DIR/vendor/bundle/bin:$PATH"

$BUILD_DIR/bin/gem info boxt_documentation
# This pack is valid if the boxt_documentation gem is installed
$BUILD_DIR/bin/gem info boxt_documentation
if [ $? -eq 0 ]; then
echo "BOXT Documentation"
exit 0
Expand Down

0 comments on commit a1af349

Please sign in to comment.