relaton-ieee 1.9.4 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/grammars/basicdoc.rng +26 -7
- data/grammars/biblio.rng +2 -2
- data/grammars/isodoc.rng +617 -89
- data/grammars/reqt.rng +34 -5
- data/lib/relaton_ieee/bibxml_parser.rb +11 -2
- data/lib/relaton_ieee/hit_collection.rb +18 -14
- data/lib/relaton_ieee/ieee_bibliography.rb +3 -3
- data/lib/relaton_ieee/scrapper.rb +40 -47
- data/lib/relaton_ieee/version.rb +1 -1
- data/relaton_ieee.gemspec +1 -1
- metadata +6 -6
data/grammars/reqt.rng
CHANGED
@@ -58,15 +58,23 @@
|
|
58
58
|
<optional>
|
59
59
|
<attribute name="type"/>
|
60
60
|
</optional>
|
61
|
+
<optional>
|
62
|
+
<attribute name="tag"/>
|
63
|
+
</optional>
|
64
|
+
<optional>
|
65
|
+
<attribute name="multilingual-rendering">
|
66
|
+
<ref name="MultilingualRenderingType"/>
|
67
|
+
</attribute>
|
68
|
+
</optional>
|
61
69
|
<optional>
|
62
70
|
<ref name="reqtitle"/>
|
63
71
|
</optional>
|
64
72
|
<optional>
|
65
73
|
<ref name="label"/>
|
66
74
|
</optional>
|
67
|
-
<
|
75
|
+
<zeroOrMore>
|
68
76
|
<ref name="subject"/>
|
69
|
-
</
|
77
|
+
</zeroOrMore>
|
70
78
|
<zeroOrMore>
|
71
79
|
<ref name="reqinherit"/>
|
72
80
|
</zeroOrMore>
|
@@ -80,6 +88,7 @@
|
|
80
88
|
<ref name="verification"/>
|
81
89
|
<ref name="import"/>
|
82
90
|
<ref name="description"/>
|
91
|
+
<ref name="component"/>
|
83
92
|
</choice>
|
84
93
|
</zeroOrMore>
|
85
94
|
<optional>
|
@@ -100,17 +109,23 @@
|
|
100
109
|
</define>
|
101
110
|
<define name="label">
|
102
111
|
<element name="label">
|
103
|
-
<
|
112
|
+
<oneOrMore>
|
113
|
+
<ref name="TextElement"/>
|
114
|
+
</oneOrMore>
|
104
115
|
</element>
|
105
116
|
</define>
|
106
117
|
<define name="subject">
|
107
118
|
<element name="subject">
|
108
|
-
<
|
119
|
+
<oneOrMore>
|
120
|
+
<ref name="TextElement"/>
|
121
|
+
</oneOrMore>
|
109
122
|
</element>
|
110
123
|
</define>
|
111
124
|
<define name="reqinherit">
|
112
125
|
<element name="inherit">
|
113
|
-
<
|
126
|
+
<oneOrMore>
|
127
|
+
<ref name="TextElement"/>
|
128
|
+
</oneOrMore>
|
114
129
|
</element>
|
115
130
|
</define>
|
116
131
|
<define name="measurementtarget">
|
@@ -138,6 +153,12 @@
|
|
138
153
|
<ref name="RequirementSubpart"/>
|
139
154
|
</element>
|
140
155
|
</define>
|
156
|
+
<define name="component">
|
157
|
+
<element name="component">
|
158
|
+
<attribute name="class"/>
|
159
|
+
<ref name="RequirementSubpart"/>
|
160
|
+
</element>
|
161
|
+
</define>
|
141
162
|
<define name="reqt_references">
|
142
163
|
<element name="references">
|
143
164
|
<oneOrMore>
|
@@ -164,6 +185,14 @@
|
|
164
185
|
<data type="boolean"/>
|
165
186
|
</attribute>
|
166
187
|
</optional>
|
188
|
+
<optional>
|
189
|
+
<attribute name="tag"/>
|
190
|
+
</optional>
|
191
|
+
<optional>
|
192
|
+
<attribute name="multilingual-rendering">
|
193
|
+
<ref name="MultilingualRenderingType"/>
|
194
|
+
</attribute>
|
195
|
+
</optional>
|
167
196
|
<oneOrMore>
|
168
197
|
<ref name="BasicBlock"/>
|
169
198
|
</oneOrMore>
|
@@ -3,12 +3,21 @@ module RelatonIeee
|
|
3
3
|
extend RelatonBib::BibXMLParser
|
4
4
|
extend BibXMLParser
|
5
5
|
|
6
|
-
FLAVOR = "IEEE".freeze
|
7
|
-
|
8
6
|
# @param attrs [Hash]
|
9
7
|
# @return [RelatonBib::IetfBibliographicItem]
|
10
8
|
def bib_item(**attrs)
|
11
9
|
IeeeBibliographicItem.new(**attrs)
|
12
10
|
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Return PubID type
|
14
|
+
#
|
15
|
+
# @param [String] _ docidentifier
|
16
|
+
#
|
17
|
+
# @return [String] type
|
18
|
+
#
|
19
|
+
def pubid_type(_)
|
20
|
+
"IEEE"
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
@@ -11,23 +11,27 @@ module RelatonIeee
|
|
11
11
|
|
12
12
|
# rubocop:disable Metrics/AbcSize
|
13
13
|
|
14
|
-
# @param
|
14
|
+
# @param reference [Strig]
|
15
15
|
# @param opts [Hash]
|
16
|
-
def initialize(
|
16
|
+
def initialize(reference) # rubocop:disable Metrics/MethodLength
|
17
17
|
super
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
resp = Faraday.
|
22
|
-
|
23
|
-
|
24
|
-
@array = json["
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
+
html = Nokogiri::HTML json["html"]
|
24
|
+
# @array = json["results"]["hits"]["hit"].reduce([]) do |s, hit|
|
25
|
+
@array = html.xpath("//h4/a").reduce([]) do |s, hit|
|
26
|
+
# fields = hit["fields"]
|
27
|
+
# ref = html.at("//h4/a[@href='#{fields['doc_id_l']}']").text.strip
|
28
|
+
ref = hit.text.strip
|
29
|
+
/^(?:\w+\s)?(?<code2>[A-Z\d.]+)(?:-(?<year>\d{4}))?/ =~ ref
|
30
|
+
next s unless code2 && code1 =~ %r{^#{code2}}
|
28
31
|
|
29
|
-
|
30
|
-
|
32
|
+
hit_data = { ref: ref, year: year.to_i, url: hit[:href] }
|
33
|
+
s << Hit.new(hit_data, self)
|
34
|
+
end.sort_by { |h| h.hit[:year].to_s + h.hit[:url] }.reverse
|
31
35
|
end
|
32
36
|
# rubocop:enable Metrics/AbcSize
|
33
37
|
end
|
@@ -15,7 +15,7 @@ module RelatonIeee
|
|
15
15
|
#
|
16
16
|
# @return [Hash, NilClass] returns { ret: RelatonBib::BibliographicItem }
|
17
17
|
# if document is found else returns NilClass
|
18
|
-
def get(code, year = nil, _opts = {})
|
18
|
+
def get(code, year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
19
19
|
warn "[relaton-ieee] (\"#{code}\") fetching..."
|
20
20
|
result = search(code) || (return nil)
|
21
21
|
year ||= code.match(/(?<=-)\d{4}/)&.to_s
|
@@ -42,11 +42,11 @@ module RelatonIeee
|
|
42
42
|
# @param opts [Hash] options
|
43
43
|
#
|
44
44
|
# @return [Hash]
|
45
|
-
def bib_results_filter(result, ref, year)
|
45
|
+
def bib_results_filter(result, ref, year) # rubocop:disable Metrics/AbcSize
|
46
46
|
rp1 = ref_parts ref
|
47
47
|
missed_years = []
|
48
48
|
result.each do |hit|
|
49
|
-
rp2 = ref_parts hit.hit[
|
49
|
+
rp2 = ref_parts hit.hit[:ref]
|
50
50
|
next if rp1[:code] != rp2[:code] || rp1[:corr] != rp2[:corr]
|
51
51
|
|
52
52
|
return { ret: hit } if !year
|
@@ -6,40 +6,39 @@ module RelatonIeee
|
|
6
6
|
# papam hit [Hash]
|
7
7
|
# @return [RelatonOgc::OrcBibliographicItem]
|
8
8
|
def parse_page(hit)
|
9
|
-
doc = Nokogiri::HTML Faraday.get(hit[
|
9
|
+
doc = Nokogiri::HTML Faraday.get(hit[:url]).body
|
10
10
|
IeeeBibliographicItem.new(
|
11
11
|
fetched: Date.today.to_s,
|
12
|
-
title: fetch_title(
|
13
|
-
docid: fetch_docid(hit[
|
14
|
-
link: fetch_link(hit[
|
12
|
+
title: fetch_title(doc),
|
13
|
+
docid: fetch_docid(hit[:ref]),
|
14
|
+
link: fetch_link(hit[:url]),
|
15
15
|
docstatus: fetch_status(doc),
|
16
16
|
abstract: fetch_abstract(doc),
|
17
17
|
contributor: fetch_contributor(doc),
|
18
18
|
language: ["en"],
|
19
19
|
script: ["Latn"],
|
20
20
|
date: fetch_date(doc),
|
21
|
-
committee: fetch_committee(doc)
|
21
|
+
committee: fetch_committee(doc),
|
22
22
|
)
|
23
23
|
end
|
24
24
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
# @param
|
28
|
+
# @param doc [String] Nokogiri::HTML4::Document
|
29
29
|
# @return [Array<RelatonBib::TypedTitleString>]
|
30
|
-
def fetch_title(
|
31
|
-
[
|
30
|
+
def fetch_title(doc)
|
31
|
+
doc.xpath("//h2[@id='stnd-title']").map do |t|
|
32
32
|
RelatonBib::TypedTitleString.new(
|
33
|
-
type: "main", content:
|
34
|
-
)
|
35
|
-
|
33
|
+
type: "main", content: t.text, language: "en", script: "Latn",
|
34
|
+
)
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# @param
|
38
|
+
# @param ref [String]
|
39
39
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
40
|
-
def fetch_docid(
|
41
|
-
|
42
|
-
[RelatonBib::DocumentIdentifier.new(id: identifier, type: "IEEE")]
|
40
|
+
def fetch_docid(ref)
|
41
|
+
[RelatonBib::DocumentIdentifier.new(id: ref, type: "IEEE")]
|
43
42
|
end
|
44
43
|
|
45
44
|
# @param url [String]
|
@@ -51,10 +50,10 @@ module RelatonIeee
|
|
51
50
|
# @param doc [Nokogiri::HTML::Document]
|
52
51
|
# @return [RelatonBib::DocumentStatus, NilClass]
|
53
52
|
def fetch_status(doc)
|
54
|
-
stage = doc.at("//
|
53
|
+
stage = doc.at("//dd[@id='stnd-status']")
|
55
54
|
return unless stage
|
56
55
|
|
57
|
-
RelatonBib::DocumentStatus.new(stage: stage.text)
|
56
|
+
RelatonBib::DocumentStatus.new(stage: stage.text.split.first)
|
58
57
|
end
|
59
58
|
|
60
59
|
# @param identifier [String]
|
@@ -67,33 +66,30 @@ module RelatonIeee
|
|
67
66
|
# @param doc [Nokogiri::HTML::Document]
|
68
67
|
# @return [Array<RelatonBib::FormattedString>]
|
69
68
|
def fetch_abstract(doc)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
doc.xpath("//div[@id='stnd-description']").map do |a|
|
70
|
+
RelatonBib::FormattedString.new(
|
71
|
+
content: a.text.strip, language: "en", script: "Latn",
|
72
|
+
)
|
73
|
+
end
|
75
74
|
end
|
76
75
|
|
77
76
|
# @param doc [Nokogiri::HTML::Document]
|
78
77
|
# @return [Array<RelatonBib::ContributionInfo>]
|
79
78
|
def fetch_contributor(doc)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
return [] unless name
|
84
|
-
|
85
|
-
[personn_contrib(name.text)]
|
79
|
+
doc.xpath("//dd[@id='stnd-staff-liaison']/text()").map do |name|
|
80
|
+
person_contrib(name.text.strip)
|
81
|
+
end
|
86
82
|
end
|
87
83
|
|
88
84
|
# @param name [String]
|
89
85
|
# @return [RelatonBib::ContributionInfo]
|
90
|
-
def
|
86
|
+
def person_contrib(name)
|
91
87
|
fname = RelatonBib::FullName.new(
|
92
|
-
completename: RelatonBib::LocalizedString.new(name)
|
88
|
+
completename: RelatonBib::LocalizedString.new(name),
|
93
89
|
)
|
94
90
|
entity = RelatonBib::Person.new(name: fname)
|
95
91
|
RelatonBib::ContributionInfo.new(
|
96
|
-
entity: entity, role: [type: "author"]
|
92
|
+
entity: entity, role: [type: "author"],
|
97
93
|
)
|
98
94
|
end
|
99
95
|
|
@@ -112,16 +108,13 @@ module RelatonIeee
|
|
112
108
|
# @return [Array<RelatonBib::BibliographicDate>]
|
113
109
|
def fetch_date(doc)
|
114
110
|
dates = []
|
115
|
-
|
116
|
-
if
|
117
|
-
dates << RelatonBib::BibliographicDate.new(type: "issued",
|
118
|
-
on: issued.text)
|
111
|
+
id = doc.at "//dd[@id='stnd-approval-date']"
|
112
|
+
if id
|
113
|
+
dates << RelatonBib::BibliographicDate.new(type: "issued", on: id.text)
|
119
114
|
end
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
dates << RelatonBib::BibliographicDate.new(type: "published",
|
124
|
-
on: published)
|
115
|
+
pd = doc.at("//dd[@id='stnd-published-date']")
|
116
|
+
if pd
|
117
|
+
dates << RelatonBib::BibliographicDate.new(type: "published", on: pd.text)
|
125
118
|
end
|
126
119
|
dates
|
127
120
|
end
|
@@ -132,23 +125,23 @@ module RelatonIeee
|
|
132
125
|
# @return [Array<RelatonIeee::Committee>]
|
133
126
|
def fetch_committee(doc)
|
134
127
|
committees = []
|
135
|
-
sponsor = doc.at "//
|
128
|
+
sponsor = doc.at "//dd[@id='stnd-committee']/text()"
|
136
129
|
if sponsor
|
137
|
-
committees << Committee.new(type: "sponsor", name: sponsor.text)
|
130
|
+
committees << Committee.new(type: "sponsor", name: sponsor.text.strip)
|
138
131
|
end
|
139
132
|
sponsor = doc.at "//td[.='Standards Committee']/following-sibling::td/div/a"
|
140
133
|
if sponsor
|
141
134
|
committees << Committee.new(type: "standard", name: sponsor.text)
|
142
135
|
end
|
143
|
-
working = doc.at "//
|
144
|
-
chair = doc.at "//td[.='Working Group Chair']/following-sibling::td/div"
|
136
|
+
working = doc.at "//dd[@id='stnd-working-group']/text()"
|
145
137
|
if working
|
146
|
-
|
138
|
+
chair = doc.at "//dd[@id='stnd-working-group-chair']"
|
139
|
+
committees << Committee.new(type: "working", name: working.text.strip,
|
147
140
|
chair: chair.text)
|
148
141
|
end
|
149
|
-
society = doc.at "//
|
142
|
+
society = doc.at "//dd[@id='stnd-society']/text()"
|
150
143
|
if society
|
151
|
-
committees << Committee.new(type: "society", name: society.text)
|
144
|
+
committees << Committee.new(type: "society", name: society.text.strip)
|
152
145
|
end
|
153
146
|
committees
|
154
147
|
end
|
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.1"
|
41
|
-
spec.add_dependency "relaton-bib", "
|
41
|
+
spec.add_dependency "relaton-bib", "~> 1.10.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.10.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:
|
11
|
+
date: 2022-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: relaton-bib
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.10.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.10.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubyzip
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|