0.1.0 • Published 12 years ago
hubot-cookiejar v0.1.0
hubot-cookiejar
A Hubot library for plugins to store countable items into a cookie jar.
For an example, the hubot-punjar plugin uses it to store the name of a user every time they write a shitty pun in chat. Someone reports them, and they're "forced" to deposit $1 into the pun jar.
Usage
Instantiation
{CookieJar} = require 'hubot-cookiejar'
cookiejar = new CookieJar 'oatmeal', robot.get()
cookiejar.get('item').put()
Put a give number of items into the cookie jar.
cookiejar.put('item', 5).has()
Returns if there are cookies in the jar for a given item.
cookiejar.has('item').increment()
Increment the number of cookies in the jar for a given item.
cookiejar.increment('item').summary()
Pull an array out of the cookie jar containing every item and its sum. The array is sorted descending order by the number of sum of each items.
cookies = cookiejar.summary()Output:
[ { item: 'chocolatechip', total: 6 },
{ item: 'oatmeal', total: 5 },
{ item: 'snickerdoodle', total: 3 },
{ item: 'sugar', total: 2 } ]
