Skip to content
This repository has been archived by the owner on Oct 24, 2019. It is now read-only.

Commit

Permalink
Coffee rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Aug 20, 2015
1 parent 4933c80 commit 574a2c3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 15 deletions.
8 changes: 8 additions & 0 deletions examples/show-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@
return console.log(members);
});

gitlab.projects.milestones.list(projectId, {
per_page: 100
}, function(milestones) {
console.log("");
console.log("=== Milestones ===");
return console.log(milestones);
});

}).call(this);
8 changes: 1 addition & 7 deletions lib/ApiBaseHTTP.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@
ApiBaseHTTP.prototype.fn_wrapper = function(fn) {
return (function(_this) {
return function(err, response, ret) {
var arity, ref;
if (err) {
debug('an error has occured', err);
if ((400 <= (ref = err.statusCode) && ref <= 499)) {
throw "Authorisation error. " + err.statusCode + ". Check your key.";
}
}
var arity;
arity = fn.length;
switch (arity) {
case 1:
Expand Down
48 changes: 40 additions & 8 deletions lib/Models/ProjectMilestones.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,60 @@
Utils = require('../Utils');

ProjectMilestones = (function(superClass) {
var list;

extend(ProjectMilestones, superClass);

function ProjectMilestones() {
this.update = bind(this.update, this);
this.add = bind(this.add, this);
this.show = bind(this.show, this);
this.list = bind(this.list, this);
this.all = bind(this.all, this);
return ProjectMilestones.__super__.constructor.apply(this, arguments);
}

ProjectMilestones.prototype.list = function(projectId, fn) {
list = function(projectId, fn) {
if (fn == null) {
fn = null;
}
this.debug("Projects::milestones()");
return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/milestones", (function(_this) {
return function(data) {
if (fn) {
return fn(data);
console.log('DEPRECATED: milestone.list. Use milestone.all instead');
return this.all.apply(this, arguments);
};

ProjectMilestones.prototype.all = function(projectId, fn) {
var cb, data, params;
if (fn == null) {
fn = null;
}
this.debug("Projects::Milestones::all()");
params = {};
if (params.page == null) {
params.page = 1;
}
if (params.per_page == null) {
params.per_page = 100;
}
data = [];
cb = (function(_this) {
return function(err, retData) {
if (err) {
if (fn) {
return fn(retData || data);
}
} else if (retData.length === params.per_page) {
_this.debug("Recurse Projects::Milestones::all()");
data = data.concat(retData);
params.page++;
return _this.get("projects/" + (Utils.parseProjectId(projectId)) + "/milestones", params, cb);
} else {
data = data.concat(retData);
if (fn) {
return fn(data);
}
}
};
})(this));
})(this);
return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/milestones", params, cb);
};

ProjectMilestones.prototype.show = function(projectId, milestoneId, fn) {
Expand Down

0 comments on commit 574a2c3

Please sign in to comment.