mirror of
https://github.com/samsonjs/gitter.git
synced 2026-03-25 09:25:45 +00:00
Compare commits
13 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac9f2f6181 | ||
|
|
04ae6c4c71 | ||
|
|
1306761490 | ||
|
|
df2b8d7c33 | ||
|
|
f547829a1b | ||
|
|
5c91a0a42c | ||
|
|
dcae8398bf | ||
|
|
22af769100 | ||
|
|
ee61b0f95a | ||
|
|
93fcb0eda2 | ||
|
|
b23ab2fe01 | ||
|
|
274b6e4802 | ||
|
|
d997c74d70 |
13 changed files with 918 additions and 643 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
gitter.tmproj
|
||||||
2
Makefile
2
Makefile
|
|
@ -1,4 +1,4 @@
|
||||||
VOWS=vows/{blob,branch,commit,raw,repo,tree,user}.js
|
VOWS=vows/{blob,branch,commit,repo,tree,user}.js
|
||||||
|
|
||||||
spec:
|
spec:
|
||||||
vows --spec $(VOWS)
|
vows --spec $(VOWS)
|
||||||
|
|
|
||||||
22
Readme.md
22
Readme.md
|
|
@ -1,9 +1,11 @@
|
||||||
gitter
|
gitter
|
||||||
======
|
======
|
||||||
|
|
||||||
A GitHub client inspired by [pengwynn/octopussy](/pengwynn/octopussy).
|
A GitHub client inspired by [pengwynn/octokit](https://github.com/pengwynn/octokit).
|
||||||
|
|
||||||
v2 API
|
v3 API
|
||||||
|
|
||||||
|
Works in Node.js and most web browsers.
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|
@ -22,31 +24,31 @@ Usage
|
||||||
console.dir(user)
|
console.dir(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
gh.repo('samsonjs/gitter', function(err, repo) {
|
gh.repo('samsonjs', 'gitter', function(err, repo) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log('---- repo: ' + repo.owner + '/' + repo.name + ' ----')
|
console.log('---- repo: ' + repo.owner + '/' + repo.name + ' ----')
|
||||||
console.dir(repo)
|
console.dir(repo)
|
||||||
}).getWatchers(function(err, repos) {
|
}).fetchWatchers(function(err, watchers) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log('---- watchers ----')
|
console.log('---- watchers ----')
|
||||||
console.dir(repos)
|
console.dir(watchers)
|
||||||
}).getBranches(function(err, branches) {
|
}).fetchBranches(function(err, branches) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log('---- branches: samsonjs/gitter ----')
|
console.log('---- branches: samsonjs/gitter ----')
|
||||||
console.dir(branches)
|
console.dir(branches)
|
||||||
gh.commit(this.repo, branches['master'], function(err, commit) {
|
gh.commit(this.user, this.repo, branches['master'], function(err, commit) {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log('---- samsonjs/gitter/master commit: ' + commit.id + ' ----')
|
console.log('---- samsonjs/gitter/master commit: ' + commit.id + ' ----')
|
||||||
console.dir(commit.data())
|
console.dir(commit.data())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
For the full API have a look at the top of [lib/index.js](/samsonjs/gitter/blob/master/lib/index.js).
|
For the full API have a look at the top of [lib/index.js](https://github.com/samsonjs/gitter/blob/master/lib/index.js).
|
||||||
|
|
||||||
|
|
||||||
License
|
License
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Copyright 2010 Sami Samhuri sami.samhuri@gmail.com
|
Copyright 2010 - 2012 Sami Samhuri sami@samhuri.net
|
||||||
|
|
||||||
MIT (see included [LICENSE](/samsonjs/gitter/blob/master/LICENSE))
|
[MIT License](http://sjs.mit-license.org)
|
||||||
|
|
|
||||||
1106
lib/index.js
1106
lib/index.js
File diff suppressed because it is too large
Load diff
24
package.json
24
package.json
|
|
@ -1,25 +1,23 @@
|
||||||
{ "name" : "gitter"
|
{ "name" : "gitter"
|
||||||
, "description" : "GitHub client (API v2), inspired by pengwynn/octopussy"
|
, "description" : "GitHub client (API v3)"
|
||||||
, "version" : "0.0.2"
|
, "version" : "0.2.0"
|
||||||
, "homepage" : "http://samhuri.net/node/gitter"
|
, "homepage" : "http://samhuri.net/proj/gitter"
|
||||||
, "author" : "Sami Samhuri <sami.samhuri@gmail.com>"
|
, "author" : "Sami Samhuri <sami@samhuri.net>"
|
||||||
, "repository" :
|
, "repository" :
|
||||||
{ "type" : "git"
|
{ "type" : "git"
|
||||||
, "url" : "http://github.com/samsonjs/gitter.git"
|
, "url" : "https://github.com/samsonjs/gitter"
|
||||||
}
|
}
|
||||||
, "bugs" :
|
, "bugs" :
|
||||||
{ "mail" : "sami.samhuri+gitter@gmail.com"
|
{ "mail" : "sami@samhuri.net"
|
||||||
, "web" : "http://github.com/samsonjs/gitter/issues"
|
, "url" : "http://github.com/samsonjs/gitter/issues"
|
||||||
}
|
}
|
||||||
, "directories" : { "lib" : "./lib" }
|
, "directories" : { "lib" : "./lib" }
|
||||||
, "main" : "./lib/index"
|
, "main" : "./lib/index"
|
||||||
, "engines" : { "node" : ">=0.3.0" }
|
, "engines" : { "node" : ">=0.6.0" }
|
||||||
, "licenses" :
|
, "licenses" :
|
||||||
[ { "type" : "MIT"
|
[ { "type" : "MIT"
|
||||||
, "url" : "http://github.com/samsonjs/gitter/raw/master/LICENSE"
|
, "url" : "http://sjs.mit-license.org"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
, "dependencies" : { "request" : "0.10.0 - 0.10.999"
|
, "devDependencies" : { "vows" : "0.6.2" }
|
||||||
, "vows" : "0.5.0 - 0.5.999"
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
38
vows/blob.js
38
vows/blob.js
|
|
@ -1,35 +1,19 @@
|
||||||
var gh = require('../lib')
|
var gh = require('../')
|
||||||
, vows = require('vows')
|
, vows = require('vows')
|
||||||
, assert = require('assert')
|
, assert = require('assert')
|
||||||
, h = require('./helper')
|
, h = require('./helper')
|
||||||
|
|
||||||
, User = 'samsonjs'
|
, User = 'samsonjs'
|
||||||
, Repo = 'gitter'
|
, Repo = 'gitter'
|
||||||
, Proj = User + '/' + Repo
|
, Sha = '6c6cb9b3449c17e3ae4eee9061b4081ff33c8c64'
|
||||||
, TreeSha = '3363be22e88e50d6dd15f9a4b904bfe41cdd22bc'
|
|
||||||
, Path = 'lib/index.js'
|
|
||||||
|
|
||||||
vows.describe('Blob').addBatch({
|
vows.describe('Blob').addBatch({
|
||||||
'after fetching a blob': {
|
'after fetching a blob': {
|
||||||
topic: function() { gh.blob(Proj, TreeSha, Path, this.callback) },
|
topic: function() { gh.blob(User, Repo, Sha, this.callback) },
|
||||||
'the data object can be accessed with the data() method': function(err, blob) {
|
'the data can be accessed via the content attribute': function(err, blob) {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.ok(blob)
|
assert.ok(blob)
|
||||||
assert.instanceOf(blob.data(), Object)
|
assert.ok(blob.content)
|
||||||
},
|
}
|
||||||
'data is a blob': function(err, blob) {
|
}
|
||||||
assert.ifError(err)
|
}).export(module)
|
||||||
assert.ok(h.looksLikeABlob(blob.data()))
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'after fetching commits for a blob': {
|
|
||||||
topic: function() { gh.blob(Proj, TreeSha, Path).getCommits(this.callback) },
|
|
||||||
'list of commits is available': function(err, commits) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(commits)
|
|
||||||
assert.instanceOf(commits, Array)
|
|
||||||
assert.equal(commits.length, 1)
|
|
||||||
assert.ok(commits.every(function(c) { return h.looksLikeACommit(c) }))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}).export(module)
|
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,23 @@
|
||||||
var gh = require('../lib')
|
var gh = require('../')
|
||||||
, vows = require('vows')
|
, vows = require('vows')
|
||||||
, assert = require('assert')
|
, assert = require('assert')
|
||||||
, h = require('./helper')
|
, h = require('./helper')
|
||||||
|
|
||||||
, User = 'samsonjs'
|
, User = 'samsonjs'
|
||||||
, Repo = 'gitter'
|
, Repo = 'gitter'
|
||||||
, Proj = User + '/' + Repo
|
|
||||||
, Branch = 'master'
|
, Branch = 'master'
|
||||||
|
|
||||||
vows.describe('Branch').addBatch({
|
vows.describe('Branch').addBatch({
|
||||||
'after fetching a branch': {
|
'after fetching a branch': {
|
||||||
topic: function() { gh.branch(Proj, Branch, this.callback) },
|
topic: function() { gh.branch(User, Repo, Branch, this.callback) },
|
||||||
'the data object can be accessed with the data() method': function(err, branch) {
|
'attributes can be accessed': function(err, branch) {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.ok(branch)
|
assert.typeOf(branch.ref, 'string')
|
||||||
assert.instanceOf(branch.data(), Object)
|
assert.instanceOf(branch.object, Object)
|
||||||
},
|
|
||||||
'attributes can be accessed with the data() method': function(err, branch) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.instanceOf(branch.data('author'), Object)
|
|
||||||
},
|
|
||||||
'expected fields are present': function(err, branch) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(h.looksLikeABranch(branch.data()))
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
'after fetching commits': {
|
'expected fields are present': function(err, branch) {
|
||||||
topic: function() { gh.commits(Proj, Branch, this.callback) },
|
assert.ifError(err)
|
||||||
'list of commits is available': function(err, commits) {
|
assert.ok(h.looksLikeABranch(branch))
|
||||||
assert.ifError(err)
|
},
|
||||||
assert.ok(commits)
|
}
|
||||||
assert.instanceOf(commits, Array)
|
|
||||||
assert.ok(commits.every(function(c) { return h.looksLikeACommit(c) }))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).export(module)
|
}).export(module)
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,22 @@
|
||||||
var gh = require('../lib')
|
var gh = require('../')
|
||||||
, vows = require('vows')
|
, vows = require('vows')
|
||||||
, assert = require('assert')
|
, assert = require('assert')
|
||||||
, h = require('./helper')
|
, h = require('./helper')
|
||||||
|
|
||||||
, User = 'samsonjs'
|
, User = 'samsonjs'
|
||||||
, Repo = 'gitter'
|
, Repo = 'gitter'
|
||||||
, Proj = User + '/' + Repo
|
|
||||||
, Sha = '3363be22e88e50d6dd15f9a4b904bfe41cdd22bc'
|
, Sha = '3363be22e88e50d6dd15f9a4b904bfe41cdd22bc'
|
||||||
|
|
||||||
vows.describe('Commit').addBatch({
|
vows.describe('Commit').addBatch({
|
||||||
'after fetching a commit': {
|
'after fetching a commit': {
|
||||||
topic: function() { gh.commit(Proj, Sha, this.callback) },
|
topic: function() { gh.commit(User, Repo, Sha, this.callback) },
|
||||||
'the data object can be accessed with the data() method': function(err, commit) {
|
'attributes can be accessed': function(err, commit) {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.ok(commit)
|
assert.instanceOf(commit.author, Object)
|
||||||
assert.instanceOf(commit.data(), Object)
|
},
|
||||||
},
|
'expected fields are present': function(err, commit) {
|
||||||
'attributes can be accessed with the data() method': function(err, commit) {
|
assert.ifError(err)
|
||||||
assert.ifError(err)
|
assert.ok(h.looksLikeACommit(commit))
|
||||||
assert.instanceOf(commit.data('author'), Object)
|
},
|
||||||
},
|
}
|
||||||
'expected fields are present': function(err, commit) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(h.looksLikeACommit(commit.data()))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}).export(module)
|
}).export(module)
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,56 @@
|
||||||
module.exports = { looksLikeABlob: looksLikeABlob
|
module.exports = { looksLikeABlob: looksLikeABlob
|
||||||
, looksLikeABranch: looksLikeACommit
|
, looksLikeAFullBlob: looksLikeAFullBlob
|
||||||
|
, looksLikeABranch: looksLikeARef
|
||||||
|
, looksLikeABranchList: looksLikeABranchList
|
||||||
, looksLikeACommit: looksLikeACommit
|
, looksLikeACommit: looksLikeACommit
|
||||||
|
, looksLikeACollaborator: looksLikeAShortUser
|
||||||
, looksLikeAContributor: looksLikeAContributor
|
, looksLikeAContributor: looksLikeAContributor
|
||||||
|
, looksLikeAFollower: looksLikeAShortUser
|
||||||
, looksLikeARepo: looksLikeARepo
|
, looksLikeARepo: looksLikeARepo
|
||||||
, looksLikeASha: looksLikeASha
|
, looksLikeASha: looksLikeASha
|
||||||
, looksLikeATree: looksLikeATree
|
, looksLikeATree: looksLikeATree
|
||||||
, looksLikeAUser: looksLikeAUser
|
, looksLikeAUser: looksLikeAUser
|
||||||
|
, looksLikeAWatcher: looksLikeAShortUser
|
||||||
}
|
}
|
||||||
|
|
||||||
var BlobKeys = ('mimeType mode name sha size').split(' ')
|
var BlobKeys = 'mode path sha type url'.split(' ')
|
||||||
|
var FullBlobKeys = 'content encoding sha size url'.split(' ')
|
||||||
|
|
||||||
var CommitKeys = ('author authoredDate committedDate committer id ' +
|
var CommitKeys = 'author committer message parents sha tree url'.split(' ')
|
||||||
'message parents tree url').split(' ')
|
|
||||||
|
|
||||||
var ContributorKeys = ('blog contributions email location login name type').split(' ')
|
var ContributorKeys = 'avatarUrl contributions gravatarId id login url'.split(' ')
|
||||||
|
|
||||||
|
var RefKeys = 'object ref url'.split(' ')
|
||||||
|
var BranchListKeys = 'commit name'.split(' ')
|
||||||
|
var RefObjectKeys = 'sha type url'.split(' ')
|
||||||
|
|
||||||
var RepoKeys = ('createdAt fork forks hasDownloads hasIssues hasWiki ' +
|
var RepoKeys = ('createdAt fork forks hasDownloads hasIssues hasWiki ' +
|
||||||
'name openIssues owner private pushedAt url watchers').split(' ')
|
'name openIssues owner private pushedAt url watchers').split(' ')
|
||||||
|
|
||||||
var UserKeys = ('blog company createdAt email followersCount ' +
|
var ShortUserKeys = 'avatarUrl gravatarId id login url'.split(' ')
|
||||||
'followingCount id location login name ' +
|
|
||||||
'publicRepoCount publicGistCount type').split(' ')
|
var TreeKeys = 'tree sha url'.split(' ')
|
||||||
|
|
||||||
|
var UserKeys = ('blog company createdAt email followers ' +
|
||||||
|
'following id location login name ' +
|
||||||
|
'publicRepos publicGists type').split(' ')
|
||||||
|
|
||||||
function looksLikeABlob(obj) { return hasKeys(obj, BlobKeys) }
|
function looksLikeABlob(obj) { return hasKeys(obj, BlobKeys) }
|
||||||
|
function looksLikeAFullBlob(obj) { return hasKeys(obj, FullBlobKeys) }
|
||||||
function looksLikeACommit(obj) { return hasKeys(obj, CommitKeys) }
|
function looksLikeACommit(obj) { return hasKeys(obj, CommitKeys) }
|
||||||
function looksLikeAContributor(obj) { return hasKeys(obj, ContributorKeys) }
|
function looksLikeAContributor(obj) { return hasKeys(obj, ContributorKeys) }
|
||||||
|
function looksLikeARef(obj) {
|
||||||
|
return hasKeys(obj, RefKeys) && hasKeys(obj.object, RefObjectKeys)
|
||||||
|
}
|
||||||
|
function looksLikeABranchList(obj) {
|
||||||
|
return obj.every(function(branch) { return hasKeys(branch, BranchListKeys) })
|
||||||
|
}
|
||||||
function looksLikeARepo(obj) { return hasKeys(obj, RepoKeys) }
|
function looksLikeARepo(obj) { return hasKeys(obj, RepoKeys) }
|
||||||
function looksLikeASha(s) { return s && s.length === 40 }
|
function looksLikeASha(s) { return s && s.length === 40 }
|
||||||
function looksLikeATree(obj) { return obj && obj.every(function(b) { return looksLikeABlob(b) }) }
|
function looksLikeAShortUser(obj) { return hasKeys(obj, ShortUserKeys) }
|
||||||
|
function looksLikeATree(obj) {
|
||||||
|
return hasKeys(obj, TreeKeys) && obj.tree.every(looksLikeABlob)
|
||||||
|
}
|
||||||
function looksLikeAUser(obj) { return hasKeys(obj, UserKeys) }
|
function looksLikeAUser(obj) { return hasKeys(obj, UserKeys) }
|
||||||
|
|
||||||
function hasKeys(obj, keys) {
|
function hasKeys(obj, keys) {
|
||||||
|
|
|
||||||
20
vows/raw.js
20
vows/raw.js
|
|
@ -1,20 +0,0 @@
|
||||||
var gh = require('../lib')
|
|
||||||
, vows = require('vows')
|
|
||||||
, assert = require('assert')
|
|
||||||
, h = require('./helper')
|
|
||||||
|
|
||||||
, User = 'samsonjs'
|
|
||||||
, Repo = 'gitter'
|
|
||||||
, Proj = User + '/' + Repo
|
|
||||||
, Sha = 'a0a2d307cfe7810ccae0aec2ec6854d079de6511'
|
|
||||||
|
|
||||||
vows.describe('Raw').addBatch({
|
|
||||||
'after fetching a raw blob': {
|
|
||||||
topic: function() { gh.raw(Proj, Sha, this.callback) },
|
|
||||||
'the data object can be accessed with the data() method': function(err, raw) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(raw)
|
|
||||||
assert.equal(typeof raw.data(), 'string')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).export(module)
|
|
||||||
170
vows/repo.js
170
vows/repo.js
|
|
@ -1,100 +1,96 @@
|
||||||
var gh = require('../lib')
|
var gh = require('../')
|
||||||
, vows = require('vows')
|
, vows = require('vows')
|
||||||
, assert = require('assert')
|
, assert = require('assert')
|
||||||
, h = require('./helper')
|
, h = require('./helper')
|
||||||
|
|
||||||
, User = 'samsonjs'
|
, User = 'samsonjs'
|
||||||
, Repo = 'gitter'
|
, Repo = 'gitter'
|
||||||
, Proj = User + '/' + Repo
|
, ForkedRepo = 'strftime'
|
||||||
|
, CollaboratorsRepo = 'mojo.el'
|
||||||
|
|
||||||
vows.describe('Repo').addBatch({
|
vows.describe('Repo').addBatch({
|
||||||
'after fetching a repo': {
|
'after fetching a repo': {
|
||||||
topic: function() { gh.repo(Proj, this.callback) },
|
topic: function() { gh.repo(User, Repo, this.callback) },
|
||||||
'the data object can be accessed with the data() method': function(err, repo) {
|
'attributes can be accessed': function(err, repo) {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.ok(repo)
|
assert.equal(repo.owner.login, User)
|
||||||
assert.instanceOf(repo.data(), Object)
|
|
||||||
},
|
|
||||||
'attributes can be accessed with the data() method': function(err, repo) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.equal(repo.data('owner'), User)
|
|
||||||
},
|
|
||||||
'expected fields are present': function(err, repo) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(h.looksLikeARepo(repo.data()))
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
'after fetching branches': {
|
'expected fields are present': function(err, repo) {
|
||||||
topic: function() { gh.branches(Proj, this.callback) },
|
assert.ifError(err)
|
||||||
'map of branches is available': function(err, branches) {
|
assert.ok(h.looksLikeARepo(repo))
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(branches)
|
|
||||||
assert.instanceOf(branches, Object)
|
|
||||||
assert.ok('master' in branches)
|
|
||||||
},
|
|
||||||
'names and commit ids of branches are available': function(err, branches) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(Object.keys(branches).every(function(b) { return h.looksLikeASha(branches[b]) }))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'after fetching collaborators': {
|
},
|
||||||
topic: function() { gh.collaborators(Proj, this.callback) },
|
'after fetching branches': {
|
||||||
'list of collaborators is available': function(err, collaborators) {
|
topic: function() { gh.branches(User, Repo, this.callback) },
|
||||||
assert.ifError(err)
|
'list of branches is available': function(err, branches) {
|
||||||
assert.ok(collaborators && collaborators.length >= 1)
|
assert.ifError(err)
|
||||||
assert.ok(collaborators.indexOf(User) !== -1)
|
assert.ok(branches)
|
||||||
},
|
assert.instanceOf(branches, Array)
|
||||||
'names of collaborators are available': function(err, collaborators) {
|
assert.ok(branches.some(function(branch) { return branch.name === 'master' }))
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(collaborators.every(function(c) { return c && c.length >= 1 }))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'after fetching contributors': {
|
'names and commit ids of branches are available': function(err, branches) {
|
||||||
topic: function() { gh.contributors(Proj, this.callback) },
|
assert.ifError(err)
|
||||||
'list of contributors is available': function(err, contributors) {
|
assert.ok(h.looksLikeABranchList(branches))
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(contributors && contributors.length >= 1)
|
|
||||||
},
|
|
||||||
'names of contributors are available': function(err, contributors) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(contributors.every(function(c) { return h.looksLikeAContributor(c) }))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'after fetching languages': {
|
|
||||||
topic: function() { gh.languages(Proj, this.callback) },
|
|
||||||
'map of languages is available': function(err, languages) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(languages)
|
|
||||||
assert.instanceOf(languages, Object)
|
|
||||||
assert.ok('JavaScript' in languages)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'after fetching network': {
|
|
||||||
topic: function() { gh.network(Proj, this.callback) },
|
|
||||||
'map of network is available': function(err, network) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(network && network.length >= 1)
|
|
||||||
assert.ok(network.every(function(r) { return h.looksLikeARepo(r) }))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'after fetching tags': {
|
|
||||||
topic: function() { gh.tags(Proj, this.callback) },
|
|
||||||
'map of tags is available': function(err, tags) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(tags)
|
|
||||||
assert.instanceOf(tags, Object)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'after fetching watchers': {
|
|
||||||
topic: function() { gh.watchers(Proj, this.callback) },
|
|
||||||
'list of watchers is available': function(err, watchers) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(watchers && watchers.length >= 1)
|
|
||||||
assert.ok(watchers.indexOf(User) !== -1)
|
|
||||||
},
|
|
||||||
'names of watchers are available': function(err, watchers) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(watchers.every(function(w) { return w && w.length >= 1 }))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'after fetching collaborators': {
|
||||||
|
topic: function() { gh.collaborators(User, CollaboratorsRepo, this.callback) },
|
||||||
|
'list of collaborators is available': function(err, collaborators) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(collaborators && collaborators.length >= 1)
|
||||||
|
assert.ok(collaborators.some(function(c) { return c.login === User }))
|
||||||
|
},
|
||||||
|
'names of collaborators are available': function(err, collaborators) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(collaborators.every(function(c) { return h.looksLikeACollaborator(c) }))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'after fetching contributors': {
|
||||||
|
topic: function() { gh.contributors(User, Repo, this.callback) },
|
||||||
|
'list of contributors is available': function(err, contributors) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(contributors && contributors.length >= 1)
|
||||||
|
},
|
||||||
|
'names of contributors are available': function(err, contributors) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(contributors.every(function(c) { return h.looksLikeAContributor(c) }))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'after fetching languages': {
|
||||||
|
topic: function() { gh.languages(User, Repo, this.callback) },
|
||||||
|
'map of languages is available': function(err, languages) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(languages)
|
||||||
|
assert.instanceOf(languages, Object)
|
||||||
|
assert.ok('JavaScript' in languages)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'after fetching fork': {
|
||||||
|
topic: function() { gh.forks(User, ForkedRepo, this.callback) },
|
||||||
|
'list of forks is available': function(err, forks) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(forks && forks.length >= 1)
|
||||||
|
assert.ok(forks.every(function(r) { return h.looksLikeARepo(r) }))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'after fetching tags': {
|
||||||
|
topic: function() { gh.tags(User, Repo, this.callback) },
|
||||||
|
'map of tags is available': function(err, tags) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(tags)
|
||||||
|
assert.instanceOf(tags, Object)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'after fetching watchers': {
|
||||||
|
topic: function() { gh.watchers(User, Repo, this.callback) },
|
||||||
|
'list of watchers is available': function(err, watchers) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(watchers && watchers.length >= 1)
|
||||||
|
assert.ok(watchers.some(function(w) { return w.login === User }))
|
||||||
|
},
|
||||||
|
'names of watchers are available': function(err, watchers) {
|
||||||
|
assert.ifError(err)
|
||||||
|
assert.ok(watchers.every(h.looksLikeAWatcher))
|
||||||
|
}
|
||||||
|
}
|
||||||
}).export(module)
|
}).export(module)
|
||||||
|
|
|
||||||
51
vows/tree.js
51
vows/tree.js
|
|
@ -1,53 +1,18 @@
|
||||||
var gh = require('../lib')
|
var gh = require('../')
|
||||||
, vows = require('vows')
|
, vows = require('vows')
|
||||||
, assert = require('assert')
|
, assert = require('assert')
|
||||||
, h = require('./helper')
|
, h = require('./helper')
|
||||||
|
|
||||||
, User = 'samsonjs'
|
, User = 'samsonjs'
|
||||||
, Repo = 'gitter'
|
, Repo = 'gitter'
|
||||||
, Proj = User + '/' + Repo
|
|
||||||
, TreeSha = '3363be22e88e50d6dd15f9a4b904bfe41cdd22bc'
|
, TreeSha = '3363be22e88e50d6dd15f9a4b904bfe41cdd22bc'
|
||||||
|
|
||||||
vows.describe('Tree').addBatch({
|
vows.describe('Tree').addBatch({
|
||||||
'after fetching a tree': {
|
'after fetching a tree': {
|
||||||
topic: function() { gh.tree(Proj, TreeSha, this.callback) },
|
topic: function() { gh.tree(User, Repo, TreeSha, this.callback) },
|
||||||
'the data object can be accessed with the data() method': function(err, tree) {
|
'data is a git tree': function(err, tree) {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.ok(tree)
|
assert.ok(h.looksLikeATree(tree))
|
||||||
assert.instanceOf(tree.data(), Array)
|
}
|
||||||
},
|
}
|
||||||
'data is a git tree': function(err, tree) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(h.looksLikeATree(tree.blobs))
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'after fetching blobs': {
|
|
||||||
topic: function() { gh.blobs(Proj, TreeSha, this.callback) },
|
|
||||||
'list of blobs is available': function(err, blobs) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(blobs)
|
|
||||||
assert.instanceOf(blobs, Object)
|
|
||||||
assert.ok(Object.keys(blobs).length > 1)
|
|
||||||
assert.ok('package.json' in blobs)
|
|
||||||
assert.ok(Object.keys(blobs).every(function(k) { return h.looksLikeASha(blobs[k]) }))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'after fetching full blobs': {
|
|
||||||
topic: function() { gh.tree(Proj, TreeSha).getFullBlobs(this.callback) },
|
|
||||||
'full blobs are available': function(err, blobs) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(blobs)
|
|
||||||
assert.instanceOf(blobs, Array)
|
|
||||||
assert.ok(blobs.every(function(b) { return h.looksLikeABlob(b) }))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'after fetching the full tree': {
|
|
||||||
topic: function() { gh.tree(Proj, TreeSha).getFullTree(this.callback) },
|
|
||||||
'full contents of tree are available': function(err, tree) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(tree)
|
|
||||||
assert.instanceOf(tree, Array)
|
|
||||||
assert.ok(tree.every(function(b) { return h.looksLikeABlob(b) }))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).export(module)
|
}).export(module)
|
||||||
|
|
|
||||||
17
vows/user.js
17
vows/user.js
|
|
@ -1,4 +1,4 @@
|
||||||
var gh = require('../lib')
|
var gh = require('../')
|
||||||
, vows = require('vows')
|
, vows = require('vows')
|
||||||
, assert = require('assert')
|
, assert = require('assert')
|
||||||
, h = require('./helper')
|
, h = require('./helper')
|
||||||
|
|
@ -8,18 +8,9 @@ var gh = require('../lib')
|
||||||
vows.describe('User').addBatch({
|
vows.describe('User').addBatch({
|
||||||
'after fetching a user': {
|
'after fetching a user': {
|
||||||
topic: function() { gh.user(User, this.callback) },
|
topic: function() { gh.user(User, this.callback) },
|
||||||
'the data object can be accessed with the data() method': function(err, user) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.ok(user)
|
|
||||||
assert.instanceOf(user.data(), Object)
|
|
||||||
},
|
|
||||||
'attributes can be accessed with the data() method': function(err, user) {
|
|
||||||
assert.ifError(err)
|
|
||||||
assert.equal(user.data('login'), User)
|
|
||||||
},
|
|
||||||
'expected fields are present': function(err, user) {
|
'expected fields are present': function(err, user) {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.ok(h.looksLikeAUser(user.data()))
|
assert.ok(h.looksLikeAUser(user))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'after fetching their followers': {
|
'after fetching their followers': {
|
||||||
|
|
@ -30,7 +21,7 @@ vows.describe('User').addBatch({
|
||||||
},
|
},
|
||||||
'usernames of followers are available': function(err, followers) {
|
'usernames of followers are available': function(err, followers) {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.ok(followers.every(function(f) { return f && f.length > 1 }))
|
assert.ok(followers.every(h.looksLikeAFollower))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'after fetching users they follow': {
|
'after fetching users they follow': {
|
||||||
|
|
@ -41,7 +32,7 @@ vows.describe('User').addBatch({
|
||||||
},
|
},
|
||||||
'names of following users are available': function(err, following) {
|
'names of following users are available': function(err, following) {
|
||||||
assert.ifError(err)
|
assert.ifError(err)
|
||||||
assert.ok(following.every(function(f) { return f && f.length > 1 }))
|
assert.ok(following.every(h.looksLikeAFollower))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'after fetching their public repos': {
|
'after fetching their public repos': {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue