whois 3.6.5 → 4.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/CONTRIBUTING.md +0 -2
  4. data/README.md +8 -3
  5. data/bin/whoisrb +5 -5
  6. data/data/tld.json +437 -216
  7. data/lib/whois.rb +1 -75
  8. data/lib/whois/errors.rb +0 -44
  9. data/lib/whois/record.rb +0 -237
  10. data/lib/whois/record/part.rb +20 -4
  11. data/lib/whois/server/adapters/base.rb +18 -3
  12. data/lib/whois/version.rb +1 -13
  13. data/whois.gemspec +9 -16
  14. metadata +7 -295
  15. data/lib/whois/record/contact.rb +0 -65
  16. data/lib/whois/record/nameserver.rb +0 -48
  17. data/lib/whois/record/parser.rb +0 -398
  18. data/lib/whois/record/parser/base.rb +0 -399
  19. data/lib/whois/record/parser/base_afilias.rb +0 -141
  20. data/lib/whois/record/parser/base_afilias2.rb +0 -138
  21. data/lib/whois/record/parser/base_cocca.rb +0 -99
  22. data/lib/whois/record/parser/base_cocca2.rb +0 -100
  23. data/lib/whois/record/parser/base_icann_compliant.rb +0 -159
  24. data/lib/whois/record/parser/base_icb.rb +0 -94
  25. data/lib/whois/record/parser/base_iisse.rb +0 -113
  26. data/lib/whois/record/parser/base_shared1.rb +0 -110
  27. data/lib/whois/record/parser/base_shared2.rb +0 -129
  28. data/lib/whois/record/parser/base_shared3.rb +0 -129
  29. data/lib/whois/record/parser/base_verisign.rb +0 -108
  30. data/lib/whois/record/parser/base_whoisd.rb +0 -147
  31. data/lib/whois/record/parser/blank.rb +0 -37
  32. data/lib/whois/record/parser/capetown-whois.registry.net.za.rb +0 -27
  33. data/lib/whois/record/parser/ccwhois.ksregistry.net.rb +0 -28
  34. data/lib/whois/record/parser/ccwhois.verisign-grs.com.rb +0 -27
  35. data/lib/whois/record/parser/durban-whois.registry.net.za.rb +0 -27
  36. data/lib/whois/record/parser/example.rb +0 -166
  37. data/lib/whois/record/parser/jobswhois.verisign-grs.com.rb +0 -27
  38. data/lib/whois/record/parser/joburg-whois.registry.net.za.rb +0 -27
  39. data/lib/whois/record/parser/kero.yachay.pe.rb +0 -88
  40. data/lib/whois/record/parser/org-whois.registry.net.za.rb +0 -27
  41. data/lib/whois/record/parser/whois.1und1.info.rb +0 -30
  42. data/lib/whois/record/parser/whois.35.com.rb +0 -26
  43. data/lib/whois/record/parser/whois.aeda.net.ae.rb +0 -66
  44. data/lib/whois/record/parser/whois.aero.rb +0 -59
  45. data/lib/whois/record/parser/whois.afilias-grs.info.rb +0 -23
  46. data/lib/whois/record/parser/whois.afilias.net.rb +0 -28
  47. data/lib/whois/record/parser/whois.ai.rb +0 -64
  48. data/lib/whois/record/parser/whois.amnic.net.rb +0 -81
  49. data/lib/whois/record/parser/whois.ascio.com.rb +0 -31
  50. data/lib/whois/record/parser/whois.ati.tn.rb +0 -118
  51. data/lib/whois/record/parser/whois.audns.net.au.rb +0 -121
  52. data/lib/whois/record/parser/whois.ax.rb +0 -66
  53. data/lib/whois/record/parser/whois.biz.rb +0 -27
  54. data/lib/whois/record/parser/whois.bnnic.bn.rb +0 -77
  55. data/lib/whois/record/parser/whois.cat.rb +0 -79
  56. data/lib/whois/record/parser/whois.cctld.by.rb +0 -96
  57. data/lib/whois/record/parser/whois.cctld.uz.rb +0 -83
  58. data/lib/whois/record/parser/whois.centralnic.com.rb +0 -142
  59. data/lib/whois/record/parser/whois.cira.ca.rb +0 -194
  60. data/lib/whois/record/parser/whois.cmc.iq.rb +0 -27
  61. data/lib/whois/record/parser/whois.cnnic.cn.rb +0 -110
  62. data/lib/whois/record/parser/whois.co.ca.rb +0 -78
  63. data/lib/whois/record/parser/whois.co.pl.rb +0 -84
  64. data/lib/whois/record/parser/whois.co.ug.rb +0 -84
  65. data/lib/whois/record/parser/whois.comlaude.com.rb +0 -115
  66. data/lib/whois/record/parser/whois.corporatedomains.com.rb +0 -30
  67. data/lib/whois/record/parser/whois.denic.de.rb +0 -166
  68. data/lib/whois/record/parser/whois.dk-hostmaster.dk.rb +0 -82
  69. data/lib/whois/record/parser/whois.dns.be.rb +0 -122
  70. data/lib/whois/record/parser/whois.dns.hr.rb +0 -99
  71. data/lib/whois/record/parser/whois.dns.lu.rb +0 -128
  72. data/lib/whois/record/parser/whois.dns.pl.rb +0 -153
  73. data/lib/whois/record/parser/whois.dns.pt.rb +0 -79
  74. data/lib/whois/record/parser/whois.domain-registry.nl.rb +0 -125
  75. data/lib/whois/record/parser/whois.domain.kg.rb +0 -78
  76. data/lib/whois/record/parser/whois.domainregistry.ie.rb +0 -123
  77. data/lib/whois/record/parser/whois.domreg.lt.rb +0 -70
  78. data/lib/whois/record/parser/whois.donuts.co.rb +0 -64
  79. data/lib/whois/record/parser/whois.dot.cf.rb +0 -73
  80. data/lib/whois/record/parser/whois.dot.tk.rb +0 -72
  81. data/lib/whois/record/parser/whois.dotgov.gov.rb +0 -63
  82. data/lib/whois/record/parser/whois.dotmobiregistry.net.rb +0 -23
  83. data/lib/whois/record/parser/whois.dotpostregistry.net.rb +0 -27
  84. data/lib/whois/record/parser/whois.dotproregistry.net.rb +0 -41
  85. data/lib/whois/record/parser/whois.dreamhost.com.rb +0 -25
  86. data/lib/whois/record/parser/whois.educause.edu.rb +0 -202
  87. data/lib/whois/record/parser/whois.eenet.ee.rb +0 -74
  88. data/lib/whois/record/parser/whois.enom.com.rb +0 -36
  89. data/lib/whois/record/parser/whois.eu.org.rb +0 -60
  90. data/lib/whois/record/parser/whois.eu.rb +0 -132
  91. data/lib/whois/record/parser/whois.fi.rb +0 -119
  92. data/lib/whois/record/parser/whois.gandi.net.rb +0 -32
  93. data/lib/whois/record/parser/whois.gg.rb +0 -33
  94. data/lib/whois/record/parser/whois.godaddy.com.rb +0 -113
  95. data/lib/whois/record/parser/whois.gov.za.rb +0 -64
  96. data/lib/whois/record/parser/whois.hkirc.hk.rb +0 -73
  97. data/lib/whois/record/parser/whois.iana.org.rb +0 -104
  98. data/lib/whois/record/parser/whois.iis.nu.rb +0 -28
  99. data/lib/whois/record/parser/whois.iis.se.rb +0 -28
  100. data/lib/whois/record/parser/whois.in.ua.rb +0 -77
  101. data/lib/whois/record/parser/whois.inregistry.net.rb +0 -29
  102. data/lib/whois/record/parser/whois.isnic.is.rb +0 -72
  103. data/lib/whois/record/parser/whois.isoc.org.il.rb +0 -77
  104. data/lib/whois/record/parser/whois.ja.net.rb +0 -77
  105. data/lib/whois/record/parser/whois.je.rb +0 -27
  106. data/lib/whois/record/parser/whois.jprs.jp.rb +0 -105
  107. data/lib/whois/record/parser/whois.kenic.or.ke.rb +0 -93
  108. data/lib/whois/record/parser/whois.kr.rb +0 -81
  109. data/lib/whois/record/parser/whois.markmonitor.com.rb +0 -38
  110. data/lib/whois/record/parser/whois.monic.mo.rb +0 -85
  111. data/lib/whois/record/parser/whois.museum.rb +0 -81
  112. data/lib/whois/record/parser/whois.mynic.my.rb +0 -74
  113. data/lib/whois/record/parser/whois.na-nic.com.na.rb +0 -23
  114. data/lib/whois/record/parser/whois.nc.rb +0 -124
  115. data/lib/whois/record/parser/whois.netcom.cm.rb +0 -28
  116. data/lib/whois/record/parser/whois.networksolutions.com.rb +0 -39
  117. data/lib/whois/record/parser/whois.nic.ac.rb +0 -27
  118. data/lib/whois/record/parser/whois.nic.af.rb +0 -27
  119. data/lib/whois/record/parser/whois.nic.ag.rb +0 -23
  120. data/lib/whois/record/parser/whois.nic.as.rb +0 -65
  121. data/lib/whois/record/parser/whois.nic.asia.rb +0 -109
  122. data/lib/whois/record/parser/whois.nic.at.rb +0 -66
  123. data/lib/whois/record/parser/whois.nic.bj.rb +0 -128
  124. data/lib/whois/record/parser/whois.nic.bo.rb +0 -75
  125. data/lib/whois/record/parser/whois.nic.cd.rb +0 -36
  126. data/lib/whois/record/parser/whois.nic.ch.rb +0 -111
  127. data/lib/whois/record/parser/whois.nic.ci.rb +0 -72
  128. data/lib/whois/record/parser/whois.nic.cl.rb +0 -73
  129. data/lib/whois/record/parser/whois.nic.co.rb +0 -27
  130. data/lib/whois/record/parser/whois.nic.college.rb +0 -27
  131. data/lib/whois/record/parser/whois.nic.coop.rb +0 -72
  132. data/lib/whois/record/parser/whois.nic.cx.rb +0 -27
  133. data/lib/whois/record/parser/whois.nic.cz.rb +0 -44
  134. data/lib/whois/record/parser/whois.nic.design.rb +0 -27
  135. data/lib/whois/record/parser/whois.nic.dm.rb +0 -27
  136. data/lib/whois/record/parser/whois.nic.dz.rb +0 -60
  137. data/lib/whois/record/parser/whois.nic.ec.rb +0 -36
  138. data/lib/whois/record/parser/whois.nic.es.rb +0 -107
  139. data/lib/whois/record/parser/whois.nic.fo.rb +0 -45
  140. data/lib/whois/record/parser/whois.nic.fr.rb +0 -176
  141. data/lib/whois/record/parser/whois.nic.gd.rb +0 -33
  142. data/lib/whois/record/parser/whois.nic.gl.rb +0 -27
  143. data/lib/whois/record/parser/whois.nic.gs.rb +0 -33
  144. data/lib/whois/record/parser/whois.nic.hn.rb +0 -27
  145. data/lib/whois/record/parser/whois.nic.ht.rb +0 -27
  146. data/lib/whois/record/parser/whois.nic.hu.rb +0 -80
  147. data/lib/whois/record/parser/whois.nic.im.rb +0 -68
  148. data/lib/whois/record/parser/whois.nic.io.rb +0 -50
  149. data/lib/whois/record/parser/whois.nic.ir.rb +0 -68
  150. data/lib/whois/record/parser/whois.nic.it.rb +0 -161
  151. data/lib/whois/record/parser/whois.nic.ki.rb +0 -27
  152. data/lib/whois/record/parser/whois.nic.kz.rb +0 -69
  153. data/lib/whois/record/parser/whois.nic.la.rb +0 -27
  154. data/lib/whois/record/parser/whois.nic.li.rb +0 -66
  155. data/lib/whois/record/parser/whois.nic.lk.rb +0 -111
  156. data/lib/whois/record/parser/whois.nic.lv.rb +0 -69
  157. data/lib/whois/record/parser/whois.nic.ly.rb +0 -78
  158. data/lib/whois/record/parser/whois.nic.md.rb +0 -96
  159. data/lib/whois/record/parser/whois.nic.me.rb +0 -87
  160. data/lib/whois/record/parser/whois.nic.mg.rb +0 -33
  161. data/lib/whois/record/parser/whois.nic.ms.rb +0 -27
  162. data/lib/whois/record/parser/whois.nic.mu.rb +0 -27
  163. data/lib/whois/record/parser/whois.nic.mx.rb +0 -81
  164. data/lib/whois/record/parser/whois.nic.name.rb +0 -70
  165. data/lib/whois/record/parser/whois.nic.net.ng.rb +0 -29
  166. data/lib/whois/record/parser/whois.nic.net.sa.rb +0 -72
  167. data/lib/whois/record/parser/whois.nic.net.sb.rb +0 -33
  168. data/lib/whois/record/parser/whois.nic.nf.rb +0 -27
  169. data/lib/whois/record/parser/whois.nic.org.uy.rb +0 -77
  170. data/lib/whois/record/parser/whois.nic.pr.rb +0 -86
  171. data/lib/whois/record/parser/whois.nic.priv.at.rb +0 -64
  172. data/lib/whois/record/parser/whois.nic.pw.rb +0 -27
  173. data/lib/whois/record/parser/whois.nic.sh.rb +0 -27
  174. data/lib/whois/record/parser/whois.nic.sl.rb +0 -78
  175. data/lib/whois/record/parser/whois.nic.sm.rb +0 -78
  176. data/lib/whois/record/parser/whois.nic.sn.rb +0 -115
  177. data/lib/whois/record/parser/whois.nic.so.rb +0 -72
  178. data/lib/whois/record/parser/whois.nic.space.rb +0 -27
  179. data/lib/whois/record/parser/whois.nic.st.rb +0 -74
  180. data/lib/whois/record/parser/whois.nic.tc.rb +0 -27
  181. data/lib/whois/record/parser/whois.nic.tech.rb +0 -27
  182. data/lib/whois/record/parser/whois.nic.tel.rb +0 -27
  183. data/lib/whois/record/parser/whois.nic.tl.rb +0 -27
  184. data/lib/whois/record/parser/whois.nic.tm.rb +0 -33
  185. data/lib/whois/record/parser/whois.nic.tr.rb +0 -161
  186. data/lib/whois/record/parser/whois.nic.travel.rb +0 -27
  187. data/lib/whois/record/parser/whois.nic.tv.rb +0 -27
  188. data/lib/whois/record/parser/whois.nic.uk.rb +0 -179
  189. data/lib/whois/record/parser/whois.nic.us.rb +0 -27
  190. data/lib/whois/record/parser/whois.nic.ve.rb +0 -89
  191. data/lib/whois/record/parser/whois.nic.xxx.rb +0 -44
  192. data/lib/whois/record/parser/whois.nic.xyz.rb +0 -22
  193. data/lib/whois/record/parser/whois.norid.no.rb +0 -63
  194. data/lib/whois/record/parser/whois.pairnic.com.rb +0 -30
  195. data/lib/whois/record/parser/whois.pandi.or.id.rb +0 -27
  196. data/lib/whois/record/parser/whois.pir.org.rb +0 -92
  197. data/lib/whois/record/parser/whois.pnina.ps.rb +0 -33
  198. data/lib/whois/record/parser/whois.register.bg.rb +0 -85
  199. data/lib/whois/record/parser/whois.register.com.rb +0 -32
  200. data/lib/whois/record/parser/whois.register.si.rb +0 -75
  201. data/lib/whois/record/parser/whois.registre.ma.rb +0 -65
  202. data/lib/whois/record/parser/whois.registro.br.rb +0 -75
  203. data/lib/whois/record/parser/whois.registry.gy.rb +0 -27
  204. data/lib/whois/record/parser/whois.registry.hm.rb +0 -74
  205. data/lib/whois/record/parser/whois.registry.net.za.rb +0 -145
  206. data/lib/whois/record/parser/whois.registry.om.rb +0 -42
  207. data/lib/whois/record/parser/whois.registry.qa.rb +0 -27
  208. data/lib/whois/record/parser/whois.ripe.net.rb +0 -70
  209. data/lib/whois/record/parser/whois.rnids.rs.rb +0 -136
  210. data/lib/whois/record/parser/whois.rotld.ro.rb +0 -67
  211. data/lib/whois/record/parser/whois.rrpproxy.net.rb +0 -34
  212. data/lib/whois/record/parser/whois.safenames.net.rb +0 -50
  213. data/lib/whois/record/parser/whois.schlund.info.rb +0 -36
  214. data/lib/whois/record/parser/whois.sgnic.sg.rb +0 -89
  215. data/lib/whois/record/parser/whois.sk-nic.sk.rb +0 -103
  216. data/lib/whois/record/parser/whois.smallregistry.net.rb +0 -133
  217. data/lib/whois/record/parser/whois.srs.net.nz.rb +0 -161
  218. data/lib/whois/record/parser/whois.sx.rb +0 -134
  219. data/lib/whois/record/parser/whois.tcinet.ru.rb +0 -116
  220. data/lib/whois/record/parser/whois.thnic.co.th.rb +0 -81
  221. data/lib/whois/record/parser/whois.tld.ee.rb +0 -136
  222. data/lib/whois/record/parser/whois.tld.sy.rb +0 -36
  223. data/lib/whois/record/parser/whois.tonic.to.rb +0 -88
  224. data/lib/whois/record/parser/whois.tucows.com.rb +0 -30
  225. data/lib/whois/record/parser/whois.twnic.net.tw.rb +0 -74
  226. data/lib/whois/record/parser/whois.tznic.or.tz.rb +0 -27
  227. data/lib/whois/record/parser/whois.ua.rb +0 -242
  228. data/lib/whois/record/parser/whois.udag.net.rb +0 -30
  229. data/lib/whois/record/parser/whois.uniregistry.net.rb +0 -68
  230. data/lib/whois/record/parser/whois.usp.ac.fj.rb +0 -74
  231. data/lib/whois/record/parser/whois.verisign-grs.com.rb +0 -51
  232. data/lib/whois/record/parser/whois.website.ws.rb +0 -76
  233. data/lib/whois/record/parser/whois.wildwestdomains.com.rb +0 -37
  234. data/lib/whois/record/parser/whois.yoursrs.com.rb +0 -127
  235. data/lib/whois/record/parser/whois.za.net.rb +0 -74
  236. data/lib/whois/record/parser/whois.za.org.rb +0 -74
  237. data/lib/whois/record/parser/whois1.nic.bi.rb +0 -27
  238. data/lib/whois/record/parser/za_central_registry.rb +0 -70
  239. data/lib/whois/record/registrar.rb +0 -34
  240. data/lib/whois/record/scanners/base.rb +0 -126
  241. data/lib/whois/record/scanners/base_afilias.rb +0 -63
  242. data/lib/whois/record/scanners/base_cocca2.rb +0 -55
  243. data/lib/whois/record/scanners/base_icann_compliant.rb +0 -57
  244. data/lib/whois/record/scanners/base_iisse.rb +0 -48
  245. data/lib/whois/record/scanners/base_shared1.rb +0 -43
  246. data/lib/whois/record/scanners/base_shared2.rb +0 -47
  247. data/lib/whois/record/scanners/base_shared3.rb +0 -49
  248. data/lib/whois/record/scanners/base_whoisd.rb +0 -56
  249. data/lib/whois/record/scanners/iana.rb +0 -101
  250. data/lib/whois/record/scanners/scannable.rb +0 -77
  251. data/lib/whois/record/scanners/verisign.rb +0 -112
  252. data/lib/whois/record/scanners/whois.ati.tn.rb +0 -44
  253. data/lib/whois/record/scanners/whois.audns.net.au.rb +0 -37
  254. data/lib/whois/record/scanners/whois.cctld.by.rb +0 -47
  255. data/lib/whois/record/scanners/whois.centralnic.com.rb +0 -44
  256. data/lib/whois/record/scanners/whois.cira.ca.rb +0 -84
  257. data/lib/whois/record/scanners/whois.cnnic.cn.rb +0 -54
  258. data/lib/whois/record/scanners/whois.denic.de.rb +0 -108
  259. data/lib/whois/record/scanners/whois.dns.hr.rb +0 -37
  260. data/lib/whois/record/scanners/whois.domainregistry.ie.rb +0 -58
  261. data/lib/whois/record/scanners/whois.fi.rb +0 -51
  262. data/lib/whois/record/scanners/whois.nc.rb +0 -44
  263. data/lib/whois/record/scanners/whois.nic.cz.rb +0 -34
  264. data/lib/whois/record/scanners/whois.nic.it.rb +0 -104
  265. data/lib/whois/record/scanners/whois.pir.org.rb +0 -29
  266. data/lib/whois/record/scanners/whois.registry.net.za.rb +0 -104
  267. data/lib/whois/record/scanners/whois.rnids.rs.rb +0 -64
  268. data/lib/whois/record/scanners/whois.smallregistry.net.rb +0 -61
  269. data/lib/whois/record/scanners/whois.srs.net.nz.rb +0 -35
  270. data/lib/whois/record/scanners/whois.sx.rb +0 -49
  271. data/lib/whois/record/scanners/whois.tld.ee.rb +0 -57
  272. data/lib/whois/record/scanners/whois.tucows.com.rb +0 -35
  273. data/lib/whois/record/scanners/whois.yoursrs.com.rb +0 -36
  274. data/lib/whois/record/super_struct.rb +0 -62
