whois 2.0.7 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. data/CHANGELOG.rdoc +84 -10
  2. data/Rakefile +0 -7
  3. data/lib/core_ext.rb +9 -45
  4. data/lib/core_ext/array/extract_options.rb +29 -0
  5. data/lib/core_ext/array/wrap.rb +48 -0
  6. data/lib/core_ext/class/attribute.rb +115 -0
  7. data/lib/core_ext/date_time/conversions.rb +15 -0
  8. data/lib/core_ext/kernel/singleton_class.rb +13 -0
  9. data/lib/core_ext/module/remove_method.rb +16 -0
  10. data/lib/whois.rb +0 -4
  11. data/lib/whois/definitions/tlds.rb +10 -5
  12. data/lib/whois/record.rb +0 -3
  13. data/lib/whois/record/parser.rb +3 -3
  14. data/lib/whois/record/parser/NOTES.txt +15 -8
  15. data/lib/whois/record/parser/base.rb +12 -35
  16. data/lib/whois/record/parser/base_afilias.rb +156 -0
  17. data/lib/whois/record/parser/example.rb +8 -4
  18. data/lib/whois/record/parser/jobswhois.verisign-grs.com.rb +2 -2
  19. data/lib/whois/record/parser/scanners/afilias.rb +13 -4
  20. data/lib/whois/record/parser/{features → scanners}/ast.rb +1 -1
  21. data/lib/whois/record/parser/scanners/base.rb +9 -0
  22. data/lib/whois/record/parser/scanners/cnnic.rb +2 -2
  23. data/lib/whois/record/parser/scanners/{whoisbiz.rb → whois.biz.rb} +2 -8
  24. data/lib/whois/record/parser/scanners/whois.denic.de.rb +117 -0
  25. data/lib/whois/record/parser/scanners/whois.nic.hu.rb +187 -0
  26. data/lib/whois/record/parser/scanners/{whoisit.rb → whois.nic.it.rb} +2 -2
  27. data/lib/whois/record/parser/scanners/whois.registry.qa.rb +54 -0
  28. data/lib/whois/record/parser/scanners/whois.tld.ee.rb +41 -0
  29. data/lib/whois/record/parser/whois.aero.rb +8 -46
  30. data/lib/whois/record/parser/whois.afilias-grs.info.rb +2 -51
  31. data/lib/whois/record/parser/whois.afilias.info.rb +2 -126
  32. data/lib/whois/record/parser/whois.biz.rb +6 -6
  33. data/lib/whois/record/parser/whois.cnnic.cn.rb +5 -5
  34. data/lib/whois/record/parser/whois.crsnic.net.rb +2 -2
  35. data/lib/whois/record/parser/whois.denic.de.rb +8 -105
  36. data/lib/whois/record/parser/whois.dotmobiregistry.net.rb +2 -51
  37. data/lib/whois/record/parser/whois.godaddy.com.rb +138 -0
  38. data/lib/whois/record/parser/whois.iana.org.rb +2 -2
  39. data/lib/whois/record/parser/whois.markmonitor.com.rb +13 -12
  40. data/lib/whois/record/parser/whois.meregistry.net.rb +45 -30
  41. data/lib/whois/record/parser/whois.nic.af.rb +6 -2
  42. data/lib/whois/record/parser/whois.nic.ag.rb +2 -51
  43. data/lib/whois/record/parser/whois.nic.asia.rb +47 -38
  44. data/lib/whois/record/parser/whois.nic.cc.rb +2 -2
  45. data/lib/whois/record/parser/whois.nic.hu.rb +7 -174
  46. data/lib/whois/record/parser/whois.nic.it.rb +6 -6
  47. data/lib/whois/record/parser/whois.nic.name.rb +1 -5
  48. data/lib/whois/record/parser/whois.nic.travel.rb +4 -12
  49. data/lib/whois/record/parser/whois.nic.tv.rb +2 -2
  50. data/lib/whois/record/parser/whois.nic.us.rb +4 -4
  51. data/lib/whois/record/parser/whois.nic.xxx.rb +5 -112
  52. data/lib/whois/record/parser/whois.publicinterestregistry.net.rb +8 -168
  53. data/lib/whois/record/parser/whois.registry.in.rb +2 -60
  54. data/lib/whois/record/parser/whois.registry.qa.rb +117 -0
  55. data/lib/whois/record/parser/whois.ripn.net.rb +4 -84
  56. data/lib/whois/record/parser/whois.sgnic.sg.rb +13 -5
  57. data/lib/whois/record/parser/whois.tcinet.ru.rb +102 -0
  58. data/lib/whois/record/parser/whois.tld.ee.rb +5 -26
  59. data/lib/whois/record/parser/whois.tonic.to.rb +0 -8
  60. data/lib/whois/server/adapters/base.rb +23 -10
  61. data/lib/whois/version.rb +2 -2
  62. data/spec/fixtures/responses/FIND.txt +1 -0
  63. data/spec/fixtures/responses/whois.aero/status_available.expected +35 -1
  64. data/spec/fixtures/responses/whois.aero/status_registered.expected +77 -1
  65. data/spec/fixtures/responses/whois.afilias-grs.info/bz/status_available.expected +34 -0
  66. data/spec/fixtures/responses/whois.afilias-grs.info/bz/status_registered.expected +39 -2
  67. data/spec/fixtures/responses/whois.afilias-grs.info/bz/status_registered.txt +2 -82
  68. data/spec/fixtures/responses/whois.afilias-grs.info/gi/status_available.expected +34 -0
  69. data/spec/fixtures/responses/whois.afilias-grs.info/gi/status_registered.expected +76 -0
  70. data/spec/fixtures/responses/whois.afilias-grs.info/hn/status_available.expected +34 -0
  71. data/spec/fixtures/responses/whois.afilias-grs.info/hn/status_registered.expected +76 -0
  72. data/spec/fixtures/responses/whois.afilias-grs.info/lc/status_available.expected +34 -0
  73. data/spec/fixtures/responses/whois.afilias-grs.info/lc/status_registered.expected +76 -0
  74. data/spec/fixtures/responses/whois.afilias-grs.info/mn/status_available.expected +34 -0
  75. data/spec/fixtures/responses/whois.afilias-grs.info/mn/status_registered.expected +76 -0
  76. data/spec/fixtures/responses/whois.afilias-grs.info/sc/status_available.expected +57 -0
  77. data/spec/fixtures/responses/whois.afilias-grs.info/sc/status_registered.expected +76 -0
  78. data/spec/fixtures/responses/whois.afilias-grs.info/vc/status_available.expected +34 -0
  79. data/spec/fixtures/responses/whois.afilias-grs.info/vc/status_registered.expected +76 -0
  80. data/spec/fixtures/responses/whois.dotmobiregistry.net/status_available.expected +35 -0
  81. data/spec/fixtures/responses/whois.dotmobiregistry.net/status_available.txt +1 -25
  82. data/spec/fixtures/responses/whois.dotmobiregistry.net/status_registered.expected +76 -0
  83. data/spec/fixtures/responses/whois.educause.edu/{properties_updated_on_unknown.expected → property_updated_on_unknown.expected} +0 -0
  84. data/spec/fixtures/responses/whois.educause.edu/{properties_updated_on_unknown.txt → property_updated_on_unknown.txt} +0 -0
  85. data/spec/fixtures/responses/whois.godaddy.com/status_registered.expected +87 -0
  86. data/spec/fixtures/responses/whois.godaddy.com/status_registered.txt +60 -0
  87. data/spec/fixtures/responses/whois.markmonitor.com/{properties_empty_contacts.expected → property_contacts_are_blank.expected} +0 -0
  88. data/spec/fixtures/responses/whois.markmonitor.com/{properties_empty_contacts.txt → property_contacts_are_blank.txt} +0 -0
  89. data/spec/fixtures/responses/whois.meregistry.net/{property_nameservers_is_missing.expected → property_nameservers_is_blank.expected} +0 -0
  90. data/spec/fixtures/responses/whois.meregistry.net/{property_nameservers_is_missing.txt → property_nameservers_is_blank.txt} +0 -0
  91. data/spec/fixtures/responses/whois.meregistry.net/status_available.expected +34 -0
  92. data/spec/fixtures/responses/whois.meregistry.net/status_registered.expected +77 -0
  93. data/spec/fixtures/responses/whois.meregistry.net/status_registered.txt +1 -1
  94. data/spec/fixtures/responses/{whois.nic.asia/property_status_client_delete_prohibited.expected → whois.nic.af/property_status_active.expected} +0 -0
  95. data/spec/fixtures/responses/whois.nic.af/property_status_active.txt +56 -0
  96. data/spec/fixtures/responses/{whois.nic.asia/property_status_client_transfer_prohibited.expected → whois.nic.af/property_status_delegated.expected} +0 -0
  97. data/spec/fixtures/responses/whois.nic.af/property_status_delegated.txt +46 -0
  98. data/spec/fixtures/responses/whois.nic.af/property_status_not_registered.expected +8 -0
  99. data/spec/fixtures/responses/whois.nic.af/property_status_not_registered.txt +13 -0
  100. data/spec/fixtures/responses/whois.nic.ag/status_available.expected +34 -0
  101. data/spec/fixtures/responses/whois.nic.ag/status_registered.expected +76 -0
  102. data/spec/fixtures/responses/whois.nic.asia/property_status_multiple.expected +8 -0
  103. data/spec/fixtures/responses/whois.nic.asia/{property_status_client_delete_prohibited.txt → property_status_multiple.txt} +0 -0
  104. data/spec/fixtures/responses/whois.nic.asia/property_status_single.expected +8 -0
  105. data/spec/fixtures/responses/whois.nic.asia/{property_status_client_transfer_prohibited.txt → property_status_single.txt} +76 -76
  106. data/spec/fixtures/responses/whois.nic.asia/status_available.expected +35 -1
  107. data/spec/fixtures/responses/whois.nic.asia/status_registered.expected +78 -1
  108. data/spec/fixtures/responses/whois.nic.dz/{status_available.expected → dz/status_available.expected} +0 -0
  109. data/spec/fixtures/responses/whois.nic.dz/{status_available.txt → dz/status_available.txt} +0 -0
  110. data/spec/fixtures/responses/whois.nic.dz/{status_registered.expected → dz/status_registered.expected} +0 -0
  111. data/spec/fixtures/responses/whois.nic.dz/{status_registered.txt → dz/status_registered.txt} +0 -0
  112. data/spec/fixtures/responses/whois.nic.name/status_available.expected +1 -1
  113. data/spec/fixtures/responses/whois.nic.name/status_registered.expected +1 -1
  114. data/spec/fixtures/responses/whois.nic.travel/property_status_multiple.expected +2 -0
  115. data/spec/fixtures/responses/whois.nic.travel/property_status_multiple.txt +83 -0
  116. data/spec/fixtures/responses/whois.nic.travel/property_status_single.expected +2 -0
  117. data/spec/fixtures/responses/whois.nic.travel/property_status_single.txt +75 -0
  118. data/spec/fixtures/responses/whois.nic.travel/status_available.expected +1 -1
  119. data/spec/fixtures/responses/whois.nic.travel/status_registered.expected +1 -1
  120. data/spec/fixtures/responses/whois.nic.xxx/property_updated_on_blank.expected +2 -0
  121. data/spec/fixtures/responses/whois.nic.xxx/property_updated_on_blank.txt +98 -0
  122. data/spec/fixtures/responses/whois.nic.xxx/status_registered.expected +45 -46
  123. data/spec/fixtures/responses/whois.nic.xxx/status_registered.txt +61 -61
  124. data/spec/fixtures/responses/whois.publicinterestregistry.net/status_available.expected +1 -1
  125. data/spec/fixtures/responses/whois.publicinterestregistry.net/status_registered.expected +8 -1
  126. data/spec/fixtures/responses/whois.registry.in/property_status_missing.expected +1 -1
  127. data/spec/fixtures/responses/whois.registry.in/property_status_multiple.expected +1 -1
  128. data/spec/fixtures/responses/whois.registry.in/property_status_ok.expected +1 -1
  129. data/spec/fixtures/responses/whois.registry.in/status_available.expected +31 -1
  130. data/spec/fixtures/responses/whois.registry.in/status_registered.expected +70 -1
  131. data/spec/fixtures/responses/whois.registry.qa/qa/status_available.expected +56 -0
  132. data/spec/fixtures/responses/whois.registry.qa/qa/status_available.txt +1 -0
  133. data/spec/fixtures/responses/whois.registry.qa/qa/status_registered.expected +91 -0
  134. data/spec/fixtures/responses/whois.registry.qa/qa/status_registered.txt +23 -0
  135. data/spec/fixtures/responses/whois.sgnic.sg/property_nameservers_schema_1_with_ip.expected +12 -0
  136. data/spec/fixtures/responses/whois.sgnic.sg/property_nameservers_schema_1_with_ip.txt +94 -0
  137. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/ru/property_nameservers_with_ip.expected +0 -0
  138. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/ru/property_nameservers_with_ip.txt +0 -0
  139. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/ru/status_available.expected +0 -0
  140. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/ru/status_available.txt +0 -0
  141. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/ru/status_registered.expected +0 -0
  142. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/ru/status_registered.txt +0 -0
  143. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/su/status_available.expected +0 -0
  144. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/su/status_available.txt +0 -0
  145. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/su/status_registered.expected +0 -0
  146. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/su/status_registered.txt +0 -0
  147. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/xn--p1ai/status_available.expected +0 -0
  148. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/xn--p1ai/status_available.txt +0 -0
  149. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/xn--p1ai/status_registered.expected +0 -0
  150. data/spec/fixtures/responses/{whois.ripn.net → whois.tcinet.ru}/xn--p1ai/status_registered.txt +0 -0
  151. data/spec/integration_spec.rb +29 -12
  152. data/spec/support/helpers/spec_helper.rb +0 -10
  153. data/spec/tlds +1 -1
  154. data/spec/whois/record/parser/base_spec.rb +23 -51
  155. data/spec/whois/record/parser/responses/whois.aero/status_available_spec.rb +49 -1
  156. data/spec/whois/record/parser/responses/whois.aero/status_registered_spec.rb +91 -1
  157. data/spec/whois/record/parser/responses/whois.afilias-grs.info/bz/status_available_spec.rb +48 -0
  158. data/spec/whois/record/parser/responses/whois.afilias-grs.info/bz/status_registered_spec.rb +53 -2
  159. data/spec/whois/record/parser/responses/whois.afilias-grs.info/gi/status_available_spec.rb +48 -0
  160. data/spec/whois/record/parser/responses/whois.afilias-grs.info/gi/status_registered_spec.rb +90 -0
  161. data/spec/whois/record/parser/responses/whois.afilias-grs.info/hn/status_available_spec.rb +48 -0
  162. data/spec/whois/record/parser/responses/whois.afilias-grs.info/hn/status_registered_spec.rb +90 -0
  163. data/spec/whois/record/parser/responses/whois.afilias-grs.info/lc/status_available_spec.rb +48 -0
  164. data/spec/whois/record/parser/responses/whois.afilias-grs.info/lc/status_registered_spec.rb +90 -0
  165. data/spec/whois/record/parser/responses/whois.afilias-grs.info/mn/status_available_spec.rb +48 -0
  166. data/spec/whois/record/parser/responses/whois.afilias-grs.info/mn/status_registered_spec.rb +90 -0
  167. data/spec/whois/record/parser/responses/whois.afilias-grs.info/sc/status_available_spec.rb +48 -0
  168. data/spec/whois/record/parser/responses/whois.afilias-grs.info/sc/status_registered_spec.rb +90 -0
  169. data/spec/whois/record/parser/responses/whois.afilias-grs.info/vc/status_available_spec.rb +48 -0
  170. data/spec/whois/record/parser/responses/whois.afilias-grs.info/vc/status_registered_spec.rb +90 -0
  171. data/spec/whois/record/parser/responses/whois.dotmobiregistry.net/status_available_spec.rb +48 -0
  172. data/spec/whois/record/parser/responses/whois.dotmobiregistry.net/status_registered_spec.rb +90 -0
  173. data/spec/whois/record/parser/responses/whois.educause.edu/{properties_updated_on_unknown_spec.rb → property_updated_on_unknown_spec.rb} +3 -3
  174. data/spec/whois/record/parser/responses/whois.godaddy.com/status_registered_spec.rb +131 -0
  175. data/spec/whois/record/parser/responses/whois.markmonitor.com/{properties_empty_contacts_spec.rb → property_contacts_are_blank_spec.rb} +3 -3
  176. data/spec/whois/record/parser/responses/whois.meregistry.net/{property_nameservers_is_missing_spec.rb → property_nameservers_is_blank_spec.rb} +3 -3
  177. data/spec/whois/record/parser/responses/whois.meregistry.net/status_available_spec.rb +48 -0
  178. data/spec/whois/record/parser/responses/whois.meregistry.net/status_registered_spec.rb +91 -0
  179. data/spec/whois/record/parser/responses/whois.nic.af/property_status_active_spec.rb +39 -0
  180. data/spec/whois/record/parser/responses/whois.nic.af/property_status_delegated_spec.rb +39 -0
  181. data/spec/whois/record/parser/responses/whois.nic.af/property_status_not_registered_spec.rb +39 -0
  182. data/spec/whois/record/parser/responses/whois.nic.ag/status_available_spec.rb +48 -0
  183. data/spec/whois/record/parser/responses/whois.nic.ag/status_registered_spec.rb +90 -0
  184. data/spec/whois/record/parser/responses/whois.nic.asia/{property_status_client_delete_prohibited_spec.rb → property_status_multiple_spec.rb} +4 -4
  185. data/spec/whois/record/parser/responses/whois.nic.asia/{property_status_client_transfer_prohibited_spec.rb → property_status_single_spec.rb} +4 -4
  186. data/spec/whois/record/parser/responses/whois.nic.asia/status_available_spec.rb +49 -1
  187. data/spec/whois/record/parser/responses/whois.nic.asia/status_registered_spec.rb +92 -1
  188. data/spec/whois/record/parser/responses/whois.nic.dz/{status_available_spec.rb → dz/status_available_spec.rb} +2 -2
  189. data/spec/whois/record/parser/responses/whois.nic.dz/{status_registered_spec.rb → dz/status_registered_spec.rb} +2 -2
  190. data/spec/whois/record/parser/responses/whois.nic.name/status_available_spec.rb +1 -1
  191. data/spec/whois/record/parser/responses/whois.nic.name/status_registered_spec.rb +1 -1
  192. data/spec/whois/record/parser/responses/whois.nic.travel/property_status_multiple_spec.rb +29 -0
  193. data/spec/whois/record/parser/responses/whois.nic.travel/property_status_single_spec.rb +29 -0
  194. data/spec/whois/record/parser/responses/whois.nic.travel/status_available_spec.rb +1 -1
  195. data/spec/whois/record/parser/responses/whois.nic.travel/status_registered_spec.rb +1 -1
  196. data/spec/whois/record/parser/responses/whois.nic.xxx/property_updated_on_blank_spec.rb +29 -0
  197. data/spec/whois/record/parser/responses/whois.nic.xxx/status_registered_spec.rb +45 -46
  198. data/spec/whois/record/parser/responses/whois.publicinterestregistry.net/status_available_spec.rb +1 -1
  199. data/spec/whois/record/parser/responses/whois.publicinterestregistry.net/status_registered_spec.rb +11 -1
  200. data/spec/whois/record/parser/responses/whois.registry.in/property_status_missing_spec.rb +1 -1
  201. data/spec/whois/record/parser/responses/whois.registry.in/property_status_multiple_spec.rb +1 -1
  202. data/spec/whois/record/parser/responses/whois.registry.in/property_status_ok_spec.rb +1 -1
  203. data/spec/whois/record/parser/responses/whois.registry.in/status_available_spec.rb +44 -1
  204. data/spec/whois/record/parser/responses/whois.registry.in/status_registered_spec.rb +83 -1
  205. data/spec/whois/record/parser/responses/whois.registry.qa/qa/status_available_spec.rb +107 -0
  206. data/spec/whois/record/parser/responses/whois.registry.qa/qa/status_registered_spec.rb +142 -0
  207. data/spec/whois/record/parser/responses/whois.sgnic.sg/property_nameservers_schema_1_with_ip_spec.rb +39 -0
  208. data/spec/whois/record/parser/responses/{whois.ripn.net → whois.tcinet.ru}/ru/property_nameservers_with_ip_spec.rb +4 -4
  209. data/spec/whois/record/parser/responses/{whois.ripn.net/su → whois.tcinet.ru/ru}/status_available_spec.rb +4 -4
  210. data/spec/whois/record/parser/responses/{whois.ripn.net → whois.tcinet.ru}/ru/status_registered_spec.rb +4 -4
  211. data/spec/whois/record/parser/responses/{whois.ripn.net/ru → whois.tcinet.ru/su}/status_available_spec.rb +4 -4
  212. data/spec/whois/record/parser/responses/{whois.ripn.net → whois.tcinet.ru}/su/status_registered_spec.rb +4 -4
  213. data/spec/whois/record/parser/responses/{whois.ripn.net → whois.tcinet.ru}/xn--p1ai/status_available_spec.rb +4 -4
  214. data/spec/whois/record/parser/responses/{whois.ripn.net → whois.tcinet.ru}/xn--p1ai/status_registered_spec.rb +4 -4
  215. data/spec/whois/record_spec.rb +4 -4
  216. data/spec/whois/server/adapters/afilias_spec.rb +3 -3
  217. data/spec/whois/server/adapters/base_spec.rb +50 -10
  218. data/spec/whois/server/adapters/formatted_spec.rb +4 -4
  219. data/spec/whois/server/adapters/pir_spec.rb +3 -3
  220. data/spec/whois/server/adapters/standard_spec.rb +4 -4
  221. data/spec/whois/server/adapters/verisign_spec.rb +7 -7
  222. data/whois.gemspec +4 -4
  223. metadata +101 -57
  224. data/lib/whois/answer.rb +0 -14
