Created
August 20, 2012 23:15
-
-
Save peterhellberg/3409094 to your computer and use it in GitHub Desktop.
Find RFCs based on Alpha (app.net) user ids.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
def adn2rfc(user) | |
abort "You need to specify user on app.net" if user.nil? | |
http = Net::HTTP.new('alpha.app.net', 443) | |
http.use_ssl = true | |
res = http.request_get("/#{user}") | |
if res.code == "200" | |
rfc = res.body.match(/title="User Id (\d+)"/)[1] | |
res = Net::HTTP.new('www.faqs.org', 80).request_get("/rfcs/rfc#{rfc}.html") | |
res.code == "200" ? res.body.match(/h1>(.+)<\/h1/)[1] : "No RFC #{rfc}" | |
else | |
"No user with that name on Alpha" | |
end | |
end | |
puts adn2rfc ARGV[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Examples:
$ ruby adn2rfc.rb ralf RFC 1694 - Definitions of Managed Objects for SMDS Interfaces us
An error message is shown if no RFC was found: