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
@@ -1,122 +0,0 @@
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
-
10
- require 'whois/record/parser/scanners/base'
11
-
12
-
13
- module Whois
14
- class Record
15
- class Parser
16
- module Scanners
17
-
18
- class Verisign < Base
19
-
20
- self.tokenizers += [
21
- :skip_empty_line,
22
- :scan_response_unavailable,
23
- :scan_available,
24
- :scan_disclaimer,
25
- :scan_notice,
26
- :scan_keyvalue_indented,
27
- :skip_ianaservice,
28
- :skip_lastupdate,
29
- :skip_fuffa,
30
- ]
31
-
32
-
33
- tokenizer :scan_response_unavailable do
34
- # Check if the string starts with /*
35
- # If it does, match until the end of all /* lines
36
- # or the end of the file and check for the content.
37
- #
38
- # Flag the block as visited to force the scanner to ignore this tokenizer
39
- # if already used and the content didn't match the unavailable message.
40
- if @input.match?(/^\*\n/) && !visited?
41
- p = /^[^\*]|\z/
42
- y = @input.check_until(p) =~ /^\* Sorry, the Whois database is currently down/
43
-
44
- if y
45
- @input.skip_until(p)
46
- @ast["response:unavailable"] = true
47
- else
48
- visited!
49
- end
50
- end
51
- end
52
-
53
- tokenizer :scan_available do
54
- if @input.scan(/No match for "(.+?)"\.\n/)
55
- @ast["Domain Name"] = @input[1].strip
56
- end
57
- end
58
-
59
- tokenizer :scan_disclaimer do
60
- if @input.match?(/^TERMS OF USE:/)
61
- lines = []
62
- while @input.scan(/(.+)\n/)
63
- lines << @input[1].strip
64
- end
65
- @ast["Disclaimer"] = lines.join(" ")
66
- end
67
- end
68
-
69
- tokenizer :scan_notice do
70
- if @input.match?(/^NOTICE:/)
71
- lines = []
72
- while @input.scan(/(.+)\n/)
73
- lines << @input[1].strip
74
- end
75
- @ast["Notice"] = lines.join(" ")
76
- end
77
- end
78
-
79
- tokenizer :scan_keyvalue_indented do
80
- if @input.scan(/\s+(.+?):(.*?)\n/)
81
- key, value = @input[1].strip, @input[2].strip
82
- if @ast[key].nil?
83
- @ast[key] = value
84
- else
85
- @ast[key] = [@ast[key]] unless @ast[key].is_a?(Array)
86
- @ast[key] << value
87
- end
88
- end
89
- end
90
-
91
- tokenizer :skip_lastupdate do
92
- @input.skip(/>>>(.+?)<<<\n/)
93
- end
94
-
95
- tokenizer :skip_fuffa do
96
- @input.scan(/^\S(.+)(?:\n|\z)/)
97
- end
98
-
99
- tokenizer :skip_ianaservice do
100
- if @input.match?(/IANA Whois Service/)
101
- @ast["IANA"] = true
102
- @input.terminate
103
- end
104
- end
105
-
106
- private
107
-
108
- def visited?
109
- !!@tmp["visited:#{@input.pos}"]
110
- end
111
-
112
- def visited!
113
- @tmp["visited:#{@input.pos}"] = true
114
- nil
115
- end
116
-
117
- end
118
-
119
- end
120
- end
121
- end
122
- end
@@ -1,49 +0,0 @@
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
-
10
- require 'whois/record/parser/scanners/base'
11
-
12
-
13
- module Whois
14
- class Record
15
- class Parser
16
- module Scanners
17
-
18
- class WhoisBiz < Base
19
-
20
- self.tokenizers += [
21
- :skip_empty_line,
22
- :scan_available,
23
- :scan_keyvalue,
24
- :skip_lastupdate,
25
- :skip_fuffa,
26
- ]
27
-
28
-
29
- tokenizer :scan_available do
30
- if @input.scan(/^Not found: (.+)\n/)
31
- @ast["Domain Name"] = @input[1]
32
- @ast["status:available"] = true
33
- end
34
- end
35
-
36
- tokenizer :skip_lastupdate do
37
- @input.skip(/>>>(.+?)<<<\n/)
38
- end
39
-
40
- tokenizer :skip_fuffa do
41
- @input.scan(/^\S(.+)\n/)
42
- end
43
-
44
- end
45
-
46
- end
47
- end
48
- end
49
- end
@@ -1,52 +0,0 @@
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
-
10
- require 'whois/record/parser/scanners/base'
11
-
12
-
13
- module Whois
14
- class Record
15
- class Parser
16
- module Scanners
17
-
18
- # Scanner for the whois.centralnic.com record.
19
- #
20
- # @since 2.3.0
21
- class WhoisCentralnicCom < Base
22
-
23
- self.tokenizers += [
24
- :skip_empty_line,
25
- :scan_available,
26
- :scan_disclaimer,
27
- :scan_keyvalue,
28
- ]
29
-
30
-
31
- tokenizer :scan_available do
32
- if @input.skip(/^DOMAIN NOT FOUND\n/)
33
- @ast["status:available"] = true
34
- end
35
- end
36
-
37
- tokenizer :scan_disclaimer do
38
- if @input.match?(/^\S([^:]+)\n/)
39
- lines = []
40
- while @input.scan(/(.+)\n/)
41
- lines << @input[1].strip
42
- end
43
- @ast["field:disclaimer"] = lines.join(" ")
44
- end
45
- end
46
-
47
- end
48
-
49
- end
50
- end
51
- end
52
- end
@@ -1,46 +0,0 @@
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
-
10
- require 'whois/record/parser/scanners/base'
11
-
12
-
13
- module Whois
14
- class Record
15
- class Parser
16
- module Scanners
17
-
18
- # Scanner for the whois.cnnic.cn record.
19
- class WhoisCnnicCn < Base
20
-
21
- self.tokenizers += [
22
- :skip_empty_line,
23
- :scan_reserved,
24
- :scan_available,
25
- :scan_keyvalue,
26
- ]
27
-
28
-
29
- tokenizer :scan_available do
30
- if @input.scan(/^no matching record/)
31
- @ast["status:available"] = true
32
- end
33
- end
34
-
35
- tokenizer :scan_reserved do
36
- if @input.scan(/^the domain you want to register is reserved/)
37
- @ast["status:reserved"] = true
38
- end
39
- end
40
-
41
- end
42
-
43
- end
44
- end
45
- end
46
- end
@@ -1,124 +0,0 @@
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
-
10
- require 'whois/record/parser/scanners/base'
11
-
12
-
13
- module Whois
14
- class Record
15
- class Parser
16
- module Scanners
17
-
18
- class WhoisDenicDe < Base
19
-
20
- self.tokenizers += [
21
- :skip_empty_line,
22
- :scan_response_throttled,
23
- :scan_disclaimer,
24
- :scan_invalid,
25
- :scan_available,
26
- :scan_pair,
27
- :scan_contact,
28
- :skip_db_time,
29
- ]
30
-
31
-
32
- # Version 1.11.0, 1.10.0
33
- tokenizer :scan_available do
34
- if @input.match?(/% Object ".+" not found in database\n/)
35
- while @input.skip(/%(.*)\n/)
36
- end
37
- @ast["status:available"] = true
38
- end
39
- end
40
-
41
- # Version 1.11.0, 1.10.0
42
- tokenizer :scan_invalid do
43
- if @input.match?(/% ".+" is not a valid domain name\n/)
44
- @input.scan(/% "(.+?)" is not a valid domain name\n/)
45
- @ast["Domain"] = @input[1]
46
- @ast["status:invalid"] = true
47
- end
48
- end
49
-
50
- tokenizer :scan_response_throttled do
51
- if @input.match?(/^% Error: 55000000002/)
52
- @ast["response:throttled"] = true
53
- @input.skip(/^.+\n/)
54
- end
55
- end
56
-
57
- tokenizer :scan_disclaimer do
58
- if @input.match?(/% Copyright \(c\) *\d{4} by DENIC\n/)
59
- @input.scan_until(/% Terms and Conditions of Use\n/)
60
- lines = []
61
- while @input.match?(/%/) && @input.scan(/%(.*)\n/)
62
- lines << @input[1].strip unless @input[1].strip == ""
63
- end
64
- @ast["Disclaimer"] = lines.join(" ")
65
- end
66
- end
67
-
68
- tokenizer :scan_pair do
69
- parse_pair(@ast)
70
- end
71
-
72
- tokenizer :scan_contact do
73
- if @input.scan(/\[(.*)\]\n/)
74
- contact_name = @input[1]
75
- contact = {}
76
- while parse_pair(contact)
77
- end
78
- @ast[contact_name] = {
79
- "id" => nil,
80
- "name" => contact['Name'],
81
- "organization" => contact['Organisation'],
82
- "address" => contact['Address'],
83
- "city" => contact['City'],
84
- # 1.10.0, 1.11.0 || 2.0
85
- "zip" => contact['Pcode'] || contact['PostalCode'],
86
- "state" => nil,
87
- "country" => contact['Country'],
88
- "country_code" => contact['CountryCode'],
89
- "phone" => contact['Phone'],
90
- "fax" => contact['Fax'],
91
- "email" => contact['Email'],
92
- "created_on" => nil,
93
- "updated_on" => contact['Changed']
94
- }
95
- end
96
- end
97
-
98
- # Version 2.0
99
- tokenizer :skip_db_time do
100
- @input.skip(/^% DB time is (.+)\n/)
101
- end
102
-
103
-
104
- private
105
-
106
- def parse_pair(store)
107
- if @input.scan(/([^ \[]*):(.*)\n/)
108
- key, value = @input[1].strip, @input[2].strip
109
- if store[key].nil?
110
- store[key] = value
111
- else
112
- store[key].is_a?(Array) || store[key] = [store[key]]
113
- store[key] << value
114
- end
115
- store
116
- end
117
- end
118
-
119
- end
120
-
121
- end
122
- end
123
- end
124
- end
@@ -1,41 +0,0 @@
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
-
10
- require 'whois/record/parser/scanners/base'
11
-
12
-
13
- module Whois
14
- class Record
15
- class Parser
16
- module Scanners
17
-
18
- # Scanner for the whois.dns.hr record.
19
- #
20
- # @since RELEASE
21
- class WhoisDnsHr < Base
22
-
23
- self.tokenizers += [
24
- :skip_empty_line,
25
- :scan_available,
26
- :scan_keyvalue,
27
- ]
28
-
29
-
30
- tokenizer :scan_available do
31
- if @input.skip(/^%ERROR: no entries found\n/)
32
- @ast["status:available"] = true
33
- end
34
- end
35
-
36
- end
37
-
38
- end
39
- end
40
- end
41
- end
@@ -1,48 +0,0 @@
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
-
10
- require 'whois/record/parser/scanners/base'
11
-
12
-
13
- module Whois
14
- class Record
15
- class Parser
16
- module Scanners
17
-
18
- # Scanner for the whois.nc record.
19
- #
20
- # @since RELEASE
21
- class WhoisNc < Base
22
-
23
- self.tokenizers += [
24
- :skip_empty_line,
25
- :skip_more,
26
- :scan_available,
27
- :scan_keyvalue,
28
- ]
29
-
30
-
31
- MORES = ['Whois \.NC', 'more details on']
32
-
33
- tokenizer :scan_available do
34
- if @input.skip(/^No entries found .+\n/)
35
- @ast["status:available"] = true
36
- end
37
- end
38
-
39
- tokenizer :skip_more do
40
- MORES.any? { |more| @input.skip(/^#{more}.*\n/) }
41
- end
42
-
43
- end
44
-
45
- end
46
- end
47
- end
48
- end
@@ -1,180 +0,0 @@
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
-
10
- require 'whois/record/parser/scanners/base'
11
-
12
-
13
- module Whois
14
- class Record
15
- class Parser
16
- module Scanners
17
-
18
- class WhoisNicHu < Base
19
-
20
- self.tokenizers += [
21
- :scan_version,
22
- :scan_disclaimer,
23
- :scan_domain,
24
- :scan_available,
25
- :scan_in_progress,
26
-
27
- # v2.0
28
- :scan_moreinfo,
29
-
30
- # v1.99
31
- :scan_domain_data,
32
- :scan_contacts,
33
-
34
- :skip_empty_line,
35
- ]
36
-
37
-
38
- # FIXME: Requires UTF-8 Encoding (see #11)
39
- tokenizer :scan_available do
40
- if @input.match?(/Nincs (.*?) \/ No match\n/)
41
- @input.skip(/Nincs (.*?) \/ No match\n/)
42
- @ast["status:available"] = true
43
- end
44
- end
45
-
46
- # FIXME: Requires UTF-8 Encoding (see #11)
47
- tokenizer :scan_in_progress do
48
- if @input.match?(/(.*?) folyamatban \/ Registration in progress\n/)
49
- @input.skip(/(.*?) folyamatban \/ Registration in progress\n/)
50
- @ast["status:inprogress"] = true
51
- end
52
- end
53
-
54
- tokenizer :scan_disclaimer do
55
- if @input.match?(/^Rights.*\n/)
56
- lines = @input.scan_until(/^\n/)
57
- @ast["field:disclaimer"] = lines.strip
58
- end
59
- end
60
-
61
- tokenizer :scan_domain do
62
- if @input.match?(/^domain:\s+(.*)\n/) && @input.scan(/^domain:\s+(.*?)\n/)
63
- @ast["field:domain"] = @input[1].strip
64
- end
65
- end
66
-
67
- # FIXME: Requires UTF-8 Encoding (see #11)
68
- tokenizer :scan_moreinfo do
69
- if @input.match?(/Tov.* ld\.:\n/)
70
- @ast["field:moreinfo"] = @input.scan_until(/^\n/)
71
- end
72
- end
73
-
74
- tokenizer :scan_version do
75
- if @input.match?(/% Whois server .*\n/)
76
- @input.scan(/% Whois server ([\w\d\.]*).*?\n/)
77
- @ast["field:version"] = @input[1]
78
- end
79
- end
80
-
81
- tokenizer :scan_domain_data do
82
- if @input.match?(/(.+?):\s+(.*)\n/)
83
- while @input.scan(/(.+?):\s+(.*)\n/)
84
- key, value = @input[1].strip, @input[2].strip
85
- if key == 'person'
86
- @ast['name'] = value
87
- elsif key == 'org'
88
- if value =~ /org_name_hun:\s+(.*)\Z/
89
- @ast['name'] = $1
90
- elsif value =~ /org_name_eng:\s+(.*)\Z/
91
- @ast['org'] = $1
92
- elsif value != 'Private person'
93
- contact['org'] = value
94
- end
95
- elsif @ast[key].nil?
96
- @ast[key] = value
97
- elsif @ast[key].is_a? Array
98
- @ast[key] << value
99
- else
100
- @ast[key] = [@ast[key], value].flatten
101
- end
102
- end
103
- true
104
- end
105
- end
106
-
107
- tokenizer :scan_contacts do
108
- if @input.match?(/\n(person|org):/)
109
- @input.scan(/\n/)
110
- while @input.match?(/(.+?):\s+(.*)\n/)
111
- parse_contact
112
- end
113
- true
114
- end
115
- end
116
-
117
-
118
- private
119
-
120
- def parse_contact
121
- contact ||= {}
122
- while @input.scan(/(.+?):\s+(.*)\n/)
123
- key, value = @input[1].strip, @input[2].strip
124
- if key == 'hun-id'
125
- a1 = contact['address'][1].split(/\s/)
126
- zip = a1.shift
127
- city = a1.join(' ')
128
- # we should keep the old values if this is an already
129
- # defined contact
130
- if @ast[value].nil?
131
- @ast[value] = {
132
- "id" => value,
133
- "name" => contact['name'],
134
- "organization" => contact['org'],
135
- "address" => contact['address'][0],
136
- "city" => city,
137
- "zip" => zip,
138
- "country_code" => contact['address'][2],
139
- "phone" => contact['phone'],
140
- "fax" => contact['fax-no'],
141
- "email" => contact['e-mail']
142
- }
143
- else
144
- @ast[value]["id"] ||= value
145
- @ast[value]["name"] ||= contact['name']
146
- @ast[value]["organization"] ||= contact['org']
147
- @ast[value]["address"] ||= contact['address'][0]
148
- @ast[value]["city"] ||= city
149
- @ast[value]["zip"] ||= zip
150
- @ast[value]["country_code"] ||= contact['address'][2]
151
- @ast[value]["phone"] ||= contact['phone']
152
- @ast[value]["fax"] ||= contact['fax-no']
153
- @ast[value]["email"] ||= contact['e-mail']
154
- end
155
- contact = {}
156
- elsif key == 'person'
157
- contact['name'] = value
158
- elsif key == 'org'
159
- if value =~ /org_name_hun:\s+(.*)\Z/
160
- contact['name'] = $1
161
- elsif value =~ /org_name_eng:\s+(.*)\Z/
162
- contact['org'] = $1
163
- else
164
- contact['org'] = value
165
- end
166
- elsif key == 'address' && !contact['address'].nil?
167
- contact['address'] = [contact['address'], value].flatten
168
- else
169
- contact[key] = value
170
- end
171
- end
172
- true
173
- end
174
-
175
- end
176
-
177
- end
178
- end
179
- end
180
- end