diff --git a/src/modules/regex.coffee b/src/modules/regex.coffee index 2099c68..401ea06 100644 --- a/src/modules/regex.coffee +++ b/src/modules/regex.coffee @@ -1,4 +1,4 @@ #!/usr/bin/env coffee module.exports = 'datetime': /^(\d{4}-\d{2}-\d{2})T(.*)/ - 'size_label': /size (\d+)$/ \ No newline at end of file + 'size_label': /^size (\d+)$/ \ No newline at end of file diff --git a/src/modules/repo.coffee b/src/modules/repo.coffee index 9a62007..09191d1 100644 --- a/src/modules/repo.coffee +++ b/src/modules/repo.coffee @@ -18,6 +18,11 @@ class exports.Repo constructor: (opts) -> ( @[k] = v for k, v of opts ) + # Defaults. + @host ?= 'api.github.com' + @protocol ?= 'https' + @size_label = new RegExp(@size_label) or reg.size_label + render: (cb) => self = @ @@ -36,10 +41,12 @@ class exports.Repo # Filter them to labeled ones. (all, cb) -> async.map all, (array, cb) -> - issues.filter array, reg.size_label, (err, warn, filtered, total) -> + issues.filter array, self.size_label, (err, warn, filtered, total) -> cb err, [ filtered, total ] , (err, [ open, closed ]) -> return cb err if err + # Empty? + return cb 'No matching issues found' if open[1] + closed[1] is 0 # Save the open/closed on us first. self.issues = closed: { points: closed[1], data: closed[0] } diff --git a/src/modules/request.coffee b/src/modules/request.coffee index bd38a4f..ddb51a5 100644 --- a/src/modules/request.coffee +++ b/src/modules/request.coffee @@ -26,9 +26,6 @@ request = ({ protocol, host, token, repo }, query, path, cb) -> # Make the query params. q = ( "#{k}=#{v}" for k, v of query ).join('&') - host ?= 'api.github.com' - protocol ?= 'https' - req = sa .get("#{protocol}://#{host}/repos/#{repo}/#{path}?#{q}") .set('Content-Type', 'application/json')