relaton-ieee 1.12.6 → 1.13.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/grammars/biblio.rng +8 -5
- data/grammars/isodoc.rng +27 -1
- data/lib/relaton_ieee/data_parser.rb +3 -3
- data/lib/relaton_ieee/ieee_bibliographic_item.rb +7 -4
- data/lib/relaton_ieee/ieee_bibliography.rb +12 -59
- data/lib/relaton_ieee/processor.rb +1 -1
- data/lib/relaton_ieee/version.rb +1 -1
- data/relaton_ieee.gemspec +1 -1
- metadata +4 -5
- data/lib/relaton_ieee/hit_collection.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fda50884de36443dda8e3963c57396ac334a1c5e70d433a02db5249fbcfea2bf
|
4
|
+
data.tar.gz: 7b8d5327947ec30d0a0d3a05d5a291305686eaf1de2a58675cbb2f0ff9478ce6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d401406eb5049882c1aec5ee87293c998ff45603876f9acc21ad4c5cf523d32abdbed278075740dfc4c863d7c3c6b7447c1c38b5222b441f03c45bc30fc3f252
|
7
|
+
data.tar.gz: 66d9e5789967dec4619da6145ff2d218a2fc5bce1b5fd8e00dc043366ff2758522ce40c921a5283e6bd0b294b3bdfcc0d86f93b0e692fe1eeac50580cb7d6cb9
|
data/grammars/biblio.rng
CHANGED
@@ -225,9 +225,9 @@
|
|
225
225
|
<zeroOrMore>
|
226
226
|
<ref name="forename"/>
|
227
227
|
</zeroOrMore>
|
228
|
-
<
|
229
|
-
<ref name="
|
230
|
-
</
|
228
|
+
<optional>
|
229
|
+
<ref name="formatted-initials"/>
|
230
|
+
</optional>
|
231
231
|
<ref name="surname"/>
|
232
232
|
<zeroOrMore>
|
233
233
|
<ref name="addition"/>
|
@@ -247,8 +247,8 @@
|
|
247
247
|
<ref name="LocalizedString"/>
|
248
248
|
</element>
|
249
249
|
</define>
|
250
|
-
<define name="
|
251
|
-
<element name="
|
250
|
+
<define name="formatted-initials">
|
251
|
+
<element name="formatted-initials">
|
252
252
|
<ref name="LocalizedString"/>
|
253
253
|
</element>
|
254
254
|
</define>
|
@@ -264,6 +264,9 @@
|
|
264
264
|
</define>
|
265
265
|
<define name="forename">
|
266
266
|
<element name="forename">
|
267
|
+
<optional>
|
268
|
+
<attribute name="initial"/>
|
269
|
+
</optional>
|
267
270
|
<ref name="LocalizedString"/>
|
268
271
|
</element>
|
269
272
|
</define>
|
data/grammars/isodoc.rng
CHANGED
@@ -69,6 +69,17 @@
|
|
69
69
|
</zeroOrMore>
|
70
70
|
</element>
|
71
71
|
</define>
|
72
|
+
<define name="AdmonitionType">
|
73
|
+
<choice>
|
74
|
+
<value>warning</value>
|
75
|
+
<value>note</value>
|
76
|
+
<value>tip</value>
|
77
|
+
<value>important</value>
|
78
|
+
<value>caution</value>
|
79
|
+
<value>statement</value>
|
80
|
+
<value>editorial</value>
|
81
|
+
</choice>
|
82
|
+
</define>
|
72
83
|
<define name="index">
|
73
84
|
<element name="index">
|
74
85
|
<optional>
|
@@ -1274,7 +1285,12 @@
|
|
1274
1285
|
</define>
|
1275
1286
|
<define name="span">
|
1276
1287
|
<element name="span">
|
1277
|
-
<
|
1288
|
+
<optional>
|
1289
|
+
<attribute name="class"/>
|
1290
|
+
</optional>
|
1291
|
+
<optional>
|
1292
|
+
<attribute name="style"/>
|
1293
|
+
</optional>
|
1278
1294
|
<oneOrMore>
|
1279
1295
|
<ref name="TextElement"/>
|
1280
1296
|
</oneOrMore>
|
@@ -2493,6 +2509,16 @@
|
|
2493
2509
|
<text/>
|
2494
2510
|
</element>
|
2495
2511
|
</optional>
|
2512
|
+
<optional>
|
2513
|
+
<element name="amendment">
|
2514
|
+
<text/>
|
2515
|
+
</element>
|
2516
|
+
</optional>
|
2517
|
+
<optional>
|
2518
|
+
<element name="corrigendum">
|
2519
|
+
<text/>
|
2520
|
+
</element>
|
2521
|
+
</optional>
|
2496
2522
|
<optional>
|
2497
2523
|
<element name="language">
|
2498
2524
|
<text/>
|
@@ -46,7 +46,7 @@ module RelatonIeee
|
|
46
46
|
copyright: parse_copyright,
|
47
47
|
language: ["en"],
|
48
48
|
script: ["Latn"],
|
49
|
-
|
49
|
+
docstatus: parse_status,
|
50
50
|
relation: parse_relation,
|
51
51
|
link: parse_link,
|
52
52
|
keyword: parse_keyword,
|
@@ -63,8 +63,8 @@ module RelatonIeee
|
|
63
63
|
#
|
64
64
|
def parse_title
|
65
65
|
t = []
|
66
|
-
content = doc.at("./volume/article/title").text
|
67
|
-
if content =~ /\A(.+)\s-\sredline\z/i
|
66
|
+
content = CGI.unescapeHTML doc.at("./volume/article/title").text
|
67
|
+
if content =~ /\A(.+)\s[-\u2014]\sredline\z/i
|
68
68
|
t << RelatonBib::TypedTitleString.new(content: $1, type: "title-main")
|
69
69
|
end
|
70
70
|
t << RelatonBib::TypedTitleString.new(content: content, type: "main")
|
@@ -12,14 +12,17 @@ module RelatonIeee
|
|
12
12
|
#
|
13
13
|
# @param [Hash] args
|
14
14
|
# @option args [Boolean, nil] :trialuse Trial use
|
15
|
-
# @option args [Array<RelatonIeee::EditorialGroup>] :editorialgroup
|
15
|
+
# @option args [Array<RelatonIeee::EditorialGroup>] :editorialgroup
|
16
|
+
# Editorial group
|
16
17
|
#
|
17
|
-
def initialize(**args)
|
18
|
+
def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
18
19
|
if args[:doctype] && !TYPES.include?(args[:doctype])
|
19
|
-
warn "[relaton-ieee] doctype
|
20
|
+
warn "[relaton-ieee] invalid doctype \"#{args[:doctype]}\". " \
|
21
|
+
"It should be one of: #{TYPES.join(', ')}."
|
20
22
|
end
|
21
23
|
if args[:docsubtype] && !SUBTYPES.include?(args[:docsubtype])
|
22
|
-
warn "[relaton-ieee] docsubtype
|
24
|
+
warn "[relaton-ieee] invalid docsubtype \"#{args[:docsubtype]}\". " \
|
25
|
+
"It should be one of: #{SUBTYPES.join(', ')}."
|
23
26
|
end
|
24
27
|
eg = args.delete(:editorialgroup)
|
25
28
|
@trialuse = args.delete(:trialuse)
|
@@ -3,10 +3,14 @@ module RelatonIeee
|
|
3
3
|
class << self
|
4
4
|
GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ieee/main/data/".freeze
|
5
5
|
|
6
|
+
#
|
7
|
+
# Search IEEE bibliography item by reference.
|
8
|
+
#
|
6
9
|
# @param code [String]
|
10
|
+
#
|
7
11
|
# @return [RelatonIeee::HitCollection]
|
12
|
+
#
|
8
13
|
def search(code)
|
9
|
-
# HitCollection.new text
|
10
14
|
ref = code.sub(/Std\s/i, "").gsub(/[\s,:\/]/, "_").squeeze("_").upcase
|
11
15
|
url = "#{GH_URL}#{ref}.yaml"
|
12
16
|
resp = Faraday.get url
|
@@ -17,77 +21,26 @@ module RelatonIeee
|
|
17
21
|
raise RelatonBib::RequestError, "Could not access #{GH_URL}"
|
18
22
|
end
|
19
23
|
|
24
|
+
#
|
25
|
+
# Get IEEE bibliography item by reference.
|
26
|
+
#
|
20
27
|
# @param code [String] the IEEE standard Code to look up (e..g "528-2019")
|
21
28
|
# @param year [String] the year the standard was published (optional)
|
22
29
|
# @param opts [Hash] options
|
23
30
|
#
|
24
31
|
# @return [Hash, NilClass] returns { ret: RelatonBib::BibliographicItem }
|
25
32
|
# if document is found else returns NilClass
|
33
|
+
#
|
26
34
|
def get(code, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
27
35
|
warn "[relaton-ieee] (\"#{code}\") fetching..."
|
28
36
|
item = search(code)
|
29
|
-
|
30
|
-
# ret = bib_results_filter(result, code, year)
|
31
|
-
if item # ret[:ret]
|
32
|
-
# item = ret[:ret].fetch
|
37
|
+
if item
|
33
38
|
warn "[relaton-ieee] (\"#{code}\") found #{item.docidentifier.first.id}"
|
34
39
|
item
|
35
|
-
|
36
|
-
|
40
|
+
else
|
41
|
+
warn "[relaton-ieee] (\"#{code}\") not found"
|
37
42
|
end
|
38
43
|
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
# Sort through the results from RelatonIeee, fetching them three at a time,
|
43
|
-
# and return the first result that matches the code,
|
44
|
-
# matches the year (if provided), and which # has a title (amendments do not).
|
45
|
-
# Only expects the first page of results to be populated.
|
46
|
-
# Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
|
47
|
-
# If no match, returns any years which caused mismatch, for error reporting
|
48
|
-
#
|
49
|
-
# @param result [RelatonIeee::HitCollection]
|
50
|
-
# @param opts [Hash] options
|
51
|
-
#
|
52
|
-
# @return [Hash]
|
53
|
-
# def bib_results_filter(result, ref, year) # rubocop:disable Metrics/AbcSize
|
54
|
-
# rp1 = ref_parts ref
|
55
|
-
# missed_years = []
|
56
|
-
# result.each do |hit|
|
57
|
-
# rp2 = ref_parts hit.hit[:ref]
|
58
|
-
# next if rp1[:code] != rp2[:code] || rp1[:corr] != rp2[:corr]
|
59
|
-
|
60
|
-
# return { ret: hit } if !year
|
61
|
-
|
62
|
-
# return { ret: hit } if year.to_i == hit.hit[:year]
|
63
|
-
|
64
|
-
# missed_years << hit.hit[:year]
|
65
|
-
# end
|
66
|
-
# { years: missed_years.uniq }
|
67
|
-
# end
|
68
|
-
|
69
|
-
# def ref_parts(ref)
|
70
|
-
# %r{
|
71
|
-
# ^(?:IEEE\s(?:Std\s)?)?
|
72
|
-
# (?<code>[^-/]+)
|
73
|
-
# (?:-(?<year>\d{4}))?
|
74
|
-
# (?:/(?<corr>\w+\s\d+-\d{4}))?
|
75
|
-
# }x.match ref
|
76
|
-
# end
|
77
|
-
|
78
|
-
# @param code [Strig]
|
79
|
-
# @param year [String]
|
80
|
-
# @param missed_years [Array<Strig>]
|
81
|
-
# def fetch_ref_err(code, year, missed_years)
|
82
|
-
# id = year ? "#{code} year #{year}" : code
|
83
|
-
# warn "[relaton-ieee] WARNING: no match found online for #{id}. "\
|
84
|
-
# "The code must be exactly like it is on the standards website."
|
85
|
-
# unless missed_years.empty?
|
86
|
-
# warn "[relaton-ieee] (There was no match for #{year}, though there were matches "\
|
87
|
-
# "found for #{missed_years.join(', ')}.)"
|
88
|
-
# end
|
89
|
-
# nil
|
90
|
-
# end
|
91
44
|
end
|
92
45
|
end
|
93
46
|
end
|
@@ -41,7 +41,7 @@ module RelatonIeee
|
|
41
41
|
# @param hash [Hash]
|
42
42
|
# @return [RelatonIeee::IeeeBibliographicItem]
|
43
43
|
def hash_to_bib(hash)
|
44
|
-
::RelatonIeee::IeeeBibliographicItem.new
|
44
|
+
::RelatonIeee::IeeeBibliographicItem.new(**hash)
|
45
45
|
end
|
46
46
|
|
47
47
|
# Returns hash of XML grammar
|
data/lib/relaton_ieee/version.rb
CHANGED
data/relaton_ieee.gemspec
CHANGED
@@ -38,6 +38,6 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "webmock"
|
39
39
|
|
40
40
|
spec.add_dependency "faraday", "~> 1.0"
|
41
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
41
|
+
spec.add_dependency "relaton-bib", "~> 1.13.0"
|
42
42
|
spec.add_dependency "rubyzip", "~> 2.3.0"
|
43
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-ieee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.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: 2022-
|
11
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.13.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.13.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubyzip
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,6 @@ files:
|
|
154
154
|
- lib/relaton_ieee/editorial_group.rb
|
155
155
|
- lib/relaton_ieee/hash_converter.rb
|
156
156
|
- lib/relaton_ieee/hit.rb
|
157
|
-
- lib/relaton_ieee/hit_collection.rb
|
158
157
|
- lib/relaton_ieee/ieee_bibliographic_item.rb
|
159
158
|
- lib/relaton_ieee/ieee_bibliography.rb
|
160
159
|
- lib/relaton_ieee/processor.rb
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "faraday"
|
2
|
-
require "relaton_ieee/hit"
|
3
|
-
require "fileutils"
|
4
|
-
|
5
|
-
module RelatonIeee
|
6
|
-
class HitCollection < RelatonBib::HitCollection
|
7
|
-
# DOMAIN = "https://standards.ieee.org".freeze
|
8
|
-
GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ieee/main/data/".freeze
|
9
|
-
|
10
|
-
# @param reference [Strig]
|
11
|
-
# @param opts [Hash]
|
12
|
-
def initialize(reference) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
13
|
-
super
|
14
|
-
ref = reference.gsub(/[\s,:\/]/, "_").squeeze("_").upcase
|
15
|
-
url = "#{GH_URL}#{ref}.yaml"
|
16
|
-
resp = Faraday.get url
|
17
|
-
hit = YAML.load resp.body
|
18
|
-
# code1 = reference.sub(/^IEEE\s(Std\s)?/, "")
|
19
|
-
# url = "#{DOMAIN}/wp-admin/admin-ajax.php"
|
20
|
-
# query = reference.gsub("/", " ")
|
21
|
-
# resp = Faraday.post url, { action: "ieee_cloudsearch", q: query }
|
22
|
-
# json = JSON.parse resp.body
|
23
|
-
# unless json["results"]
|
24
|
-
# @array = []
|
25
|
-
# return
|
26
|
-
# end
|
27
|
-
|
28
|
-
# @array = json["results"]["hits"]["hit"].reduce([]) do |s, hit|
|
29
|
-
# flds = hit["fields"]
|
30
|
-
# /^(?:\w+\s)?(?<code2>[A-Z\d.]+)(?:-(?<year>\d{4}))?/ =~ flds["meta_designation_l"]
|
31
|
-
# next s unless code2 && code1 =~ %r{^#{code2}}
|
32
|
-
|
33
|
-
# hit_data = {
|
34
|
-
# ref: flds["meta_designation_l"],
|
35
|
-
# year: year.to_i,
|
36
|
-
# url: flds["doc_id_l"],
|
37
|
-
# }
|
38
|
-
# s << Hit.new(hit_data, self)
|
39
|
-
# end.sort_by { |h| h.hit[:year].to_s + h.hit[:url] }.reverse
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|