whois 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/.rspec +0 -1
  2. data/Rakefile +25 -1
  3. data/lib/whois/definitions/tlds.rb +1 -1
  4. data/lib/whois/record/parser/base.rb +1 -1
  5. data/lib/whois/record/parser/base_afilias.rb +2 -2
  6. data/lib/whois/record/parser/jobswhois.verisign-grs.com.rb +1 -1
  7. data/lib/whois/record/parser/whois.audns.net.au.rb +81 -16
  8. data/lib/whois/record/parser/whois.biz.rb +1 -1
  9. data/lib/whois/record/parser/whois.cctld.by.rb +107 -0
  10. data/lib/whois/record/parser/whois.centralnic.com.rb +1 -1
  11. data/lib/whois/record/parser/whois.cira.ca.rb +103 -51
  12. data/lib/whois/record/parser/whois.cnnic.cn.rb +1 -1
  13. data/lib/whois/record/parser/whois.crsnic.net.rb +1 -1
  14. data/lib/whois/record/parser/whois.denic.de.rb +1 -1
  15. data/lib/whois/record/parser/whois.dns.hr.rb +2 -2
  16. data/lib/whois/record/parser/whois.domainregistry.ie.rb +77 -21
  17. data/lib/whois/record/parser/whois.domainregistry.my.rb +5 -8
  18. data/lib/whois/record/parser/whois.dreamhost.com.rb +1 -1
  19. data/lib/whois/record/parser/whois.enom.com.rb +124 -0
  20. data/lib/whois/record/parser/whois.fi.rb +1 -1
  21. data/lib/whois/record/parser/whois.iana.org.rb +1 -1
  22. data/lib/whois/record/parser/whois.nc.rb +2 -2
  23. data/lib/whois/record/parser/whois.nic.cc.rb +1 -1
  24. data/lib/whois/record/parser/whois.nic.hu.rb +1 -1
  25. data/lib/whois/record/parser/whois.nic.it.rb +1 -1
  26. data/lib/whois/record/parser/whois.nic.lk.rb +1 -1
  27. data/lib/whois/record/parser/whois.nic.tv.rb +1 -1
  28. data/lib/whois/record/parser/whois.registry.qa.rb +1 -1
  29. data/lib/whois/record/parser/whois.rnids.rs.rb +4 -4
  30. data/lib/whois/record/parser/whois.smallregistry.net.rb +1 -1
  31. data/lib/whois/record/parser/whois.tld.ee.rb +1 -1
  32. data/lib/whois/record/parser/whois.ua.rb +1 -1
  33. data/lib/whois/record/scanners/afilias.rb +60 -0
  34. data/lib/whois/record/scanners/ast.rb +67 -0
  35. data/lib/whois/record/scanners/base.rb +102 -0
  36. data/lib/whois/record/scanners/iana.rb +101 -0
  37. data/lib/whois/record/scanners/verisign.rb +112 -0
  38. data/lib/whois/record/scanners/whois.audns.net.au.rb +39 -0
  39. data/lib/whois/record/scanners/whois.biz.rb +47 -0
  40. data/lib/whois/record/scanners/whois.cctld.by.rb +46 -0
  41. data/lib/whois/record/scanners/whois.centralnic.com.rb +46 -0
  42. data/lib/whois/record/scanners/whois.cira.ca.rb +87 -0
  43. data/lib/whois/record/scanners/whois.cnnic.cn.rb +44 -0
  44. data/lib/whois/record/scanners/whois.denic.de.rb +122 -0
  45. data/lib/whois/record/scanners/whois.dns.hr.rb +39 -0
  46. data/lib/whois/record/scanners/whois.domainregistry.ie.rb +50 -0
  47. data/lib/whois/record/scanners/whois.nc.rb +46 -0
  48. data/lib/whois/record/scanners/whois.nic.hu.rb +178 -0
  49. data/lib/whois/record/scanners/whois.nic.it.rb +104 -0
  50. data/lib/whois/record/scanners/whois.registry.qa.rb +39 -0
  51. data/lib/whois/record/scanners/whois.rnids.rs.rb +75 -0
  52. data/lib/whois/record/scanners/whois.smallregistry.net.rb +61 -0
  53. data/lib/whois/record/scanners/whois.tld.ee.rb +50 -0
  54. data/lib/whois/version.rb +1 -1
  55. data/spec/fixtures/responses/whois.audns.net.au/status_available.expected +33 -0
  56. data/spec/fixtures/responses/whois.audns.net.au/status_registered.expected +53 -0
  57. data/spec/fixtures/responses/whois.cctld.by/status_available.expected +54 -0
  58. data/spec/fixtures/responses/whois.cctld.by/status_available.txt +1 -0
  59. data/spec/fixtures/responses/whois.cctld.by/status_registered.expected +64 -0
  60. data/spec/fixtures/responses/whois.cctld.by/status_registered.txt +11 -0
  61. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_autorenew_grace.expected → property_status_autorenew_grace.expected} +0 -0
  62. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_autorenew_grace.txt → property_status_autorenew_grace.txt} +0 -0
  63. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_available.expected → property_status_available.expected} +0 -0
  64. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_available.txt → property_status_available.txt} +0 -0
  65. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_redemption.expected → property_status_redemption.expected} +0 -0
  66. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_redemption.txt → property_status_redemption.txt} +0 -0
  67. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_registered.expected → property_status_registered.expected} +0 -0
  68. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_registered.txt → property_status_registered.txt} +0 -0
  69. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_tobereleased.expected → property_status_tobereleased.expected} +0 -0
  70. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_tobereleased.txt → property_status_tobereleased.txt} +0 -0
  71. data/spec/fixtures/responses/whois.cira.ca/{schema-2/property_status_unavailable.txt → property_status_unavailable.txt} +0 -0
  72. data/spec/fixtures/responses/whois.cira.ca/status_available.expected +64 -0
  73. data/spec/fixtures/responses/whois.cira.ca/{schema-2/status_available.txt → status_available.txt} +0 -0
  74. data/spec/fixtures/responses/whois.cira.ca/{schema-2/status_invalid.expected → status_invalid.expected} +0 -0
  75. data/spec/fixtures/responses/whois.cira.ca/{schema-2/status_invalid.txt → status_invalid.txt} +0 -0
  76. data/spec/fixtures/responses/whois.cira.ca/status_registered.expected +118 -0
  77. data/spec/fixtures/responses/whois.cira.ca/{schema-2/status_registered.txt → status_registered.txt} +11 -10
  78. data/spec/fixtures/responses/whois.domainregistry.ie/status_available.expected +34 -0
  79. data/spec/fixtures/responses/whois.domainregistry.ie/status_available.txt +2 -4
  80. data/spec/fixtures/responses/whois.domainregistry.ie/status_registered.expected +47 -1
  81. data/spec/fixtures/responses/whois.domainregistry.ie/status_registered.txt +5 -6
  82. data/spec/fixtures/responses/whois.enom.com/property_contacts_almost_empty.expected +31 -0
  83. data/spec/fixtures/responses/whois.enom.com/property_contacts_almost_empty.txt +61 -0
  84. data/spec/fixtures/responses/whois.enom.com/property_contacts_long_address.expected +15 -0
  85. data/spec/fixtures/responses/whois.enom.com/property_contacts_long_address.txt +67 -0
  86. data/spec/fixtures/responses/whois.enom.com/status_registered.expected +97 -0
  87. data/spec/fixtures/responses/whois.enom.com/status_registered.txt +68 -0
  88. data/spec/fixtures/responses/whois.nic.it/status_registered.expected +25 -25
  89. data/spec/whois/record/parser/responses/whois.audns.net.au/status_available_spec.rb +47 -0
  90. data/spec/whois/record/parser/responses/whois.audns.net.au/status_registered_spec.rb +67 -0
  91. data/spec/whois/record/parser/responses/whois.cctld.by/status_available_spec.rb +105 -0
  92. data/spec/whois/record/parser/responses/whois.cctld.by/status_registered_spec.rb +115 -0
  93. data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_autorenew_grace_spec.rb → property_status_autorenew_grace_spec.rb} +2 -2
  94. data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_available_spec.rb → property_status_available_spec.rb} +2 -2
  95. data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_redemption_spec.rb → property_status_redemption_spec.rb} +2 -2
  96. data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_registered_spec.rb → property_status_registered_spec.rb} +2 -2
  97. data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/property_status_tobereleased_spec.rb → property_status_tobereleased_spec.rb} +2 -2
  98. data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/status_available_spec.rb → status_available_spec.rb} +45 -2
  99. data/spec/whois/record/parser/responses/whois.cira.ca/{schema-2/status_invalid_spec.rb → status_invalid_spec.rb} +2 -2
  100. data/spec/whois/record/parser/responses/whois.cira.ca/status_registered_spec.rb +172 -0
  101. data/spec/whois/record/parser/responses/whois.domainregistry.ie/status_available_spec.rb +48 -0
  102. data/spec/whois/record/parser/responses/whois.domainregistry.ie/status_registered_spec.rb +61 -1
  103. data/spec/whois/record/parser/responses/whois.enom.com/property_contacts_almost_empty_spec.rb +60 -0
  104. data/spec/whois/record/parser/responses/whois.enom.com/property_contacts_long_address_spec.rb +42 -0
  105. data/spec/whois/record/parser/responses/whois.enom.com/status_registered_spec.rb +140 -0
  106. data/spec/whois/record/parser/responses/whois.nic.it/status_registered_spec.rb +25 -25
  107. data/whois.gemspec +8 -7
  108. metadata +101 -61
  109. data/lib/whois/record/parser/scanners/afilias.rb +0 -66
  110. data/lib/whois/record/parser/scanners/ast.rb +0 -69
  111. data/lib/whois/record/parser/scanners/base.rb +0 -85
  112. data/lib/whois/record/parser/scanners/iana.rb +0 -108
  113. data/lib/whois/record/parser/scanners/verisign.rb +0 -122
  114. data/lib/whois/record/parser/scanners/whois.biz.rb +0 -49
  115. data/lib/whois/record/parser/scanners/whois.centralnic.com.rb +0 -52
  116. data/lib/whois/record/parser/scanners/whois.cnnic.cn.rb +0 -46
  117. data/lib/whois/record/parser/scanners/whois.denic.de.rb +0 -124
  118. data/lib/whois/record/parser/scanners/whois.dns.hr.rb +0 -41
  119. data/lib/whois/record/parser/scanners/whois.nc.rb +0 -48
  120. data/lib/whois/record/parser/scanners/whois.nic.hu.rb +0 -180
  121. data/lib/whois/record/parser/scanners/whois.nic.it.rb +0 -111
  122. data/lib/whois/record/parser/scanners/whois.registry.qa.rb +0 -41
  123. data/lib/whois/record/parser/scanners/whois.rnids.rs.rb +0 -78
  124. data/lib/whois/record/parser/scanners/whois.smallregistry.net.rb +0 -62
  125. data/lib/whois/record/parser/scanners/whois.tld.ee.rb +0 -52
  126. data/spec/fixtures/responses/whois.cira.ca/schema-1/status_available.expected +0 -27
  127. data/spec/fixtures/responses/whois.cira.ca/schema-1/status_available.txt +0 -9
  128. data/spec/fixtures/responses/whois.cira.ca/schema-1/status_registered.expected +0 -46
  129. data/spec/fixtures/responses/whois.cira.ca/schema-1/status_registered.txt +0 -47
  130. data/spec/fixtures/responses/whois.cira.ca/schema-2/status_available.expected +0 -34
  131. data/spec/fixtures/responses/whois.cira.ca/schema-2/status_registered.expected +0 -48
  132. data/spec/whois/record/parser/responses/whois.cira.ca/schema-1/status_available_spec.rb +0 -65
  133. data/spec/whois/record/parser/responses/whois.cira.ca/schema-1/status_registered_spec.rb +0 -84
  134. data/spec/whois/record/parser/responses/whois.cira.ca/schema-2/status_registered_spec.rb +0 -89
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --format Fuubar
2
1
  --colour
