relaton-gb 1.9.0 → 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/README.adoc +10 -0
- data/grammars/basicdoc.rng +26 -7
- data/grammars/biblio.rng +2 -2
- data/grammars/gbstandard.rng +1 -1
- data/grammars/isodoc.rng +617 -89
- data/grammars/isostandard.rng +24 -23
- data/grammars/reqt.rng +34 -5
- data/lib/relaton_gb/gb_scrapper.rb +6 -7
- data/lib/relaton_gb/sec_scrapper.rb +1 -1
- data/lib/relaton_gb/version.rb +1 -1
- data/relaton_gb.gemspec +2 -2
- metadata +8 -8
data/grammars/isostandard.rng
CHANGED
@@ -142,14 +142,9 @@
|
|
142
142
|
</optional>
|
143
143
|
<choice>
|
144
144
|
<choice>
|
145
|
-
<
|
146
|
-
<
|
147
|
-
|
148
|
-
</oneOrMore>
|
149
|
-
<zeroOrMore>
|
150
|
-
<ref name="note"/>
|
151
|
-
</zeroOrMore>
|
152
|
-
</group>
|
145
|
+
<oneOrMore>
|
146
|
+
<ref name="BasicBlock"/>
|
147
|
+
</oneOrMore>
|
153
148
|
<ref name="amend"/>
|
154
149
|
</choice>
|
155
150
|
<oneOrMore>
|
@@ -164,6 +159,20 @@
|
|
164
159
|
<data type="ID"/>
|
165
160
|
</attribute>
|
166
161
|
</optional>
|
162
|
+
<optional>
|
163
|
+
<attribute name="language"/>
|
164
|
+
</optional>
|
165
|
+
<optional>
|
166
|
+
<attribute name="script"/>
|
167
|
+
</optional>
|
168
|
+
<optional>
|
169
|
+
<attribute name="tag"/>
|
170
|
+
</optional>
|
171
|
+
<optional>
|
172
|
+
<attribute name="multilingual-rendering">
|
173
|
+
<ref name="MultilingualRenderingType"/>
|
174
|
+
</attribute>
|
175
|
+
</optional>
|
167
176
|
<ref name="preferred"/>
|
168
177
|
<zeroOrMore>
|
169
178
|
<ref name="admitted"/>
|
@@ -174,7 +183,7 @@
|
|
174
183
|
<optional>
|
175
184
|
<ref name="termdomain"/>
|
176
185
|
</optional>
|
177
|
-
<ref name="
|
186
|
+
<ref name="termdefinition"/>
|
178
187
|
<zeroOrMore>
|
179
188
|
<ref name="termnote"/>
|
180
189
|
</zeroOrMore>
|
@@ -184,6 +193,9 @@
|
|
184
193
|
<zeroOrMore>
|
185
194
|
<ref name="termsource"/>
|
186
195
|
</zeroOrMore>
|
196
|
+
<zeroOrMore>
|
197
|
+
<ref name="term"/>
|
198
|
+
</zeroOrMore>
|
187
199
|
</element>
|
188
200
|
</define>
|
189
201
|
<define name="annex">
|
@@ -222,9 +234,6 @@
|
|
222
234
|
-->
|
223
235
|
<ref name="BasicBlock"/>
|
224
236
|
</zeroOrMore>
|
225
|
-
<zeroOrMore>
|
226
|
-
<ref name="note"/>
|
227
|
-
</zeroOrMore>
|
228
237
|
<zeroOrMore>
|
229
238
|
<ref name="clause-hanging-paragraph-with-footnote"/>
|
230
239
|
</zeroOrMore>
|
@@ -348,14 +357,9 @@
|
|
348
357
|
<ref name="section-title"/>
|
349
358
|
</optional>
|
350
359
|
<choice>
|
351
|
-
<
|
352
|
-
<
|
353
|
-
|
354
|
-
</zeroOrMore>
|
355
|
-
<zeroOrMore>
|
356
|
-
<ref name="note"/>
|
357
|
-
</zeroOrMore>
|
358
|
-
</group>
|
360
|
+
<zeroOrMore>
|
361
|
+
<ref name="BasicBlock"/>
|
362
|
+
</zeroOrMore>
|
359
363
|
<oneOrMore>
|
360
364
|
<ref name="content-subsection"/>
|
361
365
|
</oneOrMore>
|
@@ -472,9 +476,6 @@
|
|
472
476
|
<!-- allow hanging paragraphs in annexes: they introduce lists -->
|
473
477
|
<ref name="BasicBlock"/>
|
474
478
|
</zeroOrMore>
|
475
|
-
<zeroOrMore>
|
476
|
-
<ref name="note"/>
|
477
|
-
</zeroOrMore>
|
478
479
|
<zeroOrMore>
|
479
480
|
<ref name="clause-hanging-paragraph-with-footnote"/>
|
480
481
|
</zeroOrMore>
|
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>
|
@@ -14,10 +14,9 @@ module RelatonGb
|
|
14
14
|
class << self
|
15
15
|
# @param text [Strin] code of standard for serarch
|
16
16
|
# @return [RelatonGb::HitCollection]
|
17
|
-
def scrape_page(text)
|
18
|
-
|
19
|
-
|
20
|
-
)
|
17
|
+
def scrape_page(text) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
18
|
+
host = "http://openstd.samr.gov.cn/bzgk/gb/std_list"
|
19
|
+
search_html = OpenURI.open_uri("#{host}?p.p2=#{text}")
|
21
20
|
result = Nokogiri::HTML search_html
|
22
21
|
hits = result.xpath(
|
23
22
|
"//table[contains(@class, 'result_list')]/tbody[2]/tr",
|
@@ -29,15 +28,15 @@ module RelatonGb
|
|
29
28
|
end
|
30
29
|
HitCollection.new hits.sort_by(&:release_date).reverse
|
31
30
|
rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError, Net::OpenTimeout
|
32
|
-
raise RelatonBib::RequestError, "Cannot access
|
31
|
+
raise RelatonBib::RequestError, "Cannot access #{host}"
|
33
32
|
end
|
34
33
|
|
35
34
|
# @param hit [RelatonGb::Hit] standard's page id
|
36
35
|
# @return [RelatonGb::GbBibliographicItem]
|
37
36
|
def scrape_doc(hit)
|
38
|
-
src = "http://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno
|
37
|
+
src = "http://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=#{hit.pid}"
|
39
38
|
doc = Nokogiri::HTML OpenURI.open_uri(src)
|
40
|
-
GbBibliographicItem.new
|
39
|
+
GbBibliographicItem.new(**scrapped_data(doc, src, hit))
|
41
40
|
rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError, Net::OpenTimeout
|
42
41
|
raise RelatonBib::RequestError, "Cannot access #{src}"
|
43
42
|
end
|
@@ -42,7 +42,7 @@ module RelatonGb
|
|
42
42
|
src = "http://hbba.sacinfo.org.cn/stdDetail/#{hit.pid}"
|
43
43
|
page_uri = URI src
|
44
44
|
doc = Nokogiri::HTML Net::HTTP.get(page_uri)
|
45
|
-
GbBibliographicItem.new
|
45
|
+
GbBibliographicItem.new(**scrapped_data(doc, src, hit))
|
46
46
|
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
47
47
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
|
48
48
|
OpenSSL::SSL::SSLError, Errno::ETIMEDOUT, Net::OpenTimeout
|
data/lib/relaton_gb/version.rb
CHANGED
data/relaton_gb.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
28
28
|
spec.add_development_dependency "pry-byebug"
|
29
|
-
spec.add_development_dependency "rake", "~>
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
31
|
spec.add_development_dependency "ruby-jing"
|
32
32
|
spec.add_development_dependency "simplecov"
|
@@ -35,5 +35,5 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_dependency "cnccs", "~> 0.1.1"
|
37
37
|
spec.add_dependency "gb-agencies", "~> 0.0.1"
|
38
|
-
spec.add_dependency "relaton-iso-bib", "
|
38
|
+
spec.add_dependency "relaton-iso-bib", "~> 1.10.0"
|
39
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-gb
|
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
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: relaton-iso-bib
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
159
|
+
version: 1.10.0
|
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: 1.
|
166
|
+
version: 1.10.0
|
167
167
|
description: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using
|
168
168
|
the BibliographicItem model.'
|
169
169
|
email:
|