@@ -13,7 +13,7 @@ require 'strscan'
13
13
  module Whois
14
14
  class Record
15
15
  class Parser
16
- module Features
16
+ module Scanners
17
17
 
18
18
  # The Ast module tries to emulate a super-simple Abstract Syntax Tree structure
19
19
  # including method for accessing ast nodes.
@@ -12,6 +12,15 @@ module Whois
12
12
  class Parser
13
13
  module Scanners
14
14
 
15
+ # Represents the abstract base scanner class,
16
+ # containing common scanner methods.
17
+ #
18
+ # Concrete classes should implement the following methods:
19
+ #
20
+ # * {#parse_content}
21
+ #
22
+ # @abstract
23
+ #
15
24
  class Base
16
25
 
17
26
  def initialize(content)
@@ -27,13 +27,13 @@ module Whois
27
27
 
28
28
  def parse_available
29
29
  if @input.scan(/^no matching record/)
30
- @ast["status-available"] = true
30
+ @ast["status:available"] = true
31
31
  end
32
32
  end
33
33
 
34
34
  def parse_reserved
35
35
  if @input.scan(/^the domain you want to register is reserved/)
36
- @ast["status-reserved"] = true
36
+ @ast["status:reserved"] = true
37
37
  end
38
38
  end
39
39
 
