Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 33 lines (31 sloc) 0.909 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# Description:
# Whois for gems, because gem names are like domains in the 90's
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot gem whois <gemname> - returns gem details if it exists
#
# Author:
# jonmagic

module.exports = (robot) ->
  robot.respond /gem whois (.*)/i, (msg) ->
    gemname = escape(msg.match[1])
    msg.http("http://rubygems.org/api/v1/gems/#{gemname}.json")
      .get() (err, res, body) ->
        try
          json = JSON.parse(body)
          msg.send " gem name: #{json.name}\n
owners: #{json.authors}\n
info: #{json.info}\n
version: #{json.version}\n
downloads: #{json.downloads}\n
homepage: #{json.homepage_uri}\n
documentation: #{json.documentation_uri}\n
source code: #{json.source_code_uri}\n"
        catch err
          msg.send "Gem not found. It will be mine. Oh yes. It will be mine. *sinister laugh*"
Something went wrong with that request. Please try again.