Name: x-api
Owner: Turing School of Software & Design
Description: Application to serve exercism assignments
Forked from: exercism/x-api
Created: 2016-09-17 05:50:12.0
Updated: 2016-09-17 05:50:13.0
Pushed: 2016-09-13 07:48:51.0
Homepage: http://x.exercism.io/
Size: 2870
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Exercism exercise API
This codebase provides an API for delivering Exercism exercises. This is consumed both by the Exercism command-line client, as well as the Exercism website.
The exercises for each language are stored in separate repositories, included here as git submodules.
The common metadata which is shared between all the language tracks are also included as a git submodule.
The API is implemented in Ruby as a Sinatra application.
Fork and clone per usual, then run:
ndle install
t submodule init
t submodule update
We've struggled a bit with the terminology, and the project currently has a mix of old and new.
Here's the terminology we're working towards:
cpp
.
api # sinatra APIs
??? helpers
??? helpers.rb # helpers used by both APIs
??? services # services used by both APIs
??? v1 # API v1 routes and views (also contains some hacky v2 stuff)
??? v1.rb
??? v3 # API v3 routes and views
??? v3.rb
lib/xapi/ # application logic
metadata/ # shared metadata
tracks/ # language track submodules
The metadata directory is actually a git submodule. A git submodule is essentially a project in another project. This particular submodule is the exercism/x-common project.
The x-common
repo contains shared metadata for Exercism exercises. When there is a need to get common information such as generic problem descriptions of exercises, they can be accessed via the git submodule.
Run the server with rackup
:
ckup
2.7.1 starting...
n threads: 0, max threads: 16
vironment: development
stening on tcp://0.0.0.0:9292...
At this point you can navigate to an existing endpoint in your browser, e.g. localhost:9292/tracks/ruby/bob
If the endpoint does not return exercism problem data, it is probably because you haven't updated or inititialized the submodules. Be sure to work through the Getting Started section of the README.
Run the entire test suite with rake
.
ndle exec rake # runs the entire suite
To run individual tests, you can use the ruby
command directly:
path/to/file_test.rb # runs only the tests in file_test.rb
Some of the API tests use approvals, which is a form of Golden Master testing. The test captures the entire body of the response, dumps it to a file, and compares it to the previously accepted version (which lives in a fixture file).
If the two versions are all good, then fine. The test passes. If they're different, then the test fails.
View the diffs using the approvals script:
ovals verify -d diff -a
-d
is for the diff library, use whatever you're comfortable with.
opendiff
is nice if you don't already have a preference.
-a
is a boolean option that, if passed, will ask you if you want to accept the change.
Accepting the change means that the new output gets copied over the old one. Running the test again will compare against this new output.
The approvals tests are particularly handy when tweaking the view templates.
The entire project serves up JSON. It uses the petroglyph library to write the views. Petroglyph is a tiny library that essentially lets you write some simple ruby to define the JSON structure.
Please see the CONTRIBUTING guidelines in the root of this repository.
To update all of the language tracks with their latest commits, run:
submodule foreach git pull origin master
Then commit the changes (git commit -m "Update submodules"
) and push to both GitHub and Heroku.
The MIT License (MIT)
Copyright (c) 2014 Katrina Owen, _@kytrinyx.com