class Relaton3gpp::Parser

Public Class Methods

new(row, specs, specrels, releases, tstatus) click to toggle source

Document parser initalization

@param [Hash] row row @param [Array<Hash>] specrels Spec + Release table @param [Array<Hash>] relaeases Releases table @param [Array<Hash>] specs Specs table @param [Array<Hash>] tstatus temp status-table

# 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
parse(row, specs, specrels, relaeases, tstatus) click to toggle source

Initialize document parser and run it

@param [Hash] row row @param [Array<Hash>] specrels Spec + Release table @param [Array<Hash>] relaeases Releases table @param [Array<Hash>] specs Specs table @param [Array<Hash>] tstatus temp status-table

@return [RelatonBib:BibliographicItem, nil] bibliographic item

# File lib/relaton_3gpp/parser.rb, line 35
def self.parse(row, specs, specrels, relaeases, tstatus)
  new(row, specs, specrels, relaeases, tstatus).parse
end

Public Instance Methods

create_workgroup(name, type) click to toggle source
# File lib/relaton_3gpp/parser.rb, line 167
def create_workgroup(name, type)
  wgf = RelatonBib::WorkGroup.new(name: name, type: type)
  RelatonBib::TechnicalCommittee.new(wgf)
end
number() click to toggle source

Generate number

@return [String] number

# File lib/relaton_3gpp/parser.rb, line 118
def number
  "#{@spec[:Type]} #{@row[:spec]}:#{@row[:release]}/#{version}"
end
parse() click to toggle source

Parse document

@return [Relaton3gpp:BibliographicItem, nil] bibliographic item

# 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,
    place: ["Sophia Antipolis Cedex, France"],
  )
end
parse_abstract() click to toggle source

Parse abstract

@return [Array<RelatonBib::FormattedString>]

# File lib/relaton_3gpp/parser.rb, line 98
def parse_abstract
  return [] unless @spec[:description]

  [RelatonBib::FormattedString.new(content: @spec[:description])]
end
parse_contributor() click to toggle source

Create contributors

@return [Array<RelatonBib::ContributionInfo>] contributor

# File lib/relaton_3gpp/parser.rb, line 245
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],
  )
  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() click to toggle source

Parse date

@return [Array<RelatonBib::BibliographicDate>] date

# File lib/relaton_3gpp/parser.rb, line 136
def parse_date
  dates = { completed: "created", ACHIEVED_DATE: "published" }.each_with_object([]) do |(k, t), d|
  # if @row[:completed]
    next unless @row[k]

    cd = Date.parse(@row[k]).to_s
    d << RelatonBib::BibliographicDate.new(type: t, on: cd)
  end
  if @spec[:"title verified"]
    td = Date.parse(@spec[:"title verified"]).to_s
    dates << RelatonBib::BibliographicDate.new(type: "confirmed", on: td)
  end
  dates
end
parse_docid() click to toggle source

Parse docidentifier

@return [Arra<RelatonBib::DocumentIdentifier>] docidentifier

# File lib/relaton_3gpp/parser.rb, line 109
def parse_docid
  [RelatonBib::DocumentIdentifier.new(type: "3GPP", id: "3GPP #{number}", primary: true)]
end
parse_editorialgroup() click to toggle source

Parse editorialgroup

@return [RelatonBib::EditorialGroup] editorialgroups

# File lib/relaton_3gpp/parser.rb, line 156
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_note() click to toggle source

Parse note

@return [RelatonBib::BiblioNoteCollection] notes

# File lib/relaton_3gpp/parser.rb, line 177
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() click to toggle source

Parse radio technology

@return [String] radio technology

# File lib/relaton_3gpp/parser.rb, line 206
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() click to toggle source

Parse release

@return [Relaton3gpp::Release, nil] release

# File lib/relaton_3gpp/parser.rb, line 219
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() click to toggle source

Prase status

@return [RelatnoBib::DocumentStatus, nil] status

# File lib/relaton_3gpp/parser.rb, line 193
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() click to toggle source

Parse title

@return [RelatonBib::TypedTitleStringCollection] title

# File lib/relaton_3gpp/parser.rb, line 76
def parse_title
  t = RelatonBib::TypedTitleString.new content: @spec[:Title], type: "main"
  RelatonBib::TypedTitleStringCollection.new [t]
end
version() click to toggle source

Version

@return [String] version

# File lib/relaton_3gpp/parser.rb, line 127
def version
  "#{@row[:MAJOR_VERSION_NB]}.#{@row[:TECHNICAL_VERSION_NB]}.#{@row[:EDITORIAL_VERSION_NB]}"
end