relaton-ietf 0.12.1 → 1.0.4
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/grammars/basicdoc.rng +12 -55
- data/grammars/biblio.rng +109 -44
- data/grammars/ietf.rng +758 -112
- data/grammars/isodoc.rng +575 -28
- data/grammars/isostandard.rng +137 -472
- data/lib/relaton_ietf/scrapper.rb +31 -17
- data/lib/relaton_ietf/version.rb +1 -1
- data/relaton_ietf.gemspec +1 -1
- metadata +6 -6
@@ -192,7 +192,8 @@ module RelatonIetf
|
|
192
192
|
|
193
193
|
# @return [Array<Hash{Symbol=>RelatonBib::Person,Symbol=>Array<String>}>]
|
194
194
|
def persons(reference)
|
195
|
-
reference.xpath("./front/author").
|
195
|
+
reference.xpath("./front/author[@surname]|./front/author[@fullname]").
|
196
|
+
map do |author|
|
196
197
|
entity = RelatonBib::Person.new(
|
197
198
|
name: full_name(author, reference),
|
198
199
|
affiliation: [affiliation(author)],
|
@@ -204,29 +205,33 @@ module RelatonIetf
|
|
204
205
|
|
205
206
|
# @return [Array<Hash{Symbol=>RelatonBib::Organization,Symbol=>Array<String>}>]
|
206
207
|
def organizations(reference)
|
207
|
-
|
208
|
-
|
208
|
+
publisher = { entity: new_org, role: [type: "publisher"] }
|
209
|
+
reference.xpath("./seriesinfo").reduce([publisher]) do |mem, si|
|
210
|
+
next mem unless si[:stream]
|
209
211
|
|
210
|
-
|
211
|
-
|
212
|
-
end.compact
|
212
|
+
mem << { entity: new_org(si[:stream]), role: [type: "author"] }
|
213
|
+
end
|
213
214
|
end
|
214
215
|
|
215
216
|
# @param author [Nokogiri::XML::Document]
|
216
217
|
# @param ref [Nokogiri::XML::Document]
|
217
218
|
# @return [RelatonBib::FullName]
|
218
219
|
def full_name(author, ref)
|
220
|
+
lang = language ref
|
219
221
|
RelatonBib::FullName.new(
|
220
|
-
completename: localized_string(author[:fullname],
|
221
|
-
initial: [localized_string(author[:initials],
|
222
|
-
surname:
|
222
|
+
completename: localized_string(author[:fullname], lang),
|
223
|
+
initial: [localized_string(author[:initials], lang)].compact,
|
224
|
+
surname: localized_string(author[:surname], lang),
|
223
225
|
)
|
224
226
|
end
|
225
227
|
|
226
228
|
# @param content [String]
|
229
|
+
# @param lang [String]
|
227
230
|
# @return [RelatonBib::LocalizedString]
|
228
|
-
def localized_string(content,
|
229
|
-
|
231
|
+
def localized_string(content, lang)
|
232
|
+
return unless content
|
233
|
+
|
234
|
+
RelatonBib::LocalizedString.new(content, lang)
|
230
235
|
end
|
231
236
|
|
232
237
|
# @param postal [Nokogiri::XML::Document]
|
@@ -267,13 +272,21 @@ module RelatonIetf
|
|
267
272
|
# @return [RelatonBib::Affiliation]
|
268
273
|
def affiliation(author)
|
269
274
|
organization = author.at("./organization")
|
270
|
-
org =
|
271
|
-
|
272
|
-
|
273
|
-
|
275
|
+
org = if organization.nil? || organization&.text&.empty?
|
276
|
+
new_org
|
277
|
+
else
|
278
|
+
new_org organization.text, organization[:abbrev]
|
279
|
+
end
|
274
280
|
RelatonBib::Affiliation.new organization: org
|
275
281
|
end
|
276
282
|
|
283
|
+
# @param name [String]
|
284
|
+
# @param abbr [String]
|
285
|
+
# @return [RelatonBib::Organization]
|
286
|
+
def new_org(name = "Internet Engineering Task Force", abbr = "IETF")
|
287
|
+
RelatonBib::Organization.new name: name, abbreviation: abbr
|
288
|
+
end
|
289
|
+
|
277
290
|
# @param author [Nokogiri::XML::Document]
|
278
291
|
# @return [Hash]
|
279
292
|
def contributor_role(author)
|
@@ -281,6 +294,7 @@ module RelatonIetf
|
|
281
294
|
end
|
282
295
|
|
283
296
|
def month(mon)
|
297
|
+
return 1 if !mon || mon.empty?
|
284
298
|
return mon if /^\d+$/ =~ mon
|
285
299
|
|
286
300
|
Date::MONTHNAMES.index(mon)
|
@@ -294,8 +308,8 @@ module RelatonIetf
|
|
294
308
|
def dates(reference)
|
295
309
|
return unless (date = reference.at "./front/date")
|
296
310
|
|
297
|
-
d = [date[:year], month(date[:month])
|
298
|
-
(date[:day] ||
|
311
|
+
d = [date[:year], month(date[:month]),
|
312
|
+
(date[:day] || 1)].compact.join "-"
|
299
313
|
date = Time.parse(d).strftime "%Y-%m-%d"
|
300
314
|
[RelatonBib::BibliographicDate.new(type: "published", on: date)]
|
301
315
|
end
|
data/lib/relaton_ietf/version.rb
CHANGED
data/relaton_ietf.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-ietf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: relaton-bib
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 1.0.4
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 1.0.4
|
167
167
|
description: "RelatonIetf: retrieve IETF Standards for bibliographic use \nusing the
|
168
168
|
BibliographicItem model.\n\nFormerly known as rfcbib.\n"
|
169
169
|
email:
|