Sha256: dff25a2e4ba5f4c79b9b55da705d7cee51d36e01832cffd0246e51f91ea04595

Contents?: true

Size: 795 Bytes

Versions: 3

Compression:

Stored size: 795 Bytes

Contents

require "ansi"
require "date"
require "whois"

class DomainCheck::SingleCheck
  def initialize(domain)
    @domain = domain.downcase
  end

  def check
    whois = Whois.whois(@domain)
    if whois.available?
      { :domain => @domain, :status => :available }
    else
      result = { :domain => @domain, :status => :registered }

      contact = whois.registrant_contact || whois.admin_contact ||
        whois.technical_contact || whois.contacts.first
      result[:contact_name] = contact.name if contact
      result[:contact_email] = contact.email if contact

      result[:created_at] = whois.created_on
      result[:expires_at] = whois.expires_on

      yield(result) if block_given?
      result
    end
  rescue Whois::Error
    { :domain => @domain, :status => :unknown }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
domain_check-0.0.3 lib/domain_check/single_check.rb
domain_check-0.0.2 lib/domain_check/single_check.rb
domain_check-0.0.1 lib/domain_check/single_check.rb