@@ -1,48 +0,0 @@
1
- #--
2
- # Ruby Whois
3
- #
4
- # An intelligent pure Ruby WHOIS client and parser.
5
- #
6
- # Copyright (c) 2009-2015 Simone Carletti <weppos@weppos.net>
7
- #++
8
-
9
-
10
- require 'whois/record/super_struct'
11
-
12
-
13
- module Whois
14
- class Record
15
-
16
- # Holds the details of the Name Servers extracted from the WHOIS response.
17
- #
18
- # A name server is composed by the several attributes,
19
- # accessible through corresponding getter / setter methods.
20
- #
21
- # Please note that a response is not required to provide
22
- # all the attributes. When an attribute is not available,
23
- # the corresponding value is set to nil.
24
- #
25
- # @attr [String] name
26
- # @attr [String] ipv4
27
- # @attr [String] ipv6
28
- #
29
- class Nameserver < SuperStruct.new(:name, :ipv4, :ipv6)
30
-
31
- # Returns a string representation of this object
32
- # composed by the host +name+.
33
- #
34
- # @example
35
- # Nameserver.new(:name => "ns.example.com").to_s
36
- # # => "ns.example.com"
37
- # Nameserver.new.to_s
38
- # # => ""
39
- #
40
- # @return [String] The string representation.
41
- def to_s
42
- name.to_s
43
- end
44
-
45
- end
46
-
47
- end
48
- end
@@ -1,398 +0,0 @@
1
- #--
2
- # Ruby Whois
3
- #
4
- # An intelligent pure Ruby WHOIS client and parser.
5
- #
6
- # Copyright (c) 2009-2015 Simone Carletti <weppos@weppos.net>
7
- #++
8
-
9
-
10
- module Whois
11
- class Record
12
-
13
- # The parsing controller that stays behind the {Whois::Record}.
14
- #
15
- # It provides object-oriented access to a WHOIS response.
16
- # The list of properties and methods is available
17
- # in the following constants:
18
- #
19
- # * {Whois::Record::Parser::METHODS}
20
- # * {Whois::Record::Parser::PROPERTIES}
21
- #
22
- class Parser
23
-
24
- METHODS = [
25
- :contacts,
26
- :changed?, :unchanged?,
27
- # :response_incomplete?, :response_throttled?, :response_unavailable?,
28
- # :referral_whois, :referral_url,
29
- ]
30
-
31
- PROPERTIES = [
32
- :disclaimer,
33
- :domain, :domain_id,
34
- :status, :available?, :registered?,
35
- :created_on, :updated_on, :expires_on,
36
- :registrar,
37
- :registrant_contacts, :admin_contacts, :technical_contacts,
38
- :nameservers,
39
- ]
40
-
41
- PROPERTY_STATE_NOT_IMPLEMENTED = :not_implemented
42
- PROPERTY_STATE_NOT_SUPPORTED = :not_supported
43
- PROPERTY_STATE_SUPPORTED = :supported
44
-
45
-
46
- # Returns the proper parser instance for given <tt>part</tt>.
47
- # The parser class is selected according to the
48
- # value of the <tt>#host</tt> attribute for given <tt>part</tt>.
49
- #
50
- # @param [Whois::Record::Part] part The part to get the parser for.
51
- #
52
- # @return [Whois::Record::Parser::Base]
53
- # An instance of the specific parser for given part.
54
- # The instance is expected to be a child of {Whois::Record::Parser::Base}.
55
- #
56
- # @example
57
- #
58
- # # Parser for a known host
59
- # Parser.parser_for("whois.example.com")
60
- # # => #<Whois::Record::Parser::WhoisExampleCom>
61
- #
62
- # # Parser for an unknown host
63
- # Parser.parser_for("missing.example.com")
64
- # # => #<Whois::Record::Parser::Blank>
65
- #
66
- def self.parser_for(part)
67
- parser_klass(part.host).new(part)
68
- rescue LoadError
69
- Parser.const_defined?("Blank") || autoload("blank")
70
- Parser::Blank.new(part)
71
- end
72
-
73
- # Detects the proper parser class according to given <tt>host</tt>
74
- # and returns the class constant.
75
- #
76
- # This method autoloads missing parser classes. If you want to define
77
- # a custom parser, simple make sure the class is loaded in the Ruby
78
- # environment before this method is called.
79
- #
80
- # @param [String] host The server host.
81
- #
82
- # @return [Class] The instance of Class representing the parser Class
83
- # corresponding to <tt>host</tt>. If <tt>host</tt> doesn't have
84
- # a specific parser implementation, then returns
85
- # the {Whois::Record::Parser::Blank} {Class}.
86
- # The {Class} is expected to be a child of {Whois::Record::Parser::Base}.
87
- # @raises LoadError If the class is not found.
88
- #
89
- # @example
90
- #
91
- # Parser.parser_klass("whois.example.com")
92
- # # => Whois::Record::Parser::WhoisExampleCom
93
- #
94
- def self.parser_klass(host)
95
- name = host_to_parser(host)
96
- Parser.const_defined?(name) || autoload(host)
97
- Parser.const_get(name)
98
- end
99
-
100
- # Converts <tt>host</tt> to the corresponding parser class name.
101
- #
102
- # @param [String] host The server host.
103
- # @return [String] The class name.
104
- #
105
- # @example
106
- #
107
- # Parser.host_to_parser("whois.nic.it")
108
- # # => "WhoisNicIt"
109
- #
110
- # Parser.host_to_parser("whois.nic-info.it")
111
- # # => "WhoisNicInfoIt"
112
- #
113
- def self.host_to_parser(host)
114
- host.to_s.downcase.
115
- gsub(/[.-]/, '_').
116
- gsub(/(?:^|_)(.)/) { $1.upcase }.
117
- gsub(/\A(\d+)\z/) { "Host#{$1}" }
118
- end
119
-
120
- # Requires the file at <tt>whois/record/parser/#{name}</tt>.
121
- #
122
- # @param [String] name The file name to load.
123
- #
124
- # @return [void]
125
- #
126
- def self.autoload(name)
127
- require "whois/record/parser/#{name}"
128
- end
129
-
130
-
131
- # @return [Whois::Record] The record referenced by this parser.
132
- attr_reader :record
133
-
134
-
135
- # Initializes and return a new parser from +record+.
136
- #
137
- # @param [Whois::Record] record
138
- #
139
- def initialize(record)
140
- @record = record
141
- end
142
-
143
- # Checks if this class respond to given method.
144
- #
145
- # Overrides the default implementation to add support
146
- # for {PROPERTIES} and {METHODS}.
147
- #
148
- # @return [Boolean]
149
- def respond_to?(symbol, include_private = false)
150
- respond_to_parser_method?(symbol) || super
151
- end
152
-
153
-
154
- # Returns an array with all host-specific parsers initialized for the parts
155
- # contained into this parser.
156
- # The array is lazy-initialized.
157
- #
158
- # @return [Array<Whois::Record::Parser::Base>]
159
- #
160
- def parsers
161
- @parsers ||= init_parsers
162
- end
163
-
164
- # Checks if the <tt>property</tt> passed as symbol
165
- # is supported in any of the parsers.
166
- #
167
- # @return [Boolean]
168
- #
169
- # @see Whois::Record::Parser::Base.property_supported?
170
- #
171
- def property_any_supported?(property)
172
- parsers.any? { |parser| parser.property_supported?(property) }
173
- end
174
-
175
- # Checks if the <tt>property</tt> passed as symbol
176
- # is "not implemented" in any of the parsers.
177
- #
178
- # @return [Boolean]
179
- #
180
- def property_any_not_implemented?(property)
181
- parsers.any? { |parser| parser.class.property_state?(property, Whois::Record::Parser::PROPERTY_STATE_NOT_IMPLEMENTED) }
182
- end
183
-
184
-
185
- # @!group Methods
186
-
187
- # Collects and returns all the contacts from all the record parts.
188
- #
189
- # @return [Array<Whois::Record::Contact>]
190
- #
191
- # @see Whois::Record#contacts
192
- # @see Whois::Record::Parser::Base#contacts
193
- #
194
- def contacts
195
- parsers.map(&:contacts).flatten
196
- end
197
-
198
- # @!endgroup
199
-
200
-
201
- # @!group Response
202
-
203
- # Loop through all the record parts to check
204
- # if at least one part changed.
205
- #
206
- # @param [Whois::Record::Parser] other The other parser instance to compare.
207
- # @return [Boolean]
208
- #
209
- # @see Whois::Record#changed?
210
- # @see Whois::Record::Parser::Base#changed?
211
- #
212
- def changed?(other)
213
- !unchanged?(other)
214
- end
215
-
216
- # The opposite of {#changed?}.
217
- #
218
- # @param [Whois::Record::Parser] other The other parser instance to compare.
219
- # @return [Boolean]
220
- #
221
- # @see Whois::Record#unchanged?
222
- # @see Whois::Record::Parser::Base#unchanged?
223
- #
224
- def unchanged?(other)
225
- unless other.is_a?(self.class)
226
- raise(ArgumentError, "Can't compare `#{self.class}' with `#{other.class}'")
227
- end
228
-
229
- equal?(other) ||
230
- parsers.size == other.parsers.size && all_in_parallel?(parsers, other.parsers) { |one, two| one.unchanged?(two) }
231
- end
232
-
233
-
234
- # Loop through all the parts to check if at least
235
- # one part is an incomplete response.
236
- #
237
- # @return [Boolean]
238
- #
239
- # @see Whois::Record#response_incomplete?
240
- # @see Whois::Record::Parser::Base#response_incomplete?
241
- #
242
- def response_incomplete?
243
- any_is?(parsers, :response_incomplete?)
244
- end
245
-
246
- # Loop through all the parts to check if at least
247
- # one part is a throttle response.
248
- #
249
- # @return [Boolean]
250
- #
251
- # @see Whois::Record#response_throttled?
252
- # @see Whois::Record::Parser::Base#response_throttled?
253
- #
254
- def response_throttled?
255
- any_is?(parsers, :response_throttled?)
256
- end
257
-
258
- # Loop through all the parts to check if at least
259
- # one part is an unavailable response.
260
- #
261
- # @return [Boolean]
262
- #
263
- # @see Whois::Record#response_unavailable?
264
- # @see Whois::Record::Parser::Base#response_unavailable?
265
- #
266
- def response_unavailable?
267
- any_is?(parsers, :response_unavailable?)
268
- end
269
-
270
- # @!endgroup
271
-
272
-
273
- private
274
-
275
- # @api private
276
- def self.define_property_method(method)
277
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
278
- def #{method}(*args, &block)
279
- delegate_property_to_parsers(:#{method}, *args, &block)
280
- end
281
- RUBY
282
- end
283
-
284
- # @api private
285
- def self.define_method_method(method)
286
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
287
- def #{method}(*args, &block)
288
- delegate_method_to_parsers(:#{method}, *args, &block)
289
- end
290
- RUBY
291
- end
292
-
293
- def respond_to_parser_method?(symbol)
294
- Parser::PROPERTIES.include?(symbol) || Parser::METHODS.include?(symbol)
295
- end
296
-
297
- def method_missing(method, *args, &block)
298
- if PROPERTIES.include?(method)
299
- self.class.define_property_method(method)
300
- send(method, *args, &block)
301
- elsif METHODS.include?(method)
302
- self.class.define_method_method(method)
303
- send(method, *args, &block)
304
- else
305
- super
306
- end
307
- end
308
-
309
- def delegate_property_to_parsers(method, *args, &block)
310
- if parsers.empty?
311
- raise ParserError, "Unable to select a parser because the Record is empty"
312
- elsif (parser = select_parser { |p| p.class.property_state?(method, PROPERTY_STATE_SUPPORTED) })
313
- parser.send(method, *args, &block)
314
- elsif (parser = select_parser { |p| p.class.property_state?(method, PROPERTY_STATE_NOT_SUPPORTED) })
315
- parser.send(method, *args, &block)
316
- else
317
- raise AttributeNotImplemented, "Unable to find a parser for property `#{method}'"
318
- end
319
- end
320
-
321
- def delegate_method_to_parsers(method, *args, &block)
322
- if parsers.empty?
323
- raise ParserError, "Unable to select a parser because the Record is empty"
324
- elsif (parser = select_parser { |p| p.respond_to?(method) })
325
- parser.send(method, *args, &block)
326
- else
327
- nil
328
- end
329
- end
330
-
331
- # Loops through all record parts, for each part
332
- # tries to guess the appropriate parser object whenever available,
333
- # and returns the final array of server-specific parsers.
334
- #
335
- # Parsers are initialized in reverse order for performance reason.
336
- #
337
- # @return [Array<Class>] An array of Class,
338
- # where each item is the parts reverse-N specific parser {Class}.
339
- # Each {Class} is expected to be a child of {Whois::Record::Parser::Base}.
340
- #
341
- # @example
342
- #
343
- # parser.parts
344
- # # => [whois.foo.com, whois.bar.com]
345
- #
346
- # parser.parsers
347
- # # => [Whois::Record::Parser::WhoisBarCom, Whois::Record::Parser::WhoisFooCom]
348
- #
349
- # @api private
350
- def init_parsers
351
- record.parts.reverse.map { |part| self.class.parser_for(part) }
352
- end
353
-
354
- # Selects the first parser in {#parsers} where blocks evaluates to true.
355
- #
356
- # @return [Whois::Record::Parser::Base]
357
- # The parser for which the block returns true.
358
- # @return [nil]
359
- # If the parser wasn't found.
360
- #
361
- # @yield [parser]
362
- #
363
- # @example
364
- #
365
- # select_parser { |parser| parser.class.property_state?(:nameserver, :any) }
366
- # # => #<Whois::Record::Parser::WhoisExampleCom>
367
- # select_parser { |parser| parser.class.property_state?(:nameservers, PROPERTY_STATE_SUPPORTED) }
368
- # # => nil
369
- #
370
- # @api private
371
- def select_parser(&block)
372
- parsers.each do |parser|
373
- return parser if block.call(parser)
374
- end
375
- nil
376
- end
377
-
378
- # @api private
379
- def all_in_parallel?(*args)
380
- count = args.first.size
381
- index = 0
382
-
383
- while index < count
384
- return false unless yield(*args.map { |arg| arg[index] })
385
- index += 1
386
- end
387
- true
388
- end
389
-
390
- # @api private
391
- def any_is?(collection, symbol)
392
- collection.any? { |item| item.is(symbol) }
393
- end
394
-
395
- end
396
-
397
- end
398
- end
@@ -1,399 +0,0 @@
1
- #--
2
- # Ruby Whois
3
- #
4
- # An intelligent pure Ruby WHOIS client and parser.
5
- #
6
- # Copyright (c) 2009-2015 Simone Carletti <weppos@weppos.net>
7
- #++
8
-
9
-
10
- require 'time'
11
- require 'whois/record/contact'
12
- require 'whois/record/registrar'
13
- require 'whois/record/nameserver'
14
- require 'whois/record/scanners/scannable'
15
-
16
-
17
- module Whois
18
- class Record
19
- class Parser
20
-
21
- # Represents the abstract base parser class for all
22
- # server-specific parser implementations.
23
- #
24
- # NOTE. This class is for the most part auto-generated via meta programming.
25
- # This is the reason why RDoc can't detect and document all available methods.
26
- #
27
- # @abstract
28
- #
29
- class Base
30
-
31
- class_attribute :_properties
32
- self._properties = {}
33
-
34
- # Returns the status for the +property+ passed as symbol.
35
- #
36
- # @param [Symbol] property
37
- # @return [Symbol, nil]
38
- #
39
- # @example Undefined property
40
- # property_state(:disclaimer)
41
- # # => nil
42
- #
43
- # @example Defined property
44
- # property_register(:disclaimer, Whois::Record::Parser::PROPERTY_STATE_SUPPORTED) {}
45
- # property_state(:disclaimer)
46
- # # => :supported
47
- #
48
- def self.property_state(property)
49
- self._properties[property]
50
- end
51
-
52
- # Check if the +property+ passed as symbol
53
- # is registered in the registry for current parser.
54
- #
55
- # @param [Symbol] property
56
- # @param [Symbol] status
57
- # @return [Boolean]
58
- #
59
- # @example Not-registered property
60
- # property_state?(:disclaimer)
61
- # # => false
62
- #
63
- # @example Registered property
64
- # property_register(:disclaimer) {}
65
- # property_state?(:disclaimer)
66
- # # => true
67
- #
68
- def self.property_state?(property, status = :any)
69
- if status == :any
70
- self._properties.key?(property)
71
- else
72
- self._properties[property] == status
73
- end
74
- end
75
-
76
- # Registers a <tt>property</tt> in the registry.
77
- #
78
- # @param [Symbol] property
79
- # @param [Symbol] status
80
- #
81
- # @return [void]
82
- #
83
- def self.property_register(property, status)
84
- self._properties = self._properties.merge({ property => status })
85
- end
86
-
87
-
88
- # Registers a <tt>property</tt> as "not implemented"
89
- # and defines the corresponding private _property_PROPERTY method.
90
- #
91
- # A "not implemented" property always raises a <tt>AttributeNotImplemented</tt> error
92
- # when the property method is called.
93
- #
94
- # @param [Symbol] property
95
- # @return [void]
96
- #
97
- # @example Defining a not implemented property
98
- # # Defines a not implemented property called :disclaimer.
99
- # property_not_implemented(:disclaimer)
100
- #
101
- def self.property_not_implemented(property)
102
- property_register(property, Whois::Record::Parser::PROPERTY_STATE_NOT_IMPLEMENTED)
103
-
104
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
105
- def _property_#{property}(*args)
106
- raise AttributeNotImplemented
107
- end
108
-
109
- private :_property_#{property}
110
- RUBY
111
- end
112
-
113
- # Registers a <tt>property</tt> as "not supported"
114
- # and defines the corresponding private _property_PROPERTY method.
115
- #
116
- # A "not supported" property always raises a <tt>AttributeNotSupported</tt> error
117
- # when the property method is called.
118
- #
119
- # @param [Symbol] property
120
- # @return [void]
121
- #
122
- # @example Defining an unsupported property
123
- # # Defines an unsupported property called :disclaimer.
124
- # property_not_supported(:disclaimer)
125
- #
126
- def self.property_not_supported(property)
127
- property_register(property, Whois::Record::Parser::PROPERTY_STATE_NOT_SUPPORTED)
128
-
129
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
130
- def _property_#{property}(*args)
131
- raise AttributeNotSupported
132
- end
133
-
134
- private :_property_#{property}
135
- RUBY
136
- end
137
-
138
- # Registers a <tt>property</tt> as "supported"
139
- # and defines the corresponding private _property_PROPERTY method.
140
- #
141
- # @param [Symbol] property
142
- # @return [void]
143
- #
144
- # @example Defining a supported property
145
- # # Defines a supported property called :disclaimer.
146
- # property_supported(:disclaimer) do
147
- # ...
148
- # end
149
- #
150
- def self.property_supported(property, &block)
151
- property_register(property, Whois::Record::Parser::PROPERTY_STATE_SUPPORTED)
152
-
153
- define_method("_property_#{property}", &block)
154
- private :"_property_#{property}"
155
- end
156
-
157
- # Checks if the <tt>property</tt> passed as symbol
158
- # is supported by the current parser.
159
- #
160
- # @param [Symbol] property The name of the property to check.
161
- # @return [Boolean]
162
- #
163
- def property_supported?(property)
164
- self.class.property_state?(property, Whois::Record::Parser::PROPERTY_STATE_SUPPORTED)
165
- end
166
-
167
-
168
-
169
- # @return [Whois::Record::Part] The part referenced by this parser.
170
- attr_reader :part
171
-
172
- # Initializes a new parser with given +part+.
173
- #
174
- # @param [Whois::Record::Part] part
175
- #
176
- def initialize(part)
177
- @part = part
178
- @cached_properties = {}
179
- end
180
-
181
-
182
- # This is an internal method primary used as a common access point
183
- # to get the content to be parsed as a string.
184
- #
185
- # The main reason behind this method is because, in the past,
186
- # the internal representation of the data to be parsed changed
187
- # several times, and I always had to rewrite all single parsers
188
- # in order to reflect these changes.
189
- # Now, as far as the parser access the data via the content method,
190
- # there's no need to change each single implementation
191
- # in case the content source changes.
192
- #
193
- # That said, the only constraints about this method
194
- # is to return the data to be parsed as string.
195
- #
196
- # @return [String] The part body.
197
- def content
198
- part.body
199
- end
200
-
201
- # Check if the parser respond to +symbol+
202
- # and calls the method if defined.
203
- # The method referenced by the +symbol+
204
- # is supposed to be a question? method and to return a boolean.
205
- #
206
- # @param [Symbol] symbol
207
- # @return [Boolean]
208
- #
209
- # @example
210
- # is(:response_throttled?)
211
- # # => true
212
- #
213
- # @api private
214
- def is(symbol)
215
- respond_to?(symbol) && send(symbol)
216
- end
217
-
218
- # @api private
219
- def validate!
220
- raise ResponseIsThrottled if is(:response_throttled?)
221
- raise ResponseIsUnavailable if is(:response_unavailable?)
222
- end
223
-
224
-
225
- # @!group Properties
226
-
227
- Whois::Record::Parser::PROPERTIES.each do |property|
228
- class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
229
- def #{property}(*args)
230
- handle_property(:#{property}, *args)
231
- end
232
- RUBY
233
-
234
- property_not_implemented(property)
235
- end
236
-
237
- # @!endgroup
238
-
239
-
240
- # @!group Methods
241
-
242
- # Collects and returns all the available contacts.
243
- #
244
- # @return [Array<Whois::Record::Contact>]
245
- #
246
- # @see Whois::Record#contacts
247
- # @see Whois::Record::Parser#contacts
248
- #
249
- def contacts
250
- [:registrant_contacts, :admin_contacts, :technical_contacts].inject([]) do |contacts, property|
251
- contacts += send(property) if property_supported?(property)
252
- contacts
253
- end
254
- end
255
-
256
- # @!endgroup
257
-
258
-
259
- # @!group Response
260
-
261
- # Checks whether the content of this part is different than +other+.
262
- #
263
- # Comparing a WHOIS response is not as trivial as you may think.
264
- # WHOIS servers can inject into the WHOIS response strings
265
- # that changes at every request, such as the timestamp the request
266
- # was generated or the number of requests left for your current IP.
267
- #
268
- # These strings causes a simple equal comparison to fail even if
269
- # the registry data is the same.
270
- #
271
- # This method should provide a bulletproof way to detect
272
- # whether this record changed compared with +other+.
273
- #
274
- # @param [Base] other The other parser instance to compare.
275
- # @return [Boolean]
276
- #
277
- # @see Whois::Record#changed?
278
- # @see Whois::Record::Parser#changed?
279
- #
280
- def changed?(other)
281
- !unchanged?(other)
282
- end
283
-
284
- # The opposite of {#changed?}.
285
- #
286
- # @param [Base] other The other parser instance to compare.
287
- # @return [Boolean]
288
- #
289
- # @see Whois::Record#unchanged?
290
- # @see Whois::Record::Parser#unchanged?
291
- #
292
- def unchanged?(other)
293
- unless other.is_a?(self.class)
294
- raise(ArgumentError, "Can't compare `#{self.class}' with `#{other.class}'")
295
- end
296
-
297
- equal?(other) ||
298
- content_for_scanner == other.content_for_scanner
299
- end
300
-
301
-
302
- # Checks whether this is an incomplete response.
303
- #
304
- # @return [Boolean]
305
- #
306
- # @abstract This method is just a stub.
307
- # Define it in your parser class.
308
- #
309
- # @see Whois::Record#response_incomplete?
310
- # @see Whois::Record::Parser#response_incomplete?
311
- #
312
- def response_incomplete?
313
- end
314
-
315
- # Checks whether this is a throttle response.
316
- #
317
- # @return [Boolean]
318
- #
319
- # @abstract This method is just a stub.
320
- # Define it in your parser class.
321
- #
322
- # @see Whois::Record#response_throttled?
323
- # @see Whois::Record::Parser#response_throttled?
324
- #
325
- def response_throttled?
326
- end
327
-
328
- # Checks whether this response contains a message
329
- # that can be reconducted to a "WHOIS Server Unavailable" status.
330
- #
331
- # Some WHOIS servers returns error messages
332
- # when they are experiencing failures.
333
- #
334
- # @return [Boolean]
335
- #
336
- # @abstract This method is just a stub.
337
- # Define it in your parser class.
338
- #
339
- # @see Whois::Record#response_unavailable?
340
- # @see Whois::Record::Parser#response_unavailable?
341
- #
342
- def response_unavailable?
343
- end
344
-
345
- # Let them be documented
346
- undef response_incomplete?
347
- undef response_throttled?
348
- undef response_unavailable?
349
-
350
- # @!endgroup
351
-
352
-
353
- protected
354
-
355
- def content_for_scanner
356
- @content_for_scanner ||= content.to_s.gsub(/\r\n/, "\n")
357
- end
358
-
359
- def cached_properties_fetch(key)
360
- if !@cached_properties.key?(key)
361
- @cached_properties[key] = yield
362
- end
363
- @cached_properties[key]
364
- end
365
-
366
-
367
- private
368
-
369
- def typecast(value, type)
370
- if Array == type
371
- Array.wrap(value)
372
- else
373
- value
374
- end
375
- end
376
-
377
- def handle_property(property, *args)
378
- unless property_supported?(property)
379
- return send(:"_property_#{property}", *args)
380
- end
381
-
382
- cached_properties_fetch(property) do
383
- validate!
384
- value = send(:"_property_#{property}", *args)
385
-
386
- case property.to_s
387
- when /_contacts$/, "nameservers"
388
- typecast(value, Array)
389
- else
390
- value
391
- end
392
- end
393
- end
394
-
395
- end
396
-
397
- end
398
- end
399
- end