data/Rakefile CHANGED
@@ -33,9 +33,27 @@ spec = Gem::Specification.new do |s|
33
33
  s.require_paths = %w( lib )
34
34
 
35
35
  s.add_development_dependency "rake", "~> 0.9"
36
- s.add_development_dependency "rspec", "~> 2.8.0"
36
+ s.add_development_dependency "rspec", "~> 2.9.0"
37
37
  s.add_development_dependency "mocha"
38
38
  s.add_development_dependency "yard"
39
+
40
+ s.post_install_message = <<EOS
41
+ ********************************************************************************
42
+
43
+ Thank you for installing the whois gem!
44
+
45
+ If you like this gem, please support the project.
46
+ http://pledgie.com/campaigns/11383
47
+
48
+ Does your project or organization use this gem? Add it to the apps wiki.
49
+ https://github.com/weppos/whois/wiki/apps
50
+
51
+ Are you looking for a quick and convenient way to perform WHOIS queries?
52
+ Check out RoboWhois WHOIS API.
53
+ http://www.robowhois.com/
54
+
55
+ ********************************************************************************
56
+ EOS
39
57
  end
40
58
 
41
59
 
@@ -64,9 +82,15 @@ task :package => [:gemspec]
64
82
 
65
83
 
66
84
  require 'rspec/core/rake_task'
