Class: RelatonEtsi::DataParser

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_etsi/data_parser.rb

Constant Summary collapse

ATTRS =
%i[id title docnumber link date docid version status contributor
keyword editorialgroup doctype abstract language script].freeze

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ DataParser

Returns a new instance of DataParser.



6
7
8
# File 'lib/relaton_etsi/data_parser.rb', line 6

def initialize(row)
  @row = row
end

Instance Method Details

#abstractObject



83
84
85
86
87
# File 'lib/relaton_etsi/data_parser.rb', line 83

def abstract
  return [] unless @row["Scope"]

  [RelatonBib::FormattedString.new(content: @row["Scope"], language: "en", script: "Latn")]
end

#contributorObject



60
61
62
63
64
65
66
67
# File 'lib/relaton_etsi/data_parser.rb', line 60

def contributor
  name = RelatonBib::LocalizedString.new(
    "European Telecommunications Standards Institute", "en", "Latn"
  )
  abbrev = RelatonBib::LocalizedString.new("ETSI", "en", "Latn")
  entity = RelatonBib::Organization.new name: [name], abbreviation: abbrev
  [RelatonBib::ContributionInfo.new(entity: entity, role: [{ type: "publisher" }])]
end

#dateObject



39
40
41
42
43
# File 'lib/relaton_etsi/data_parser.rb', line 39

def date
  return [] unless pubid.date

  [RelatonBib::BibliographicDate.new(type: "published", on: pubid.date)]
end

#docidObject



45
46
47
# File 'lib/relaton_etsi/data_parser.rb', line 45

def docid
  [RelatonBib::DocumentIdentifier.new(id: @row["ETSI deliverable"], type: "ETSI", primary: true)]
end

#docnumberObject



29
30
31
# File 'lib/relaton_etsi/data_parser.rb', line 29

def docnumber
  @row["ETSI deliverable"]
end

#doctypeObject



79
80
81
# File 'lib/relaton_etsi/data_parser.rb', line 79

def doctype
  DocumentType.create_from_abbreviation pubid.type
end

#editorialgroupObject



73
74
75
76
77
# File 'lib/relaton_etsi/data_parser.rb', line 73

def editorialgroup
  wg = RelatonBib::WorkGroup.new name: @row["Technical body"]
  tc = RelatonBib::TechnicalCommittee.new wg
  RelatonBib::EditorialGroup.new [tc]
end

#idObject



21
22
23
# File 'lib/relaton_etsi/data_parser.rb', line 21

def id
  @row["ETSI deliverable"].gsub(/[\s\(\)]/, "")
end

#keywordObject



69
70
71
# File 'lib/relaton_etsi/data_parser.rb', line 69

def keyword
  @row["Keywords"].split(",")
end

#languageObject



89
90
91
# File 'lib/relaton_etsi/data_parser.rb', line 89

def language
  ["en"]
end


33
34
35
36
37
# File 'lib/relaton_etsi/data_parser.rb', line 33

def link
  urls = []
  urls << RelatonBib::TypedUri.new(content: @row["Details link"], type: "src")
  urls << RelatonBib::TypedUri.new(content: @row["PDF link"], type: "pdf")
end

#parseObject



10
11
12
13
14
15
# File 'lib/relaton_etsi/data_parser.rb', line 10

def parse
  args = ATTRS.each_with_object({}) do |attr, hash|
    hash[attr] = send(attr)
  end
  BibliographicItem.new(**args)
end

#pubidObject



17
18
19
# File 'lib/relaton_etsi/data_parser.rb', line 17

def pubid
  @pubid ||= PubId.parse(@row["ETSI deliverable"])
end

#scriptObject



93
94
95
# File 'lib/relaton_etsi/data_parser.rb', line 93

def script
  ["Latn"]
end

#statusObject



55
56
57
58
# File 'lib/relaton_etsi/data_parser.rb', line 55

def status
  status = @row["Status"] == "On Approval" ? "#{pubid.type} approval" : @row["Status"]
  RelatonBib::DocumentStatus.new(stage: status)
end

#titleObject



25
26
27
# File 'lib/relaton_etsi/data_parser.rb', line 25

def title
  [RelatonBib::TypedTitleString.new(content: @row["title"], language: "en", script: "Latn")]
end

#versionObject



49
50
51
52
53
# File 'lib/relaton_etsi/data_parser.rb', line 49

def version
  return [] unless pubid.version

  [RelatonBib::BibliographicItem::Version.new(nil, pubid.version)]
end