Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

There's a gem for that! #2

Merged
merged 1 commit into from
Oct 25, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/scripts/rubygems.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Find a rubygem from rubygems.org
#
# hubot <there's a gem for> that - Returns a link to a gem on rubygems.org
#

module.exports = (robot) ->
robot.respond /there's a gem for (.*)/i, (msg) ->
search = escape(msg.match[1])
msg.http('https://rubygems.org/api/v1/search.json')
.query(query: search)
.get() (err, res, body) ->
results = JSON.parse(body)
result = results[0]
msg.send "https://rubygems.org/gems/#{result.name}"