Move "GitHub" special-case to _.capitalize. Add specs.

This commit is contained in:
Nathan Sobo
2013-03-14 11:35:06 -06:00
parent 634117ed66
commit a1882ffd1f
2 changed files with 10 additions and 5 deletions

View File

@@ -53,18 +53,19 @@ _.mixin
string.replace(regex, "\\$&");
humanizeEventName: (eventName, eventDoc) ->
return "GitHub" if eventName.toLowerCase() is "github"
[namespace, event] = eventName.split(':')
return _.capitalize(namespace) unless event?
namespaceDoc = _.undasherize(namespace)
eventDoc ||= _.undasherize(event)
namespaceDoc = _.undasherize(namespace)
eventDoc ?= _.undasherize(event)
"#{namespaceDoc}: #{eventDoc}"
capitalize: (word) ->
word[0].toUpperCase() + word[1..]
if word.toLowerCase() is 'github'
'GitHub'
else
word[0].toUpperCase() + word[1..]
pluralize: (count=0, singular, plural=singular+'s') ->
if count is 1