philschatz/octokit.js — pull request #59 by cirosantilli (2014-06-23 19:03:10+00:00)
Title: [WIP][waiting-feedback] Add GitLab support.

With this I can do:

```js
var Octokit = require('octokit')
var gh = Octokit.new({
api: 'gitlab',
token: config.gitlab.token
})
var repo = gh.getRepo(config.user, config.repo)
repo.getInfo().then(function(repo) {
console.log(repo)
console.log(repo.name)
})
```

If you think I'm going in the right direction I will continue to implement as much of GitLab as possible in this manner, and add tests.

The goal is to:

- keep the GitHub part unaltered.
- allow the same interface to interact with both websites by converting GitHub input URLs GitLab's, and GitLab's output JSON to their GitHub analogues. E.g.:
- GitHub URL `/repos/:user/:name` becomes GitLab `/projects/#{user}%2F#{repo}`
- GitLab's `.path` reply field becomes is converted to it's GitHub analogue `.name`, and `.name` which is the humanish name is converted to a new identifier `humanName`.
This is simplistic, but works for many fields.

I felt that implementing it here was simpler than at https://github.com/philschatz/octokat.js because in my mind this is a perfect case for using inheritance to model the situation, and Octokat has no explicit methods that can be polymorphed.