85
+ begin
86
+ require 'fuubar'
87
+ rescue LoadError
88
+ end
67
89
 
68
90
  RSpec::Core::RakeTask.new do |t|
69
91
  t.verbose = !!ENV["VERBOSE"]
92
+ t.rspec_opts = []
93
+ t.rspec_opts << ['--format', 'Fuubar'] if defined?(Fuubar)
70
94
  end
71
95
 
72
96
 
@@ -84,7 +84,7 @@ Whois::Server.define :tld, ".br", "whois.registro.br"
84
84
  Whois::Server.define :tld, ".bs", nil, { :web => "http://www.nic.bs/cgi-bin/search.pl", :adapter => Whois::Server::Adapters::Web }
85
85
  Whois::Server.define :tld, ".bt", nil, { :web => "http://www.nic.bt/", :adapter => Whois::Server::Adapters::Web }
86
86
  Whois::Server.define :tld, ".bv", nil, { :adapter => Whois::Server::Adapters::None }
87
- Whois::Server.define :tld, ".by", nil, { :web => "http://www.tld.by/indexeng.html", :adapter => Whois::Server::Adapters::Web }
87
+ Whois::Server.define :tld, ".by", 'whois.cctld.by'
88
88
  Whois::Server.define :tld, ".bw", nil, { :adapter => Whois::Server::Adapters::None }
