Skip to content

Commit

Permalink
Change whois.ripn.net #nameservers to return Nameserver objects
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Feb 14, 2011
2 parents 5f0e06f + 38268b6 commit 3c89227
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/whois/answer/parser/whois.ripn.net.rb
Expand Up @@ -87,10 +87,11 @@ class WhoisRipnNet < Base
#
# nserver: ns.masterhost.ru.
# nserver: ns.masterhost.ru. 217.16.20.30
#
# In both cases, always return only the name.
property_supported :nameservers do
content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten.map { |value| value.split(" ").first.chomp(".") }
content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten.map do |line|
name, ip = line.split(" ")
Answer::Nameserver.new(name.chomp('.'), ip)
end
end

end
Expand Down
14 changes: 11 additions & 3 deletions test/whois/answer/parser/whois.ripn.net_test.rb
Expand Up @@ -101,7 +101,9 @@ def test_admin_contact

def test_nameservers
parser = @klass.new(load_part('registered.txt'))
expected = %w( ns1.google.com ns2.google.com ns3.google.com ns4.google.com )
expected = %w( ns1.google.com ns2.google.com ns3.google.com ns4.google.com ).map do |ns|
Whois::Answer::Nameserver.new(ns)
end
assert_equal_and_cached expected, parser, :nameservers

parser = @klass.new(load_part('available.txt'))
Expand All @@ -111,7 +113,11 @@ def test_nameservers

def test_nameservers_with_ip
parser = @klass.new(load_part('property_nameservers_with_ip.txt'))
expected = %w( ns.masterhost.ru ns1.masterhost.ru ns2.masterhost.ru )
names = %w( ns.masterhost.ru ns1.masterhost.ru ns2.masterhost.ru )
ips = %w( 217.16.20.30 217.16.16.30 217.16.22.30 )
expected = Hash[names.zip(ips)].map do |name, ip|
Whois::Answer::Nameserver.new(name, ip)
end
assert_equal_and_cached expected, parser, :nameservers
end

Expand Down Expand Up @@ -209,7 +215,9 @@ def test_admin_contact

def test_nameservers
parser = @klass.new(load_part('registered.txt'))
expected = %w( ns1073.hostgator.com ns1074.hostgator.com )
expected = %w( ns1073.hostgator.com ns1074.hostgator.com ).map do |ns|
Whois::Answer::Nameserver.new(ns)
end
assert_equal_and_cached expected, parser, :nameservers

parser = @klass.new(load_part('available.txt'))
Expand Down

0 comments on commit 3c89227

Please sign in to comment.