@@ -15,7 +15,7 @@ module Whois
15
15
  class Parser
16
16
  module Scanners
17
17
 
18
- class Whoisbiz < Scanners::Base
18
+ class WhoisBiz < Scanners::Base
19
19
 
20
20
  def parse_content
21
21
  parse_available ||
@@ -35,16 +35,10 @@ module Whois
35
35
  @input.scan(/^\S(.+)\n/)
36
36
  end
37
37
 
38
- def skip_unless_keyvalue
39
- if !@input.match?(/(.+?):(.*?)\n/)
40
- @input.scan(/.*\n/)
41
- end
42
- end
43
-
44
38
  def parse_available
45
39
  if @input.scan(/^Not found: (.+)\n/)
46
40
  @ast["Domain Name"] = @input[1]
47
- @ast["status-available"] = true
41
+ @ast["status:available"] = true
48
42
  end
49
43
  end
50
44
 
@@ -0,0 +1,117 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2011 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 < Scanners::Base
19
+
20
+ def parse_content
21
+ parse_throttled ||
22
+ parse_disclaimer ||
23
+ parse_invalid || # 1.10.0, 1.11.0
24
+ parse_available || # 1.10.0, 1.11.0
25
+ parse_pair(@ast) ||
26
+ parse_contact ||
27
+ parse_db_time || # 2.0
28
+
29
+ trim_empty_line ||
30
+ error!("Unexpected token")
31
+ end
32
+
33
+
34
+ def parse_throttled
35
+ if @input.match?(/^% Error: 55000000002/)
36
+ @ast["response:throttled"] = true
37
+ @input.skip(/^.+\n/)
38
+ end
39
+ end
40
+
41
+ def parse_disclaimer
42
+ if @input.match?(/% Copyright \(c\) *\d{4} by DENIC\n/)
43
+ @input.scan_until(/% Terms and Conditions of Use\n/)
44
+ lines = []
45
+ while @input.match?(/%/) && @input.scan(/%(.*)\n/)
46
+ lines << @input[1].strip unless @input[1].strip == ""
47
+ end
48
+ @ast["Disclaimer"] = lines.join(" ")
49
+ end
50
+ end
51
+
52
+ def parse_pair(node)
53
+ if @input.scan(/([^ \[]*):(.*)\n/)
54
+ key, value = @input[1].strip, @input[2].strip
55
+ if node[key].nil?
56
+ node[key] = value
57
+ else
58
+ node[key].is_a?(Array) || node[key] = [node[key]]
59
+ node[key] << value
60
+ end
61
+ true
62
+ end
63
+ end
64
+
65
+ def parse_contact
66
+ if @input.scan(/\[(.*)\]\n/)
67
+ contact_name = @input[1]
68
+ contact = {}
69
+ while parse_pair(contact)
70
+ end
71
+ @ast[contact_name] = {
72
+ "id" => nil,
73
+ "name" => contact['Name'],
74
+ "organization" => contact['Organisation'],
75
+ "address" => contact['Address'],
76
+ "city" => contact['City'],
77
+ # 1.10.0, 1.11.0 || 2.0
78
+ "zip" => contact['Pcode'] || contact['PostalCode'],
79
+ "state" => nil,
80
+ "country" => contact['Country'],
81
+ "country_code" => contact['CountryCode'],
82
+ "phone" => contact['Phone'],
83
+ "fax" => contact['Fax'],
84
+ "email" => contact['Email'],
85
+ "created_on" => nil,
86
+ "updated_on" => contact['Changed']
87
+ }
88
+ end
89
+ end
90
+
91
+ # Compatibility with Version: 1.11.0, 1.10.0
92
+ def parse_available
93
+ if @input.match?(/% Object ".+" not found in database\n/)
94
+ while @input.scan(/%(.*)\n/) # strip junk
95
+ end
96
+ @ast["status:available"] = true
97
+ end
98
+ end
99
+
100
+ def parse_invalid
101
+ if @input.match?(/% ".+" is not a valid domain name\n/)
102
+ @input.scan(/% "(.+?)" is not a valid domain name\n/)
103
+ @ast["Domain"] = @input[1]
104
+ @ast["status:invalid"] = true
105
+ end
106
+ end
107
+
108
+ def parse_db_time
109
+ @input.scan(/^% DB time is (.+)\n$/)
110
+ end
111
+
112
+ end
113
+
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,187 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2011 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 < Scanners::Base
19
+
20
+ def parse_content
21
+ parse_version ||
22
+ parse_disclaimer ||
23
+ parse_domain ||
24
+ parse_available ||
25
+ parse_in_progress ||
26
+
27
+ # v2.0
28
+ parse_moreinfo ||
29
+
30
+ # v1.99
31
+ parse_domain_data ||
32
+ parse_contacts ||
33
+
34
+ trim_empty_line ||
35
+ error!("Unexpected token")
36
+ end
37
+
38
+
39
+ def parse_version
40
+ if @input.match?(/% Whois server .*\n/)
41
+ p("whois.nic.hu: parse_version") if 1 == 2 || $DEBUG
42
+ @input.scan(/% Whois server ([\w\d\.]*).*?\n/)
43
+ @ast["version"] = @input[1]
44
+ end
45
+ end
46
+
47
+ # FIXME: Requires UTF-8 Encoding (see #11)
48
+ def parse_moreinfo
49
+ if @input.match?(/Tov.* ld\.:\n/)
50
+ p("whois.nic.hu: parse_moreinfo") if 1 == 2 || $DEBUG
51
+ @ast["moreinfo"] = @input.scan_until(/^\n/)
52
+ end
53
+ end
54
+
55
+ def parse_disclaimer
56
+ if @input.match?(/^Rights.*\n/)
57
+ p("whois.nic.hu: parse_disclaimer") if 1 == 2 || $DEBUG
58
+ lines = @input.scan_until(/^\n/)
59
+ @ast["disclaimer"] = lines.strip
60
+ end
61
+ end
62
+
63
+ def parse_domain
64
+ if @input.match?(/^domain:\s+(.*)\n/) && @input.scan(/^domain:\s+(.*?)\n/)
65
+ p("whois.nic.hu: parse_domain") if 1 == 2 || $DEBUG
66
+ @ast["domain"] = @input[1].strip
67
+ end
68
+ end
69
+
70
+ # FIXME: Requires UTF-8 Encoding (see #11)
71
+ def parse_available
72
+ if @input.match?(/Nincs (.*?) \/ No match\n/)
73
+ p("whois.nic.hu: parse_not_found") if 1 == 2 || $DEBUG
74
+ @input.scan(/Nincs (.*?) \/ No match\n/)
75
+ @ast["status:available"] = true
76
+ end
77
+ end
78
+
79
+ # FIXME: Requires UTF-8 Encoding (see #11)
80
+ def parse_in_progress
81
+ if @input.match?(/(.*?) folyamatban \/ Registration in progress\n/)
82
+ p("whois.nic.hu: parse_in_progress") if 1 == 2 || $DEBUG
83
+ @input.scan(/(.*?) folyamatban \/ Registration in progress\n/)
84
+ @ast["status:inprogress"] = true
85
+ end
86
+ end
87
+
88
+ def parse_domain_data
89
+ if @input.match?(/(.+?):\s+(.*)\n/)
90
+ p("whois.nic.hu: parse_domain_data") if 1 == 2 || $DEBUG
91
+ while @input.scan(/(.+?):\s+(.*)\n/)
92
+ key, value = @input[1].strip, @input[2].strip
93
+ if key == 'person'
94
+ @ast['name'] = value
95
+ elsif key == 'org'
96
+ if value =~ /org_name_hun:\s+(.*)\Z/
97
+ @ast['name'] = $1
98
+ elsif value =~ /org_name_eng:\s+(.*)\Z/
99
+ @ast['org'] = $1
100
+ elsif value != 'Private person'
101
+ contact['org'] = value
102
+ end
103
+ elsif @ast[key].nil?
104
+ @ast[key] = value
105
+ elsif @ast[key].is_a? Array
106
+ @ast[key] << value
107
+ else
108
+ @ast[key] = [@ast[key], value].flatten
109
+ end
110
+ end
111
+ true
112
+ end
113
+ end
114
+
115
+ def parse_contacts
116
+ if @input.match?(/\n(person|org):/)
117
+ p("whois.nic.hu: parse_contacts") if 1 == 2 || $DEBUG
118
+ @input.scan(/\n/)
119
+ while @input.match?(/(.+?):\s+(.*)\n/)
120
+ parse_contact
121
+ end
122
+ true
123
+ end
124
+ end
125
+
126
+ def parse_contact
127
+ contact ||= {}
128
+ p("whois.nic.hu: parse_contact") if 1 == 2 || $DEBUG
129
+ while @input.scan(/(.+?):\s+(.*)\n/)
130
+ key, value = @input[1].strip, @input[2].strip
131
+ if key == 'hun-id'
132
+ a1 = contact['address'][1].split(/\s/)
133
+ zip = a1.shift
134
+ city = a1.join(' ')
135
+ # we should keep the old values if this is an already
136
+ # defined contact
137
+ if @ast[value].nil?
138
+ @ast[value] = {
139
+ "id" => value,
140
+ "name" => contact['name'],
141
+ "organization" => contact['org'],
142
+ "address" => contact['address'][0],
143
+ "city" => city,
144
+ "zip" => zip,
145
+ "country_code" => contact['address'][2],
146
+ "phone" => contact['phone'],
147
+ "fax" => contact['fax-no'],
148
+ "email" => contact['e-mail']
149
+ }
150
+ else
151
+ @ast[value]["id"] ||= value
152
+ @ast[value]["name"] ||= contact['name']
153
+ @ast[value]["organization"] ||= contact['org']
154
+ @ast[value]["address"] ||= contact['address'][0]
155
+ @ast[value]["city"] ||= city
156
+ @ast[value]["zip"] ||= zip
157
+ @ast[value]["country_code"] ||= contact['address'][2]
158
+ @ast[value]["phone"] ||= contact['phone']
159
+ @ast[value]["fax"] ||= contact['fax-no']
160
+ @ast[value]["email"] ||= contact['e-mail']
161
+ end
162
+ contact = {}
163
+ elsif key == 'person'
164
+ contact['name'] = value
165
+ elsif key == 'org'
166
+ if value =~ /org_name_hun:\s+(.*)\Z/
167
+ contact['name'] = $1
168
+ elsif value =~ /org_name_eng:\s+(.*)\Z/
169
+ contact['org'] = $1
170
+ else
171
+ contact['org'] = value
172
+ end
173
+ elsif key == 'address' && !contact['address'].nil?
174
+ contact['address'] = [contact['address'], value].flatten
175
+ else
176
+ contact[key] = value
177
+ end
178
+ end
179
+ true
180
+ end
181
+
182
+ end
183
+
184
+ end
185
+ end
186
+ end
187
+ end
@@ -15,7 +15,7 @@ module Whois
15
15
  class Parser
16
16
  module Scanners
17
17
 
18
- class Whoisit < Scanners::Base
18
+ class WhoisNicIt < Scanners::Base
19
19
 
20
20
  def parse_content
21
21
  parse_response_unavailable ||
@@ -29,7 +29,7 @@ module Whois
29
29
 
30
30
  def parse_response_unavailable
31
31
  if @input.scan(/Service temporarily unavailable\.\n/)
32
- @ast["status-unavailable"] = true
32
+ @ast["status:unavailable"] = true
33
33
  end
34
34
  end
35
35
 
@@ -0,0 +1,54 @@
1
+ #--
2
+ # Ruby Whois
3
+ #
4
+ # An intelligent pure Ruby WHOIS client and parser.
5
+ #
6
+ # Copyright (c) 2009-2011 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.registry.qa server response.
19
+ #
20
+ # @since 2.1.0
21
+ class WhoisRegistryQa < Scanners::Base
22
+
23
+ def parse_content
24
+ parse_available ||
25
+ parse_keyvalue_spaced ||
26
+
27
+ trim_empty_line ||
28
+ error!("Unexpected token")
29
+ end
30
+
31
+ def parse_available
32
+ if @input.scan(/^No Data Found\n/)
33
+ @ast["status:available"] = true
34
+ end
35
+ end
36
+
37
+ def parse_keyvalue_spaced
38
+ if @input.scan(/(.+?):\s+(.*?)\n/)
39
+ key, value = @input[1].strip, @input[2].strip
40
+ if @ast[key].nil?
41
+ @ast[key] = value
42
+ else
43
+ @ast[key].is_a?(Array) || @ast[key] = [@ast[key]]
44
+ @ast[key] << value
45
+ end
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end