89
89
  Whois::Server.define :tld, ".bz", "whois.afilias-grs.info", { :adapter => Whois::Server::Adapters::Afilias }
90
90
  Whois::Server.define :tld, ".co.ca", "whois.co.ca"
@@ -11,7 +11,7 @@ require 'time'
11
11
  require 'whois/record/contact'
12
12
  require 'whois/record/registrar'
13
13
  require 'whois/record/nameserver'
14
- require 'whois/record/parser/scanners/ast'
14
+ require 'whois/record/scanners/ast'
15
15
 
16
16
 
17
17
  module Whois
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
- require 'whois/record/parser/scanners/afilias'
11
+ require 'whois/record/scanners/afilias'
12
12
 
13
13
 
14
14
  module Whois
@@ -24,7 +24,7 @@ module Whois
24
24
 
25
25
 
26
26
  property_supported :disclaimer do
27
- node("property:disclaimer")
27
+ node("field:disclaimer")
28
28
  end
29
29
 
30
30
 
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
- require 'whois/record/parser/scanners/verisign'
11
+ require 'whois/record/scanners/verisign'
12
12
 
13
13
 
14
14
  module Whois
@@ -8,24 +8,36 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
+ require 'whois/record/scanners/whois.audns.net.au.rb'
11
12
 
