custom label regex
This commit is contained in:
parent
ffff8f76d7
commit
20257e0875
|
@ -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+)$/
|
|
@ -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] }
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue