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
8 9 10 11 12 13 14 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 8 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
35 36 37 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 35 def committee(wgr) Committee.new wgr end |
#contributors(reference) ⇒ Array<Hash>
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 41 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
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 126 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
108 109 110 111 112 113 114 115 116 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 108 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
56 57 58 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 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 56 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
147 148 149 150 151 152 153 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 147 def parse_surname_initials(fname, sname, inits) 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[:inits]&.strip [surname, initials, match[:name]] end |
#person(author, reference) ⇒ Object
52 53 54 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 52 def person(, reference) full_name_org([:fullname]) || super end |
#pubid_type(id) ⇒ String
Extract document identifier type form identifier
23 24 25 26 27 28 29 30 31 |
# File 'lib/relaton_ietf/bibxml_parser.rb', line 23 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 |