12
13
 
13
14
  module Whois
14
15
  class Record
15
16
  class Parser
16
17
 
17
- #
18
- # = whois.audns.net.au parser
19
- #
20
18
  # Parser for the whois.audns.net.au server.
19
+ #
20
+ # @see Whois::Record::Parser::Example
21
+ # The Example parser for the list of all available methods.
21
22
  #
22
- # NOTE: This parser is just a stub and provides only a few basic methods
23
- # to check for domain availability and get domain status.
24
- # Please consider to contribute implementing missing methods.
25
- # See WhoisNicIt parser for an explanation of all available methods
26
- # and examples.
27
- #
23
+ # @since 2.5.0
28
24
  class WhoisAudnsNetAu < Base
25
+ include Scanners::Ast
26
+
27
+ property_not_supported :disclaimer
28
+
29
+
30
+ property_supported :domain do
31
+ node("Domain Name")
32
+ end
33
+
34
+ property_not_supported :domain_id
35
+
36
+
37
+ property_not_supported :referral_whois
38
+
39
+ property_not_supported :referral_url
40
+
29
41
 
30
42
  # == Values for Status
31
43
  #
@@ -33,11 +45,11 @@ module Whois
33
45
  # @see http://www.auda.org.au/policies/auda-2006-07/
34
46
  #
35
47
  property_supported :status do
36
- content_for_scanner.scan(/Status:\s+(.+?)\n/).flatten
48
+ Array.wrap(node("Status"))
37
49
  end
38
50
 
39
51
  property_supported :available? do
40
- (content_for_scanner.strip == "No Data Found")
52
+ !!node("status:available")
41
53
  end
42
54
 
43
55
  property_supported :registered? do
@@ -48,17 +60,70 @@ module Whois
48
60
  property_not_supported :created_on
49
61
 
50
62
  property_supported :updated_on do
51
- if content_for_scanner =~ /Last Modified:\s+(.+)\n/
52
- Time.parse($1)
53
- end
63
+ node("Last Modified") { |value| Time.parse(value) }
54
64
  end
55
65
 
56
66
  property_not_supported :expires_on
57
67
 
58
68
 
69
+ property_supported :registrar do
70
+ node("Registrar ID") do |str|
71
+ Record::Registrar.new(
72
+ :id => str,
73
+ :name => node("Registrar Name")
74
+ )
75
+ end
76
+ end
77
+
78
+
79
+ property_supported :registrant_contacts do
80
+ contact = build_contact("Registrant Contact", Record::Contact::TYPE_REGISTRANT)
81
+ contact.organization = node("Registrant") if contact
82
+ contact
83
+ end
84
+
85
+ property_not_supported :admin_contacts
86
+
87
+ property_supported :technical_contacts do
88
+ build_contact("Tech Contact", Record::Contact::TYPE_TECHNICAL)
89
+ end
90
+
91
+
59
92
  property_supported :nameservers do
60
- content_for_scanner.scan(/Name Server:\s+(.+)\n/).flatten.map do |name|
61
- Record::Nameserver.new(name)
93
+ Array.wrap(node("Name Server")).map do |name|
94
+ Record::Nameserver.new(:name => name)
95
+ end
96
+ end
97
+
98
+
99
+ # Initializes a new {Scanners::WhoisAudnsNetAu} instance
100
+ # passing the {#content_for_scanner}
101
+ # and calls +parse+ on it.
102
+ #
103
+ # @return [Hash]
104
+ def parse
105
+ Scanners::WhoisAudnsNetAu.new(content_for_scanner).parse
106
+ end
107
+
108
+
109
+ private
110
+
111
+ def build_contact(element, type)
112
+ node("#{element} ID") do |str|
113
+ Record::Contact.new(
114
+ :type => type,
115
+ :id => str,
116
+ :name => node("#{element} Name"),
117
+ :organization => nil,
118
+ :address => nil,
119
+ :city => nil,
120
+ :zip => nil,
121
+ :state => nil,
122
+ :country => nil,
123
+ :phone => nil,
124
+ :fax => nil,
125
+ :email => nil
126
+ )
62
127
  end
