Class: Relaton3gpp::Parser
- Inherits:
-
Object
- Object
- Relaton3gpp::Parser
- Defined in:
- lib/relaton_3gpp/parser.rb
Constant Summary collapse
- DOCTYPES =
{ "TS" => "Technical Specification", "TR" => "Technical Report"}.freeze
Class Method Summary collapse
-
.parse(row) ⇒ RelatonBib:BibliographicItem?
Initialize document parser and run it.
Instance Method Summary collapse
- #create_workgroup(name, type) ⇒ Object
- #doctype_abbr ⇒ Object
-
#initialize(row) ⇒ Parser
constructor
Document parser initalization.
-
#number ⇒ String
Generate number.
-
#parse ⇒ Relaton3gpp:BibliographicItem?
Parse document.
-
#parse_contributor ⇒ Array<RelatonBib::ContributionInfo>
Create contributors.
-
#parse_date ⇒ Array<RelatonBib::BibliographicDate>
Parse date.
-
#parse_docid ⇒ Arra<RelatonBib::DocumentIdentifier>
Parse docidentifier.
- #parse_doctype ⇒ Object
-
#parse_editorialgroup ⇒ RelatonBib::EditorialGroup
Parse editorialgroup.
-
#parse_link ⇒ Array<RelatonBib::TypedUri>
Parse link.
-
#parse_radiotechnology ⇒ String
Parse radio technology.
-
#parse_release ⇒ Relaton3gpp::Release?
Parse release.
-
#parse_title ⇒ RelatonBib::TypedTitleStringCollection
Parse title.
- #parse_version ⇒ Object
- #release ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(row) ⇒ Parser
Document parser initalization
10 11 12 |
# File 'lib/relaton_3gpp/parser.rb', line 10 def initialize(row) @row = row end |
Class Method Details
.parse(row) ⇒ RelatonBib:BibliographicItem?
Initialize document parser and run it
21 22 23 |
# File 'lib/relaton_3gpp/parser.rb', line 21 def self.parse(row) new(row).parse end |
Instance Method Details
#create_workgroup(name, type) ⇒ Object
171 172 173 174 |
# File 'lib/relaton_3gpp/parser.rb', line 171 def create_workgroup(name, type) wgf = RelatonBib::WorkGroup.new(name: name, type: type) RelatonBib::TechnicalCommittee.new(wgf) end |
#doctype_abbr ⇒ Object
115 116 117 |
# File 'lib/relaton_3gpp/parser.rb', line 115 def doctype_abbr @row["Is TS"] == "1" ? "TS" : "TR" end |
#number ⇒ String
Generate number
101 102 103 104 105 |
# File 'lib/relaton_3gpp/parser.rb', line 101 def number num = "#{doctype_abbr} #{@row[0]}" num += ":#{release}" if release "#{num}/#{version}" end |
#parse ⇒ Relaton3gpp:BibliographicItem?
Parse document
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/relaton_3gpp/parser.rb', line 30 def parse # rubocop:disable Metrics/MethodLength, Metrics/AbcSize Relaton3gpp::BibliographicItem.new( type: "standard", language: ["en"], script: ["Latn"], title: parse_title, link: parse_link, # abstract: parse_abstract, docid: parse_docid, docnumber: number, date: parse_date, doctype: parse_doctype, editorialgroup: parse_editorialgroup, version: parse_version, # biblionote: parse_note, # docstatus: parse_status, radiotechnology: parse_radiotechnology, # common_ims_spec: @spec[:ComIMS] == "1", # internal: @spec[:"For publication"] == "0", release: parse_release, contributor: parse_contributor, place: ["Sophia Antipolis Cedex, France"], ) end |
#parse_contributor ⇒ Array<RelatonBib::ContributionInfo>
Create contributors
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/relaton_3gpp/parser.rb', line 248 def parse_contributor # rubocop:disable Metrics/MethodLength, Metrics/AbcSize address = RelatonBib::Address.new( street: ["c/o ETSI 650, route des Lucioles", "3GPP Mobile Competence Centre"], postcode: "06921", city: "Sophia Antipolis Cedex", country: "France" ) org = RelatonBib::Organization.new( name: "3rd Generation Partnership Project", abbreviation: "3GPP", contact: [address], ) roles = [{ type: "author" }, { type: "publisher" }] contribs = [RelatonBib::ContributionInfo.new(entity: org, role: roles)] return contribs unless @row["Last Name"] && @row["Last Name"] != "Vacant" aff = [] if @row["Organisation"] org = RelatonBib::Organization.new(name: @row["Organisation"]) aff << RelatonBib::Affiliation.new(organization: org) end surname = RelatonBib::LocalizedString.new @row["Last Name"], "en", "Latn" forename = RelatonBib::Forename.new content: @row["First Name"], language: ["en"], script: ["Latn"] name = RelatonBib::FullName.new(surname: surname, forename: [forename]) person = RelatonBib::Person.new(name: name, affiliation: aff) role = { type: "author" } contribs << RelatonBib::ContributionInfo.new(entity: person, role: [role]) end |
#parse_date ⇒ Array<RelatonBib::BibliographicDate>
Parse date
141 142 143 144 145 146 147 148 |
# File 'lib/relaton_3gpp/parser.rb', line 141 def parse_date dates = [] if @row["Date"] on = Date.parse(@row["Date"]).to_s dates << RelatonBib::BibliographicDate.new(type: "published", on: on) end dates end |
#parse_docid ⇒ Arra<RelatonBib::DocumentIdentifier>
Parse docidentifier
92 93 94 |
# File 'lib/relaton_3gpp/parser.rb', line 92 def parse_docid [RelatonBib::DocumentIdentifier.new(type: "3GPP", id: "3GPP #{number}", primary: true)] end |
#parse_doctype ⇒ Object
150 151 152 153 |
# File 'lib/relaton_3gpp/parser.rb', line 150 def parse_doctype # type = DOCTYPES[doctype_abbr] DocumentType.new(type: doctype_abbr) end |
#parse_editorialgroup ⇒ RelatonBib::EditorialGroup
Parse editorialgroup
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/relaton_3gpp/parser.rb', line 160 def parse_editorialgroup # rubocop:disable Metrics/MethodLength, Metrics/AbcSize eg = [] prime = @row["Responsible Primary"] eg << create_workgroup(prime, "prime") if prime @row["Responsible Secondary"].strip.split(", ").each do |wg| eg << create_workgroup(wg, "other") end RelatonBib::EditorialGroup.new eg end |
#parse_link ⇒ Array<RelatonBib::TypedUri>
Parse link
70 71 72 73 74 |
# File 'lib/relaton_3gpp/parser.rb', line 70 def parse_link return [] unless @row["Link"] [RelatonBib::TypedUri.new(type: "src", content: @row["Link"])] end |
#parse_radiotechnology ⇒ String
Parse radio technology
210 211 212 213 214 215 216 217 |
# File 'lib/relaton_3gpp/parser.rb', line 210 def parse_radiotechnology case @row["WPM Code 3G"] when /5G/ then "5G" when /4G/ then "LTE" when /3G/ then "3G" else @row["WPM Code 2G"] && "2G" end end |
#parse_release ⇒ Relaton3gpp::Release?
Parse release
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/relaton_3gpp/parser.rb', line 224 def parse_release # rubocop:disable Metrics/MethodLength, Metrics/AbcSize project_start = Date.parse(@row["Project Start"]).to_s if @row["Project Start"] project_end = Date.parse(@row["Project End"]).to_s if @row["Project End"] Release.new( # version2g: @rel[:version_2g], # version3g: @rel[:version_3g], # defunct: @rel[:defunct] == "1", wpm_code_2g: @row["WPM Code 2G"], wpm_code_3g: @row["WPM Code 3G"], # freeze_meeting: @rel[:"freeze meeting"], freeze_stage1_meeting: @row["Stage 1 Freeze"], freeze_stage2_meeting: @row["Stage 2 Freeze"], freeze_stage3_meeting: @row["Stage 3 Freeze"], close_meeting: @row["Close Meeting"], project_start: project_start, project_end: project_end, ) end |
#parse_title ⇒ RelatonBib::TypedTitleStringCollection
Parse title
60 61 62 63 |
# File 'lib/relaton_3gpp/parser.rb', line 60 def parse_title t = RelatonBib::TypedTitleString.new content: @row["Title"], type: "main" RelatonBib::TypedTitleStringCollection.new [t] end |
#parse_version ⇒ Object
111 112 113 |
# File 'lib/relaton_3gpp/parser.rb', line 111 def parse_version [RelatonBib::BibliographicItem::Version.new(nil, version)] end |
#release ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/relaton_3gpp/parser.rb', line 119 def release @release ||= case @row["WPM Code 2G"] when /Release_(\d+)/ then "REL-#{$1}" when /PH(\d+)/ then "Ph#{$1}" else @row["Release"] end end |
#version ⇒ Object
107 108 109 |
# File 'lib/relaton_3gpp/parser.rb', line 107 def version @row["Version"] end |