Method: TTL2HTML::App#extract_toplevel

Defined in:
lib/ttl2html.rb

#extract_toplevelObject



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/ttl2html.rb', line 416

def extract_toplevel
  result = {}
  toplevel = nil
  @data.each do |s, v|
    if @data[s]["http://purl.org/pav/hasCurrentVersion"]
      toplevel = s
    end
  end
  data  = @data[toplevel.to_s]
  if toplevel
    license = extract_license(data)
    if data["http://purl.org/dc/terms/publisher"]
      publisher_data = @data[data["http://purl.org/dc/terms/publisher"].first]
      email = publisher_data["http://xmlns.com/foaf/0.1/mbox"]&.first
      contact = { email: email }
      name = publisher_data["http://xmlns.com/foaf/0.1/name"]
      contact[:name] = name if name
      members = []
      if publisher_data["http://xmlns.com/foaf/0.1/member"]
        publisher_data["http://xmlns.com/foaf/0.1/member"].each do |member|
          member_data = @data[member]
          members << {
            name: member_data["http://xmlns.com/foaf/0.1/name"],
            org: member_data["http://www.w3.org/2006/vcard/ns#organization-name"]
          }
        end
        contact[:members] = members
      end
    end
    result = {
      uri: toplevel.to_s,
      description: data["http://purl.org/dc/terms/description"],
      license: license,
      contact: contact,
    }
  end
  result
end