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
data/lib/whois.rb CHANGED
@@ -7,13 +7,6 @@
7
7
  #++
8
8
 
9
9
 
10
- require 'active_support/core_ext/array/extract_options'
11
- require 'active_support/core_ext/array/wrap'
12
- require 'active_support/core_ext/class/attribute'
13
- require 'active_support/core_ext/kernel/singleton_class'
14
- require 'active_support/core_ext/object/blank'
15
- require 'active_support/core_ext/time/calculations'
16
-
17
10
  require 'whois/version'
18
11
  require 'whois/errors'
19
12
  require 'whois/client'
@@ -44,73 +37,6 @@ module Whois
44
37
 
45
38
  alias_method :whois, :lookup
46
39
 
47
- def query(object)
48
- deprecate("Whois.query is now Whois.lookup")
49
- lookup(object)
50
- end
51
-
52
- # Checks whether the object represented by <tt>object</tt> is available.
53
- #
54
- # Warning: this method is only available if a Whois parser exists
55
- # for the top level domain of <tt>object</tt>.
56
- # If no parser exists for <tt>object</tt>, you'll receive a
57
- # warning message and the method will return <tt>nil</tt>.
58
- # This is a technical limitation. Browse the lib/whois/record/parsers
59
- # folder to view all available parsers.
60
- #
61
- # @param [String] object The string to be sent as query parameter.
62
- # It is intended to be a domain name, otherwise this method
63
- # may return unexpected responses.
64
- # @return [Boolean]
65
- #
66
- # @example
67
- # Whois.available?("google.com")
68
- # # => false
69
- #
70
- # @example
71
- # Whois.available?("google-is-not-available-try-again-later.com")
72
- # # => true
73
- #
74
- def available?(object)
75
- result = lookup(object).available?
76
- if result.nil?
77
- warn "This method is not supported for this kind of object.\n" +
78
- "Use Whois.lookup('#{object}') instead."
79
- end
80
- result
81
- end
82
-
83
- # Checks whether the object represented by <tt>object</tt> is registered.
84
- #
85
- # Warning: this method is only available if a Whois parser exists
86
- # for the top level domain of <tt>object</tt>.
87
- # If no parser exists for <tt>object</tt>, you'll receive a warning message
88
- # and the method will return <tt>nil</tt>.
89
- # This is a technical limitation. Browse the lib/whois/record/parsers folder
90
- # to view all available parsers.
91
- #
92
- # @param [String] object The string to be sent as query parameter.
93
- # It is intended to be a domain name, otherwise this method
94
- # may return unexpected responses.
95
- # @return [Boolean]
96
- #
97
- # @example
98
- # Whois.registered?("google.com")
99
- # # => true
100
- #
101
- # @example
102
- # Whois.registered?("google-is-not-available-try-again-later.com")
103
- # # => false
104
- #
105
- def registered?(object)
106
- result = lookup(object).registered?
107
- if result.nil?
108
- warn "This method is not supported for this kind of object.\n" +
109
- "Use Whois.lookup('#{object}') instead."
110
- end
111
- result
112
- end
113
-
114
40
 
115
41
  # Echoes a deprecation warning message.
116
42
  #
@@ -140,7 +66,7 @@ module Whois
140
66
  " http://github.com/weppos/whois/issues"
141
67
  end
142
68
 
143
- private
69
+ private
144
70
 
145
71
  def deprecation_caller_message(callstack)
146
72
  file, line, method = extract_callstack(callstack)
data/lib/whois/errors.rb CHANGED
@@ -87,48 +87,4 @@ module Whois
87
87
 
88
88
  # @!endgroup
89
89
 
90
-
91
- # @!group Parser
92
-
93
- # Generic class for parser errors.
94
- class ParserError < Error
95
- end
96
-
97
- # Raised when the library hasn't been able to load a valid parser
98
- # according to current settings and you're trying to access a property
99
- # that requires a valid parser.
100
- class ParserNotFound < ParserError
101
- end
102
-
103
- # Raised when you are trying to access an attribute that has not been implemented.
104
- class AttributeNotImplemented < ParserError
105
- end
106
-
107
- # Raised when you are trying to access an attribute that is not supported.
108
- class AttributeNotSupported < ParserError
109
- end
110
-
111
- # @!endgroup
112
-
113
-
114
- # @!group Response
115
-
116
- # Generic class for response errors.
117
- class ResponseError < Error
118
- end
119
-
120
- # Raised when attempting to access a property when the response is throttled.
121
- #
122
- # @see Whois::Record::Parser::Base#response_throttled?
123
- class ResponseIsThrottled < ResponseError
124
- end
125
-
126
- # Raised when attempting to access a property when the response is unavailable.
127
- #
128
- # @see Whois::Record::Parser::Base#response_unavailable?
129
- class ResponseIsUnavailable < ResponseError
130
- end
131
-
132
- # @!endgroup
133
-
134
90
  end
data/lib/whois/record.rb CHANGED
@@ -14,8 +14,6 @@ module Whois
14
14
 
