class NicInfo::CommonJson
deals with common JSON RDAP structures
Public Class Methods
new(config)
click to toggle source
# File lib/nicinfo/common_json.rb, line 62 def initialize config @config = config end
Public Instance Methods
display_as_events_actors(asEventActors)
click to toggle source
# File lib/nicinfo/common_json.rb, line 177 def display_as_events_actors asEventActors asEventActors.each do |asEventActor| item_name = NicInfo::capitalize( asEventActor.eventAction ) item_value = Time.parse( asEventActor.eventDate ).rfc2822 item_value << " by #{asEventActor.entity_cn}" @config.logger.datum item_name, item_value end end
display_events(objectclass)
click to toggle source
# File lib/nicinfo/common_json.rb, line 158 def display_events objectclass events = objectclass[ "events" ] if events if events.instance_of?( Array ) events.each do |event| item_name = NicInfo::capitalize( event[ "eventAction" ] ) item_value = Time.parse( event[ "eventDate" ] ).rfc2822 actor = event[ "eventActor" ] if actor item_value << " by #{actor}" end @config.logger.datum item_name, item_value end else @config.conf_msgs << "'events' is not an array." end end end
display_links(cn, objectclass)
click to toggle source
# File lib/nicinfo/common_json.rb, line 145 def display_links cn, objectclass links = NicInfo::get_links objectclass, @config if links @config.logger.extra "Links", "-- for #{cn} --" @config.logger.extra "Reference", NicInfo::get_self_link( links ) @config.logger.extra "More", NicInfo::get_alternate_link( links ) @config.logger.extra "About", NicInfo::get_about_link( links ) @config.logger.extra "TOS", NicInfo::get_tos_link( links ) @config.logger.extra "(C)", NicInfo::get_copyright_link( links ) @config.logger.extra "License", NicInfo::get_license_link( links ) end end
display_port43(objectclass)
click to toggle source
# File lib/nicinfo/common_json.rb, line 141 def display_port43 objectclass @config.logger.extra "Port 43 Whois", objectclass[ "port43" ] end
display_public_ids(objectclass)
click to toggle source
# File lib/nicinfo/common_json.rb, line 186 def display_public_ids objectclass public_ids = objectclass[ "publicIds" ] if public_ids if public_ids.instance_of?( Array ) public_ids.each do |public_id| if public_id.instance_of?( Hash ) item_name = "Public ID" item_value = public_id[ "identifier" ] authority = public_id[ "type" ] item_value << " (#{authority})" if authority @config.logger.datum item_name, item_value else @config.conf_msgs << "public id in array 'publicIds' is not an object." end end else @config.conf_msgs << "'publicIds' is not an array." end end end
display_remarks(objectclass)
click to toggle source
# File lib/nicinfo/common_json.rb, line 77 def display_remarks objectclass remarks = objectclass[ "remarks" ] if remarks excessive_notice = @config.factory.new_notices.is_excessive_notice(remarks) if (excessive_notice && (@config.logger.data_amount != NicInfo::DataAmount::EXTRA_DATA)) @config.logger.datum "Excessive Remarks", "Use \"-V\" or \"--data extra\" to see them." else if remarks.instance_of?(Array) remarks.each do |remark| if remark.instance_of?(Hash) title = remark["title"] @config.logger.datum "Remarks", "-- #{title} --" if title descriptions = NicInfo::get_descriptions remark, @config i = 1 descriptions.each do |line| if !title && i == 1 @config.logger.datum "Remarks", line elsif i != 1 || title @config.logger.datum i.to_s, line end i = i + 1 end if descriptions links = NicInfo::get_links remark, @config if links @config.logger.datum "More", NicInfo::get_alternate_link(links) @config.logger.datum "About", NicInfo::get_about_link(links) @config.logger.datum "TOS", NicInfo::get_tos_link(links) @config.logger.datum "(C)", NicInfo::get_copyright_link(links) @config.logger.datum "License", NicInfo::get_license_link(links) end else @config.conf_msgs << "remark is not an object." end end else @config.conf_msgs << "'remarks' is not an array." end end end end
display_simple_links(links)
click to toggle source
# File lib/nicinfo/common_json.rb, line 207 def display_simple_links links if links if links.instance_of?( Array ) alternate = NicInfo.get_alternate_link links @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "More", alternate, NicInfo::AttentionType::SECONDARY if alternate about = NicInfo.get_about_link links @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "About", about, NicInfo::AttentionType::SECONDARY if about tos = NicInfo.get_tos_link links @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "TOS", tos, NicInfo::AttentionType::SECONDARY if tos copyright = NicInfo.get_copyright_link links @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "(C)", copyright, NicInfo::AttentionType::SECONDARY if copyright license = NicInfo.get_license_link links @config.logger.prose NicInfo::DataAmount::NORMAL_DATA, "License", license, NicInfo::AttentionType::SECONDARY if license else @config.conf_msgs << "'links' is not an array." end end end
display_status(objectclass)
click to toggle source
# File lib/nicinfo/common_json.rb, line 137 def display_status objectclass display_string_array "status", "Status", objectclass, DataAmount::NORMAL_DATA end
display_string_array(json_name, display_name, json_data, data_amount)
click to toggle source
# File lib/nicinfo/common_json.rb, line 118 def display_string_array json_name, display_name, json_data, data_amount arr = json_data[ json_name ] if arr if arr.instance_of?( Array ) new_arr = Array.new arr.each do |str| if str.instance_of?( String ) new_arr << NicInfo::capitalize( str ) else @config.conf_msgs << "value in string array is not a string." end end @config.logger.info data_amount, display_name, new_arr.join( ", " ) else @config.conf_msgs << "'#{json_name}' is not an array." end end end
process_entities(objectclass)
click to toggle source
# File lib/nicinfo/common_json.rb, line 66 def process_entities objectclass entities = Array.new json_entities = NicInfo::get_entitites( objectclass ) json_entities.each do |json_entity| entity = @config.factory.new_entity entity.process( json_entity ) entities << entity end if json_entities return entities end