63
128
  end
64
129
 
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
- require 'whois/record/parser/scanners/whois.biz.rb'
11
+ require 'whois/record/scanners/whois.biz.rb'
12
12
 
13
13
 
14
14
  module Whois
@@ -0,0 +1,107 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+ require 'whois/record/parser/base'
10
+ require 'whois/record/scanners/whois.cctld.by.rb'
11
+
12
+ module Whois
13
+ class Record
14
+ class Parser
15
+
16
+ # Parser for the whois.cctld.by server.
17
+ #
18
+ # @see Whois::Record::Parser::Example
19
+ # The Example parser for the list of all available methods.
20
+ #
21
+ # @author Aliaksei Kliuchnikau <aliaksei.kliuchnikau@gmail.com>
22
+ # @since 2.5.0
23
+ class WhoisCctldBy < Base
24
+ include Scanners::Ast
25
+
26
+ property_not_supported :disclaimer
27
+
28
+
29
+ property_supported :domain do
30
+ node("Domain Name", &:downcase)
31
+ end
32
+
33
+ property_not_supported :domain_id
34
+
35
+
36
+ property_not_supported :referral_whois
37
+
38
+ property_not_supported :referral_url
39
+
40
+
41
+ property_supported :status do
42
+ if available?
43
+ :available
44
+ else
45
+ :registered
46
+ end
47
+ end
48
+
49
+ property_supported :available? do
50
+ !!node("status:available")
51
+ end
52
+
53
+ property_supported :registered? do
54
+ !available?
55
+ end
56
+
57
+
58
+ property_supported :created_on do
59
+ node("Creation Date") { |value| Time.parse(value) }
60
+ end
61
+
62
+ property_supported :updated_on do
63
+ node("Updated Date") { |value| Time.parse(value) }
64
+ end
65
+
66
+ property_supported :expires_on do
67
+ node("Expiration Date") { |value| Time.parse(value) }
68
+ end
69
+
70
+
71
+ property_supported :registrar do
72
+ node("Registrar") do |registrar|
73
+ Record::Registrar.new(
74
+ :id => registrar,
75
+ :name => registrar,
76
+ :organization => registrar
77
+ )
78
+ end
79
+ end
80
+
81
+ property_not_supported :registrant_contacts
82
+
83
+ property_not_supported :admin_contacts
84
+
85
+ property_not_supported :technical_contacts
86
+
87
+
88
+ property_supported :nameservers do
89
+ Array.wrap(node("Name Server")).map do |name|
90
+ Nameserver.new(:name => name.downcase)
91
+ end
92
+ end
93
+
94
+
95
+ # Initializes a new {Scanners::WhoisCctldBy} instance
96
+ # passing the {#content_for_scanner}
97
+ # and calls +parse+ on it.
98
+ #
99
+ # @return [Hash]
100
+ def parse
101
+ Scanners::WhoisCctldBy.new(content_for_scanner).parse
102
+ end
103
+
104
+ end
105
+ end
106
+ end
107
+ end
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
- require 'whois/record/parser/scanners/whois.centralnic.com.rb'
11
+ require 'whois/record/scanners/whois.centralnic.com.rb'
12
12
 
13
13
 
14
14
  module Whois
@@ -8,40 +8,56 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
+ require 'whois/record/scanners/whois.cira.ca.rb'
11
12
 
12
13
 
13
14
  module Whois
14
15
  class Record
15
16
  class Parser
16
17
 
