Lightweight Rails API taking a Pokémon name and returning a Shakespearean description of that Pokémon.
Requests are made to the server in the format:
GET /pokemon/:pokemon
Where :pokemon
is the intended Pokémon name in lowercase (note that spaces or irregular characters should be submitted with a substitute hyphen - i.e. Mr.Mime should be submitted as mr-mime
)
Responses are returned as JSON in the format:
{ "name": "pokemon name", "description": "pokemon description" }
For instance, the following request:
GET /pokemon/octillery
Should return:
{
"name": "octillery",
"description": "The ink 't spits at which hour escaping is special. 't enwheels a substance yond dulls the sense of smelleth, so pokémon with keen noses receiveth did lose."
}
This project makes use of two external APIs, PokéAPI and Shakespeare Translator, and is therefore restricted by the constraints of those services. As of April 2020, this means that Sword & Shield Pokémon are not included, with Shakespeare translations limited to 5 API calls per hour.
With a local Ruby installation, cd
into the project directory and install dependencies:
$ gem install bundler
$ bundle install
Run the project locally on port 3000
:
$ bundle exec rails server
Alternatively, this project contains a Dockerfile so that it can be run inside a container (get Docker). To get a server up and running:
$ docker build . -t pikachu
$ docker run -p 3000:3000 pikachu:latest
With a server running, requests can be made to localhost
as follows:
GET http://localhost:3000/pokemon/:pokemon
Assuming the above Ruby and dependency installations are complete, test cases for this project can be run using:
$ bundle exec rspec