relaton-ieee 1.12.2 → 1.12.5
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 +12 -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/pub_id.rb +10 -3
- data/lib/relaton_ieee/rawbib_id_parser.rb +4 -3
- data/lib/relaton_ieee/scrapper.rb +23 -30
- 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: b6ad7f017d693570ce6e8c4831ce40b7d5c6385014292abd35511b73b33e4dfa
|
4
|
+
data.tar.gz: 851deaf7128da40b1e419a9bb1003879a7ac86580ea9386abd62c7549d4c3292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 796570f9e1769e5550e77c5f41a675c7f8a8ae8c3ad39e975fa7a7db6bd20379752ca0b1e8fddd3e58e4f650ff8fc6588fcd6cb3c9ecaf6c1559d3814e44fe79
|
7
|
+
data.tar.gz: 67a34e3ab8b37a25c128cb46f3957b453a111b7a4afea312cd925f4a33579ef63bc32e2400420900a71f4c5fb1fd206402ca90a9d6868d99af1c5f6d6d2fe65f
|
@@ -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,
|
@@ -113,8 +114,11 @@ module RelatonIeee
|
|
113
114
|
#
|
114
115
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
115
116
|
#
|
116
|
-
def parse_docid
|
117
|
-
ids = [
|
117
|
+
def parse_docid # rubocop:disable Metrics/MethodLength
|
118
|
+
ids = [
|
119
|
+
{ id: pubid.to_s, type: "IEEE", primary: true },
|
120
|
+
{ id: pubid.to_s(trademark: true), scope: "trademark", type: "IEEE", primary: true },
|
121
|
+
]
|
118
122
|
isbn = doc.at("./publicationinfo/isbn")
|
119
123
|
ids << { id: isbn.text, type: "ISBN" } if isbn
|
120
124
|
doi = doc.at("./volume/article/articleinfo/articledoi")
|
@@ -124,6 +128,11 @@ module RelatonIeee
|
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
131
|
+
#
|
132
|
+
# Create PubID
|
133
|
+
#
|
134
|
+
# @return [RelatonIeee::RawbibIdParser] PubID
|
135
|
+
#
|
127
136
|
def pubid
|
128
137
|
@pubid ||= begin
|
129
138
|
nt = doc.at("./normtitle").text
|
@@ -220,7 +229,7 @@ module RelatonIeee
|
|
220
229
|
#
|
221
230
|
def parse_status
|
222
231
|
stage = doc.at("./publicationinfo/standard_status").text
|
223
|
-
|
232
|
+
DocumentStatus.new stage: stage
|
224
233
|
end
|
225
234
|
|
226
235
|
#
|
@@ -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
|
data/lib/relaton_ieee/pub_id.rb
CHANGED
@@ -48,15 +48,20 @@ module RelatonIeee
|
|
48
48
|
#
|
49
49
|
# PubId string representation
|
50
50
|
#
|
51
|
+
# @param [Boolean] trademark if true, add trademark symbol
|
52
|
+
#
|
51
53
|
# @return [String]
|
52
54
|
#
|
53
|
-
def to_s # rubocop:disable Metrics/AbcSize
|
55
|
+
def to_s(trademark: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
54
56
|
out = number
|
55
57
|
out = "#{stage} #{out}" if stage
|
56
58
|
out = "#{approval} #{out}" if approval
|
57
59
|
out = "#{status} #{out}" if status
|
58
60
|
out = "#{publisher} #{out}" if publisher
|
59
61
|
out += ".#{part}" if part
|
62
|
+
if trademark
|
63
|
+
out += out.match?(/^IEEE\s(Std\s)?(802|2030)/) ? "\u00AE" : "\u2122"
|
64
|
+
end
|
60
65
|
out += edition_to_s + draft_to_s + rev_to_s + corr_to_s + amd_to_s
|
61
66
|
out + year_to_s + month_to_s + redline_to_s
|
62
67
|
end
|
@@ -120,10 +125,12 @@ module RelatonIeee
|
|
120
125
|
#
|
121
126
|
# PubId string representation
|
122
127
|
#
|
128
|
+
# @param [Boolean] trademark if true, add trademark symbol
|
129
|
+
#
|
123
130
|
# @return [String]
|
124
131
|
#
|
125
|
-
def to_s
|
126
|
-
pubid.map(
|
132
|
+
def to_s(trademark: false)
|
133
|
+
pubid.map { |id| id.to_s(trademark: trademark) }.join("/")
|
127
134
|
end
|
128
135
|
|
129
136
|
#
|
@@ -471,9 +471,10 @@ module RelatonIeee
|
|
471
471
|
def yn(year)
|
472
472
|
return year if year.size == 4
|
473
473
|
|
474
|
+
y = Date.today.year.to_s[2..4].to_i + 1
|
474
475
|
case year.to_i
|
475
|
-
when 0
|
476
|
-
when
|
476
|
+
when 0...y then "20#{year}"
|
477
|
+
when y..99 then "19#{year}"
|
477
478
|
end
|
478
479
|
end
|
479
480
|
|
@@ -496,7 +497,7 @@ module RelatonIeee
|
|
496
497
|
#
|
497
498
|
# @param [Strin] edition
|
498
499
|
#
|
499
|
-
# @return [String]
|
500
|
+
# @return [String, Integer]
|
500
501
|
#
|
501
502
|
def en(edition)
|
502
503
|
case edition
|
@@ -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
|
@@ -39,7 +39,12 @@ module RelatonIeee
|
|
39
39
|
# @param ref [String]
|
40
40
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
41
41
|
def fetch_docid(ref)
|
42
|
-
|
42
|
+
args = { id: ref, type: "IEEE", primary: true }
|
43
|
+
ids = [RelatonBib::DocumentIdentifier.new(**args)]
|
44
|
+
args[:scope] = "trademark"
|
45
|
+
tm = ref.match?(/^IEEE\s(Std\s)?(802|2030)/) ? "\u00AE" : "\u2122"
|
46
|
+
args[:id] = ref.sub(/^(IEEE\s(?:Std\s)?[.\w]+)/) { |s| "#{s}#{tm}" }
|
47
|
+
ids << RelatonBib::DocumentIdentifier.new(**args)
|
43
48
|
end
|
44
49
|
|
45
50
|
# @param url [String]
|
@@ -54,7 +59,7 @@ module RelatonIeee
|
|
54
59
|
stage = doc.at("//dd[@id='stnd-status']")
|
55
60
|
return unless stage
|
56
61
|
|
57
|
-
|
62
|
+
DocumentStatus.new(stage: stage.text.split.first)
|
58
63
|
end
|
59
64
|
|
60
65
|
# @param identifier [String]
|
@@ -112,8 +117,6 @@ module RelatonIeee
|
|
112
117
|
# )
|
113
118
|
# end
|
114
119
|
|
115
|
-
# rubocop:disable Metrics/MethodLength
|
116
|
-
|
117
120
|
# @param date [Nokogiri::HTML::Document]
|
118
121
|
# @return [Array<RelatonBib::BibliographicDate>]
|
119
122
|
def fetch_date(doc)
|
@@ -129,33 +132,23 @@ module RelatonIeee
|
|
129
132
|
dates
|
130
133
|
end
|
131
134
|
|
132
|
-
#
|
133
|
-
|
135
|
+
#
|
134
136
|
# @param doc [Nokogiri::HTML::Document]
|
135
|
-
#
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
committees << Committee.new(type: "working", name: working.text.strip,
|
150
|
-
chair: chair.text)
|
151
|
-
end
|
152
|
-
society = doc.at "//dd[@id='stnd-society']/text()"
|
153
|
-
if society
|
154
|
-
committees << Committee.new(type: "society", name: society.text.strip)
|
155
|
-
end
|
156
|
-
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)
|
157
151
|
end
|
158
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
159
152
|
end
|
160
153
|
end
|
161
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.5
|
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-26 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
|