Class: Relaton3gpp::Parser
- Inherits:
-
Object
- Object
- Relaton3gpp::Parser
- Defined in:
- lib/relaton_3gpp/parser.rb
Class Method Summary collapse
-
.parse(row, specs, specrels, relaeases, tstatus) ⇒ RelatonBib:BibliographicItem?
Initialize document parser and run it.
Instance Method Summary collapse
- #create_workgroup(name, type) ⇒ Object
-
#initialize(row, specs, specrels, releases, tstatus) ⇒ Parser
constructor
Document parser initalization.
-
#number ⇒ String
Generate number.
-
#parse ⇒ Relaton3gpp:BibliographicItem?
Parse document.
-
#parse_abstract ⇒ Array<RelatonBib::FormattedString>
Parse abstract.
-
#parse_contributor ⇒ Array<RelatonBib::ContributionInfo>
Create contributors.
-
#parse_date ⇒ Array<RelatonBib::BibliographicDate>
Parse date.
-
#parse_docid ⇒ Arra<RelatonBib::DocumentIdentifier>
Parse docidentifier.
-
#parse_editorialgroup ⇒ RelatonBib::EditorialGroup
Parse editorialgroup.
-
#parse_link ⇒ Array<RelatonBib::TypedUri>
Parse link.
-
#parse_note ⇒ RelatonBib::BiblioNoteCollection
Parse note.
-
#parse_radiotechnology ⇒ String
Parse radio technology.
-
#parse_release ⇒ Relaton3gpp::Release?
Parse release.
-
#parse_status ⇒ RelatnoBib::DocumentStatus?
Prase status.
-
#parse_title ⇒ RelatonBib::TypedTitleStringCollection
Parse title.
-
#version ⇒ String
Version.
Constructor Details
#initialize(row, specs, specrels, releases, tstatus) ⇒ Parser
Document parser initalization
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/relaton_3gpp/parser.rb', line 12 def initialize(row, specs, specrels, releases, tstatus) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity @row = row @spec = specs.detect { |s| s[:Number] == row[:spec] } if @spec @specrel = specrels.detect do |sr| sr[:Spec] == row[:spec] && sr[:Release] == row[:release] end @rel = releases.detect { |r| r[:Release_code] == row[:release] } end @tstatus = tstatus.detect { |t| t[:Number] == row[:spec] } end |
Class Method Details
.parse(row, specs, specrels, relaeases, tstatus) ⇒ RelatonBib:BibliographicItem?
Initialize document parser and run it
35 36 37 |
# File 'lib/relaton_3gpp/parser.rb', line 35 def self.parse(row, specs, specrels, relaeases, tstatus) new(row, specs, specrels, relaeases, tstatus).parse end |
Instance Method Details
#create_workgroup(name, type) ⇒ Object
164 165 166 167 |
# File 'lib/relaton_3gpp/parser.rb', line 164 def create_workgroup(name, type) wgf = RelatonBib::WorkGroup.new(name: name, type: type) RelatonBib::TechnicalCommittee.new(wgf) end |
#number ⇒ String
Generate number
117 118 119 |
# File 'lib/relaton_3gpp/parser.rb', line 117 def number "#{@spec[:Type]} #{@row[:spec]}:#{@row[:release]}/#{version}" end |
#parse ⇒ Relaton3gpp:BibliographicItem?
Parse document
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/relaton_3gpp/parser.rb', line 44 def parse # rubocop:disable Metrics/MethodLength, Metrics/AbcSize return unless @spec && @row[:"3guId"] Relaton3gpp::BibliographicItem.new( type: "standard", fetched: Date.today.to_s, language: ["en"], script: ["Latn"], title: parse_title, link: parse_link, abstract: parse_abstract, docid: parse_docid, docnumber: number, date: parse_date, doctype: @spec[:Type], editorialgroup: parse_editorialgroup, 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, ) end |
#parse_abstract ⇒ Array<RelatonBib::FormattedString>
Parse abstract
97 98 99 100 101 |
# File 'lib/relaton_3gpp/parser.rb', line 97 def parse_abstract return [] unless @spec[:description] [RelatonBib::FormattedString.new(content: @spec[:description])] end |
#parse_contributor ⇒ Array<RelatonBib::ContributionInfo>
Create contributors
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/relaton_3gpp/parser.rb', line 242 def parse_contributor # rubocop:disable Metrics/MethodLength, Metrics/AbcSize org = RelatonBib::Organization.new( name: "3rd Generation Partnership Project", abbreviation: "3GPP", ) contribs = [RelatonBib::ContributionInfo.new(entity: org, role: [type: "author"])] return contribs unless @tstatus && @tstatus[:rapporteur] aff = [] if @tstatus[:"rapp org"] org = RelatonBib::Organization.new(name: @tstatus[:"rapp org"]) cn = RelatonBib::LocalizedString.new @tstatus[:rapporteur], "en", "Latn" name = RelatonBib::FullName.new(completename: cn) aff << RelatonBib::Affiliation.new(organization: org) end 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
135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/relaton_3gpp/parser.rb', line 135 def parse_date d = [] if @row[:completed] cd = Date.parse(@row[:completed]).to_s d << RelatonBib::BibliographicDate.new(type: "created", on: cd) end if @spec[:"title verified"] td = Date.parse(@spec[:"title verified"]).to_s d << RelatonBib::BibliographicDate.new(type: "confirmed", on: td) end d end |
#parse_docid ⇒ Arra<RelatonBib::DocumentIdentifier>
Parse docidentifier
108 109 110 |
# File 'lib/relaton_3gpp/parser.rb', line 108 def parse_docid [RelatonBib::DocumentIdentifier.new(type: "3GPP", id: "3GPP #{number}")] end |
#parse_editorialgroup ⇒ RelatonBib::EditorialGroup
Parse editorialgroup
153 154 155 156 157 158 159 160 161 162 |
# File 'lib/relaton_3gpp/parser.rb', line 153 def parse_editorialgroup # rubocop:disable Metrics/MethodLength, Metrics/AbcSize eg = [create_workgroup(@spec[:"WG prime"], "prime")] if @spec[:"WG other"] && @spec[:"WG other"] != "-" eg << create_workgroup(@spec[:"WG other"], "other") end if @spec[:"former WG"] eg << create_workgroup(@spec[:"former WG"], "former") end RelatonBib::EditorialGroup.new eg end |
#parse_link ⇒ Array<RelatonBib::TypedUri>
Parse link
85 86 87 88 89 90 |
# File 'lib/relaton_3gpp/parser.rb', line 85 def parse_link return [] unless @row[:location] content = @row[:location].split("#").last [RelatonBib::TypedUri.new(type: "src", content: content)] end |
#parse_note ⇒ RelatonBib::BiblioNoteCollection
Parse note
174 175 176 177 178 179 180 181 182 183 |
# File 'lib/relaton_3gpp/parser.rb', line 174 def parse_note n = [] if @specrel && @specrel[:remarks] && @specrel[:remarks] != "." n << RelatonBib::BiblioNote.new(type: "remark", content: @specrel[:remarks]) end if @row[:comment] && @row[:comment] != "." n << RelatonBib::BiblioNote.new(type: "comment", content: @row[:comment]) end RelatonBib::BiblioNoteCollection.new n end |
#parse_radiotechnology ⇒ String
Parse radio technology
203 204 205 206 207 208 209 |
# File 'lib/relaton_3gpp/parser.rb', line 203 def parse_radiotechnology if @spec[:"2g"] == "1" then "2G" elsif @spec[:"3g"] == "1" then "3G" elsif @spec[:LTE] == "1" then "LTE" elsif @spec[:"5G"] == "1" then "5G" end end |
#parse_release ⇒ Relaton3gpp::Release?
Parse release
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/relaton_3gpp/parser.rb', line 216 def parse_release # rubocop:disable Metrics/MethodLength, Metrics/AbcSize if @rel project_start = Date.parse(@rel[:"rel-proj-start"]).to_s if @rel[:"rel-proj-start"] project_end = Date.parse(@rel[:"rel-proj-end"]).to_s if @rel[:"rel-proj-end"] Release.new( version2g: @rel[:version_2g], version3g: @rel[:version_3g], defunct: @rel[:defunct] == "1", wpm_code_2g: @rel[:wpm_code_2g], wpm_code_3g: @rel[:wpm_code_3g], freeze_meeting: @rel[:"freeze meeting"], freeze_stage1_meeting: @rel[:Stage1_freeze], freeze_stage2_meeting: @rel[:Stage2_freeze], freeze_stage3_meeting: @rel[:Stage3_freeze], close_meeting: @rel[:Closed], project_start: project_start, project_end: project_end, ) end end |
#parse_status ⇒ RelatnoBib::DocumentStatus?
Prase status
190 191 192 193 194 195 196 |
# File 'lib/relaton_3gpp/parser.rb', line 190 def parse_status if @specrel && @specrel[:withdrawn] == "1" RelatonBib::DocumentStatus.new stage: "withdrawn" elsif @spec[:"For publication"] == "1" RelatonBib::DocumentStatus.new stage: "published" end end |
#parse_title ⇒ RelatonBib::TypedTitleStringCollection
Parse title
75 76 77 78 |
# File 'lib/relaton_3gpp/parser.rb', line 75 def parse_title t = RelatonBib::TypedTitleString.new content: @spec[:Title], type: "main" RelatonBib::TypedTitleStringCollection.new [t] end |
#version ⇒ String
Version
126 127 128 |
# File 'lib/relaton_3gpp/parser.rb', line 126 def version "#{@row[:MAJOR_VERSION_NB]}.#{@row[:TECHNICAL_VERSION_NB]}.#{@row[:EDITORIAL_VERSION_NB]}" end |