17
- #
18
- # = whois.cira.ca parser
19
- #
20
18
  # Parser for the whois.cira.ca server.
19
+ #
20
+ # @see Whois::Record::Parser::Example
21
+ # The Example parser for the list of all available methods.
21
22
  #
22
- # NOTE: This parser is just a stub and provides only a few basic methods
23
- # to check for domain availability and get domain status.
24
- # Please consider to contribute implementing missing methods.
25
- # See WhoisNicIt parser for an explanation of all available methods
26
- # and examples.
27
- #
23
+ # @since 2.5.0
28
24
  class WhoisCiraCa < Base
25
+ include Scanners::Ast
26
+
27
+ property_supported :disclaimer do
28
+ node("field:disclaimer")
29
+ end
30
+
31
+
32
+ property_supported :domain do
33
+ node("Domain name")
34
+ end
35
+
36
+ property_not_supported :domain_id
37
+
38
+
39
+ property_not_supported :referral_whois
40
+
41
+ property_not_supported :referral_url
42
+
29
43
 
30
44
  property_supported :status do
31
- if content_for_scanner =~ /Domain status:\s+(.*?)\n/
32
- case $1.downcase
33
- # schema-2
34
- when "registered" then :registered
35
- when "redemption" then :registered
36
- when "auto-renew grace" then :registered
37
- when "to be released" then :registered
38
- when "available" then :available
39
- when "unavailable" then :invalid
40
- # schema-1
41
- when "exist" then :registered
42
- when "avail" then :available
43
- else
44
- Whois.bug!(ParserError, "Unknown status `#{$1}'.")
45
+ if content_for_scanner =~ /Domain status:\s+(.+?)\n/
46
+ case node("Domain status", &:downcase)
47
+ when "registered"
48
+ :registered
49
+ when "redemption"
50
+ :registered
51
+ when "auto-renew grace"
52
+ :registered
53
+ when "to be released"
54
+ :registered
55
+ when "available"
56
+ :available
57
+ when "unavailable"
58
+ :invalid
59
+ else
60
+ Whois.bug!(ParserError, "Unknown status `#{$1}'.")
45
61
  end
46
62
  else
47
63
  Whois.bug!(ParserError, "Unable to parse status.")
@@ -58,39 +74,46 @@ module Whois
58
74
 
59
75
 
60
76
  property_supported :created_on do
61
- # schema-2
62
- if content_for_scanner =~ /Creation date:\s+(.*?)\n/
63
- Time.parse($1)
64
- # schema-1
65
- elsif content_for_scanner =~ /Approval date:\s+(.*?)\n/
66
- Time.parse($1)
67
- end
77
+ node("Creation date") { |str| Time.parse(str) }
68
78
  end
69
79
 
70
- # TODO: Not supported in schema-2?
71
80
  property_supported :updated_on do
72
- if content_for_scanner =~ /Updated date:\s+(.*?)\n/
73
- Time.parse($1)
74
- end
81
+ node("Updated date") { |str| Time.parse(str) }
75
82
  end
76
83
 
77
84
  property_supported :expires_on do
78
- # schema-2
79
- if content_for_scanner =~ /Expiry date:\s+(.*?)\n/
80
- Time.parse($1)
81
- # schema-1
82
- elsif content_for_scanner =~ /Renewal date:\s+(.*?)\n/
83
- Time.parse($1)
84
- end
85
+ node("Expiry date") { |str| Time.parse(str) }
85
86
  end
86
87
 
87
88
 
88
89
  property_supported :registrar do
