custom label regex
This commit is contained in:
parent
ffff8f76d7
commit
20257e0875
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env coffee
|
#!/usr/bin/env coffee
|
||||||
module.exports =
|
module.exports =
|
||||||
'datetime': /^(\d{4}-\d{2}-\d{2})T(.*)/
|
'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) ->
|
constructor: (opts) ->
|
||||||
( @[k] = v for k, v of 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) =>
|
render: (cb) =>
|
||||||
self = @
|
self = @
|
||||||
|
|
||||||
|
@ -36,10 +41,12 @@ class exports.Repo
|
||||||
# Filter them to labeled ones.
|
# Filter them to labeled ones.
|
||||||
(all, cb) ->
|
(all, cb) ->
|
||||||
async.map all, (array, 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 ]
|
cb err, [ filtered, total ]
|
||||||
, (err, [ open, closed ]) ->
|
, (err, [ open, closed ]) ->
|
||||||
return cb err if err
|
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.
|
# Save the open/closed on us first.
|
||||||
self.issues =
|
self.issues =
|
||||||
closed: { points: closed[1], data: closed[0] }
|
closed: { points: closed[1], data: closed[0] }
|
||||||
|
|
|
@ -26,9 +26,6 @@ request = ({ protocol, host, token, repo }, query, path, cb) ->
|
||||||
# Make the query params.
|
# Make the query params.
|
||||||
q = ( "#{k}=#{v}" for k, v of query ).join('&')
|
q = ( "#{k}=#{v}" for k, v of query ).join('&')
|
||||||
|
|
||||||
host ?= 'api.github.com'
|
|
||||||
protocol ?= 'https'
|
|
||||||
|
|
||||||
req = sa
|
req = sa
|
||||||
.get("#{protocol}://#{host}/repos/#{repo}/#{path}?#{q}")
|
.get("#{protocol}://#{host}/repos/#{repo}/#{path}?#{q}")
|
||||||
.set('Content-Type', 'application/json')
|
.set('Content-Type', 'application/json')
|
||||||
|
|
Loading…
Reference in New Issue