class BitterDomain::DomainChecker
Attributes
available[R]
errors[R]
tested[R]
Public Class Methods
new(domains)
click to toggle source
# File lib/bitter_domain/domain_checker.rb, line 8 def initialize(domains) @domains = domains @available = [] @errors = [] @tested = [] @whois = Whois::Client.new @error_msgs = [] end
Public Instance Methods
print_available()
click to toggle source
# File lib/bitter_domain/domain_checker.rb, line 41 def print_available @available.each { |domain| puts domain } puts "No available domains" if @available.empty? end
print_verbose()
click to toggle source
# File lib/bitter_domain/domain_checker.rb, line 17 def print_verbose puts "\n\nHere are all the tested domains\n".blue @tested.each { |domain| puts domain } if @errors.any? puts "\n\nHere are all of the domains that errored out\n".red @errors.each { |domain| puts domain } end if @error_msgs.any? puts "\n\nHere are the error messages\n".red @error_msgs.each { |msg| puts msg } end rejected = @tested - @available if rejected.any? puts "\n\nHere are the rejected domains".yellow rejected.each { |dom| puts dom } end puts "\n\nHere are the available domains\n".green print_available end
retry()
click to toggle source
# File lib/bitter_domain/domain_checker.rb, line 50 def retry copies = @errors.dup @errors = [] query_domains(copies) end
test_domains()
click to toggle source
# File lib/bitter_domain/domain_checker.rb, line 46 def test_domains query_domains(@domains) end
Private Instance Methods
query_domains(domains)
click to toggle source
# File lib/bitter_domain/domain_checker.rb, line 59 def query_domains(domains) domains.each do |url| begin record = @whois.lookup(url) @tested.push(url) is_available = record.parser.available? @available.push(url) if is_available rescue Exception => boom @error_msgs.push(boom) @errors.push(url) end end end