iso-bib-item 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/iso_bib_item/bibliographic_item.rb +7 -1
- data/lib/iso_bib_item/iso_bibliographic_item.rb +14 -14
- data/lib/iso_bib_item/version.rb +1 -1
- data/lib/iso_bib_item/xml_parser.rb +196 -0
- metadata +3 -3
- data/lib/iso_bib_item/from_xml.rb +0 -154
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1a1bd9ee86b20e2f62362a7d3a32a3d652d37a940faf0b84a72a0a33154f7f0
|
4
|
+
data.tar.gz: 3b4368c16c6d0339a4fb248a4b625adf4a4480f4a0d9b2d127f4e097e9a9259e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf24100c5bb263e037001e48cce1d93a5125b794f92738ee3c1b6dfb4422cd3af042dd5d6cf2982c222cc8384ff9547cc06dc5fe78748117905cb3be72940501
|
7
|
+
data.tar.gz: 78f2b6faa51d28559b2043bde2e64c47f92487e9b2d1f486218b73258bf0541a844ac82d382e7a6aac725b13502e1fd478de6459bbcf2d5f7edc61a2c6a64cf8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
iso-bib-item (0.
|
4
|
+
iso-bib-item (0.4.0)
|
5
5
|
isoics (~> 0.1.6)
|
6
6
|
nokogiri (~> 1.8.4)
|
7
7
|
ruby_deep_clone (~> 0.8.0)
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
json (2.1.0)
|
20
20
|
method_source (0.9.0)
|
21
21
|
mini_portile2 (2.3.0)
|
22
|
-
nokogiri (1.8.
|
22
|
+
nokogiri (1.8.5)
|
23
23
|
mini_portile2 (~> 2.3.0)
|
24
24
|
pry (0.11.3)
|
25
25
|
coderay (~> 1.1.0)
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
rspec-mocks (~> 3.8.0)
|
35
35
|
rspec-core (3.8.0)
|
36
36
|
rspec-support (~> 3.8.0)
|
37
|
-
rspec-expectations (3.8.
|
37
|
+
rspec-expectations (3.8.2)
|
38
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
39
|
rspec-support (~> 3.8.0)
|
40
40
|
rspec-mocks (3.8.0)
|
@@ -61,4 +61,4 @@ DEPENDENCIES
|
|
61
61
|
simplecov
|
62
62
|
|
63
63
|
BUNDLED WITH
|
64
|
-
1.16.
|
64
|
+
1.16.6
|
@@ -133,7 +133,7 @@ module IsoBibItem
|
|
133
133
|
attr_reader :formatted_ref
|
134
134
|
|
135
135
|
# @!attribute [r] abstract
|
136
|
-
# @return [
|
136
|
+
# @return [Array<IsoBibItem::FormattedString>]
|
137
137
|
|
138
138
|
# @return [IsoBibItem::DocumentStatus]
|
139
139
|
attr_reader :status
|
@@ -147,6 +147,9 @@ module IsoBibItem
|
|
147
147
|
# @return [Array<IsoBibItem::Series>]
|
148
148
|
attr_reader :series
|
149
149
|
|
150
|
+
# @return [Date]
|
151
|
+
attr_reader :fetched
|
152
|
+
|
150
153
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
151
154
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
152
155
|
|
@@ -163,6 +166,7 @@ module IsoBibItem
|
|
163
166
|
# script=>String, type=>String}>]
|
164
167
|
# @param relations [Array<Hash{type=>String, identifier=>String}>]
|
165
168
|
# @param series [Array<IsoBibItem::Series>]
|
169
|
+
# @param fetched [Date] default today
|
166
170
|
def initialize(**args)
|
167
171
|
@id = args[:id]
|
168
172
|
@title = (args[:titles] || []).map { |t| FormattedString.new t }
|
@@ -187,6 +191,7 @@ module IsoBibItem
|
|
187
191
|
@relations = DocRelationCollection.new(args[:relations] || [])
|
188
192
|
@link = args[:link].map { |s| s.is_a?(Hash) ? TypedUri.new(s) : s }
|
189
193
|
@series = args[:series]
|
194
|
+
@fetched = args.fetch :fetched, Date.today
|
190
195
|
end
|
191
196
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
192
197
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -207,6 +212,7 @@ module IsoBibItem
|
|
207
212
|
def to_xml
|
208
213
|
Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
209
214
|
xml.bibitem(id: id) do
|
215
|
+
xml.fetched fetched
|
210
216
|
title.each { |t| xml.title { t.to_xml xml } }
|
211
217
|
link.each { |s| s.to_xml xml }
|
212
218
|
docidentifier.each { |di| di.to_xml xml }
|
@@ -8,7 +8,7 @@ require 'iso_bib_item/iso_document_status'
|
|
8
8
|
require 'iso_bib_item/iso_localized_title'
|
9
9
|
require 'iso_bib_item/iso_project_group'
|
10
10
|
require 'iso_bib_item/document_relation_collection'
|
11
|
-
require 'iso_bib_item/
|
11
|
+
require 'iso_bib_item/xml_parser'
|
12
12
|
|
13
13
|
# Add filter method to Array.
|
14
14
|
class Array
|
@@ -23,13 +23,13 @@ module IsoBibItem
|
|
23
23
|
# @return [Integer]
|
24
24
|
attr_reader :tc_document_number
|
25
25
|
|
26
|
-
# @return [
|
26
|
+
# @return [String]
|
27
27
|
attr_reader :project_number
|
28
28
|
|
29
|
-
# @return [
|
29
|
+
# @return [String]
|
30
30
|
attr_reader :part_number
|
31
31
|
|
32
|
-
# @return [
|
32
|
+
# @return [String]
|
33
33
|
attr_reader :subpart_number
|
34
34
|
|
35
35
|
# @return [String]
|
@@ -41,19 +41,19 @@ module IsoBibItem
|
|
41
41
|
# @return [String]
|
42
42
|
attr_reader :type
|
43
43
|
|
44
|
-
# @param project_number [
|
45
|
-
# @param part_number [
|
46
|
-
# @param subpart_number [
|
44
|
+
# @param project_number [String]
|
45
|
+
# @param part_number [String]
|
46
|
+
# @param subpart_number [String]
|
47
47
|
# @param prefix [String]
|
48
48
|
# @param id [String]
|
49
49
|
# @param type [String]
|
50
|
-
def initialize(
|
51
|
-
@project_number = project_number
|
52
|
-
@part_number = part_number
|
53
|
-
@subpart_number = subpart_number
|
54
|
-
@prefix = prefix
|
55
|
-
@type = type
|
56
|
-
@id = id
|
50
|
+
def initialize(**args)
|
51
|
+
@project_number = args[:project_number]
|
52
|
+
@part_number = args[:part_number]
|
53
|
+
@subpart_number = args[:subpart_number]
|
54
|
+
@prefix = args[:prefix]
|
55
|
+
@type = args[:type]
|
56
|
+
@id = args[:id]
|
57
57
|
end
|
58
58
|
|
59
59
|
# in docid manipulations, assume ISO as the default: id-part:year
|
data/lib/iso_bib_item/version.rb
CHANGED
@@ -0,0 +1,196 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module IsoBibItem
|
4
|
+
class XMLParser
|
5
|
+
class << self
|
6
|
+
def from_xml(xml)
|
7
|
+
doc = Nokogiri::XML(xml)
|
8
|
+
IsoBibliographicItem.new(
|
9
|
+
docid: fetch_docid(doc),
|
10
|
+
edition: doc.at('/bibitem/edition')&.text,
|
11
|
+
language: doc.xpath('/bibitem/language').map(&:text),
|
12
|
+
script: doc.xpath('/bibitem/script').map(&:text),
|
13
|
+
titles: fetch_titles(doc),
|
14
|
+
type: doc.at('bibitem')&.attr(:type),
|
15
|
+
docstatus: fetch_status(doc),
|
16
|
+
ics: fetch_ics(doc),
|
17
|
+
dates: fetch_dates(doc),
|
18
|
+
contributors: fetch_contributors(doc),
|
19
|
+
workgroup: fetch_workgroup(doc),
|
20
|
+
abstract: fetch_abstract(doc),
|
21
|
+
copyright: fetch_copyright(doc),
|
22
|
+
link: fetch_link(doc),
|
23
|
+
relations: fetch_relations(doc)
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def get_id(did)
|
30
|
+
did.text.match(/^(?<project>.*?\d+)(?<hyphen>-)?(?(<hyphen>)(?<part>\d*))/)
|
31
|
+
end
|
32
|
+
|
33
|
+
def fetch_docid(doc)
|
34
|
+
ret = []
|
35
|
+
doc.xpath("/bibitem/docidentifier").each do |did|
|
36
|
+
#did = doc.at('/bibitem/docidentifier')
|
37
|
+
type = did.at("./@type")
|
38
|
+
if did.text == "IEV" then ret << IsoBibItem::IsoDocumentId.new(project_number: "IEV", part_number: nil, prefix: nil)
|
39
|
+
else
|
40
|
+
id = get_id did
|
41
|
+
ret << IsoBibItem::IsoDocumentId.new(project_number: id.nil? ? did.text : id[:project],
|
42
|
+
part_number: id.nil? ? nil : id[:part],
|
43
|
+
prefix: nil,
|
44
|
+
id: did.text,
|
45
|
+
type: type&.text)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
ret
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch_titles(doc)
|
52
|
+
doc.xpath('/bibitem/title').map do |t|
|
53
|
+
titl = t.text.split ' -- '
|
54
|
+
case titl.size
|
55
|
+
when 0
|
56
|
+
intro, main, part = nil, "", nil
|
57
|
+
when 1
|
58
|
+
intro, main, part = nil, titl[0], nil
|
59
|
+
when 2
|
60
|
+
if /^(Part|Partie) \d+:/.match? titl[1]
|
61
|
+
intro, main, part = nil, titl[0], titl[1]
|
62
|
+
else
|
63
|
+
intro, main, part = titl[0], titl[1], nil
|
64
|
+
end
|
65
|
+
when 3
|
66
|
+
intro, main, part = titl[0], titl[1], titl[2]
|
67
|
+
else
|
68
|
+
intro, main, part = titl[0], titl[1], titl[2..-1]&.join(" -- ")
|
69
|
+
end
|
70
|
+
IsoLocalizedTitle.new(title_intro: intro, title_main: main,
|
71
|
+
title_part: part, language: t[:language],
|
72
|
+
script: t[:script])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def fetch_status(doc)
|
77
|
+
status = doc.at('/bibitem/status')
|
78
|
+
stage = status&.at('stage')&.text
|
79
|
+
substage = status&.at('substage')&.text
|
80
|
+
iteration = status&.at('iterarion')&.text&.to_i
|
81
|
+
IsoDocumentStatus.new(status: status&.text, stage: stage,
|
82
|
+
substage: substage, iteration: iteration)
|
83
|
+
end
|
84
|
+
|
85
|
+
def fetch_ics(doc)
|
86
|
+
doc.xpath('/bibitem/ics/code').map { |ics| Ics.new ics.text }
|
87
|
+
end
|
88
|
+
|
89
|
+
def fetch_dates(doc)
|
90
|
+
doc.xpath('/bibitem/date').map do |d|
|
91
|
+
BibliographicDate.new(type: d[:type], on: d.at('on')&.text,
|
92
|
+
from: d.at('from')&.text,
|
93
|
+
to: d.at('to')&.text)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_org(org)
|
98
|
+
names = org.xpath('name').map do |n|
|
99
|
+
{ content: n.text, language: n[:language], script: n[:script] }
|
100
|
+
end
|
101
|
+
IsoBibItem::Organization.new(name: names,
|
102
|
+
abbreviation: org.at('abbreviation')&.text,
|
103
|
+
url: org.at('uri')&.text)
|
104
|
+
end
|
105
|
+
|
106
|
+
def get_person(person)
|
107
|
+
name = person.at './name/completename'
|
108
|
+
affilations = person.xpath('./affiliation').map do |a|
|
109
|
+
org = a.at './organization'
|
110
|
+
IsoBibItem::Affilation.new get_org(org)
|
111
|
+
end
|
112
|
+
contacts = person.xpath('./contact').map do |c|
|
113
|
+
if (addr = c.at './address')
|
114
|
+
streets = addr.xpath('./street').map(&:text)
|
115
|
+
IsoBibItem::Address.new(
|
116
|
+
street: streets,
|
117
|
+
city: addr.at('./city').text,
|
118
|
+
state: addr.at('./state').text,
|
119
|
+
country: addr.at('./country').text,
|
120
|
+
postcode: addr.at('./postcode').text
|
121
|
+
)
|
122
|
+
else
|
123
|
+
contact = c.child
|
124
|
+
IsoBibItem::Contact.new(type: contact[:name], value: contact.text)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
completename = IsoBibItem::LocalizedString.new(name.text, name[:language])
|
128
|
+
IsoBibItem::Person.new(
|
129
|
+
name: IsoBibItem::FullName.new(completename: completename),
|
130
|
+
affiliation: affilations,
|
131
|
+
contacts: contacts
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
def fetch_contributors(doc)
|
136
|
+
doc.xpath('/bibitem/contributor').map do |c|
|
137
|
+
entity = if (org = c.at './organization') then get_org(org)
|
138
|
+
elsif (person = c.at './person') then get_person(person)
|
139
|
+
end
|
140
|
+
IsoBibItem::ContributionInfo.new entity: entity, role: [c.at('role')[:type]]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# @TODO Organization doesn't recreated
|
145
|
+
def fetch_workgroup(doc)
|
146
|
+
eg = doc.at('/bibitem/editorialgroup')
|
147
|
+
tc = eg&.at('technical_committee')
|
148
|
+
sc = eg&.at('subcommittee')
|
149
|
+
scom = iso_subgroup(sc)
|
150
|
+
wg = eg&.at('workgroup')
|
151
|
+
wgrp = iso_subgroup(wg)
|
152
|
+
IsoProjectGroup.new(technical_committee: iso_subgroup(tc),
|
153
|
+
subcommittee: scom, workgroup: wgrp)
|
154
|
+
end
|
155
|
+
|
156
|
+
def iso_subgroup(com)
|
157
|
+
return nil if com.nil?
|
158
|
+
IsoSubgroup.new(name: com.text, type: com[:type],
|
159
|
+
number: com[:number].to_i)
|
160
|
+
end
|
161
|
+
|
162
|
+
def fetch_abstract(doc)
|
163
|
+
doc.xpath('/bibitem/abstract').map do |a|
|
164
|
+
FormattedString.new(content: a.text, language: a[:language],
|
165
|
+
script: a[:script], type: a[:format])
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def fetch_copyright(doc)
|
170
|
+
cp = doc.at('/bibitem/copyright') || return
|
171
|
+
org = cp&.at('owner/organization')
|
172
|
+
name = org&.at('name').text
|
173
|
+
abbr = org&.at('abbreviation')&.text
|
174
|
+
url = org&.at('uri')&.text
|
175
|
+
entity = Organization.new(name: name, abbreviation: abbr, url: url)
|
176
|
+
from = cp.at('from')&.text
|
177
|
+
to = cp.at('to')&.text
|
178
|
+
owner = ContributionInfo.new entity: entity
|
179
|
+
CopyrightAssociation.new(owner: owner, from: from, to: to)
|
180
|
+
end
|
181
|
+
|
182
|
+
def fetch_link(doc)
|
183
|
+
doc.xpath('/bibitem/uri').map do |l|
|
184
|
+
TypedUri.new type: l[:type], content: l.text
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def fetch_relations(doc)
|
189
|
+
doc.xpath('/bibitem/relation').map do |r|
|
190
|
+
DocumentRelation.new(type: r[:type],
|
191
|
+
identifier: r.at('bibitem/formattedref').text)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso-bib-item
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -163,7 +163,6 @@ files:
|
|
163
163
|
- lib/iso_bib_item/document_relation_collection.rb
|
164
164
|
- lib/iso_bib_item/document_status.rb
|
165
165
|
- lib/iso_bib_item/formatted_string.rb
|
166
|
-
- lib/iso_bib_item/from_xml.rb
|
167
166
|
- lib/iso_bib_item/iso_bibliographic_item.rb
|
168
167
|
- lib/iso_bib_item/iso_document_status.rb
|
169
168
|
- lib/iso_bib_item/iso_localized_title.rb
|
@@ -173,6 +172,7 @@ files:
|
|
173
172
|
- lib/iso_bib_item/person.rb
|
174
173
|
- lib/iso_bib_item/series.rb
|
175
174
|
- lib/iso_bib_item/version.rb
|
175
|
+
- lib/iso_bib_item/xml_parser.rb
|
176
176
|
homepage: https://github.com/riboseinc/gdbib
|
177
177
|
licenses:
|
178
178
|
- BSD-2-Clause
|
@@ -1,154 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module IsoBibItem
|
4
|
-
class << self
|
5
|
-
def from_xml(xml)
|
6
|
-
doc = Nokogiri::XML(xml)
|
7
|
-
IsoBibliographicItem.new(
|
8
|
-
docid: fetch_docid(doc),
|
9
|
-
edition: doc.at('/bibitem/edition')&.text,
|
10
|
-
language: doc.xpath('/bibitem/language').map(&:text),
|
11
|
-
script: doc.xpath('/bibitem/script').map(&:text),
|
12
|
-
titles: fetch_titles(doc),
|
13
|
-
type: doc.at('bibitem')&.attr(:type),
|
14
|
-
docstatus: fetch_status(doc),
|
15
|
-
ics: fetch_ics(doc),
|
16
|
-
dates: fetch_dates(doc),
|
17
|
-
contributors: fetch_contributors(doc),
|
18
|
-
workgroup: fetch_workgroup(doc),
|
19
|
-
abstract: fetch_abstract(doc),
|
20
|
-
copyright: fetch_copyright(doc),
|
21
|
-
link: fetch_link(doc),
|
22
|
-
relations: fetch_relations(doc)
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def fetch_docid(doc)
|
29
|
-
ret = []
|
30
|
-
doc.xpath("/bibitem/docidentifier").each do |did|
|
31
|
-
#did = doc.at('/bibitem/docidentifier')
|
32
|
-
type = did.at("./@type")
|
33
|
-
if did.text == "IEV" then ret << IsoBibItem::IsoDocumentId.new(project_number: "IEV", part_number: nil, prefix: nil)
|
34
|
-
else
|
35
|
-
id = did.text.match(/^(?<project>.*\d+)(?<hyphen>-)?(?(<hyphen>)(?<part>\d*))(-(?<subpart>\d+))?$/)
|
36
|
-
ret << IsoBibItem::IsoDocumentId.new(project_number: id.nil? ? did.text : id[:project],
|
37
|
-
part_number: id.nil? ? nil : id[:part],
|
38
|
-
subpart_number: id.nil? ? nil : id[:subpart],
|
39
|
-
prefix: nil,
|
40
|
-
id: did.text,
|
41
|
-
type: type&.text)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
ret
|
45
|
-
end
|
46
|
-
|
47
|
-
def fetch_titles(doc)
|
48
|
-
doc.xpath('/bibitem/title').map do |t|
|
49
|
-
titl = t.text.split ' -- '
|
50
|
-
case titl.size
|
51
|
-
when 0
|
52
|
-
intro, main, part = nil, "", nil
|
53
|
-
when 1
|
54
|
-
intro, main, part = nil, titl[0], nil
|
55
|
-
when 2
|
56
|
-
if /^(Part|Partie) \d+:/.match? titl[1]
|
57
|
-
intro, main, part = nil, titl[0], titl[1]
|
58
|
-
else
|
59
|
-
intro, main, part = titl[0], titl[1], nil
|
60
|
-
end
|
61
|
-
when 3
|
62
|
-
intro, main, part = titl[0], titl[1], titl[2]
|
63
|
-
else
|
64
|
-
intro, main, part = titl[0], titl[1], titl[2..-1]&.join(" -- ")
|
65
|
-
end
|
66
|
-
IsoLocalizedTitle.new(title_intro: intro, title_main: main,
|
67
|
-
title_part: part, language: t[:language],
|
68
|
-
script: t[:script])
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def fetch_status(doc)
|
73
|
-
status = doc.at('/bibitem/status')
|
74
|
-
stage = status&.at('stage')&.text
|
75
|
-
substage = status&.at('substage')&.text
|
76
|
-
iteration = status&.at('iterarion')&.text&.to_i
|
77
|
-
IsoDocumentStatus.new(status: status&.text, stage: stage,
|
78
|
-
substage: substage, iteration: iteration)
|
79
|
-
end
|
80
|
-
|
81
|
-
def fetch_ics(doc)
|
82
|
-
doc.xpath('/bibitem/ics/code').map { |ics| Ics.new ics.text }
|
83
|
-
end
|
84
|
-
|
85
|
-
def fetch_dates(doc)
|
86
|
-
doc.xpath('/bibitem/date').map do |d|
|
87
|
-
BibliographicDate.new(type: d[:type], on: d.at('on')&.text,
|
88
|
-
from: d.at('from')&.text,
|
89
|
-
to: d.at('to')&.text)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def fetch_contributors(doc)
|
94
|
-
doc.xpath('/bibitem/contributor').map do |c|
|
95
|
-
o = c.at 'organization'
|
96
|
-
org = Organization.new(name: o.at('name')&.text,
|
97
|
-
abbreviation: o.at('abbreviation')&.text,
|
98
|
-
url: o.at('uri')&.text)
|
99
|
-
ContributionInfo.new entity: org, role: [c.at('role')[:type]]
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# @TODO Organization doesn't recreated
|
104
|
-
def fetch_workgroup(doc)
|
105
|
-
eg = doc.at('/bibitem/editorialgroup')
|
106
|
-
tc = eg&.at('technical_committee')
|
107
|
-
sc = eg&.at('subcommittee')
|
108
|
-
scom = iso_subgroup(sc)
|
109
|
-
wg = eg&.at('workgroup')
|
110
|
-
wgrp = iso_subgroup(wg)
|
111
|
-
IsoProjectGroup.new(technical_committee: iso_subgroup(tc),
|
112
|
-
subcommittee: scom, workgroup: wgrp)
|
113
|
-
end
|
114
|
-
|
115
|
-
def iso_subgroup(com)
|
116
|
-
return nil if com.nil?
|
117
|
-
IsoSubgroup.new(name: com.text, type: com[:type],
|
118
|
-
number: com[:number].to_i)
|
119
|
-
end
|
120
|
-
|
121
|
-
def fetch_abstract(doc)
|
122
|
-
doc.xpath('/bibitem/abstract').map do |a|
|
123
|
-
FormattedString.new(content: a.text, language: a[:language],
|
124
|
-
script: a[:script], type: a[:format])
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def fetch_copyright(doc)
|
129
|
-
cp = doc.at('/bibitem/copyright') || return
|
130
|
-
org = cp&.at('owner/organization')
|
131
|
-
name = org&.at('name').text
|
132
|
-
abbr = org&.at('abbreviation')&.text
|
133
|
-
url = org&.at('uri')&.text
|
134
|
-
entity = Organization.new(name: name, abbreviation: abbr, url: url)
|
135
|
-
from = cp.at('from')&.text
|
136
|
-
to = cp.at('to')&.text
|
137
|
-
owner = ContributionInfo.new entity: entity
|
138
|
-
CopyrightAssociation.new(owner: owner, from: from, to: to)
|
139
|
-
end
|
140
|
-
|
141
|
-
def fetch_link(doc)
|
142
|
-
doc.xpath('/bibitem/uri').map do |l|
|
143
|
-
TypedUri.new type: l[:type], content: l.text
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def fetch_relations(doc)
|
148
|
-
doc.xpath('/bibitem/relation').map do |r|
|
149
|
-
DocumentRelation.new(type: r[:type],
|
150
|
-
identifier: r.at('bibitem/formattedref').text)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|