Class: MonoVM::Whois::Registry::Sources::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/monovm/whois/registry/sources/base.rb

Overview

Interface for anything that can supply TLD definitions.

MonoVM::Whois::Registry::ServerRegistry depends on this, not on files: that is what lets a host application feed definitions from a database, an internal HTTP service or a hard-coded hash in a test, without the registry knowing. A source needs two methods, #name and #load.

Direct Known Subclasses

IanaBootstrap, JsonFile

Instance Method Summary collapse

Instance Method Details

#loadHash{String => Definition}

Returns keyed by TLD, with the leading dot.

Returns:

  • (Hash{String => Definition})

    keyed by TLD, with the leading dot

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/monovm/whois/registry/sources/base.rb', line 26

def load
  raise NotImplementedError, "#{self.class} must implement #load"
end

#nameString

A short identifier recorded in Definition#sources, so a surprising endpoint can be traced back to whichever source supplied it.

Returns:

  • (String)


21
22
23
# File 'lib/monovm/whois/registry/sources/base.rb', line 21

def name
  self.class.name.to_s.split("::").last.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
end

#optional?Boolean

Sources that cannot be read are usually optional (an override file that does not exist yet). Returning true here lets MonoVM::Whois::Registry::ServerRegistry skip a failure instead of aborting every lookup.

Returns:

  • (Boolean)


33
34
35
# File 'lib/monovm/whois/registry/sources/base.rb', line 33

def optional?
  false
end