Comparing version 0.2.14 to 0.2.15
@@ -18,4 +18,2 @@ #!/usr/bin/env node | ||
var Url = require("url"); | ||
var Optimist = require("optimist"); | ||
var Util = require("./util"); | ||
@@ -43,2 +41,45 @@ | ||
function prepareApi(struct, baseType) { | ||
if (!baseType) | ||
baseType = ""; | ||
Object.keys(struct).sort().forEach(function(routePart) { | ||
var block = struct[routePart]; | ||
if (!block) | ||
return; | ||
var messageType = baseType + "/" + routePart; | ||
if (block.url && block.params) { | ||
// we ended up at an API definition part! | ||
var parts = messageType.split("/"); | ||
var section = Util.toCamelCase(parts[1]); | ||
if (!block.method) { | ||
throw new Error("No HTTP method specified for " + messageType + | ||
"in section " + section); | ||
} | ||
// add the handler to the sections | ||
if (!sections[section]) { | ||
sections[section] = []; | ||
} | ||
parts.splice(0, 2); | ||
var funcName = Util.toCamelCase(parts.join("-")); | ||
apidocs += createComment(section, funcName, block); | ||
// add test to the testSections | ||
if (!testSections[section]) | ||
testSections[section] = []; | ||
testSections[section].push(TestHandlerTpl | ||
.replace("<%name%>", block.method + " " + block.url + " (" + funcName + ")") | ||
.replace("<%funcName%>", section + "." + funcName) | ||
.replace("<%params%>", getParams(block.params, " ")) | ||
); | ||
} | ||
else { | ||
// recurse into this block next: | ||
prepareApi(block, messageType); | ||
} | ||
}); | ||
} | ||
function createComment(section, funcName, block) { | ||
@@ -58,2 +99,3 @@ var method = block['method'].toLowerCase(); | ||
" * @apiName " + funcDisplayName, | ||
" * @apiDescription " + block['description'], | ||
" * @apiGroup " + section, | ||
@@ -100,3 +142,3 @@ " *" | ||
commentLines.push(" * @apiExample {js} ex:\ngithub." + section + "." + funcName + "({ ... });"); | ||
commentLines.push(" * @apiExample {js} ex:\ngithub." + section + "." + funcName + "({ ... });"); | ||
@@ -132,45 +174,2 @@ return commentLines.join("\n") + "\n */\n\n"; | ||
function prepareApi(struct, baseType) { | ||
if (!baseType) | ||
baseType = ""; | ||
Object.keys(struct).sort().forEach(function(routePart) { | ||
var block = struct[routePart]; | ||
if (!block) | ||
return; | ||
var messageType = baseType + "/" + routePart; | ||
if (block.url && block.params) { | ||
// we ended up at an API definition part! | ||
var parts = messageType.split("/"); | ||
var section = Util.toCamelCase(parts[1]); | ||
if (!block.method) { | ||
throw new Error("No HTTP method specified for " + messageType + | ||
"in section " + section); | ||
} | ||
// add the handler to the sections | ||
if (!sections[section]) { | ||
sections[section] = []; | ||
} | ||
parts.splice(0, 2); | ||
var funcName = Util.toCamelCase(parts.join("-")); | ||
apidocs += createComment(section, funcName, block); | ||
// add test to the testSections | ||
if (!testSections[section]) | ||
testSections[section] = []; | ||
testSections[section].push(TestHandlerTpl | ||
.replace("<%name%>", block.method + " " + block.url + " (" + funcName + ")") | ||
.replace("<%funcName%>", section + "." + funcName) | ||
.replace("<%params%>", getParams(block.params, " ")) | ||
); | ||
} | ||
else { | ||
// recurse into this block next: | ||
prepareApi(block, messageType); | ||
} | ||
}); | ||
} | ||
Util.log("Converting routes to functions"); | ||
@@ -177,0 +176,0 @@ prepareApi(routes); |
{ | ||
"name": "github4", | ||
"version": "0.2.14", | ||
"version": "0.2.15", | ||
"description": "NodeJS wrapper for the GitHub API", | ||
@@ -20,6 +20,6 @@ "author": "Mike de Boer <info@mikedeboer.nl>", | ||
], | ||
"homepage": "https://github.com/kaizensoze/github4", | ||
"homepage": "https://github.com/kaizensoze/node-github", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kaizensoze/github4.git" | ||
"url": "https://github.com/kaizensoze/node-github.git" | ||
}, | ||
@@ -35,6 +35,3 @@ "engine": { | ||
"devDependencies": { | ||
"async": "^0.9.0", | ||
"mocha": "~1.13.0", | ||
"optimist": "~0.6.0", | ||
"should": "^8.0.2" | ||
"mocha": "~1.13.0" | ||
}, | ||
@@ -53,3 +50,4 @@ "main": ".", | ||
"apidoc": { | ||
"title": "github4", | ||
"title": "node-github", | ||
"name": "node-github", | ||
"template": { | ||
@@ -56,0 +54,0 @@ "withCompare": false |
@@ -42,4 +42,4 @@ /* | ||
it("should successfully execute GET /orgs/:org/events (getFromOrg)", function(next) { | ||
client.events.getFromOrg( | ||
it("should successfully execute GET /orgs/:org/events (getForOrg)", function(next) { | ||
client.events.getForOrg( | ||
{ | ||
@@ -58,4 +58,4 @@ org: "String", | ||
it("should successfully execute GET /repos/:user/:repo/events (getFromRepo)", function(next) { | ||
client.events.getFromRepo( | ||
it("should successfully execute GET /repos/:user/:repo/events (getForRepo)", function(next) { | ||
client.events.getForRepo( | ||
{ | ||
@@ -75,4 +75,4 @@ user: "String", | ||
it("should successfully execute GET /repos/:user/:repo/issues/events (getFromRepoIssues)", function(next) { | ||
client.events.getFromRepoIssues( | ||
it("should successfully execute GET /repos/:user/:repo/issues/events (getForRepoIssues)", function(next) { | ||
client.events.getForRepoIssues( | ||
{ | ||
@@ -92,4 +92,4 @@ user: "String", | ||
it("should successfully execute GET /networks/:user/:repo/events (getFromRepoNetwork)", function(next) { | ||
client.events.getFromRepoNetwork( | ||
it("should successfully execute GET /networks/:user/:repo/events (getForRepoNetwork)", function(next) { | ||
client.events.getForRepoNetwork( | ||
{ | ||
@@ -109,4 +109,4 @@ user: "String", | ||
it("should successfully execute GET /users/:user/events (getFromUser)", function(next) { | ||
client.events.getFromUser( | ||
it("should successfully execute GET /users/:user/events (getForUser)", function(next) { | ||
client.events.getForUser( | ||
{ | ||
@@ -125,4 +125,4 @@ user: "String", | ||
it("should successfully execute GET /users/:user/events/orgs/:org (getFromUserOrg)", function(next) { | ||
client.events.getFromUserOrg( | ||
it("should successfully execute GET /users/:user/events/orgs/:org (getForUserOrg)", function(next) { | ||
client.events.getForUserOrg( | ||
{ | ||
@@ -142,4 +142,4 @@ user: "String", | ||
it("should successfully execute GET /users/:user/events/public (getFromUserPublic)", function(next) { | ||
client.events.getFromUserPublic( | ||
it("should successfully execute GET /users/:user/events/public (getForUserPublic)", function(next) { | ||
client.events.getForUserPublic( | ||
{ | ||
@@ -146,0 +146,0 @@ user: "String", |
@@ -44,5 +44,5 @@ /* | ||
{ | ||
files: "Json", | ||
description: "String", | ||
public: "Boolean", | ||
files: "Json" | ||
public: "Boolean" | ||
}, | ||
@@ -98,15 +98,2 @@ function(err, res) { | ||
it("should successfully execute DELETE /gists/:id/star (deleteStar)", function(next) { | ||
client.gists.deleteStar( | ||
{ | ||
id: "String" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute PATCH /gists/:id (edit)", function(next) { | ||
@@ -142,3 +129,3 @@ client.gists.edit( | ||
it("should successfully execute POST /gists/:id/fork (fork)", function(next) { | ||
it("should successfully execute POST /gists/:id/forks (fork)", function(next) { | ||
client.gists.fork( | ||
@@ -211,5 +198,18 @@ { | ||
it("should successfully execute GET /users/:user/gists (getFromUser)", function(next) { | ||
client.gists.getFromUser( | ||
it("should successfully execute GET /gists/:id/commits (getCommits)", function(next) { | ||
client.gists.getCommits( | ||
{ | ||
id: "String" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute GET /users/:user/gists (getForUser)", function(next) { | ||
client.gists.getForUser( | ||
{ | ||
user: "String", | ||
@@ -228,5 +228,20 @@ page: "Number", | ||
it("should successfully execute GET /gists/public (public)", function(next) { | ||
client.gists.public( | ||
it("should successfully execute GET /gists/:id/forks (getForks)", function(next) { | ||
client.gists.getForks( | ||
{ | ||
id: "String", | ||
page: "Number", | ||
per_page: "Number" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute GET /gists/public (getPublic)", function(next) { | ||
client.gists.getPublic( | ||
{ | ||
since: "Date" | ||
@@ -242,2 +257,29 @@ }, | ||
it("should successfully execute GET /gists/:id/:sha (getRevision)", function(next) { | ||
client.gists.getRevision( | ||
{ | ||
id: "String", | ||
sha: "String" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute GET /gists/starred (getStarred)", function(next) { | ||
client.gists.getStarred( | ||
{ | ||
since: "Date" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute PUT /gists/:id/star (star)", function(next) { | ||
@@ -256,6 +298,6 @@ client.gists.star( | ||
it("should successfully execute GET /gists/starred (starred)", function(next) { | ||
client.gists.starred( | ||
it("should successfully execute DELETE /gists/:id/star (unStar)", function(next) { | ||
client.gists.unStar( | ||
{ | ||
since: "Date" | ||
id: "String" | ||
}, | ||
@@ -262,0 +304,0 @@ function(err, res) { |
@@ -129,7 +129,8 @@ /* | ||
it("should successfully execute GET /repos/:user/:repo/git/refs (getAllReferences)", function(next) { | ||
client.gitdata.getAllReferences( | ||
it("should successfully execute GET /repos/:user/:repo/git/blobs/:sha (getBlob)", function(next) { | ||
client.gitdata.getBlob( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
sha: "String", | ||
page: "Number", | ||
@@ -146,10 +147,8 @@ per_page: "Number" | ||
it("should successfully execute GET /repos/:user/:repo/git/blobs/:sha (getBlob)", function(next) { | ||
client.gitdata.getBlob( | ||
it("should successfully execute GET /repos/:user/:repo/git/commits/:sha (getCommit)", function(next) { | ||
client.gitdata.getCommit( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
sha: "String", | ||
page: "Number", | ||
per_page: "Number" | ||
sha: "String" | ||
}, | ||
@@ -164,8 +163,8 @@ function(err, res) { | ||
it("should successfully execute GET /repos/:user/:repo/git/commits/:sha (getCommit)", function(next) { | ||
client.gitdata.getCommit( | ||
it("should successfully execute GET /repos/:user/:repo/git/refs/:ref (getReference)", function(next) { | ||
client.gitdata.getReference( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
sha: "String" | ||
ref: "String" | ||
}, | ||
@@ -180,8 +179,9 @@ function(err, res) { | ||
it("should successfully execute GET /repos/:user/:repo/git/refs/:ref (getReference)", function(next) { | ||
client.gitdata.getReference( | ||
it("should successfully execute GET /repos/:user/:repo/git/refs (getReferences)", function(next) { | ||
client.gitdata.getReferences( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
ref: "String" | ||
page: "Number", | ||
per_page: "Number" | ||
}, | ||
@@ -211,2 +211,18 @@ function(err, res) { | ||
it("should successfully execute GET /repos/:user/:repo/git/refs/tags (getTags)", function(next) { | ||
client.gitdata.getTags( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
page: "Number", | ||
per_page: "Number" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute GET /repos/:user/:repo/git/trees/:sha (getTree)", function(next) { | ||
@@ -213,0 +229,0 @@ client.gitdata.getTree( |
@@ -28,2 +28,17 @@ /* | ||
it("should successfully execute GET /repos/:user/:repo/assignees/:assignee (checkAssignee)", function(next) { | ||
client.issues.checkAssignee( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
assignee: "String" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute POST /repos/:user/:repo/issues (create)", function(next) { | ||
@@ -180,2 +195,17 @@ client.issues.create( | ||
it("should successfully execute GET /repos/:user/:repo/issues/:number (get)", function(next) { | ||
client.issues.get( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
number: "Number" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute GET /issues (getAll)", function(next) { | ||
@@ -219,2 +249,16 @@ client.issues.getAll( | ||
it("should successfully execute GET /repos/:user/:repo/assignees (getAssignees)", function(next) { | ||
client.issues.getAssignees( | ||
{ | ||
user: "String", | ||
repo: "String" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute GET /repos/:user/:repo/issues/comments/:id (getComment)", function(next) { | ||
@@ -252,2 +296,21 @@ client.issues.getComment( | ||
it("should successfully execute GET /repos/:user/:repo/issues/comments (getCommentsForRepo)", function(next) { | ||
client.issues.getCommentsForRepo( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
sort: "String", | ||
direction: "String", | ||
since: "Date", | ||
page: "Number", | ||
per_page: "Number" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
it("should successfully execute GET /repos/:user/:repo/issues/events/:id (getEvent)", function(next) { | ||
@@ -285,8 +348,9 @@ client.issues.getEvent( | ||
it("should successfully execute GET /repos/:user/:repo/issues/:number/labels (getIssueLabels)", function(next) { | ||
client.issues.getIssueLabels( | ||
it("should successfully execute GET /repos/:user/:repo/issues/events (getEventsForRepo)", function(next) { | ||
client.issues.getEventsForRepo( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
number: "Number" | ||
page: "Number", | ||
per_page: "Number" | ||
}, | ||
@@ -301,8 +365,13 @@ function(err, res) { | ||
it("should successfully execute GET /repos/:user/:repo/labels/:name (getLabel)", function(next) { | ||
client.issues.getLabel( | ||
it("should successfully execute GET /orgs/:org/issues (getForOrg)", function(next) { | ||
client.issues.getForOrg( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
name: "String" | ||
filter: "String", | ||
state: "String", | ||
labels: "String", | ||
sort: "String", | ||
direction: "String", | ||
since: "Date", | ||
page: "Number", | ||
per_page: "Number" | ||
}, | ||
@@ -317,7 +386,16 @@ function(err, res) { | ||
it("should successfully execute GET /repos/:user/:repo/labels (getLabels)", function(next) { | ||
client.issues.getLabels( | ||
it("should successfully execute GET /repos/:user/:repo/issues (getForRepo)", function(next) { | ||
client.issues.getForRepo( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
milestone: "String", | ||
state: "String", | ||
assignee: "String", | ||
creator: "String", | ||
mentioned: "String", | ||
labels: "String", | ||
sort: "String", | ||
direction: "String", | ||
since: "Date", | ||
page: "Number", | ||
@@ -334,8 +412,13 @@ per_page: "Number" | ||
it("should successfully execute GET /repos/:user/:repo/milestones/:number (getMilestone)", function(next) { | ||
client.issues.getMilestone( | ||
it("should successfully execute GET /user/issues (getForUser)", function(next) { | ||
client.issues.getForUser( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
number: "Number" | ||
filter: "String", | ||
state: "String", | ||
labels: "String", | ||
sort: "String", | ||
direction: "String", | ||
since: "Date", | ||
page: "Number", | ||
per_page: "Number" | ||
}, | ||
@@ -350,9 +433,8 @@ function(err, res) { | ||
it("should successfully execute GET /repos/:user/:repo/issues/events (getRepoEvents)", function(next) { | ||
client.issues.getRepoEvents( | ||
it("should successfully execute GET /repos/:user/:repo/issues/:number/labels (getIssueLabels)", function(next) { | ||
client.issues.getIssueLabels( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
page: "Number", | ||
per_page: "Number" | ||
number: "Number" | ||
}, | ||
@@ -367,8 +449,8 @@ function(err, res) { | ||
it("should successfully execute GET /repos/:user/:repo/issues/:number (getRepoIssue)", function(next) { | ||
client.issues.getRepoIssue( | ||
it("should successfully execute GET /repos/:user/:repo/labels/:name (getLabel)", function(next) { | ||
client.issues.getLabel( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
number: "Number" | ||
name: "String" | ||
}, | ||
@@ -383,10 +465,7 @@ function(err, res) { | ||
it("should successfully execute GET /repos/:user/:repo/issues/comments (repoComments)", function(next) { | ||
client.issues.repoComments( | ||
it("should successfully execute GET /repos/:user/:repo/labels (getLabels)", function(next) { | ||
client.issues.getLabels( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
sort: "String", | ||
direction: "String", | ||
since: "Date", | ||
page: "Number", | ||
@@ -403,18 +482,8 @@ per_page: "Number" | ||
it("should successfully execute GET /repos/:user/:repo/issues (repoIssues)", function(next) { | ||
client.issues.repoIssues( | ||
it("should successfully execute GET /repos/:user/:repo/milestones/:number (getMilestone)", function(next) { | ||
client.issues.getMilestone( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
milestone: "String", | ||
state: "String", | ||
assignee: "String", | ||
creator: "String", | ||
mentioned: "String", | ||
labels: "String", | ||
sort: "String", | ||
direction: "String", | ||
since: "Date", | ||
page: "Number", | ||
per_page: "Number" | ||
number: "Number" | ||
}, | ||
@@ -421,0 +490,0 @@ function(err, res) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
403398
1
11964