Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update whois.nic.lv parser #146

Merged
merged 5 commits into from
Feb 3, 2012
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/whois/record/parser/whois.nic.lv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Whois
class Record
class Parser

#
# = whois.nic.lv parser
#
# Parser for the whois.nic.lv server.
Expand All @@ -36,27 +35,25 @@ class WhoisNicLv < Base
end

property_supported :available? do
!!(content_for_scanner =~ /%ERR - Nothing found/)
!!(content_for_scanner =~ /Status: free/)
end

property_supported :registered? do
!available?
end


property_not_supported :created_on

property_supported :updated_on do
if content_for_scanner =~ /changed:\s+(.*)\n/
if content_for_scanner =~ /Changed:\s+(.*)\n/
Time.parse($1.split(" ", 2).last)
end
end

property_not_supported :expires_on


property_supported :nameservers do
content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten.map do |name|
content_for_scanner.scan(/Nserver:\s+(.+)\n/).flatten.map do |name|
Record::Nameserver.new(name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't remove extra lines 46 and 57, they exists to group methods by scope.

end
end
Expand Down
23 changes: 0 additions & 23 deletions spec/fixtures/responses/whois.nic.lv/status_available.expected

This file was deleted.

7 changes: 0 additions & 7 deletions spec/fixtures/responses/whois.nic.lv/status_available.txt

This file was deleted.

8 changes: 8 additions & 0 deletions spec/fixtures/responses/whois.nic.lv/status_free.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#status
should: %s == :available

#available?
should: %s == true

#registered?
should: %s == false
6 changes: 6 additions & 0 deletions spec/fixtures/responses/whois.nic.lv/status_free.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Domain]
Domain: farug0e7er.lv
Status: free

[Whois]
Updated: 2012-01-30 12:12:27.309824
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#registered?
should: %s == true


#created_on
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separator exists to group properties by scope. Please restore line 10 and 21.

should: %s raise_error(Whois::PropertyNotSupported)

Expand All @@ -18,7 +17,6 @@
#expires_on
should: %s raise_error(Whois::PropertyNotSupported)


#nameservers
should: %s (array)
should: %s have(4).items
Expand Down
60 changes: 32 additions & 28 deletions spec/fixtures/responses/whois.nic.lv/status_registered.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
[Domain]
Domain: google.lv
Status: active
Changed: 2009-06-10T00:00:00+03:00

% Information from TLD .lv whois service.
% Please visit http://www.nic.lv for more information.
[Holder]
Type: Legal person
Name: Google, Inc.
Email: dns-admin@google.com
Fax: +1.6502530001
Phone: +1.6502530000
Address: 1600 Amphitheatre Parkway, Mountain View, CA, 94043, USA
RegNr: None

domain: google.lv
descr: Google, Inc.
admin-c: 9370-LUMII
tech-c: 13942-LUMII
nserver: ns1.google.com
nserver: ns2.google.com
nserver: ns3.google.com
nserver: ns4.google.com
changed: dns-reg@nic.lv 20090610
source: LUMII

person: <hidden>
address: none
phone: +12083895740
fax-no: +12083895799
e-mail: ccops@markmonitor.com
nic-hdl: 13942-LUMII
source: LUMII

person: <hidden>
address: none
phone: +1 650 330 0100
fax-no: +1 650 618 1499
e-mail: dns-admin@google.com
nic-hdl: 9370-LUMII
source: LUMII
[Tech]
Type: Natural person
Email: ccops@markmonitor.com
Fax: +12083895799
Phone: +12083895740

[Registrar]
Type: Legal person
Name: MarkMonitor Inc.
Email: ccops@markmonitor.com
Fax: +12083895771
Phone: +12083895740
Address: 391 N.Ancestor place, Boise, ID 83704 Idaho, USA
RegNr: 82-0513468

[Nservers]
Nserver: ns1.google.com
Nserver: ns2.google.com
Nserver: ns3.google.com
Nserver: ns4.google.com

[Whois]
Updated: 2012-01-30T12:12:27.309824+00:00

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# encoding: utf-8

# This file is autogenerated. Do not edit it manually.
# If you want change the content of this file, edit
#
# /spec/fixtures/responses/whois.nic.lv/status_free.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#

require 'spec_helper'
require 'whois/record/parser/whois.nic.lv.rb'

describe Whois::Record::Parser::WhoisNicLv, "status_free.expected" do

before(:each) do
file = fixture("responses", "whois.nic.lv/status_free.txt")
part = Whois::Record::Part.new(:body => File.read(file))
@parser = klass.new(part)
end

describe "#status" do
it do
@parser.status.should == :available
end
end
describe "#available?" do
it do
@parser.available?.should == true
end
end
describe "#registered?" do
it do
@parser.registered?.should == false
end
end
end