Class: Relaton::Render::Ietf::Parse

Inherits:
Parse
  • Object
show all
Defined in:
lib/relaton/render/parse.rb

Instance Method Summary collapse

Instance Method Details

#abstract(doc) ⇒ Object



39
40
41
# File 'lib/relaton/render/parse.rb', line 39

def abstract(doc)
  doc.abstract.join
end

#authoritative_identifier(doc) ⇒ Object

add BCP number



91
92
93
94
95
96
97
# File 'lib/relaton/render/parse.rb', line 91

def authoritative_identifier(doc)
  ret = super
  if bcp = doc.series.detect { |s| s.title.title.content == "BCP" }
    ret.unshift("BCP #{bcp.number}")
  end
  ret.reject { |x| /^(rfc-anchor|Internet-Draft)/.match? (x) }
end

#creatornames1(doc) ⇒ Object

return authors and editors together



80
81
82
83
84
85
86
87
88
# File 'lib/relaton/render/parse.rb', line 80

def creatornames1(doc)
  return [] if doc.nil?

  add1 = pick_contributor(doc, "author") || []
  add2 = pick_contributor(doc, "editor") || []
  cr = add1 + add2
  cr.empty? or return cr
  super
end

#creatornames_roles_allowedObject

allow publisher for standards



20
21
22
23
# File 'lib/relaton/render/parse.rb', line 20

def creatornames_roles_allowed
  %w(author performer adapter translator editor publisher distributor
     authorizer)
end

#date(doc, host) ⇒ Object

not just year-only



73
74
75
76
77
# File 'lib/relaton/render/parse.rb', line 73

def date(doc, host)
  ret = date1(doc.date)
  host and ret ||= date1(host.date)
  datepick(ret)
end

#extract_orgabbrev(org) ⇒ Object



57
58
59
# File 'lib/relaton/render/parse.rb', line 57

def extract_orgabbrev(org)
  content(org.abbreviation)
end

#extract_personname(person) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/relaton/render/parse.rb', line 61

def extract_personname(person)
  surname = person.name.surname
  completename = person.name.completename
  given, middle, initials = given_and_middle_name(person)
  { surname: content(surname),
    completename: content(completename),
    given: given,
    middle: middle,
    initials: initials }.compact
end

#extractname(contributor) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/relaton/render/parse.rb', line 43

def extractname(contributor)
  org = contributor.entity if contributor.entity
    .is_a?(RelatonBib::Organization)
  person = contributor.entity if contributor.entity
    .is_a?(RelatonBib::Person)
  if org
    return { nonpersonal: extract_orgname(org),
             nonpersonalabbrev: extract_orgabbrev(org) }
  end
  return extract_personname(person) if person

  nil
end

#home_standard(_doc, pubs) ⇒ Object



12
13
14
15
16
17
# File 'lib/relaton/render/parse.rb', line 12

def home_standard(_doc, pubs)
  pubs&.any? do |r|
    ["Internet Engineering Task Force", "IETF", "RFC Publisher"]
      .include?(r[:nonpersonal])
  end
end

#keywords(doc) ⇒ Object



35
36
37
# File 'lib/relaton/render/parse.rb', line 35

def keywords(doc)
  doc.keyword.map { |u| content(u) }
end

#series_xml2hash1(series, doc) ⇒ Object



25
26
27
28
29
# File 'lib/relaton/render/parse.rb', line 25

def series_xml2hash1(series, doc)
  ret = super
  %w(BCP RFC I-D. Internet-Draft).include?(ret[:series_title]) and return {}
  ret
end

#simple_or_host_xml2hash(doc, host) ⇒ Object



5
6
7
8
9
10
# File 'lib/relaton/render/parse.rb', line 5

def simple_or_host_xml2hash(doc, host)
  ret = super
  ret.merge(home_standard: home_standard(doc, ret[:publisher_raw]),
            uris: uris(doc), keywords: keywords(doc),
            abstract: abstract(doc))
end

#uris(doc) ⇒ Object



31
32
33
# File 'lib/relaton/render/parse.rb', line 31

def uris(doc)
  doc.link.map { |u| { content: u.content.to_s.strip, type: u.type } }
end