Class: Relaton::Render::Ietf::Parse
- Inherits:
-
Parse
- Object
- Parse
- Relaton::Render::Ietf::Parse
- Defined in:
- lib/relaton/render/parse.rb
Instance Method Summary collapse
- #abstract(doc) ⇒ Object
- #authoritative_identifier(doc) ⇒ Object
-
#creatornames1(doc) ⇒ Object
return authors and editors together.
-
#creatornames_roles_allowed ⇒ Object
allow publisher for standards.
-
#date(doc, host) ⇒ Object
not just year-only.
- #extract(doc) ⇒ Object
- #extract_orgabbrev(org) ⇒ Object
- #extract_personname(person) ⇒ Object
- #extractname(contributor) ⇒ Object
- #home_standard(_doc, pubs) ⇒ Object
- #included_xml2hash(doc) ⇒ Object
-
#initialize(options) ⇒ Parse
constructor
A new instance of Parse.
- #keywords(doc) ⇒ Object
- #parse_single_bibitem(doc) ⇒ Object
- #series(doc) ⇒ Object
- #series_xml2hash1(series, doc) ⇒ Object
- #simple_or_host_xml2hash(doc, host) ⇒ Object
- #simple_xml2hash(doc) ⇒ Object
- #stream(doc) ⇒ Object
- #uris(doc) ⇒ Object
Constructor Details
Instance Method Details
#abstract(doc) ⇒ Object
45 46 47 |
# File 'lib/relaton/render/parse.rb', line 45 def abstract(doc) doc.abstract.join end |
#authoritative_identifier(doc) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/relaton/render/parse.rb', line 96 def (doc) ret = super bcp = doc.series.detect do |s| %w(BCP STD).include?(s.title.title.content) end bcp and ret.unshift("BCP #{bcp.number}") ret.reject { |x| /^(rfc-anchor|Internet-Draft)/.match? (x) } end |
#creatornames1(doc) ⇒ Object
return authors and editors together
86 87 88 89 90 91 92 93 94 |
# File 'lib/relaton/render/parse.rb', line 86 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_allowed ⇒ Object
allow publisher for standards
25 26 27 28 |
# File 'lib/relaton/render/parse.rb', line 25 def creatornames_roles_allowed %w(author performer adapter translator editor publisher distributor authorizer) end |
#date(doc, host) ⇒ Object
not just year-only
79 80 81 82 83 |
# File 'lib/relaton/render/parse.rb', line 79 def date(doc, host) ret = date1(doc.date) host and ret ||= date1(host.date) datepick(ret) end |
#extract(doc) ⇒ Object
121 122 123 |
# File 'lib/relaton/render/parse.rb', line 121 def extract(doc) super.merge(included_xml2hash(doc)) end |
#extract_orgabbrev(org) ⇒ Object
63 64 65 |
# File 'lib/relaton/render/parse.rb', line 63 def extract_orgabbrev(org) content(org.abbreviation) end |
#extract_personname(person) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/relaton/render/parse.rb', line 67 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
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/relaton/render/parse.rb', line 49 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
17 18 19 20 21 22 |
# File 'lib/relaton/render/parse.rb', line 17 def home_standard(_doc, pubs) pubs&.any? do |r| ["Internet Engineering Task Force", "IETF", "RFC Publisher"] .include?(r[:nonpersonal]) end end |
#included_xml2hash(doc) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/relaton/render/parse.rb', line 125 def included_xml2hash(doc) r = doc.relation.select { |x| x.type == "includes" }.map do |x| parse_single_bibitem(x.bibitem) end r.empty? and return {} { included: r } end |
#keywords(doc) ⇒ Object
41 42 43 |
# File 'lib/relaton/render/parse.rb', line 41 def keywords(doc) doc.keyword.map { |u| content(u) } end |
#parse_single_bibitem(doc) ⇒ Object
133 134 135 136 137 138 |
# File 'lib/relaton/render/parse.rb', line 133 def parse_single_bibitem(doc) data = extract(doc) # enhance_data(data, r.template_raw) # data_liquid = @fieldsklass.new(renderer: self) # .compound_fields_format(data) end |
#series(doc) ⇒ Object
109 110 111 112 113 114 |
# File 'lib/relaton/render/parse.rb', line 109 def series(doc) a = doc.series.reject { |s| s.type == "stream" } a.empty? and return nil a.detect { |s| s.type == "main" } || a.detect { |s| s.type.nil? } || a.first end |
#series_xml2hash1(series, doc) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/relaton/render/parse.rb', line 30 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
10 11 12 13 14 15 |
# File 'lib/relaton/render/parse.rb', line 10 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 |
#simple_xml2hash(doc) ⇒ Object
105 106 107 |
# File 'lib/relaton/render/parse.rb', line 105 def simple_xml2hash(doc) super.merge(stream: stream(doc)) end |
#stream(doc) ⇒ Object
116 117 118 119 |
# File 'lib/relaton/render/parse.rb', line 116 def stream(doc) a = doc.series.detect { |s| s.type == "stream" } or return nil series_title(a, doc) end |
#uris(doc) ⇒ Object
37 38 39 |
# File 'lib/relaton/render/parse.rb', line 37 def uris(doc) doc.link.map { |u| { content: u.content.to_s.strip, type: u.type } } end |