whois-parser-next 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +80 -0
- data/CODE_OF_CONDUCT.md +30 -0
- data/CONTRIBUTING.md +80 -0
- data/GOVERNANCE.md +59 -0
- data/LICENSE.txt +22 -0
- data/MAINTAINERS.md +44 -0
- data/README.md +123 -0
- data/RELEASING.md +43 -0
- data/ROADMAP.md +59 -0
- data/SECURITY.md +41 -0
- data/lib/whois/parser/contact.rb +56 -0
- data/lib/whois/parser/errors.rb +46 -0
- data/lib/whois/parser/nameserver.rb +39 -0
- data/lib/whois/parser/registrar.rb +25 -0
- data/lib/whois/parser/super_struct.rb +50 -0
- data/lib/whois/parser/version.rb +6 -0
- data/lib/whois/parser.rb +447 -0
- data/lib/whois/parser_extensions/whois.rb +83 -0
- data/lib/whois/parser_extensions/whois_parser.rb +24 -0
- data/lib/whois/parser_extensions/whois_record.rb +236 -0
- data/lib/whois/parser_extensions.rb +3 -0
- data/lib/whois/parsers/base.rb +413 -0
- data/lib/whois/parsers/base_afilias.rb +144 -0
- data/lib/whois/parsers/base_afilias2.rb +145 -0
- data/lib/whois/parsers/base_cocca.rb +97 -0
- data/lib/whois/parsers/base_cocca2.rb +93 -0
- data/lib/whois/parsers/base_icann_compliant.rb +158 -0
- data/lib/whois/parsers/base_icb.rb +51 -0
- data/lib/whois/parsers/base_iisse.rb +113 -0
- data/lib/whois/parsers/base_nic_fr.rb +175 -0
- data/lib/whois/parsers/base_shared1.rb +112 -0
- data/lib/whois/parsers/base_shared2.rb +130 -0
- data/lib/whois/parsers/base_shared3.rb +131 -0
- data/lib/whois/parsers/base_unsupported_registry.rb +30 -0
- data/lib/whois/parsers/base_verisign.rb +106 -0
- data/lib/whois/parsers/base_whoisd.rb +150 -0
- data/lib/whois/parsers/blank.rb +35 -0
- data/lib/whois/parsers/capetown-whois.registry.net.za.rb +25 -0
- data/lib/whois/parsers/ccwhois.ksregistry.net.rb +25 -0
- data/lib/whois/parsers/ccwhois.verisign-grs.com.rb +25 -0
- data/lib/whois/parsers/coza-whois.registry.net.za.rb +25 -0
- data/lib/whois/parsers/durban-whois.registry.net.za.rb +25 -0
- data/lib/whois/parsers/example.rb +163 -0
- data/lib/whois/parsers/joburg-whois.registry.net.za.rb +25 -0
- data/lib/whois/parsers/kero.yachay.pe.rb +97 -0
- data/lib/whois/parsers/org-whois.registry.net.za.rb +25 -0
- data/lib/whois/parsers/registry_response_safety.rb +29 -0
- data/lib/whois/parsers/tvwhois.verisign-grs.com.rb +25 -0
- data/lib/whois/parsers/vunic.vu.rb +11 -0
- data/lib/whois/parsers/whois.1und1.info.rb +28 -0
- data/lib/whois/parsers/whois.35.com.rb +23 -0
- data/lib/whois/parsers/whois.aeda.net.ae.rb +65 -0
- data/lib/whois/parsers/whois.aero.rb +58 -0
- data/lib/whois/parsers/whois.afilias-grs.info.rb +33 -0
- data/lib/whois/parsers/whois.afilias-srs.net.rb +16 -0
- data/lib/whois/parsers/whois.afilias.net.rb +41 -0
- data/lib/whois/parsers/whois.amnic.net.rb +81 -0
- data/lib/whois/parsers/whois.ascio.com.rb +29 -0
- data/lib/whois/parsers/whois.ati.tn.rb +120 -0
- data/lib/whois/parsers/whois.auda.org.au.rb +12 -0
- data/lib/whois/parsers/whois.audns.net.au.rb +118 -0
- data/lib/whois/parsers/whois.ax.rb +64 -0
- data/lib/whois/parsers/whois.biz.rb +34 -0
- data/lib/whois/parsers/whois.bnnic.bn.rb +77 -0
- data/lib/whois/parsers/whois.cat.rb +75 -0
- data/lib/whois/parsers/whois.cctld.by.rb +98 -0
- data/lib/whois/parsers/whois.cctld.uz.rb +83 -0
- data/lib/whois/parsers/whois.cdmon.com.rb +23 -0
- data/lib/whois/parsers/whois.centralnic.com.rb +144 -0
- data/lib/whois/parsers/whois.cira.ca.rb +227 -0
- data/lib/whois/parsers/whois.cmc.iq.rb +25 -0
- data/lib/whois/parsers/whois.cnnic.cn.rb +108 -0
- data/lib/whois/parsers/whois.co.ca.rb +74 -0
- data/lib/whois/parsers/whois.co.pl.rb +82 -0
- data/lib/whois/parsers/whois.co.ug.rb +93 -0
- data/lib/whois/parsers/whois.comlaude.com.rb +113 -0
- data/lib/whois/parsers/whois.corporatedomains.com.rb +28 -0
- data/lib/whois/parsers/whois.denic.de.rb +164 -0
- data/lib/whois/parsers/whois.dk-hostmaster.dk.rb +88 -0
- data/lib/whois/parsers/whois.dns.be.rb +120 -0
- data/lib/whois/parsers/whois.dns.hr.rb +119 -0
- data/lib/whois/parsers/whois.dns.lu.rb +125 -0
- data/lib/whois/parsers/whois.dns.pl.rb +151 -0
- data/lib/whois/parsers/whois.dns.pt.rb +92 -0
- data/lib/whois/parsers/whois.domain-registry.nl.rb +133 -0
- data/lib/whois/parsers/whois.domainregistry.ie.rb +128 -0
- data/lib/whois/parsers/whois.domreg.lt.rb +68 -0
- data/lib/whois/parsers/whois.donuts.co.rb +59 -0
- data/lib/whois/parsers/whois.dot.cf.rb +71 -0
- data/lib/whois/parsers/whois.dot.tk.rb +70 -0
- data/lib/whois/parsers/whois.dotgov.gov.rb +58 -0
- data/lib/whois/parsers/whois.dotmobiregistry.net.rb +21 -0
- data/lib/whois/parsers/whois.dotpostregistry.net.rb +25 -0
- data/lib/whois/parsers/whois.dreamhost.com.rb +23 -0
- data/lib/whois/parsers/whois.educause.edu.rb +198 -0
- data/lib/whois/parsers/whois.eenet.ee.rb +72 -0
- data/lib/whois/parsers/whois.enom.com.rb +34 -0
- data/lib/whois/parsers/whois.eu.org.rb +58 -0
- data/lib/whois/parsers/whois.eu.rb +130 -0
- data/lib/whois/parsers/whois.fi.rb +119 -0
- data/lib/whois/parsers/whois.gandi.net.rb +36 -0
- data/lib/whois/parsers/whois.gg.rb +93 -0
- data/lib/whois/parsers/whois.godaddy.com.rb +42 -0
- data/lib/whois/parsers/whois.gov.za.rb +60 -0
- data/lib/whois/parsers/whois.hkirc.hk.rb +71 -0
- data/lib/whois/parsers/whois.iana.org.rb +102 -0
- data/lib/whois/parsers/whois.id.rb +26 -0
- data/lib/whois/parsers/whois.iedr.ie.rb +18 -0
- data/lib/whois/parsers/whois.iis.nu.rb +46 -0
- data/lib/whois/parsers/whois.iis.se.rb +26 -0
- data/lib/whois/parsers/whois.in.ua.rb +75 -0
- data/lib/whois/parsers/whois.inregistry.net.rb +27 -0
- data/lib/whois/parsers/whois.isnic.is.rb +70 -0
- data/lib/whois/parsers/whois.isoc.org.il.rb +75 -0
- data/lib/whois/parsers/whois.ja.net.rb +75 -0
- data/lib/whois/parsers/whois.je.rb +75 -0
- data/lib/whois/parsers/whois.jprs.jp.rb +103 -0
- data/lib/whois/parsers/whois.kenic.or.ke.rb +93 -0
- data/lib/whois/parsers/whois.kg.rb +77 -0
- data/lib/whois/parsers/whois.kr.rb +79 -0
- data/lib/whois/parsers/whois.markmonitor.com.rb +36 -0
- data/lib/whois/parsers/whois.marnet.mk.rb +20 -0
- data/lib/whois/parsers/whois.monic.mo.rb +83 -0
- data/lib/whois/parsers/whois.museum.rb +79 -0
- data/lib/whois/parsers/whois.mx.rb +16 -0
- data/lib/whois/parsers/whois.mynic.my.rb +86 -0
- data/lib/whois/parsers/whois.na-nic.com.na.rb +21 -0
- data/lib/whois/parsers/whois.nc.rb +122 -0
- data/lib/whois/parsers/whois.netcom.cm.rb +54 -0
- data/lib/whois/parsers/whois.networksolutions.com.rb +37 -0
- data/lib/whois/parsers/whois.nic.ac.rb +33 -0
- data/lib/whois/parsers/whois.nic.af.rb +32 -0
- data/lib/whois/parsers/whois.nic.ag.rb +33 -0
- data/lib/whois/parsers/whois.nic.ai.rb +62 -0
- data/lib/whois/parsers/whois.nic.ar.rb +54 -0
- data/lib/whois/parsers/whois.nic.art.rb +9 -0
- data/lib/whois/parsers/whois.nic.as.rb +73 -0
- data/lib/whois/parsers/whois.nic.asia.rb +112 -0
- data/lib/whois/parsers/whois.nic.at.rb +68 -0
- data/lib/whois/parsers/whois.nic.best.rb +9 -0
- data/lib/whois/parsers/whois.nic.bj.rb +127 -0
- data/lib/whois/parsers/whois.nic.bo.rb +82 -0
- data/lib/whois/parsers/whois.nic.business.rb +8 -0
- data/lib/whois/parsers/whois.nic.cat.rb +23 -0
- data/lib/whois/parsers/whois.nic.cd.rb +38 -0
- data/lib/whois/parsers/whois.nic.cfd.rb +9 -0
- data/lib/whois/parsers/whois.nic.ch.rb +109 -0
- data/lib/whois/parsers/whois.nic.chat.rb +10 -0
- data/lib/whois/parsers/whois.nic.ci.rb +74 -0
- data/lib/whois/parsers/whois.nic.cl.rb +76 -0
- data/lib/whois/parsers/whois.nic.cloud.rb +15 -0
- data/lib/whois/parsers/whois.nic.club.rb +15 -0
- data/lib/whois/parsers/whois.nic.co.rb +25 -0
- data/lib/whois/parsers/whois.nic.college.rb +25 -0
- data/lib/whois/parsers/whois.nic.coop.rb +70 -0
- data/lib/whois/parsers/whois.nic.cr.rb +64 -0
- data/lib/whois/parsers/whois.nic.cx.rb +25 -0
- data/lib/whois/parsers/whois.nic.cz.rb +42 -0
- data/lib/whois/parsers/whois.nic.delivery.rb +9 -0
- data/lib/whois/parsers/whois.nic.design.rb +30 -0
- data/lib/whois/parsers/whois.nic.direct.rb +9 -0
- data/lib/whois/parsers/whois.nic.dm.rb +39 -0
- data/lib/whois/parsers/whois.nic.domains.rb +8 -0
- data/lib/whois/parsers/whois.nic.dz.rb +67 -0
- data/lib/whois/parsers/whois.nic.ec.rb +44 -0
- data/lib/whois/parsers/whois.nic.es.rb +114 -0
- data/lib/whois/parsers/whois.nic.fm.rb +18 -0
- data/lib/whois/parsers/whois.nic.fo.rb +69 -0
- data/lib/whois/parsers/whois.nic.fr.rb +25 -0
- data/lib/whois/parsers/whois.nic.fun.rb +13 -0
- data/lib/whois/parsers/whois.nic.games.rb +9 -0
- data/lib/whois/parsers/whois.nic.gd.rb +31 -0
- data/lib/whois/parsers/whois.nic.gl.rb +49 -0
- data/lib/whois/parsers/whois.nic.group.rb +8 -0
- data/lib/whois/parsers/whois.nic.gs.rb +31 -0
- data/lib/whois/parsers/whois.nic.hn.rb +49 -0
- data/lib/whois/parsers/whois.nic.host.rb +37 -0
- data/lib/whois/parsers/whois.nic.ht.rb +25 -0
- data/lib/whois/parsers/whois.nic.hu.rb +78 -0
- data/lib/whois/parsers/whois.nic.icu.rb +12 -0
- data/lib/whois/parsers/whois.nic.im.rb +66 -0
- data/lib/whois/parsers/whois.nic.ink.rb +12 -0
- data/lib/whois/parsers/whois.nic.io.rb +52 -0
- data/lib/whois/parsers/whois.nic.ir.rb +70 -0
- data/lib/whois/parsers/whois.nic.it.rb +159 -0
- data/lib/whois/parsers/whois.nic.jobs.rb +25 -0
- data/lib/whois/parsers/whois.nic.ki.rb +25 -0
- data/lib/whois/parsers/whois.nic.kz.rb +69 -0
- data/lib/whois/parsers/whois.nic.la.rb +32 -0
- data/lib/whois/parsers/whois.nic.li.rb +68 -0
- data/lib/whois/parsers/whois.nic.life.rb +10 -0
- data/lib/whois/parsers/whois.nic.link.rb +13 -0
- data/lib/whois/parsers/whois.nic.lk.rb +109 -0
- data/lib/whois/parsers/whois.nic.ltd.rb +8 -0
- data/lib/whois/parsers/whois.nic.lv.rb +69 -0
- data/lib/whois/parsers/whois.nic.ly.rb +78 -0
- data/lib/whois/parsers/whois.nic.market.rb +8 -0
- data/lib/whois/parsers/whois.nic.md.rb +101 -0
- data/lib/whois/parsers/whois.nic.me.rb +85 -0
- data/lib/whois/parsers/whois.nic.mg.rb +35 -0
- data/lib/whois/parsers/whois.nic.ms.rb +37 -0
- data/lib/whois/parsers/whois.nic.mu.rb +25 -0
- data/lib/whois/parsers/whois.nic.mw.rb +33 -0
- data/lib/whois/parsers/whois.nic.mx.rb +79 -0
- data/lib/whois/parsers/whois.nic.name.rb +68 -0
- data/lib/whois/parsers/whois.nic.net.bw.rb +11 -0
- data/lib/whois/parsers/whois.nic.net.ng.rb +27 -0
- data/lib/whois/parsers/whois.nic.net.sa.rb +74 -0
- data/lib/whois/parsers/whois.nic.net.sb.rb +35 -0
- data/lib/whois/parsers/whois.nic.news.rb +8 -0
- data/lib/whois/parsers/whois.nic.nf.rb +50 -0
- data/lib/whois/parsers/whois.nic.ninja.rb +8 -0
- data/lib/whois/parsers/whois.nic.one.rb +41 -0
- data/lib/whois/parsers/whois.nic.online.rb +39 -0
- data/lib/whois/parsers/whois.nic.org.uy.rb +75 -0
- data/lib/whois/parsers/whois.nic.plus.rb +8 -0
- data/lib/whois/parsers/whois.nic.pm.rb +25 -0
- data/lib/whois/parsers/whois.nic.pr.rb +84 -0
- data/lib/whois/parsers/whois.nic.priv.at.rb +62 -0
- data/lib/whois/parsers/whois.nic.pub.rb +8 -0
- data/lib/whois/parsers/whois.nic.pw.rb +25 -0
- data/lib/whois/parsers/whois.nic.re.rb +29 -0
- data/lib/whois/parsers/whois.nic.rocks.rb +8 -0
- data/lib/whois/parsers/whois.nic.run.rb +8 -0
- data/lib/whois/parsers/whois.nic.sh.rb +25 -0
- data/lib/whois/parsers/whois.nic.site.rb +62 -0
- data/lib/whois/parsers/whois.nic.sl.rb +80 -0
- data/lib/whois/parsers/whois.nic.sm.rb +84 -0
- data/lib/whois/parsers/whois.nic.sn.rb +119 -0
- data/lib/whois/parsers/whois.nic.so.rb +71 -0
- data/lib/whois/parsers/whois.nic.software.rb +9 -0
- data/lib/whois/parsers/whois.nic.solutions.rb +9 -0
- data/lib/whois/parsers/whois.nic.space.rb +25 -0
- data/lib/whois/parsers/whois.nic.st.rb +76 -0
- data/lib/whois/parsers/whois.nic.store.rb +15 -0
- data/lib/whois/parsers/whois.nic.studio.rb +8 -0
- data/lib/whois/parsers/whois.nic.systems.rb +8 -0
- data/lib/whois/parsers/whois.nic.tc.rb +25 -0
- data/lib/whois/parsers/whois.nic.tech.rb +33 -0
- data/lib/whois/parsers/whois.nic.technology.rb +8 -0
- data/lib/whois/parsers/whois.nic.tel.rb +25 -0
- data/lib/whois/parsers/whois.nic.tg.rb +49 -0
- data/lib/whois/parsers/whois.nic.tl.rb +32 -0
- data/lib/whois/parsers/whois.nic.tm.rb +101 -0
- data/lib/whois/parsers/whois.nic.today.rb +8 -0
- data/lib/whois/parsers/whois.nic.tools.rb +9 -0
- data/lib/whois/parsers/whois.nic.tr.rb +159 -0
- data/lib/whois/parsers/whois.nic.travel.rb +25 -0
- data/lib/whois/parsers/whois.nic.tv.rb +15 -0
- data/lib/whois/parsers/whois.nic.uk.rb +177 -0
- data/lib/whois/parsers/whois.nic.us.rb +25 -0
- data/lib/whois/parsers/whois.nic.ve.rb +94 -0
- data/lib/whois/parsers/whois.nic.vg.rb +16 -0
- data/lib/whois/parsers/whois.nic.video.rb +10 -0
- data/lib/whois/parsers/whois.nic.vip.rb +13 -0
- data/lib/whois/parsers/whois.nic.website.rb +9 -0
- data/lib/whois/parsers/whois.nic.wf.rb +29 -0
- data/lib/whois/parsers/whois.nic.win.rb +10 -0
- data/lib/whois/parsers/whois.nic.work.rb +10 -0
- data/lib/whois/parsers/whois.nic.works.rb +8 -0
- data/lib/whois/parsers/whois.nic.world.rb +10 -0
- data/lib/whois/parsers/whois.nic.xxx.rb +42 -0
- data/lib/whois/parsers/whois.nic.xyz.rb +25 -0
- data/lib/whois/parsers/whois.nixiregistry.in.rb +15 -0
- data/lib/whois/parsers/whois.norid.no.rb +61 -0
- data/lib/whois/parsers/whois.ovh.com.rb +12 -0
- data/lib/whois/parsers/whois.pairnic.com.rb +28 -0
- data/lib/whois/parsers/whois.pandi.or.id.rb +25 -0
- data/lib/whois/parsers/whois.pir.org.rb +90 -0
- data/lib/whois/parsers/whois.pnina.ps.rb +31 -0
- data/lib/whois/parsers/whois.register.bg.rb +86 -0
- data/lib/whois/parsers/whois.register.com.rb +30 -0
- data/lib/whois/parsers/whois.register.si.rb +73 -0
- data/lib/whois/parsers/whois.registre.ma.rb +65 -0
- data/lib/whois/parsers/whois.registro.br.rb +126 -0
- data/lib/whois/parsers/whois.registry.co.rb +19 -0
- data/lib/whois/parsers/whois.registry.gy.rb +32 -0
- data/lib/whois/parsers/whois.registry.hm.rb +72 -0
- data/lib/whois/parsers/whois.registry.om.rb +40 -0
- data/lib/whois/parsers/whois.registry.qa.rb +25 -0
- data/lib/whois/parsers/whois.ricta.org.rw.rb +16 -0
- data/lib/whois/parsers/whois.ripe.net.rb +68 -0
- data/lib/whois/parsers/whois.rnids.rs.rb +135 -0
- data/lib/whois/parsers/whois.rotld.ro.rb +65 -0
- data/lib/whois/parsers/whois.rrpproxy.net.rb +32 -0
- data/lib/whois/parsers/whois.safenames.net.rb +48 -0
- data/lib/whois/parsers/whois.schlund.info.rb +34 -0
- data/lib/whois/parsers/whois.sgnic.sg.rb +92 -0
- data/lib/whois/parsers/whois.sk-nic.sk.rb +111 -0
- data/lib/whois/parsers/whois.smallregistry.net.rb +131 -0
- data/lib/whois/parsers/whois.srs.net.nz.rb +177 -0
- data/lib/whois/parsers/whois.sx.rb +127 -0
- data/lib/whois/parsers/whois.tcinet.ru.rb +114 -0
- data/lib/whois/parsers/whois.thnic.co.th.rb +80 -0
- data/lib/whois/parsers/whois.tld.ee.rb +134 -0
- data/lib/whois/parsers/whois.tld.sy.rb +34 -0
- data/lib/whois/parsers/whois.tonic.to.rb +100 -0
- data/lib/whois/parsers/whois.tonicregistry.to.rb +12 -0
- data/lib/whois/parsers/whois.trabis.gov.tr.rb +58 -0
- data/lib/whois/parsers/whois.tucows.com.rb +28 -0
- data/lib/whois/parsers/whois.twnic.net.tw.rb +72 -0
- data/lib/whois/parsers/whois.tznic.or.tz.rb +36 -0
- data/lib/whois/parsers/whois.ua.rb +242 -0
- data/lib/whois/parsers/whois.udag.net.rb +28 -0
- data/lib/whois/parsers/whois.uniregistry.net.rb +71 -0
- data/lib/whois/parsers/whois.usp.ac.fj.rb +72 -0
- data/lib/whois/parsers/whois.verisign-grs.com.rb +49 -0
- data/lib/whois/parsers/whois.vunic.vu.rb +14 -0
- data/lib/whois/parsers/whois.website.ws.rb +79 -0
- data/lib/whois/parsers/whois.wildwestdomains.com.rb +37 -0
- data/lib/whois/parsers/whois.yoursrs.com.rb +125 -0
- data/lib/whois/parsers/whois.za.net.rb +72 -0
- data/lib/whois/parsers/whois.za.org.rb +72 -0
- data/lib/whois/parsers/whois.zicta.zm.rb +13 -0
- data/lib/whois/parsers/whois1.nic.bi.rb +25 -0
- data/lib/whois/parsers/za_central_registry.rb +80 -0
- data/lib/whois/parsers.rb +1 -0
- data/lib/whois/safe_record.rb +170 -0
- data/lib/whois/scanners/base.rb +114 -0
- data/lib/whois/scanners/base_afilias.rb +51 -0
- data/lib/whois/scanners/base_cocca2.rb +58 -0
- data/lib/whois/scanners/base_icann_compliant.rb +45 -0
- data/lib/whois/scanners/base_iisse.rb +36 -0
- data/lib/whois/scanners/base_shared1.rb +31 -0
- data/lib/whois/scanners/base_shared2.rb +35 -0
- data/lib/whois/scanners/base_shared3.rb +37 -0
- data/lib/whois/scanners/base_whoisd.rb +44 -0
- data/lib/whois/scanners/iana.rb +89 -0
- data/lib/whois/scanners/scannable.rb +65 -0
- data/lib/whois/scanners/verisign.rb +100 -0
- data/lib/whois/scanners/whois.ati.tn.rb +32 -0
- data/lib/whois/scanners/whois.audns.net.au.rb +32 -0
- data/lib/whois/scanners/whois.cctld.by.rb +35 -0
- data/lib/whois/scanners/whois.centralnic.com.rb +32 -0
- data/lib/whois/scanners/whois.cira.ca.rb +72 -0
- data/lib/whois/scanners/whois.cnnic.cn.rb +42 -0
- data/lib/whois/scanners/whois.denic.de.rb +103 -0
- data/lib/whois/scanners/whois.dns.hr.rb +30 -0
- data/lib/whois/scanners/whois.domainregistry.ie.rb +51 -0
- data/lib/whois/scanners/whois.fi.rb +66 -0
- data/lib/whois/scanners/whois.nc.rb +32 -0
- data/lib/whois/scanners/whois.nic.cz.rb +22 -0
- data/lib/whois/scanners/whois.nic.it.rb +92 -0
- data/lib/whois/scanners/whois.pir.org.rb +17 -0
- data/lib/whois/scanners/whois.rnids.rs.rb +52 -0
- data/lib/whois/scanners/whois.smallregistry.net.rb +50 -0
- data/lib/whois/scanners/whois.srs.net.nz.rb +23 -0
- data/lib/whois/scanners/whois.sx.rb +37 -0
- data/lib/whois/scanners/whois.tld.ee.rb +47 -0
- data/lib/whois/scanners/whois.tucows.com.rb +23 -0
- data/lib/whois/scanners/whois.yoursrs.com.rb +24 -0
- data/lib/whois-parser.rb +10 -0
- metadata +507 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Whois
|
|
2
|
+
|
|
3
|
+
# @!group Parser
|
|
4
|
+
|
|
5
|
+
# Generic class for parser errors.
|
|
6
|
+
class ParserError < Error
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Raised when the library hasn't been able to load a valid parser
|
|
10
|
+
# according to current settings and you're trying to access a property
|
|
11
|
+
# that requires a valid parser.
|
|
12
|
+
class ParserNotFound < ParserError
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Raised when you are trying to access an attribute that has not been implemented.
|
|
16
|
+
class AttributeNotImplemented < ParserError
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Raised when you are trying to access an attribute that is not supported.
|
|
20
|
+
class AttributeNotSupported < ParserError
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @!endgroup
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# @!group Response
|
|
27
|
+
|
|
28
|
+
# Generic class for response errors.
|
|
29
|
+
class ResponseError < Error
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Raised when attempting to access a property when the response is throttled.
|
|
33
|
+
#
|
|
34
|
+
# @see Whois::Parsers::Base#response_throttled?
|
|
35
|
+
class ResponseIsThrottled < ResponseError
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Raised when attempting to access a property when the response is unavailable.
|
|
39
|
+
#
|
|
40
|
+
# @see Whois::Parsers::Base#response_unavailable?
|
|
41
|
+
class ResponseIsUnavailable < ResponseError
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @!endgroup
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require_relative 'super_struct'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module Whois
|
|
5
|
+
class Parser
|
|
6
|
+
|
|
7
|
+
# Holds the details of the Name Servers extracted from the WHOIS response.
|
|
8
|
+
#
|
|
9
|
+
# A name server is composed by the several attributes,
|
|
10
|
+
# accessible through corresponding getter / setter methods.
|
|
11
|
+
#
|
|
12
|
+
# Please note that a response is not required to provide
|
|
13
|
+
# all the attributes. When an attribute is not available,
|
|
14
|
+
# the corresponding value is set to nil.
|
|
15
|
+
#
|
|
16
|
+
# @attr [String] name
|
|
17
|
+
# @attr [String] ipv4
|
|
18
|
+
# @attr [String] ipv6
|
|
19
|
+
#
|
|
20
|
+
class Nameserver < SuperStruct.new(:name, :ipv4, :ipv6)
|
|
21
|
+
|
|
22
|
+
# Returns a string representation of this object
|
|
23
|
+
# composed by the host +name+.
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# Nameserver.new(:name => "ns.example.com").to_s
|
|
27
|
+
# # => "ns.example.com"
|
|
28
|
+
# Nameserver.new.to_s
|
|
29
|
+
# # => ""
|
|
30
|
+
#
|
|
31
|
+
# @return [String] The string representation.
|
|
32
|
+
def to_s
|
|
33
|
+
name.to_s
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require_relative 'super_struct'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module Whois
|
|
5
|
+
class Parser
|
|
6
|
+
|
|
7
|
+
# Holds the details of the Registrar extracted from the WHOIS response.
|
|
8
|
+
#
|
|
9
|
+
# A registrar is composed by the several attributes,
|
|
10
|
+
# accessible through corresponding getter / setter methods.
|
|
11
|
+
#
|
|
12
|
+
# Please note that a response is not required to provide
|
|
13
|
+
# all the attributes. When an attribute is not available,
|
|
14
|
+
# the corresponding value is set to nil.
|
|
15
|
+
#
|
|
16
|
+
# @attr [String] id
|
|
17
|
+
# @attr [String] name
|
|
18
|
+
# @attr [String] organization
|
|
19
|
+
# @attr [String] url
|
|
20
|
+
#
|
|
21
|
+
class Registrar < SuperStruct.new(:id, :name, :organization, :url)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# SuperStruct is an enhanced version of the Ruby Standard library {Struct}.
|
|
2
|
+
#
|
|
3
|
+
# Compared with the original version, it provides the following additional features:
|
|
4
|
+
# * ability to initialize an instance from Hash
|
|
5
|
+
# * ability to pass a block on creation
|
|
6
|
+
#
|
|
7
|
+
class SuperStruct < Struct
|
|
8
|
+
|
|
9
|
+
# Overwrites the standard {Struct} initializer
|
|
10
|
+
# to add the ability to create an instance from a {Hash} of parameters.
|
|
11
|
+
#
|
|
12
|
+
# @overload initialize({ Symbol => Object })
|
|
13
|
+
# Initializes the object with a key/value hash.
|
|
14
|
+
# @param [{ Symbol => Object }] values
|
|
15
|
+
# @return [SuperStruct]
|
|
16
|
+
# @overload initialize([ value1, value1, ... ])
|
|
17
|
+
# Initializes the object with given values.
|
|
18
|
+
# @param [Array] values
|
|
19
|
+
# @return [SuperStruct]
|
|
20
|
+
# @overload initialize(value1, value1, ...)
|
|
21
|
+
# Initializes the object with given values.
|
|
22
|
+
# @return [SuperStruct]
|
|
23
|
+
#
|
|
24
|
+
# @yield self
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# attributes = { :foo => 1, :bar => "baz" }
|
|
28
|
+
# Struct.new(attributes)
|
|
29
|
+
# # => #<Struct foo=1, bar="baz">
|
|
30
|
+
#
|
|
31
|
+
def initialize(*args)
|
|
32
|
+
if args.first.is_a? Hash
|
|
33
|
+
initialize_with_hash(args.first)
|
|
34
|
+
elsif args.size == 0
|
|
35
|
+
super
|
|
36
|
+
else
|
|
37
|
+
raise ArgumentError
|
|
38
|
+
end
|
|
39
|
+
yield(self) if block_given?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def initialize_with_hash(attributes = {})
|
|
45
|
+
attributes.each do |key, value|
|
|
46
|
+
self[key] = value
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
data/lib/whois/parser.rb
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Ruby Whois
|
|
3
|
+
#
|
|
4
|
+
# An intelligent pure Ruby WHOIS client and parser.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
|
|
7
|
+
#++
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
require 'whois'
|
|
11
|
+
require 'active_support/core_ext/array/extract_options'
|
|
12
|
+
require 'active_support/core_ext/array/wrap'
|
|
13
|
+
require 'active_support/core_ext/class/attribute'
|
|
14
|
+
require 'active_support/core_ext/kernel/singleton_class'
|
|
15
|
+
require 'active_support/core_ext/object/blank'
|
|
16
|
+
require 'active_support/core_ext/time/calculations'
|
|
17
|
+
|
|
18
|
+
require_relative 'parser/version'
|
|
19
|
+
require_relative 'parser/errors'
|
|
20
|
+
|
|
21
|
+
# These extensions add Whois::Record#parser, the Whois.registered?, and
|
|
22
|
+
# Whois.available? shortcuts.
|
|
23
|
+
# These are handy convenient methods, and they are loaded by default.
|
|
24
|
+
require_relative 'parser_extensions/whois'
|
|
25
|
+
require_relative 'parser_extensions/whois_parser'
|
|
26
|
+
|
|
27
|
+
# These extensions add most of Whois::Record parser-specific extensions
|
|
28
|
+
# that were loaded by default in Whois 3. This is not recommended as it adds
|
|
29
|
+
# a lot of stuff into the Whois::Record class.
|
|
30
|
+
# Instead of Whois::Record.foo you should just use Whois::Record.parser.foo
|
|
31
|
+
# and add your own abstraction if you need to manipulate the results.
|
|
32
|
+
require_relative 'parser_extensions' if ENV["WHOISRB_4EXTENSIONS"] == "1"
|
|
33
|
+
|
|
34
|
+
# This is really not recommended. It will restore Whois 3 old behavior
|
|
35
|
+
# where the record was silently swallowing the error (returnin nil)
|
|
36
|
+
# when the property was not implemented or not supported.
|
|
37
|
+
# This compatibility layer will likely be removed in future releases.
|
|
38
|
+
# See https://github.com/weppos/whois-parser/pull/5
|
|
39
|
+
# require_relative 'safe_record'
|
|
40
|
+
|
|
41
|
+
# This is required at the end of the file
|
|
42
|
+
# because it depends on Whois::Parser::PROPERTIES
|
|
43
|
+
# require_relative 'parsers'
|
|
44
|
+
|
|
45
|
+
# The parsing controller that stays behind the {Whois::Record}.
|
|
46
|
+
#
|
|
47
|
+
# It provides object-oriented access to a WHOIS response.
|
|
48
|
+
# The list of properties and methods is available
|
|
49
|
+
# in the following constants:
|
|
50
|
+
#
|
|
51
|
+
# * {Whois::Parser::METHODS}
|
|
52
|
+
# * {Whois::Parser::PROPERTIES}
|
|
53
|
+
#
|
|
54
|
+
module Whois
|
|
55
|
+
class Parser
|
|
56
|
+
|
|
57
|
+
# Appends `Please report issue to` to the message
|
|
58
|
+
# and raises a new +error+ with the final message.
|
|
59
|
+
#
|
|
60
|
+
# @param [Exception] error
|
|
61
|
+
# @param [String] message
|
|
62
|
+
# @return [void]
|
|
63
|
+
#
|
|
64
|
+
# @api private
|
|
65
|
+
# @private
|
|
66
|
+
def self.bug!(error, message)
|
|
67
|
+
raise error, message.dup +
|
|
68
|
+
" Please report the issue at" +
|
|
69
|
+
" https://github.com/estevecastells/whois-parser-next/issues"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
METHODS = [
|
|
73
|
+
:contacts,
|
|
74
|
+
:changed?, :unchanged?,
|
|
75
|
+
# :response_incomplete?, :response_throttled?, :response_unavailable?,
|
|
76
|
+
# :referral_whois, :referral_url,
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
PROPERTIES = [
|
|
80
|
+
:disclaimer,
|
|
81
|
+
:domain, :domain_id,
|
|
82
|
+
:status, :available?, :registered?,
|
|
83
|
+
:created_on, :updated_on, :expires_on,
|
|
84
|
+
:registrar,
|
|
85
|
+
:registrant_contacts, :admin_contacts, :technical_contacts,
|
|
86
|
+
:nameservers,
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
PROPERTY_STATE_NOT_IMPLEMENTED = :not_implemented
|
|
90
|
+
PROPERTY_STATE_NOT_SUPPORTED = :not_supported
|
|
91
|
+
PROPERTY_STATE_SUPPORTED = :supported
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# Returns the proper parser instance for given <tt>part</tt>.
|
|
95
|
+
# The parser class is selected according to the
|
|
96
|
+
# value of the <tt>#host</tt> attribute for given <tt>part</tt>.
|
|
97
|
+
#
|
|
98
|
+
# @param [Whois::Record::Part] part The part to get the parser for.
|
|
99
|
+
#
|
|
100
|
+
# @return [Whois::Parsers::Base]
|
|
101
|
+
# An instance of the specific parser for given part.
|
|
102
|
+
# The instance is expected to be a child of {Whois::Parsers::Base}.
|
|
103
|
+
#
|
|
104
|
+
# @example
|
|
105
|
+
#
|
|
106
|
+
# # Parser for a known host
|
|
107
|
+
# Parser.parser_for("whois.example.com")
|
|
108
|
+
# # => #<Whois::Parsers::WhoisExampleCom>
|
|
109
|
+
#
|
|
110
|
+
# # Parser for an unknown host
|
|
111
|
+
# Parser.parser_for("missing.example.com")
|
|
112
|
+
# # => #<Whois::Parsers::Blank>
|
|
113
|
+
#
|
|
114
|
+
def self.parser_for(part)
|
|
115
|
+
parser_klass(part.host).new(part)
|
|
116
|
+
rescue LoadError
|
|
117
|
+
Parsers.const_defined?("Blank") || autoload("blank")
|
|
118
|
+
Parsers::Blank.new(part)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Detects the proper parser class according to given <tt>host</tt>
|
|
122
|
+
# and returns the class constant.
|
|
123
|
+
#
|
|
124
|
+
# This method autoloads missing parser classes. If you want to define
|
|
125
|
+
# a custom parser, simple make sure the class is loaded in the Ruby
|
|
126
|
+
# environment before this method is called.
|
|
127
|
+
#
|
|
128
|
+
# @param [String] host The server host.
|
|
129
|
+
#
|
|
130
|
+
# @return [Class] The instance of Class representing the parser Class
|
|
131
|
+
# corresponding to <tt>host</tt>. If <tt>host</tt> doesn't have
|
|
132
|
+
# a specific parser implementation, then returns
|
|
133
|
+
# the {Whois::Parsers::Blank} {Class}.
|
|
134
|
+
# The {Class} is expected to be a child of {Whois::Parsers::Base}.
|
|
135
|
+
# @raises LoadError If the class is not found.
|
|
136
|
+
#
|
|
137
|
+
# @example
|
|
138
|
+
#
|
|
139
|
+
# Parser.parser_klass("whois.example.com")
|
|
140
|
+
# # => Whois::Parsers::WhoisExampleCom
|
|
141
|
+
#
|
|
142
|
+
def self.parser_klass(host)
|
|
143
|
+
name = host_to_parser(host)
|
|
144
|
+
Parsers.const_defined?(name) || autoload(host)
|
|
145
|
+
Parsers.const_get(name)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Converts <tt>host</tt> to the corresponding parser class name.
|
|
149
|
+
#
|
|
150
|
+
# @param [String] host The server host.
|
|
151
|
+
# @return [String] The class name.
|
|
152
|
+
#
|
|
153
|
+
# @example
|
|
154
|
+
#
|
|
155
|
+
# Parser.host_to_parser("whois.nic.it")
|
|
156
|
+
# # => "WhoisNicIt"
|
|
157
|
+
#
|
|
158
|
+
# Parser.host_to_parser("whois.nic-info.it")
|
|
159
|
+
# # => "WhoisNicInfoIt"
|
|
160
|
+
#
|
|
161
|
+
def self.host_to_parser(host)
|
|
162
|
+
host.to_s.downcase
|
|
163
|
+
.gsub(/[.-]/, '_')
|
|
164
|
+
.gsub(/(?:^|_)(.)/) { ::Regexp.last_match(1).upcase }
|
|
165
|
+
.gsub(/\A(\d+)\z/) { "Host#{::Regexp.last_match(1)}" }
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Requires the file at <tt>whois/parsers/#{name}</tt>.
|
|
169
|
+
#
|
|
170
|
+
# @param [String] name The file name to load.
|
|
171
|
+
#
|
|
172
|
+
# @return [void]
|
|
173
|
+
#
|
|
174
|
+
def self.autoload(name)
|
|
175
|
+
require "whois/parsers/#{name}"
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
# @return [Whois::Record] The record referenced by this parser.
|
|
180
|
+
attr_reader :record
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# Initializes and return a new parser from +record+.
|
|
184
|
+
#
|
|
185
|
+
# @param [Whois::Record] record
|
|
186
|
+
#
|
|
187
|
+
def initialize(record)
|
|
188
|
+
@record = record
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Checks if this class respond to given method.
|
|
192
|
+
#
|
|
193
|
+
# Overrides the default implementation to add support
|
|
194
|
+
# for {PROPERTIES} and {METHODS}.
|
|
195
|
+
#
|
|
196
|
+
# @return [Boolean]
|
|
197
|
+
def respond_to?(symbol, include_private = false)
|
|
198
|
+
respond_to_parser_method?(symbol) || super
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
# Returns an array with all host-specific parsers initialized for the parts
|
|
203
|
+
# contained into this parser.
|
|
204
|
+
# The array is lazy-initialized.
|
|
205
|
+
#
|
|
206
|
+
# @return [Array<Whois::Parsers::Base>]
|
|
207
|
+
#
|
|
208
|
+
def parsers
|
|
209
|
+
@parsers ||= init_parsers
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Checks if the <tt>property</tt> passed as symbol
|
|
213
|
+
# is supported in any of the parsers.
|
|
214
|
+
#
|
|
215
|
+
# @return [Boolean]
|
|
216
|
+
#
|
|
217
|
+
# @see Whois::Parsers::Base.property_supported?
|
|
218
|
+
#
|
|
219
|
+
def property_any_supported?(property)
|
|
220
|
+
parsers.any? { |parser| parser.property_supported?(property) }
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Checks if the <tt>property</tt> passed as symbol
|
|
224
|
+
# is "not implemented" in any of the parsers.
|
|
225
|
+
#
|
|
226
|
+
# @return [Boolean]
|
|
227
|
+
#
|
|
228
|
+
def property_any_not_implemented?(property)
|
|
229
|
+
parsers.any? { |parser| parser.class.property_state?(property, Whois::Parser::PROPERTY_STATE_NOT_IMPLEMENTED) }
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
# @!group Methods
|
|
234
|
+
|
|
235
|
+
# Collects and returns all the contacts from all the record parts.
|
|
236
|
+
#
|
|
237
|
+
# @return [Array<Whois::Record::Contact>]
|
|
238
|
+
#
|
|
239
|
+
# @see Whois::Record#contacts
|
|
240
|
+
# @see Whois::Parsers::Base#contacts
|
|
241
|
+
#
|
|
242
|
+
def contacts
|
|
243
|
+
parsers.map(&:contacts).flatten
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# @!endgroup
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
# @!group Response
|
|
250
|
+
|
|
251
|
+
# Loop through all the record parts to check
|
|
252
|
+
# if at least one part changed.
|
|
253
|
+
#
|
|
254
|
+
# @param [Whois::Parser] other The other parser instance to compare.
|
|
255
|
+
# @return [Boolean]
|
|
256
|
+
#
|
|
257
|
+
# @see Whois::Record#changed?
|
|
258
|
+
# @see Whois::Parsers::Base#changed?
|
|
259
|
+
#
|
|
260
|
+
def changed?(other)
|
|
261
|
+
!unchanged?(other)
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# The opposite of {#changed?}.
|
|
265
|
+
#
|
|
266
|
+
# @param [Whois::Parser] other The other parser instance to compare.
|
|
267
|
+
# @return [Boolean]
|
|
268
|
+
#
|
|
269
|
+
# @see Whois::Record#unchanged?
|
|
270
|
+
# @see Whois::Parsers::Base#unchanged?
|
|
271
|
+
#
|
|
272
|
+
def unchanged?(other)
|
|
273
|
+
unless other.is_a?(self.class)
|
|
274
|
+
raise(ArgumentError, "Can't compare `#{self.class}' with `#{other.class}'")
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
equal?(other) ||
|
|
278
|
+
(parsers.size == other.parsers.size && all_in_parallel?(parsers, other.parsers) { |one, two| one.unchanged?(two) })
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
# Loop through all the parts to check if at least
|
|
283
|
+
# one part is an incomplete response.
|
|
284
|
+
#
|
|
285
|
+
# @return [Boolean]
|
|
286
|
+
#
|
|
287
|
+
# @see Whois::Record#response_incomplete?
|
|
288
|
+
# @see Whois::Parsers::Base#response_incomplete?
|
|
289
|
+
#
|
|
290
|
+
def response_incomplete?
|
|
291
|
+
any_is?(parsers, :response_incomplete?)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Loop through all the parts to check if at least
|
|
295
|
+
# one part is a throttle response.
|
|
296
|
+
#
|
|
297
|
+
# @return [Boolean]
|
|
298
|
+
#
|
|
299
|
+
# @see Whois::Record#response_throttled?
|
|
300
|
+
# @see Whois::Parsers::Base#response_throttled?
|
|
301
|
+
#
|
|
302
|
+
def response_throttled?
|
|
303
|
+
any_is?(parsers, :response_throttled?)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# Loop through all the parts to check if at least
|
|
307
|
+
# one part is an unavailable response.
|
|
308
|
+
#
|
|
309
|
+
# @return [Boolean]
|
|
310
|
+
#
|
|
311
|
+
# @see Whois::Record#response_unavailable?
|
|
312
|
+
# @see Whois::Parsers::Base#response_unavailable?
|
|
313
|
+
#
|
|
314
|
+
def response_unavailable?
|
|
315
|
+
any_is?(parsers, :response_unavailable?)
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# @!endgroup
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
private
|
|
322
|
+
|
|
323
|
+
# @api private
|
|
324
|
+
def self.define_property_method(method)
|
|
325
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
|
326
|
+
def #{method}(*args, &block)
|
|
327
|
+
delegate_property_to_parsers(:#{method}, *args, &block)
|
|
328
|
+
end
|
|
329
|
+
RUBY
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
# @api private
|
|
333
|
+
def self.define_method_method(method)
|
|
334
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
|
335
|
+
def #{method}(*args, &block)
|
|
336
|
+
delegate_method_to_parsers(:#{method}, *args, &block)
|
|
337
|
+
end
|
|
338
|
+
RUBY
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
def respond_to_parser_method?(symbol)
|
|
342
|
+
PROPERTIES.include?(symbol) || METHODS.include?(symbol)
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
def method_missing(method, *, &)
|
|
346
|
+
if PROPERTIES.include?(method)
|
|
347
|
+
self.class.define_property_method(method)
|
|
348
|
+
send(method, *, &)
|
|
349
|
+
elsif METHODS.include?(method)
|
|
350
|
+
self.class.define_method_method(method)
|
|
351
|
+
send(method, *, &)
|
|
352
|
+
else
|
|
353
|
+
super
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
def delegate_property_to_parsers(method, *, &)
|
|
358
|
+
if parsers.empty?
|
|
359
|
+
raise ParserError, "Unable to select a parser because the Record is empty"
|
|
360
|
+
elsif (parser = select_parser { |p| p.class.property_state?(method, PROPERTY_STATE_SUPPORTED) })
|
|
361
|
+
parser.send(method, *, &)
|
|
362
|
+
elsif (parser = select_parser { |p| p.class.property_state?(method, PROPERTY_STATE_NOT_SUPPORTED) })
|
|
363
|
+
parser.send(method, *, &)
|
|
364
|
+
else
|
|
365
|
+
raise AttributeNotImplemented, "Unable to find a parser for property `#{method}'"
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
def delegate_method_to_parsers(method, *, &)
|
|
370
|
+
if parsers.empty?
|
|
371
|
+
raise ParserError, "Unable to select a parser because the Record is empty"
|
|
372
|
+
elsif (parser = select_parser { |p| p.respond_to?(method) })
|
|
373
|
+
parser.send(method, *, &)
|
|
374
|
+
else
|
|
375
|
+
nil
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Loops through all record parts, for each part
|
|
380
|
+
# tries to guess the appropriate parser object whenever available,
|
|
381
|
+
# and returns the final array of server-specific parsers.
|
|
382
|
+
#
|
|
383
|
+
# Parsers are initialized in reverse order for performance reason.
|
|
384
|
+
#
|
|
385
|
+
# @return [Array<Class>] An array of Class,
|
|
386
|
+
# where each item is the parts reverse-N specific parser {Class}.
|
|
387
|
+
# Each {Class} is expected to be a child of {Whois::Parsers::Base}.
|
|
388
|
+
#
|
|
389
|
+
# @example
|
|
390
|
+
#
|
|
391
|
+
# parser.parts
|
|
392
|
+
# # => [whois.foo.com, whois.bar.com]
|
|
393
|
+
#
|
|
394
|
+
# parser.parsers
|
|
395
|
+
# # => [Whois::Parsers::WhoisBarCom, Whois::Parsers::WhoisFooCom]
|
|
396
|
+
#
|
|
397
|
+
# @api private
|
|
398
|
+
def init_parsers
|
|
399
|
+
record.parts.reverse.map { |part| self.class.parser_for(part) }
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
# Selects the first parser in {#parsers} where blocks evaluates to true.
|
|
403
|
+
#
|
|
404
|
+
# @return [Whois::Parsers::Base]
|
|
405
|
+
# The parser for which the block returns true.
|
|
406
|
+
# @return [nil]
|
|
407
|
+
# If the parser wasn't found.
|
|
408
|
+
#
|
|
409
|
+
# @yield [parser]
|
|
410
|
+
#
|
|
411
|
+
# @example
|
|
412
|
+
#
|
|
413
|
+
# select_parser { |parser| parser.class.property_state?(:nameserver, :any) }
|
|
414
|
+
# # => #<Whois::Parsers::WhoisExampleCom>
|
|
415
|
+
# select_parser { |parser| parser.class.property_state?(:nameservers, PROPERTY_STATE_SUPPORTED) }
|
|
416
|
+
# # => nil
|
|
417
|
+
#
|
|
418
|
+
# @api private
|
|
419
|
+
def select_parser(&block)
|
|
420
|
+
parsers.each do |parser|
|
|
421
|
+
return parser if block.call(parser)
|
|
422
|
+
end
|
|
423
|
+
nil
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
# @api private
|
|
427
|
+
def all_in_parallel?(*args)
|
|
428
|
+
count = args.first.size
|
|
429
|
+
index = 0
|
|
430
|
+
|
|
431
|
+
while index < count
|
|
432
|
+
return false unless yield(*args.map { |arg| arg[index] })
|
|
433
|
+
|
|
434
|
+
index += 1
|
|
435
|
+
end
|
|
436
|
+
true
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
# @api private
|
|
440
|
+
def any_is?(collection, symbol)
|
|
441
|
+
collection.any? { |item| item.is(symbol) }
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
require_relative 'parsers'
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'whois'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module Whois
|
|
5
|
+
class ParserExtensions
|
|
6
|
+
|
|
7
|
+
module Whois
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.extend ClassMethods
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module ClassMethods
|
|
13
|
+
# Checks whether the object represented by <tt>object</tt> is available.
|
|
14
|
+
#
|
|
15
|
+
# Warning: this method is only available if a Whois parser exists
|
|
16
|
+
# for the top level domain of <tt>object</tt>.
|
|
17
|
+
# If no parser exists for <tt>object</tt>, you'll receive a
|
|
18
|
+
# warning message and the method will return <tt>nil</tt>.
|
|
19
|
+
# This is a technical limitation. Browse the lib/whois/record/parsers
|
|
20
|
+
# folder to view all available parsers.
|
|
21
|
+
#
|
|
22
|
+
# @param [String] object The string to be sent as query parameter.
|
|
23
|
+
# It is intended to be a domain name, otherwise this method
|
|
24
|
+
# may return unexpected responses.
|
|
25
|
+
# @return [Boolean]
|
|
26
|
+
#
|
|
27
|
+
# @example
|
|
28
|
+
# Whois.available?("google.com")
|
|
29
|
+
# # => false
|
|
30
|
+
#
|
|
31
|
+
# @example
|
|
32
|
+
# Whois.available?("google-is-not-available-try-again-later.com")
|
|
33
|
+
# # => true
|
|
34
|
+
#
|
|
35
|
+
def available?(object)
|
|
36
|
+
result = lookup(object).available?
|
|
37
|
+
if result.nil?
|
|
38
|
+
warn "This method is not supported for this kind of object.\n" +
|
|
39
|
+
"Use Whois.lookup('#{object}') instead."
|
|
40
|
+
end
|
|
41
|
+
result
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Checks whether the object represented by <tt>object</tt> is registered.
|
|
45
|
+
#
|
|
46
|
+
# Warning: this method is only available if a Whois parser exists
|
|
47
|
+
# for the top level domain of <tt>object</tt>.
|
|
48
|
+
# If no parser exists for <tt>object</tt>, you'll receive a warning message
|
|
49
|
+
# and the method will return <tt>nil</tt>.
|
|
50
|
+
# This is a technical limitation. Browse the lib/whois/record/parsers folder
|
|
51
|
+
# to view all available parsers.
|
|
52
|
+
#
|
|
53
|
+
# @param [String] object The string to be sent as query parameter.
|
|
54
|
+
# It is intended to be a domain name, otherwise this method
|
|
55
|
+
# may return unexpected responses.
|
|
56
|
+
# @return [Boolean]
|
|
57
|
+
#
|
|
58
|
+
# @example
|
|
59
|
+
# Whois.registered?("google.com")
|
|
60
|
+
# # => true
|
|
61
|
+
#
|
|
62
|
+
# @example
|
|
63
|
+
# Whois.registered?("google-is-not-available-try-again-later.com")
|
|
64
|
+
# # => false
|
|
65
|
+
#
|
|
66
|
+
def registered?(object)
|
|
67
|
+
result = lookup(object).registered?
|
|
68
|
+
if result.nil?
|
|
69
|
+
warn "This method is not supported for this kind of object.\n" +
|
|
70
|
+
"Use Whois.lookup('#{object}') instead."
|
|
71
|
+
end
|
|
72
|
+
result
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Whois.class_eval do
|
|
82
|
+
include Whois::ParserExtensions::Whois
|
|
83
|
+
end
|