relaton-gb 1.4.0 → 1.7.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/.github/workflows/macos.yml +2 -0
- data/grammars/gbstandard.rng +7 -0
- data/grammars/isodoc.rng +21 -44
- data/grammars/isostandard.rng +7 -0
- data/lib/relaton_gb/gb_bibliographic_item.rb +12 -14
- data/lib/relaton_gb/gb_bibliography.rb +21 -16
- data/lib/relaton_gb/version.rb +1 -1
- data/relaton_gb.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aecc3ac0ccd54e50b1040011e5e134a760081cca158085cf1ee72765788075d
|
4
|
+
data.tar.gz: e193dc6d10e45f348ce68308954ffddb7944ca87359be7b4d70031efc4cea647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8113fb3674db10343c7c46a731af5c5fa274d3ea18a85461602f4629467306dff91026bca86d41768912a4910622d3821c32f25631d3d6d674615bc9047e4bed
|
7
|
+
data.tar.gz: 71c26d2b131adca579a1c21e8582a96b003f62c43af794a337e7906f75b51745ab8a27760352e947ad3c5326596239c769b9a56187c4e092e7e696bec232a1b3
|
data/.github/workflows/macos.yml
CHANGED
@@ -26,6 +26,8 @@ jobs:
|
|
26
26
|
- name: Update gems
|
27
27
|
run: |
|
28
28
|
sudo gem install bundler --force
|
29
|
+
ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
|
30
|
+
ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
|
29
31
|
bundle install --jobs 4 --retry 3
|
30
32
|
- name: Run specs
|
31
33
|
run: |
|
data/grammars/gbstandard.rng
CHANGED
@@ -183,6 +183,13 @@
|
|
183
183
|
<!-- identical structure to iso-standard -->
|
184
184
|
<define name="gb-standard">
|
185
185
|
<element name="gb-standard">
|
186
|
+
<attribute name="version"/>
|
187
|
+
<attribute name="type">
|
188
|
+
<choice>
|
189
|
+
<value>semantic</value>
|
190
|
+
<value>presentation</value>
|
191
|
+
</choice>
|
192
|
+
</attribute>
|
186
193
|
<ref name="bibdata"/>
|
187
194
|
<zeroOrMore>
|
188
195
|
<ref name="termdocsource"/>
|
data/grammars/isodoc.rng
CHANGED
@@ -24,6 +24,14 @@
|
|
24
24
|
<start>
|
25
25
|
<ref name="standard-document"/>
|
26
26
|
</start>
|
27
|
+
<define name="doctype">
|
28
|
+
<element name="doctype">
|
29
|
+
<optional>
|
30
|
+
<attribute name="abbreviation"/>
|
31
|
+
</optional>
|
32
|
+
<ref name="DocumentType"/>
|
33
|
+
</element>
|
34
|
+
</define>
|
27
35
|
<define name="hyperlink">
|
28
36
|
<element name="link">
|
29
37
|
<attribute name="target">
|
@@ -42,7 +50,6 @@
|
|
42
50
|
</define>
|
43
51
|
<define name="xref">
|
44
52
|
<element name="xref">
|
45
|
-
<!-- attribute target { xsd:IDREF }, -->
|
46
53
|
<attribute name="target">
|
47
54
|
<data type="string">
|
48
55
|
<param name="pattern">\i\c*|\c+#\c+</param>
|
@@ -142,6 +149,11 @@
|
|
142
149
|
<data type="boolean"/>
|
143
150
|
</attribute>
|
144
151
|
</optional>
|
152
|
+
<optional>
|
153
|
+
<attribute name="key">
|
154
|
+
<data type="boolean"/>
|
155
|
+
</attribute>
|
156
|
+
</optional>
|
145
157
|
<oneOrMore>
|
146
158
|
<ref name="dt"/>
|
147
159
|
<ref name="dd"/>
|
@@ -864,6 +876,13 @@
|
|
864
876
|
</define>
|
865
877
|
<define name="standard-document">
|
866
878
|
<element name="standard-document">
|
879
|
+
<attribute name="version"/>
|
880
|
+
<attribute name="type">
|
881
|
+
<choice>
|
882
|
+
<value>semantic</value>
|
883
|
+
<value>presentation</value>
|
884
|
+
</choice>
|
885
|
+
</attribute>
|
867
886
|
<ref name="bibdata"/>
|
868
887
|
<optional>
|
869
888
|
<ref name="boilerplate"/>
|
@@ -1158,49 +1177,7 @@
|
|
1158
1177
|
</define>
|
1159
1178
|
<define name="annex">
|
1160
1179
|
<element name="annex">
|
1161
|
-
<
|
1162
|
-
<attribute name="id">
|
1163
|
-
<data type="ID"/>
|
1164
|
-
</attribute>
|
1165
|
-
</optional>
|
1166
|
-
<optional>
|
1167
|
-
<attribute name="language"/>
|
1168
|
-
</optional>
|
1169
|
-
<optional>
|
1170
|
-
<attribute name="script"/>
|
1171
|
-
</optional>
|
1172
|
-
<optional>
|
1173
|
-
<attribute name="inline-header">
|
1174
|
-
<data type="boolean"/>
|
1175
|
-
</attribute>
|
1176
|
-
</optional>
|
1177
|
-
<attribute name="obligation">
|
1178
|
-
<choice>
|
1179
|
-
<value>normative</value>
|
1180
|
-
<value>informative</value>
|
1181
|
-
</choice>
|
1182
|
-
</attribute>
|
1183
|
-
<optional>
|
1184
|
-
<ref name="section-title"/>
|
1185
|
-
</optional>
|
1186
|
-
<group>
|
1187
|
-
<group>
|
1188
|
-
<zeroOrMore>
|
1189
|
-
<ref name="BasicBlock"/>
|
1190
|
-
</zeroOrMore>
|
1191
|
-
<zeroOrMore>
|
1192
|
-
<ref name="note"/>
|
1193
|
-
</zeroOrMore>
|
1194
|
-
</group>
|
1195
|
-
<zeroOrMore>
|
1196
|
-
<choice>
|
1197
|
-
<ref name="annex-subsection"/>
|
1198
|
-
<ref name="terms"/>
|
1199
|
-
<ref name="definitions"/>
|
1200
|
-
<ref name="references"/>
|
1201
|
-
</choice>
|
1202
|
-
</zeroOrMore>
|
1203
|
-
</group>
|
1180
|
+
<ref name="Annex-Section"/>
|
1204
1181
|
</element>
|
1205
1182
|
</define>
|
1206
1183
|
<define name="terms">
|
data/grammars/isostandard.rng
CHANGED
@@ -405,6 +405,13 @@
|
|
405
405
|
-->
|
406
406
|
<define name="iso-standard">
|
407
407
|
<element name="iso-standard">
|
408
|
+
<attribute name="version"/>
|
409
|
+
<attribute name="type">
|
410
|
+
<choice>
|
411
|
+
<value>semantic</value>
|
412
|
+
<value>presentation</value>
|
413
|
+
</choice>
|
414
|
+
</attribute>
|
408
415
|
<ref name="bibdata"/>
|
409
416
|
<zeroOrMore>
|
410
417
|
<ref name="termdocsource"/>
|
@@ -31,27 +31,25 @@ module RelatonGb
|
|
31
31
|
|
32
32
|
def initialize(**args)
|
33
33
|
super
|
34
|
-
|
34
|
+
@committee = GbTechnicalCommittee.new args[:committee] if args[:committee]
|
35
35
|
@ccs = args[:ccs].map { |c| c.is_a?(Cnccs::Ccs) ? c : Cnccs.fetch(c) }
|
36
36
|
@gbtype = GbStandardType.new args[:gbtype]
|
37
|
-
@gbplannumber = args[:gbplannumber] ||
|
38
|
-
|
37
|
+
@gbplannumber = args[:gbplannumber] ||
|
38
|
+
structuredidentifier&.project_number
|
39
39
|
end
|
40
40
|
|
41
|
-
# @param
|
42
|
-
# @
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end.doc.root.to_xml
|
50
|
-
end
|
41
|
+
# @param opts [Hash]
|
42
|
+
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
43
|
+
# @option opts [Boolean] :bibdata
|
44
|
+
# @option opts [Symbol, NilClass] :date_format (:short), :full
|
45
|
+
# @option opts [String, Symbol] :lang language
|
46
|
+
# @return [String] XML
|
47
|
+
def to_xml(**opts)
|
48
|
+
super(**opts) { |xml| render_gbxml(xml) }
|
51
49
|
end
|
52
50
|
|
53
51
|
# @return [Hash]
|
54
|
-
def to_hash
|
52
|
+
def to_hash # rubocop:disable Metrics/AbcSize
|
55
53
|
hash = super
|
56
54
|
hash["ccs"] = single_element_array(ccs) if ccs&.any?
|
57
55
|
hash["committee"] = committee.to_hash if committee
|
@@ -63,17 +63,20 @@ module RelatonGb
|
|
63
63
|
|
64
64
|
def fetch_ref_err(code, year, missed_years)
|
65
65
|
id = year ? "#{code}:#{year}" : code
|
66
|
-
warn "[relaton-gb] WARNING: no match found on the GB website
|
67
|
-
"The code must be exactly like it is on the website."
|
68
|
-
|
69
|
-
"
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
warn "[relaton-gb] WARNING: no match found on the GB website "\
|
67
|
+
"for #{id}. The code must be exactly like it is on the website."
|
68
|
+
unless missed_years.empty?
|
69
|
+
warn "[relaton-gb] (There was no match for #{year}, though there "\
|
70
|
+
"were matches found for #{missed_years.join(', ')}.)"
|
71
|
+
end
|
72
|
+
if /\d-\d/.match? code
|
73
|
+
warn "[relaton-gb] The provided document part may not exist, or the "\
|
74
|
+
"document may no longer be published in parts."
|
73
75
|
else
|
74
|
-
warn "[relaton-gb] If you wanted to cite all document parts for the
|
75
|
-
"use \"#{code} (all parts)\".\nIf the document is not
|
76
|
-
"use its document type abbreviation (TS, TR, PAS,
|
76
|
+
warn "[relaton-gb] If you wanted to cite all document parts for the "\
|
77
|
+
"reference, use \"#{code} (all parts)\".\nIf the document is not "\
|
78
|
+
"a standard, use its document type abbreviation (TS, TR, PAS, "\
|
79
|
+
"Guide)."
|
77
80
|
end
|
78
81
|
nil
|
79
82
|
end
|
@@ -103,20 +106,22 @@ module RelatonGb
|
|
103
106
|
|
104
107
|
# Sort through the results from Isobib, fetching them three at a time,
|
105
108
|
# and return the first result that matches the code,
|
106
|
-
# matches the year (if provided), and which # has a title (amendments do
|
109
|
+
# matches the year (if provided), and which # has a title (amendments do
|
110
|
+
# not).
|
107
111
|
# Only expects the first page of results to be populated.
|
108
112
|
# Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
|
109
|
-
# If no match, returns any years which caused mismatch, for error
|
110
|
-
|
113
|
+
# If no match, returns any years which caused mismatch, for error
|
114
|
+
# reporting
|
115
|
+
def results_filter(result, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
111
116
|
missed_years = []
|
112
117
|
result.each_slice(3) do |s| # ISO website only allows 3 connections
|
113
|
-
fetch_pages(s, 3).
|
118
|
+
fetch_pages(s, 3).each do |r|
|
114
119
|
return { ret: r } if !year
|
115
120
|
|
116
121
|
r.date.select { |d| d.type == "published" }.each do |d|
|
117
|
-
return { ret: r } if year.to_i == d.on
|
122
|
+
return { ret: r } if year.to_i == d.on(:year)
|
118
123
|
|
119
|
-
missed_years << d.on
|
124
|
+
missed_years << d.on(:year)
|
120
125
|
end
|
121
126
|
end
|
122
127
|
end
|
data/lib/relaton_gb/version.rb
CHANGED
data/relaton_gb.gemspec
CHANGED
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.7.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: 2020-
|
11
|
+
date: 2020-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 1.
|
187
|
+
version: 1.7.0
|
188
188
|
type: :runtime
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: 1.
|
194
|
+
version: 1.7.0
|
195
195
|
description: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using
|
196
196
|
the BibliographicItem model.'
|
197
197
|
email:
|