Module: RelatonIetf::BibXMLParser
- Extended by:
- BibXMLParser
- Includes:
- RelatonBib::BibXMLParser
- Included in:
- BibXMLParser
- Defined in:
- lib/relaton_ietf/bibxml_parser.rb
Instance Method Summary collapse
- #bib_item(**attrs) ⇒ RelatonIetf::IetfBibliographicItem
- #committee(wgr) ⇒ RelatonIetf::Committee
- #contributors(reference) ⇒ Array<Hash>
-
#forename(initials, name, lang = nil, script = nil) ⇒ Array<RelatonBib::Forename>
Create forenames with initials.
-
#full_name(fname, sname, inits, lang, script = nil) ⇒ RelatonBib::FullName
Overrade RelatonBib::BibXMLParser#full_name method.
-
#full_name_org(name) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity.
-
#parse_surname_initials(fname, sname, inits) ⇒ Array<String, nil>
Parse name, surname, and initials from full name.
- #person(author, reference) ⇒ Object
-
#pubid_type(id) ⇒ String
Extract document identifier type form identifier.
Instance Method Details
#bib_item(**attrs) ⇒ RelatonIetf::IetfBibliographicItem
11 12 13 14 15 16 17 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 11 def bib_item(**attrs) unless attrs.delete(:is_relation) # attrs[:fetched] = Date.today.to_s # attrs[:place] = ["Fremont, CA"] end RelatonIetf::IetfBibliographicItem.new(**attrs) end |
#committee(wgr) ⇒ RelatonIetf::Committee
38 39 40 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 38 def committee(wgr) Committee.new wgr end |
#contributors(reference) ⇒ Array<Hash>
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 44 def contributors(reference) contribs = [] unless reference[:anchor]&.match?(/^I-D/) contribs << { entity: new_org("Internet Engineering Task Force", "IETF"), role: [type: "publisher"], } end contribs + super end |
#forename(initials, name, lang = nil, script = nil) ⇒ Array<RelatonBib::Forename>
Create forenames with initials
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 129 def forename(initials, name, lang = nil, script = nil) fnames = [] if name fnames << RelatonBib::Forename.new(content: name, language: lang, script: script) end return fnames unless initials initials.split(/\.-?\s?|\s/).each_with_object(fnames) do |i, a| a << RelatonBib::Forename.new(initial: i, language: lang, script: script) end end |
#full_name(fname, sname, inits, lang, script = nil) ⇒ RelatonBib::FullName
Overrade RelatonBib::BibXMLParser#full_name method
111 112 113 114 115 116 117 118 119 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 111 def full_name(fname, sname, inits, lang, script = nil) surname, ints, name = parse_surname_initials fname, sname, inits initials = localized_string(ints, lang, script) RelatonBib::FullName.new( completename: localized_string(fname, lang, script), initials: initials, forename: forename(ints, name, lang, script), surname: localized_string(surname, lang, script) ) end |
#full_name_org(name) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 59 def full_name_org(name) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity case name when "ISO" RelatonBib::Organization.new(abbreviation: name, name: "International Organization for Standardization") when "IAB" RelatonBib::Organization.new(abbreviation: name, name: "Internet Architecture Board") when "IESG" RelatonBib::Organization.new(abbreviation: name, name: "Internet Engineering Steering Group") when "IANA" RelatonBib::Organization.new(abbreviation: name, name: "Internet Assigned Numbers Authority") when "International Organization for Standardization" RelatonBib::Organization.new(abbreviation: "ISO", name: name) when "Federal Networking Council", "Internet Architecture Board", "Internet Activities Board", "Defense Advanced Research Projects Agency", "National Science Foundation", "National Research Council", "National Bureau of Standards", "Internet Engineering Steering Group" abbr = name.split.map { |w| w[0] if w[0] == w[0].upcase }.join RelatonBib::Organization.new(abbreviation: abbr, name: name) when "IETF Secretariat" RelatonBib::Organization.new(abbreviation: "IETF", name: name) when "Audio-Video Transport Working Group", /North American Directory Forum/, "EARN Staff", "Vietnamese Standardization Working Group", "ACM SIGUCCS", "ESCC X.500/X.400 Task Force", "Sun Microsystems", "NetBIOS Working Group in the Defense Advanced Research Projects Agency", "End-to-End Services Task Force", "Network Technical Advisory Group", "Bolt Beranek", "Newman Laboratories", "Gateway Algorithms and Data Structures Task Force", "Network Information Center. Stanford Research Institute", "RFC Editor", "Information Sciences Institute University of Southern California", "IAB and IESG", "RARE WG-MSG Task Force 88", "KOI8-U Working Group", "The Internet Society", "IAB Advisory Committee", "ISOC Board of Trustees", "Mitra", "RFC Editor, et al." RelatonBib::Organization.new(name: name) when "Internet Assigned Numbers Authority (IANA)" RelatonBib::Organization.new(abbreviation: "IANA", name: "Internet Assigned Numbers Authority (IANA)") when "ESnet Site Coordinating Comittee (ESCC)" RelatonBib::Organization.new(abbreviation: "ESCC", name: "ESnet Site Coordinating Comittee (ESCC)") when "Energy Sciences Network (ESnet)" RelatonBib::Organization.new(abbreviation: "ESnet", name: "Energy Sciences Network (ESnet)") when "International Telegraph and Telephone Consultative Committee of the International Telecommunication Union" RelatonBib::Organization.new(abbreviation: "CCITT", name: name) end end |
#parse_surname_initials(fname, sname, inits) ⇒ Array<String, nil>
Parse name, surname, and initials from full name
150 151 152 153 154 155 156 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 150 def parse_surname_initials(fname, sname, inits) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity regex = /(?:(?<name>\w{3,})\s)?(?<inits>(?:[A-Z]{1,2}(?:\.[\s-]?|\s))+)?/ match = fname&.match(regex) surname = sname || fname&.sub(regex, "")&.strip initials = inits || (match && match[:inits]&.strip) [surname, initials, (match && match[:name])] end |
#person(author, reference) ⇒ Object
55 56 57 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 55 def person(, reference) full_name_org([:fullname]) || super end |
#pubid_type(id) ⇒ String
Extract document identifier type form identifier
26 27 28 29 30 31 32 33 34 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 26 def pubid_type(id) type = super case type when "BCP", "FYI", "STD", "RFC" then "RFC" # when "Internet-Draft" then type when "I-D" then "Internet-Draft" else "IETF" end end |