relaton-ieee 1.12.4 → 1.12.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_ieee/balloting_group.rb +56 -0
- data/lib/relaton_ieee/data_parser.rb +22 -3
- data/lib/relaton_ieee/document_status.rb +14 -0
- data/lib/relaton_ieee/editorial_group.rb +83 -0
- data/lib/relaton_ieee/hash_converter.rb +9 -9
- data/lib/relaton_ieee/hit_collection.rb +26 -24
- data/lib/relaton_ieee/ieee_bibliographic_item.rb +31 -9
- data/lib/relaton_ieee/ieee_bibliography.rb +50 -42
- data/lib/relaton_ieee/rawbib_id_parser.rb +2 -1
- data/lib/relaton_ieee/scrapper.rb +17 -29
- data/lib/relaton_ieee/version.rb +1 -1
- data/lib/relaton_ieee/xml_parser.rb +35 -6
- data/lib/relaton_ieee.rb +5 -4
- metadata +5 -3
- data/lib/relaton_ieee/committee.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 495622b50a4332e32e7d8b72c6258ffadeeeab45ee2fa848132f6c1284f638c2
|
4
|
+
data.tar.gz: 8b4c163ce241e5f3db57df8993f7a0aea2ea47729e1ff92b62b53bfa07347c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4903079f76d6efbba076699e00ac7a2c7f5c7b0fa3d808995d34afb3d59781d08d1eb3eda804a0991b8fd89206fb537fc34b58f14eae586e3014c6265c4aed47
|
7
|
+
data.tar.gz: c57c445a08a38cb0568510544c8c89fca246bc5c3e2c6299e8d44cc1bdcf60862ddbb34dfc8f2351ccda527050c6725bd6adce300539e7e0dfcd075aec8c0f3b
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module RelatonIeee
|
2
|
+
class BallotingGroup
|
3
|
+
TYPES = %w[individual entity].freeze
|
4
|
+
|
5
|
+
# @return [String]
|
6
|
+
attr_reader :type, :content
|
7
|
+
|
8
|
+
#
|
9
|
+
# Initialize balloting group
|
10
|
+
#
|
11
|
+
# @param [String] type type
|
12
|
+
# @param [String] content content
|
13
|
+
#
|
14
|
+
def initialize(type:, content:)
|
15
|
+
unless TYPES.include?(type)
|
16
|
+
warn "[relaton-ieee] WARNING: type of Balloting group must be one of #{TYPES.join(', ')}"
|
17
|
+
end
|
18
|
+
|
19
|
+
@type = type
|
20
|
+
@content = content
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Render balloting group to XML
|
25
|
+
#
|
26
|
+
# @param [Nokogiri::XML::Builder] builder XML builder
|
27
|
+
#
|
28
|
+
def to_xml(builder)
|
29
|
+
builder.send :"balloting-group", content, type: type
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Render balloting group to Hash
|
34
|
+
#
|
35
|
+
# @return [Hash] balloting group as Hash
|
36
|
+
#
|
37
|
+
def to_hash
|
38
|
+
{ "type" => type, "content" => content }
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Render balloting group to AsciiBib
|
43
|
+
#
|
44
|
+
# @param [String] prefix Prefix
|
45
|
+
#
|
46
|
+
# @return [String] AsciiBib
|
47
|
+
#
|
48
|
+
def to_asciibib(prefix = "")
|
49
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
50
|
+
pref += "balloting-group"
|
51
|
+
out = "#{pref}.type:: #{type}\n"
|
52
|
+
out += "#{pref}.content:: #{content}\n"
|
53
|
+
out
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -35,6 +35,7 @@ module RelatonIeee
|
|
35
35
|
#
|
36
36
|
def parse # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
37
37
|
args = {
|
38
|
+
fetched: Date.today.to_s,
|
38
39
|
type: "standard",
|
39
40
|
docnumber: docnumber,
|
40
41
|
title: parse_title,
|
@@ -50,6 +51,7 @@ module RelatonIeee
|
|
50
51
|
link: parse_link,
|
51
52
|
keyword: parse_keyword,
|
52
53
|
ics: parse_ics,
|
54
|
+
editorialgroup: parse_editorialgroup,
|
53
55
|
}
|
54
56
|
IeeeBibliographicItem.new(**args)
|
55
57
|
end
|
@@ -61,8 +63,8 @@ module RelatonIeee
|
|
61
63
|
#
|
62
64
|
def parse_title
|
63
65
|
t = []
|
64
|
-
content = doc.at("./volume/article/title").text
|
65
|
-
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
|
66
68
|
t << RelatonBib::TypedTitleString.new(content: $1, type: "title-main")
|
67
69
|
end
|
68
70
|
t << RelatonBib::TypedTitleString.new(content: content, type: "main")
|
@@ -127,6 +129,11 @@ module RelatonIeee
|
|
127
129
|
end
|
128
130
|
end
|
129
131
|
|
132
|
+
#
|
133
|
+
# Create PubID
|
134
|
+
#
|
135
|
+
# @return [RelatonIeee::RawbibIdParser] PubID
|
136
|
+
#
|
130
137
|
def pubid
|
131
138
|
@pubid ||= begin
|
132
139
|
nt = doc.at("./normtitle").text
|
@@ -223,7 +230,7 @@ module RelatonIeee
|
|
223
230
|
#
|
224
231
|
def parse_status
|
225
232
|
stage = doc.at("./publicationinfo/standard_status").text
|
226
|
-
|
233
|
+
DocumentStatus.new stage: stage
|
227
234
|
end
|
228
235
|
|
229
236
|
#
|
@@ -277,5 +284,17 @@ module RelatonIeee
|
|
277
284
|
RelatonBib::ICS.new code: ics[:codenum], text: ics.text
|
278
285
|
end
|
279
286
|
end
|
287
|
+
|
288
|
+
#
|
289
|
+
# Parse editorialgroup
|
290
|
+
#
|
291
|
+
# @return [RelatonIeee::EditorialGroup, nil] editorialgroup or nil
|
292
|
+
#
|
293
|
+
def parse_editorialgroup
|
294
|
+
committee = doc.xpath(
|
295
|
+
"./publicationinfo/pubsponsoringcommitteeset/pubsponsoringcommittee",
|
296
|
+
).map &:text
|
297
|
+
EditorialGroup.new committee: committee if committee.any?
|
298
|
+
end
|
280
299
|
end
|
281
300
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RelatonIeee
|
2
|
+
class DocumentStatus < RelatonBib::DocumentStatus
|
3
|
+
class Stage < RelatonBib::DocumentStatus::Stage
|
4
|
+
STAGES = %w[developing active inactive].freeze
|
5
|
+
|
6
|
+
def initialize(value:, abbreviation: nil)
|
7
|
+
unless STAGES.include?(value.downcase)
|
8
|
+
warn "[relaton-ieee] Stage value must be one of #{STAGES.join(', ')}"
|
9
|
+
end
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module RelatonIeee
|
2
|
+
class EditorialGroup
|
3
|
+
# @return [String]
|
4
|
+
attr_reader :society, :working_group
|
5
|
+
# @return [RelatonIeee::BallotingGroup] Balloting group
|
6
|
+
attr_reader :balloting_group
|
7
|
+
# @return [Array<String>] Committee
|
8
|
+
attr_reader :committee
|
9
|
+
|
10
|
+
#
|
11
|
+
# Initialize editorial group
|
12
|
+
#
|
13
|
+
# @param [Hash] **args Hash of arguments
|
14
|
+
# @option args [String] :society Society
|
15
|
+
# @option args [RelatonIeee::BallotingGroup, Hash] :balloting_group Balloting group
|
16
|
+
# @option args [String] :working_group Working group
|
17
|
+
# @option args [Array<String>] :committee Committee
|
18
|
+
#
|
19
|
+
def initialize(**args)
|
20
|
+
unless args[:committee].is_a?(Array) && args[:committee].any?
|
21
|
+
raise ArgumentError, ":committee is required"
|
22
|
+
end
|
23
|
+
|
24
|
+
@society = args[:society]
|
25
|
+
@balloting_group = if args[:balloting_group].is_a?(Hash)
|
26
|
+
BallotingGroup.new(**args[:balloting_group])
|
27
|
+
else args[:balloting_group]
|
28
|
+
end
|
29
|
+
@working_group = args[:working_group]
|
30
|
+
@committee = args[:committee]
|
31
|
+
end
|
32
|
+
|
33
|
+
def presence?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Render editorial group to XML
|
39
|
+
#
|
40
|
+
# @param [Nokogiri::XML::Builder] builder XML builder
|
41
|
+
#
|
42
|
+
def to_xml(builder)
|
43
|
+
builder.editorialgroup do |b|
|
44
|
+
b.society society if society
|
45
|
+
balloting_group&.to_xml(b)
|
46
|
+
b.send :"working-group", working_group if working_group
|
47
|
+
committee.each { |c| b.committee c }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Render editorial group to Hash
|
53
|
+
#
|
54
|
+
# @return [Hash] editorial group as Hash
|
55
|
+
#
|
56
|
+
def to_hash
|
57
|
+
hash = {}
|
58
|
+
hash["society"] = society if society
|
59
|
+
hash["balloting_group"] = balloting_group.to_hash if balloting_group
|
60
|
+
hash["working_group"] = working_group if working_group
|
61
|
+
hash["committee"] = committee if committee
|
62
|
+
hash
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Render editorial group to AsciiBib
|
67
|
+
#
|
68
|
+
# @param [String] prefix Prefix
|
69
|
+
#
|
70
|
+
# @return [String] AsciiBib
|
71
|
+
#
|
72
|
+
def to_asciibib(prefix = "")
|
73
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
74
|
+
pref += "editorialgroup"
|
75
|
+
out = ""
|
76
|
+
out += "#{pref}.society:: #{society}\n" if society
|
77
|
+
out += balloting_group.to_asciibib(pref) if balloting_group
|
78
|
+
out += "#{pref}.working-group:: #{working_group}\n" if working_group
|
79
|
+
committee.each { |c| out += "#{pref}.committee:: #{c}\n" }
|
80
|
+
out
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -4,13 +4,13 @@ module RelatonIeee
|
|
4
4
|
# @param args [Hash]
|
5
5
|
# @param neated [TrueClas, FalseClass] default true
|
6
6
|
# @return [Hash]
|
7
|
-
def hash_to_bib(args)
|
8
|
-
|
9
|
-
|
7
|
+
# def hash_to_bib(args)
|
8
|
+
# hash = super
|
9
|
+
# return nil unless hash.is_a?(Hash)
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
11
|
+
# editorialgroup_hash_to_bib hash
|
12
|
+
# hash
|
13
|
+
# end
|
14
14
|
|
15
15
|
# @param item_hash [Hash]
|
16
16
|
# @return [RelatonIeee::IeeeBibliographicItem]
|
@@ -19,10 +19,10 @@ module RelatonIeee
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# @param hash [Hash]
|
22
|
-
def
|
23
|
-
return unless hash[:
|
22
|
+
def editorialgroup_hash_to_bib(hash)
|
23
|
+
return unless hash[:editorialgroup]
|
24
24
|
|
25
|
-
hash[:
|
25
|
+
hash[:editorialgroup] = EditorialGroup.new(**hash[:editorialgroup])
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -4,37 +4,39 @@ require "fileutils"
|
|
4
4
|
|
5
5
|
module RelatonIeee
|
6
6
|
class HitCollection < RelatonBib::HitCollection
|
7
|
-
DOMAIN = "https://standards.ieee.org".freeze
|
8
|
-
|
9
|
-
# DATAFILE = File.expand_path "bibliography.json", DATADIR
|
10
|
-
# ETAGFILE = File.expand_path "etag.txt", DATADIR
|
7
|
+
# DOMAIN = "https://standards.ieee.org".freeze
|
8
|
+
GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ieee/main/data/".freeze
|
11
9
|
|
12
10
|
# @param reference [Strig]
|
13
11
|
# @param opts [Hash]
|
14
12
|
def initialize(reference) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
15
13
|
super
|
16
|
-
|
17
|
-
url = "#{
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
25
27
|
|
26
|
-
@array = json["results"]["hits"]["hit"].reduce([]) do |s, hit|
|
27
|
-
|
28
|
-
|
29
|
-
|
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}}
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end.sort_by { |h| h.hit[:year].to_s + h.hit[:url] }.reverse
|
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
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -1,12 +1,30 @@
|
|
1
1
|
module RelatonIeee
|
2
2
|
class IeeeBibliographicItem < RelatonBib::BibliographicItem
|
3
|
-
|
4
|
-
|
3
|
+
TYPES = %w[guide recommended-practice standard].freeze
|
4
|
+
SUBTYPES = %w[amendment corrigendum erratum].freeze
|
5
5
|
|
6
|
-
# @
|
6
|
+
# @return [RelatonIeee::EditorialGroup, nil]
|
7
|
+
attr_reader :editorialgroup
|
8
|
+
|
9
|
+
# @return [Boolean, nil] Trial use
|
10
|
+
attr_reader :trialuse
|
11
|
+
|
12
|
+
#
|
13
|
+
# @param [Hash] args
|
14
|
+
# @option args [Boolean, nil] :trialuse Trial use
|
15
|
+
# @option args [Array<RelatonIeee::EditorialGroup>] :editorialgroup Editorial group
|
16
|
+
#
|
7
17
|
def initialize(**args)
|
8
|
-
|
18
|
+
if args[:doctype] && !TYPES.include?(args[:doctype])
|
19
|
+
warn "[relaton-ieee] doctype should be one of #{TYPES.join(', ')}"
|
20
|
+
end
|
21
|
+
if args[:docsubtype] && !SUBTYPES.include?(args[:docsubtype])
|
22
|
+
warn "[relaton-ieee] docsubtype should be one of #{SUBTYPES.join(', ')}"
|
23
|
+
end
|
24
|
+
eg = args.delete(:editorialgroup)
|
25
|
+
@trialuse = args.delete(:trialuse)
|
9
26
|
super
|
27
|
+
@editorialgroup = eg
|
10
28
|
end
|
11
29
|
|
12
30
|
# @param hash [Hash]
|
@@ -21,11 +39,15 @@ module RelatonIeee
|
|
21
39
|
# @option opts [Boolean] :bibdata
|
22
40
|
# @option opts [String] :lang language
|
23
41
|
# @return [String] XML
|
24
|
-
def to_xml(**opts)
|
42
|
+
def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
25
43
|
super(**opts) do |bldr|
|
26
|
-
if opts[:bibdata] &&
|
44
|
+
if opts[:bibdata] && (doctype || subdoctype || !trialuse.nil? || editorialgroup || ics.any?)
|
27
45
|
bldr.ext do |b|
|
28
|
-
|
46
|
+
b.doctype doctype if doctype
|
47
|
+
b.subdoctype subdoctype if subdoctype
|
48
|
+
b.send :"trial-use", trialuse unless trialuse.nil?
|
49
|
+
editorialgroup&.to_xml(b)
|
50
|
+
ics.each { |ic| ic.to_xml(b) }
|
29
51
|
end
|
30
52
|
end
|
31
53
|
end
|
@@ -34,7 +56,7 @@ module RelatonIeee
|
|
34
56
|
# @return [Hash]
|
35
57
|
def to_hash
|
36
58
|
hash = super
|
37
|
-
hash["
|
59
|
+
hash["trialuse"] = trialuse unless trialuse.nil?
|
38
60
|
hash
|
39
61
|
end
|
40
62
|
|
@@ -42,7 +64,7 @@ module RelatonIeee
|
|
42
64
|
# @return [String]
|
43
65
|
def to_asciibib(prefix = "")
|
44
66
|
out = super
|
45
|
-
|
67
|
+
out += "#{prefix}.trialuse:: #{trialuse}\n" unless trialuse.nil?
|
46
68
|
out
|
47
69
|
end
|
48
70
|
end
|
@@ -1,12 +1,20 @@
|
|
1
1
|
module RelatonIeee
|
2
2
|
class IeeeBibliography
|
3
3
|
class << self
|
4
|
-
|
4
|
+
GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ieee/main/data/".freeze
|
5
|
+
|
6
|
+
# @param code [String]
|
5
7
|
# @return [RelatonIeee::HitCollection]
|
6
|
-
def search(
|
7
|
-
HitCollection.new text
|
8
|
+
def search(code)
|
9
|
+
# HitCollection.new text
|
10
|
+
ref = code.sub(/Std\s/i, "").gsub(/[\s,:\/]/, "_").squeeze("_").upcase
|
11
|
+
url = "#{GH_URL}#{ref}.yaml"
|
12
|
+
resp = Faraday.get url
|
13
|
+
return unless resp.status == 200
|
14
|
+
|
15
|
+
IeeeBibliographicItem.from_hash YAML.safe_load resp.body
|
8
16
|
rescue Faraday::ConnectionFailed
|
9
|
-
raise RelatonBib::RequestError, "Could not access #{
|
17
|
+
raise RelatonBib::RequestError, "Could not access #{GH_URL}"
|
10
18
|
end
|
11
19
|
|
12
20
|
# @param code [String] the IEEE standard Code to look up (e..g "528-2019")
|
@@ -15,17 +23,17 @@ module RelatonIeee
|
|
15
23
|
#
|
16
24
|
# @return [Hash, NilClass] returns { ret: RelatonBib::BibliographicItem }
|
17
25
|
# if document is found else returns NilClass
|
18
|
-
def get(code,
|
26
|
+
def get(code, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
19
27
|
warn "[relaton-ieee] (\"#{code}\") fetching..."
|
20
|
-
|
21
|
-
year ||= code.match(/(?<=-)\d{4}/)&.to_s
|
22
|
-
ret = bib_results_filter(result, code, year)
|
23
|
-
if ret[:ret]
|
24
|
-
item = ret[:ret].fetch
|
28
|
+
item = search(code)
|
29
|
+
# year ||= code.match(/(?<=-)\d{4}/)&.to_s
|
30
|
+
# ret = bib_results_filter(result, code, year)
|
31
|
+
if item # ret[:ret]
|
32
|
+
# item = ret[:ret].fetch
|
25
33
|
warn "[relaton-ieee] (\"#{code}\") found #{item.docidentifier.first.id}"
|
26
34
|
item
|
27
|
-
else
|
28
|
-
|
35
|
+
# else
|
36
|
+
# fetch_ref_err(code, year, ret[:years])
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
@@ -42,44 +50,44 @@ module RelatonIeee
|
|
42
50
|
# @param opts [Hash] options
|
43
51
|
#
|
44
52
|
# @return [Hash]
|
45
|
-
def bib_results_filter(result, ref, year) # rubocop:disable Metrics/AbcSize
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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]
|
51
59
|
|
52
|
-
|
60
|
+
# return { ret: hit } if !year
|
53
61
|
|
54
|
-
|
62
|
+
# return { ret: hit } if year.to_i == hit.hit[:year]
|
55
63
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
64
|
+
# missed_years << hit.hit[:year]
|
65
|
+
# end
|
66
|
+
# { years: missed_years.uniq }
|
67
|
+
# end
|
60
68
|
|
61
|
-
def ref_parts(ref)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
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
|
69
77
|
|
70
78
|
# @param code [Strig]
|
71
79
|
# @param year [String]
|
72
80
|
# @param missed_years [Array<Strig>]
|
73
|
-
def fetch_ref_err(code, year, missed_years)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
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
|
83
91
|
end
|
84
92
|
end
|
85
93
|
end
|
@@ -309,7 +309,8 @@ module RelatonIeee
|
|
309
309
|
PubId.new(publisher: $1, number: $2, stage: $3, year: $5, month: mn($4))
|
310
310
|
|
311
311
|
# publisher, stage, number, part, draft
|
312
|
-
when /^([A-Z\/]+)[.-]([[:alnum:].-]+)[\/_]D([[:alnum:].]+)[\/_](#{STAGES})/o
|
312
|
+
when /^([A-Z\/]+)[.-]([[:alnum:].-]+)[\/_]D([[:alnum:].]+)[\/_](#{STAGES})/o,
|
313
|
+
/^(\w+)[.-]([[:alnum:].]+)[\/\s_]D([\d.]+)_(#{STAGES})/o
|
313
314
|
PubId.new(publisher: "IEEE", number: $1, part: sp($2), draft: dn($3), stage: $4)
|
314
315
|
|
315
316
|
# publisher, stage, number, year
|
@@ -18,7 +18,7 @@ module RelatonIeee
|
|
18
18
|
language: ["en"],
|
19
19
|
script: ["Latn"],
|
20
20
|
date: fetch_date(doc),
|
21
|
-
|
21
|
+
editorialgroup: fetch_editorialgroup(doc),
|
22
22
|
place: ["Piscataway, NJ, USA"],
|
23
23
|
)
|
24
24
|
end
|
@@ -59,7 +59,7 @@ module RelatonIeee
|
|
59
59
|
stage = doc.at("//dd[@id='stnd-status']")
|
60
60
|
return unless stage
|
61
61
|
|
62
|
-
|
62
|
+
DocumentStatus.new(stage: stage.text.split.first)
|
63
63
|
end
|
64
64
|
|
65
65
|
# @param identifier [String]
|
@@ -117,8 +117,6 @@ module RelatonIeee
|
|
117
117
|
# )
|
118
118
|
# end
|
119
119
|
|
120
|
-
# rubocop:disable Metrics/MethodLength
|
121
|
-
|
122
120
|
# @param date [Nokogiri::HTML::Document]
|
123
121
|
# @return [Array<RelatonBib::BibliographicDate>]
|
124
122
|
def fetch_date(doc)
|
@@ -134,33 +132,23 @@ module RelatonIeee
|
|
134
132
|
dates
|
135
133
|
end
|
136
134
|
|
137
|
-
#
|
138
|
-
|
135
|
+
#
|
139
136
|
# @param doc [Nokogiri::HTML::Document]
|
140
|
-
#
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
committees << Committee.new(type: "working", name: working.text.strip,
|
155
|
-
chair: chair.text)
|
156
|
-
end
|
157
|
-
society = doc.at "//dd[@id='stnd-society']/text()"
|
158
|
-
if society
|
159
|
-
committees << Committee.new(type: "society", name: society.text.strip)
|
160
|
-
end
|
161
|
-
committees
|
137
|
+
#
|
138
|
+
# @return [RelatonIeee::EditorialGroup]
|
139
|
+
#
|
140
|
+
def fetch_editorialgroup(doc) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
141
|
+
committees = doc.xpath(
|
142
|
+
"//dd[@id='stnd-committee']/text()",
|
143
|
+
"//td[.='Standards Committee']/following-sibling::td/div/a",
|
144
|
+
).map { |c| c.text.strip }
|
145
|
+
wg = doc.at("//dd[@id='stnd-working-group']/text()")&.text&.strip
|
146
|
+
# chair = doc.at "//dd[@id='stnd-working-group-chair']"
|
147
|
+
society = doc.at("//dd[@id='stnd-society']/text()")&.text&.strip
|
148
|
+
return unless committees.any? || wg || society
|
149
|
+
|
150
|
+
EditorialGroup.new(society: society, working_group: wg, committee: committees)
|
162
151
|
end
|
163
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
164
152
|
end
|
165
153
|
end
|
166
154
|
end
|
data/lib/relaton_ieee/version.rb
CHANGED
@@ -11,18 +11,47 @@ module RelatonIeee
|
|
11
11
|
ext = item.at "./ext"
|
12
12
|
return data unless ext
|
13
13
|
|
14
|
-
data[:
|
15
|
-
Committee.new(
|
16
|
-
type: c[:type], name: c.at("name").text, chair: c.at("chair")&.text
|
17
|
-
)
|
18
|
-
end
|
14
|
+
data[:editorialgroup] = parse_editorialgroup(item)
|
19
15
|
data
|
20
16
|
end
|
21
17
|
|
22
18
|
# @param item_hash [Hash]
|
23
19
|
# @return [RelatonIeee::IeeeBibliographicItem]
|
24
20
|
def bib_item(item_hash)
|
25
|
-
IeeeBibliographicItem.new
|
21
|
+
IeeeBibliographicItem.new(**item_hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Parse editorialgroup
|
26
|
+
#
|
27
|
+
# @param [Nokogiri::XML::Element] item XML element
|
28
|
+
#
|
29
|
+
# @return [RelatonIeee::EditorialGroup] Editorial group
|
30
|
+
#
|
31
|
+
def parse_editorialgroup(item)
|
32
|
+
eg = item.at "./ext/editorialgroup"
|
33
|
+
return unless eg
|
34
|
+
|
35
|
+
society = eg.at("./society")&.text
|
36
|
+
bg = parse_balloting_group(eg)
|
37
|
+
wg = eg.at("./working-group")&.text
|
38
|
+
committee = eg.xpath("./committee").map(&:text)
|
39
|
+
EditorialGroup.new(society: society, balloting_group: bg,
|
40
|
+
working_group: wg, committee: committee)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Parse balloting group
|
45
|
+
#
|
46
|
+
# @param [Nokogiri::XML::Element] editorialgroup XML element
|
47
|
+
#
|
48
|
+
# @return [RelatonIeee::BallotingGroup] Balloting group
|
49
|
+
#
|
50
|
+
def parse_balloting_group(editorialgroup)
|
51
|
+
bg = editorialgroup.at("./balloting-group")
|
52
|
+
return unless bg
|
53
|
+
|
54
|
+
BallotingGroup.new type: bg[:type], content: bg.text
|
26
55
|
end
|
27
56
|
end
|
28
57
|
end
|
data/lib/relaton_ieee.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require "digest/md5"
|
2
|
+
require "faraday"
|
2
3
|
require "yaml"
|
3
4
|
require "relaton_bib"
|
4
5
|
require "relaton_ieee/version"
|
6
|
+
require "relaton_ieee/document_status"
|
5
7
|
require "relaton_ieee/ieee_bibliography"
|
6
|
-
require "relaton_ieee/
|
7
|
-
require "relaton_ieee/hit"
|
8
|
-
require "relaton_ieee/scrapper"
|
8
|
+
# require "relaton_ieee/scrapper"
|
9
9
|
require "relaton_ieee/ieee_bibliographic_item"
|
10
|
-
require "relaton_ieee/
|
10
|
+
require "relaton_ieee/editorial_group"
|
11
|
+
require "relaton_ieee/balloting_group"
|
11
12
|
require "relaton_ieee/xml_parser"
|
12
13
|
require "relaton_ieee/bibxml_parser"
|
13
14
|
require "relaton_ieee/hash_converter"
|
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.12.
|
4
|
+
version: 1.12.7
|
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-07-
|
11
|
+
date: 2022-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -146,10 +146,12 @@ files:
|
|
146
146
|
- grammars/isodoc.rng
|
147
147
|
- grammars/reqt.rng
|
148
148
|
- lib/relaton_ieee.rb
|
149
|
+
- lib/relaton_ieee/balloting_group.rb
|
149
150
|
- lib/relaton_ieee/bibxml_parser.rb
|
150
|
-
- lib/relaton_ieee/committee.rb
|
151
151
|
- lib/relaton_ieee/data_fetcher.rb
|
152
152
|
- lib/relaton_ieee/data_parser.rb
|
153
|
+
- lib/relaton_ieee/document_status.rb
|
154
|
+
- lib/relaton_ieee/editorial_group.rb
|
153
155
|
- lib/relaton_ieee/hash_converter.rb
|
154
156
|
- lib/relaton_ieee/hit.rb
|
155
157
|
- lib/relaton_ieee/hit_collection.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module RelatonIeee
|
2
|
-
class Committee
|
3
|
-
# @return [String]
|
4
|
-
attr_reader :type, :name
|
5
|
-
|
6
|
-
# @return [String, NilClass]
|
7
|
-
attr_reader :chair
|
8
|
-
|
9
|
-
# @param type [String]
|
10
|
-
# @param name [String]
|
11
|
-
# @param chair [String, NilClass]
|
12
|
-
def initialize(type:, name:, chair: nil)
|
13
|
-
@type = type
|
14
|
-
@name = name
|
15
|
-
@chair = chair
|
16
|
-
end
|
17
|
-
|
18
|
-
# @param builder [Nokogiri::XML::Builder]
|
19
|
-
def to_xml(builder)
|
20
|
-
builder.committee type: type do |b|
|
21
|
-
b.name name
|
22
|
-
b.chair chair if chair
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# @return [Hash]
|
27
|
-
def to_hash
|
28
|
-
hash = { "type" => type, "name" => name }
|
29
|
-
hash["chair"] = chair if chair
|
30
|
-
hash
|
31
|
-
end
|
32
|
-
|
33
|
-
# @param prefix [String]
|
34
|
-
# @param count [Integer]
|
35
|
-
# @return [String]
|
36
|
-
def to_asciibib(prefix, count)
|
37
|
-
pref = prefix.empty? ? prefix : prefix + "."
|
38
|
-
pref += "committee"
|
39
|
-
out = count > 1 ? "#{pref}::\n" : ""
|
40
|
-
out += "#{pref}.type:: #{type}\n"
|
41
|
-
out += "#{pref}.name:: #{name}\n"
|
42
|
-
out += "#{pref}.chair:: #{chair}\n" if chair
|
43
|
-
out
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|