89
- if content_for_scanner =~ /^Registrar:\n(.*\n?)^\n/m
90
- match = $1
91
- id = match =~ /Number:\s+(.*)$/ ? $1.strip : nil
92
- name = match =~ /Name:\s+(.*)$/ ? $1.strip : nil
93
- Whois::Record::Registrar.new(:id => id, :name => name, :organization => name)
90
+ node("Registrar") do |hash|
91
+ Record::Registrar.new(
92
+ :id => hash["Number"],
93
+ :name => hash["Name"],
94
+ :organization => hash["Name"]
95
+ )
96
+ end
97
+ end
98
+
99
+
100
+ property_supported :registrant_contacts do
101
+ build_contact("Registrant", Whois::Record::Contact::TYPE_REGISTRANT)
102
+ end
103
+
104
+ property_supported :admin_contacts do
105
+ build_contact("Administrative contact", Whois::Record::Contact::TYPE_ADMIN)
106
+ end
107
+
108
+ property_supported :technical_contacts do
109
+ build_contact("Technical contact", Whois::Record::Contact::TYPE_TECHNICAL)
110
+ end
111
+
112
+
113
+ property_supported :nameservers do
114
+ Array.wrap(node("nserver")).map do |line|
115
+ name, ipv4 = line.split(/\s+/)
116
+ Record::Nameserver.new(:name => name, :ipv4 => ipv4)
94
117
  end
95
118
  end
96
119
 
@@ -104,11 +127,9 @@ module Whois
104
127
  # ns2.google.com 216.239.34.10
105
128
  #
106
129
  property_supported :nameservers do
107
- if content_for_scanner =~ /Name servers:\n((?:\s+([^\s]+)\s+([^\s]+)\n)+)/
108
- $1.split("\n").map do |line|
109
- name, ipv4 = line.strip.split(/\s+/)
110
- Record::Nameserver.new(name, ipv4)
111
- end
130
+ Array.wrap(node("field:nameservers")).map do |line|
131
+ name, ipv4 = line.strip.split(/\s+/)
132
+ Record::Nameserver.new(:name => name, :ipv4 => ipv4)
112
133
  end
113
134
  end
114
135
 
@@ -143,6 +164,37 @@ module Whois
143
164
  end
144
165
 
145
166
 
167
+ # Initializes a new {Scanners::WhoisCiraCa} instance
168
+ # passing the {#content_for_scanner}
169
+ # and calls +parse+ on it.
170
+ #
171
+ # @return [Hash]
172
+ def parse
173
+ Scanners::WhoisCiraCa.new(content_for_scanner).parse
174
+ end
175
+
176
+
177
+ private
178
+
179
+ def build_contact(element, type)
180
+ node(element) do |hash|
181
+ Record::Contact.new(
182
+ :type => type,
183
+ :id => nil,
184
+ :name => hash["Name"],
185
+ :organization => nil,
186
+ :address => hash["Postal address"],
187
+ :city => nil,
188
+ :zip => nil,
189
+ :state => nil,
190
+ :country => nil,
191
+ :phone => hash["Phone"],
192
+ :fax => hash["Fax"],
193
+ :email => hash["Email"]
194
+ )
195
+ end
196
+ end
197
+
146
198
  end
147
199
 
148
200
  end
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
- require 'whois/record/parser/scanners/whois.cnnic.cn.rb'
11
+ require 'whois/record/scanners/whois.cnnic.cn.rb'
12
12
 
13
13
 
14
14
  module Whois
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
- require 'whois/record/parser/scanners/verisign'
11
+ require 'whois/record/scanners/verisign'
12
12
 
13
13
 
14
14
  module Whois
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
- require 'whois/record/parser/scanners/whois.denic.de.rb'
11
+ require 'whois/record/scanners/whois.denic.de.rb'
12
12
 
13
13
 
14
14
  module Whois
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  require 'whois/record/parser/base'
11
- require 'whois/record/parser/scanners/whois.dns.hr.rb'
11
+ require 'whois/record/scanners/whois.dns.hr.rb'
12
12
 
13
13
 
14
14
  module Whois
@@ -20,7 +20,7 @@ module Whois
20
20
  # @see Whois::Record::Parser::Example
21
21
  # The Example parser for the list of all available methods.
22
22
  #
23
- # @since RELEASE
23
+ # @since 2.4.0
24
24
  class WhoisDnsHr < Base
25
25
  include Scanners::Ast
26
26