Code Monkey home page Code Monkey logo

x-api's Introduction

x-API

Build Status Coverage Status Code Climate Dependency Status Supporting 24 Pull Requests

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.

Getting Started

The API is implemented in Ruby as a Sinatra application.

Fork and clone per usual, then run:

$ bundle install
$ git submodule init
$ git submodule update

Terminology

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:

  • Language - the name of a programming language, e.g. C++.
  • Track - a collection of exercises in a programming language.
  • Track ID - a url-friendly version of the language name, e.g. cpp.
  • Problem - a high-level, language-independent description of a problem to solve.
  • Implementation - a language-specific implementation of a problem. This contains a README and a test suite.

Code Arrangement

.
├── 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

metadata directory

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.

Running Locally

Run the server with rackup:

$ rackup
Puma 2.7.1 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening 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.

Tests

Run the entire test suite with rake.

$ bundle exec rake # runs the entire suite

To run individual tests, you can use the ruby command directly:

ruby 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:

approvals 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.

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.

Contributing

Please see the CONTRIBUTING guidelines in the root of this repository.

Releasing

To update all of the language tracks with their latest commits, run:

git submodule foreach git pull origin master

Then commit the changes (git commit -m "Update submodules") and push to both GitHub and Heroku.

License

The MIT License (MIT)

Copyright (c) 2014 Katrina Owen, [email protected]

x-api's People

Contributors

abhishekbose87 avatar amar47shah avatar aranair avatar ben-biddington avatar bmulvihill avatar chischaschos avatar davearonson avatar duffn avatar gustavocaso avatar insti avatar jendiamond avatar joeltaylor avatar jtigger avatar kalisafalzone avatar kotp avatar kytrinyx avatar mhelmetag avatar michaelavila avatar mikepack avatar mixolidia avatar nickborromeo avatar parkerl avatar ramyaravindranath avatar rud avatar sarahjschultz avatar tonkpils avatar tphyahoo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.