15
15
  class Record
16
16
 
17
- autoload :Parser, 'whois/record/parser'
18
-
19
17
 
20
18
  # @return [Whois::Server] The server that originated this record.
21
19
  attr_reader :server
@@ -35,17 +33,6 @@ module Whois
35
33
  end
36
34
 
37
35
 
38
- # Checks if this class respond to given method.
39
- #
40
- # Overrides the default implementation to add support
41
- # for {Parser::PROPERTIES} and {Parser::METHODS}.
42
- #
43
- # @return [Boolean]
44
- #
45
- def respond_to?(symbol, include_private = false)
46
- respond_to_parser_method?(symbol) || super
47
- end
48
-
49
36
  # Returns a String representation of this record.
50
37
  #
51
38
  # @return [String] The record content.
@@ -125,230 +112,6 @@ module Whois
125
112
  @content ||= parts.map(&:body).join("\n")
126
113
  end
127
114
 
128
- # Lazy-loads and returns the parser proxy for current record.
129
- #
130
- # @return [Whois::Record::Parser]
131
- #
132
- def parser
133
- @parser ||= Parser.new(self)
134
- end
135
-
136
- # Checks if the <tt>property</tt> passed as symbol
137
- # is supported in any of the parsers.
138
- #
139
- # @param [Symbol] property The name of the property to check.
140
- # @return [Boolean]
141
- #
142
- # @see Whois::Record::Parser#property_any_supported?
143
- #
144
- def property_any_supported?(property)
145
- parser.property_any_supported?(property)
146
- end
147
-
148
-
149
- # @!group Properties
150
-
151
- # Returns a Hash containing all supported properties for this record
152
- # along with corresponding values.
153
- #
154
- # @return [{ Symbol => Object }]
155
- #
156
- def properties
157
- hash = {}
158
- Parser::PROPERTIES.each { |property| hash[property] = send(property) }
159
- hash
160
- end
161
-
162
- # @!endgroup
163
-
164
-
165
- # @!group Methods
166
-
167
- # Shortcut for <tt>#registrant_contacts.first</tt>.
168
- #
169
- # @return [Whois::Record::Contact]
170
- # If the property is supported and a contact exists.
171
- # @return [nil]
172
- # If the property is not supported or the contact doesn't exist.
173
- #
174
- # @see Whois::Record#registrant_contacts
175
- #
176
- def registrant_contact
177
- if property_any_supported?(:registrant_contacts)
178
- parser.registrant_contacts.first
179
- end
180
- end
181
-
182
- # Shortcut for <tt>#admin_contacts.first</tt>.
183
- #
184
- # @return [Whois::Record::Contact]
185
- # If the property is supported and a contact exists.
186
- # @return [nil]
187
- # If the property is not supported or the contact doesn't exist.
188
- #
189
- # @see Whois::Record#admin_contacts
190
- #
191
- def admin_contact
192
- if property_any_supported?(:admin_contacts)
193
- parser.admin_contacts.first
194
- end
195
- end
196
-
197
- # Shortcut for <tt>#technical_contacts.first</tt>.
198
- #
199
- # @return [Whois::Record::Contact]
200
- # If the property is supported and a contact exists.
201
- # @return [nil]
202
- # If the property is not supported or the contact doesn't exist.
203
- #
204
- # @see Whois::Record#technical_contacts
205
- #
206
- def technical_contact
207
- if property_any_supported?(:technical_contacts)
208
- parser.technical_contacts.first
209
- end
210
- end
211
-
212
- # Collects and returns all the contacts.
213
- #
214
- # @return [Array<Whois::Record::Contact>]
215
- #
216
- # @see Whois::Record::Parser#contacts
217
- #
218
- def contacts
219
- parser.contacts
220
- end
221
-
222
- # @!endgroup
223
-
224
-
225
- # @!group Response
226
-
227
- # Checks whether this {Whois::Record} is different than +other+.
228
- #
229
- # Comparing the {Whois::Record} content is not as trivial as you may think.
230
- # WHOIS servers can inject into the WHOIS response strings that changes at every request,
231
- # such as the timestamp the request was generated or the number of requests left
232
- # for your current IP.
233
- #
234
- # These strings causes a simple equal comparison to fail even if
235
- # the registry data is the same.
236
- #
237
- # This method should provide a bulletproof way to detect whether this record
238
- # changed compared with +other+.
239
- #
240
- # @param [Whois::Record] other The other record instance to compare.
241
- # @return [Boolean]
242
- #
243
- # @see Whois::Record::Parser#changed?
244
- #
245
- def changed?(other)
246
- !unchanged?(other)
247
- end
248
-
249
- # The opposite of {#changed?}.
250
- #
251
- # @param [Whois::Record] other The other record instance to compare.
252
- # @return [Boolean]
253
- #
254
- # @see Whois::Record::Parser#unchanged?
255
- #
256
- def unchanged?(other)
257
- unless other.is_a?(self.class)
258
- raise(ArgumentError, "Can't compare `#{self.class}' with `#{other.class}'")
259
- end
260
-
261
- equal?(other) || parser.unchanged?(other.parser)
262
- end
263
-
264
-
265
- # Checks whether this is an incomplete response.
266
- #
267
- # @return [Boolean]
268
- #
269
- # @see Whois::Record::Parser#response_incomplete?
270
- #
271
- def response_incomplete?
272
- parser.response_incomplete?
273
- end
274
-
275
- # Checks whether this is a throttle response.
276
- #
277
- # @return [Boolean]
278
- #
279
- # @see Whois::Record::Parser#response_throttled?
280
- #
281
- def response_throttled?
282
- parser.response_throttled?
283
- end
284
-
285
- # Checks whether this is an unavailable response.
286
- #
287
- # @return [Boolean]
288
- #
289
- # @see Whois::Record::Parser#response_unavailable?
290
- #
291
- def response_unavailable?
292
- parser.response_unavailable?
293
- end
294
-
295
- # @!endgroup
296
-
297
-
298
- private
299
-
300
- # @api private
301
- def self.define_property_method(method)
302
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
303
- def #{method}(*args, &block)
304
- if property_any_supported?(:#{method})
305
- parser.#{method}(*args, &block)
306
- end
307
- end
308
- RUBY
309
- end
310
-
311
- # @api private
312
- def self.define_method_method(method)
313
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
314
- def #{method}(*args, &block)
315
- if parser.respond_to?(:#{method})
316
- parser.#{method}(*args, &block)
317
- end
318
- end
319
- RUBY
320
- end
321
-
322
- # @api private
323
- def self.define_question_method(method)
324
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
325
- def #{method}?
326
- !#{method}.nil?
327
- end
328
- RUBY
329
- end
330
-
331
- def respond_to_parser_method?(symbol)
332
- name = symbol.to_s =~ /\?$/ ? symbol.to_s[0..-2] : symbol
333
- Parser::PROPERTIES.include?(name.to_sym) || Parser::METHODS.include?(name.to_sym)
334
- end
335
-
336
- # Delegates all method calls to the internal parser.
337
- def method_missing(method, *args, &block)
338
- if Parser::PROPERTIES.include?(method)
339
- self.class.define_property_method(method)
340
- send(method, *args, &block)
341
- elsif Parser::METHODS.include?(method)
342
- self.class.define_method_method(method)
343
- send(method, *args, &block)
344
- elsif method.to_s =~ /([a-z_]+)\?/ and (Parser::PROPERTIES + Parser::METHODS).include?($1.to_sym)
345
- self.class.define_question_method($1)
346
- send(method)
347
- else
348
- super
349
- end
350
- end
351
-
352
115
  end
353
116
 
354
117
  end
@@ -7,9 +7,6 @@
7
7
  #++
8
8
 
9
9
 
10
- require 'whois/record/super_struct'
11
-
12
-
13
10
  module Whois
14
11
  class Record
15
12
 
@@ -23,7 +20,26 @@ module Whois
23
20
  # @attr [String] body The body containing the WHOIS output.
24
21
  # @attr [String] host The host which returned the body.
25
22
  #
26
- class Part < SuperStruct.new(:body, :host)
23
+ class Part < Struct.new(:body, :host)
24
+
25
+ def initialize(*args)
26
+ if args.first.is_a? Hash
27
+ initialize_with_hash(args.first)
28
+ elsif args.size == 0
29
+ super
30
+ else
31
+ raise ArgumentError
32
+ end
33
+ yield(self) if block_given?
34
+ end
35
+
36
+ private
37
+
38
+ def initialize_with_hash(attributes = {})
39
+ attributes.each do |key, value|
40
+ self[key] = value
41
+ end
42
+ end
27
43
  end
28
44
 
29
45
  end
@@ -17,15 +17,21 @@ module Whois
17
17
  module Adapters
18
18
 
19
19
  class Base
20
+ class << self
21
+ def query_handler
22
+ @query_handler ||= SocketHandler.new
23
+ end
24
+
25
+ def query_handler=(handler)
26
+ @query_handler = handler
27
+ end
28
+ end
20
29
 
21
30
  # Default WHOIS request port.
22
31
  DEFAULT_WHOIS_PORT = 43
23
32
  # Default bind hostname.
24
33
  DEFAULT_BIND_HOST = "0.0.0.0"
25
34
 
26
- class_attribute :query_handler
27
- self.query_handler = SocketHandler.new
28
-
29
35
  # @return [Symbol] The type of WHOIS server.
30
36
  attr_reader :type
31
37
  # @return [String] The allocation this server is responsible for.
@@ -124,6 +130,15 @@ module Whois
124
130
  raise NotImplementedError
125
131
  end
126
132
 
133
+ # Gets the current query handler for this class.
134
+ #
135
+ # @see Whois::Servers::Adapters::Base.query_handler
136
+ #
137
+ # @return [Object] the query handler
138
+ def query_handler
139
+ self.class.query_handler
140
+ end
141
+
127
142
 
128
143
  private
129
144