custom label regex

This commit is contained in:
Radek Stepan 2013-08-21 14:28:42 +01:00
parent ffff8f76d7
commit 20257e0875
3 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env coffee
module.exports =
'datetime': /^(\d{4}-\d{2}-\d{2})T(.*)/
'size_label': /size (\d+)$/
'size_label': /^size (\d+)$/

View File

@ -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] }

View File

@ -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')