demirten / em-whois

Asynchronous whois based on weppos' synchronous whois gem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

em-whois Build Status

This is a container for the synchronous WHOIS gem which replaces socket communications with the EventMachine equivalent. The result is a gem permitting asynchronous WHOIS lookups.

em-whois is EventMachine-aware, meaning that it'll use asynchronous sockets when called inside the reactor, and fallback to original sockets outside the reactor context.

Supported Ruby Versions

Tested and used in production with MRI 1.9+.

em-whois relies on Ruby Fibers and em-synchrony, imposing a 1.9+ requirement.

Examples

Simple example to check domain availability via WHOIS within the EventMachine loop:

require 'em-whois'

EM.synchrony do  
  whois = Whois.whois(ARGV[0] || "github.com")
  puts whois.properties[:available?] ? "Domain Available" : "Domain Taken"

  EM.stop
end

Also take a look at examples/async_whois.rb.

License & Notes

The MIT License - Copyright (c) 2012 Mike Jarema

About

Asynchronous whois based on weppos' synchronous whois gem


Languages

Language:Ruby 100.0%