Class: MonoVM::Whois::Registry::Sources::JsonFile
- Defined in:
- lib/monovm/whois/registry/sources/json_file.rb
Overview
Reads the server-list JSON format: an array of entries, each mapping a
comma-separated extensions list to one endpoint.
[
{
"extensions": ".com,.net",
"uri": "socket://whois.verisign-grs.com",
"available": "No match for",
"premium": "Reserved",
"rdap": "https://rdap.verisign.com/com/v1/domain/",
"available_when_empty": false,
"comment": "why this entry looks like this"
}
]
Both the bundled list and a user override file use this class — they differ only in path and in whether a missing file is fatal.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path:, optional: false, name: nil) ⇒ JsonFile
constructor
A new instance of JsonFile.
- #load ⇒ Hash{String => Definition}
- #name ⇒ Object
- #optional? ⇒ Boolean
Constructor Details
#initialize(path:, optional: false, name: nil) ⇒ JsonFile
Returns a new instance of JsonFile.
34 35 36 37 38 39 |
# File 'lib/monovm/whois/registry/sources/json_file.rb', line 34 def initialize(path:, optional: false, name: nil) @path = path @optional = optional @name = name super() end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
28 29 30 |
# File 'lib/monovm/whois/registry/sources/json_file.rb', line 28 def path @path end |
Instance Method Details
#load ⇒ Hash{String => Definition}
50 51 52 53 54 55 56 57 58 |
# File 'lib/monovm/whois/registry/sources/json_file.rb', line 50 def load raw = read return {} if raw.nil? entries = parse(raw) entries.each_with_index.with_object({}) do |(entry, index), definitions| add_entry(definitions, entry, index) end end |
#name ⇒ Object
41 42 43 |
# File 'lib/monovm/whois/registry/sources/json_file.rb', line 41 def name @name || (optional? ? "override" : "bundled") end |
#optional? ⇒ Boolean
45 46 47 |
# File 'lib/monovm/whois/registry/sources/json_file.rb', line 45 def optional? @optional end |