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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6fad471830e1c0f9172e7edd3b06affad5aca2da674e83dbe2faa8c098e7b8b
4
- data.tar.gz: e0ac69e2e95a397c038538a4c6e1e7dd66c80d9732403ab3971329d955a63d95
3
+ metadata.gz: 8aecc3ac0ccd54e50b1040011e5e134a760081cca158085cf1ee72765788075d
4
+ data.tar.gz: e193dc6d10e45f348ce68308954ffddb7944ca87359be7b4d70031efc4cea647
5
5
  SHA512:
6
- metadata.gz: 9b960cff84c679239f909ea92fc4ac36ab2c4ab40c6446f065cd4d633df492a81898865f5fafaa4d172fad3c63fe2bfa381d95c3c4378acc7deda90ac3c1440a
7
- data.tar.gz: b8b755a5d5e9d86627d56254038b57cbd7fa9656bf2d277f99e3792ef76b76046b73880efc7c25173d621e0d6cc5039630b860c12306baccf1a11b17e7dd6a84
6
+ metadata.gz: 8113fb3674db10343c7c46a731af5c5fa274d3ea18a85461602f4629467306dff91026bca86d41768912a4910622d3821c32f25631d3d6d674615bc9047e4bed
7
+ data.tar.gz: 71c26d2b131adca579a1c21e8582a96b003f62c43af794a337e7906f75b51745ab8a27760352e947ad3c5326596239c769b9a56187c4e092e7e696bec232a1b3
@@ -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: |
@@ -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"/>
@@ -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
- <optional>
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">
@@ -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
- args[:committee] && @committee = GbTechnicalCommittee.new(args[:committee])
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] || structuredidentifier&.project_number
38
- # @doctype = args[:doctype]
37
+ @gbplannumber = args[:gbplannumber] ||
38
+ structuredidentifier&.project_number
39
39
  end
40
40
 
41
- # @param builder [Nokogiri::XML::Builder]
42
- # @return [String]
43
- def to_xml(builder = nil, **opts)
44
- if builder
45
- super(builder, **opts) { |xml| render_gbxml(xml) }
46
- else
47
- Nokogiri::XML::Builder.new(encoding: "UTF-8") do |bldr|
48
- super(bldr, **opts) { |xml| render_gbxml(xml) }
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 for #{id}. "\
67
- "The code must be exactly like it is on the website."
68
- warn "[relaton-gb] (There was no match for #{year}, though there were matches "\
69
- "found for #{missed_years.join(', ')}.)" unless missed_years.empty?
70
- if /\d-\d/ =~ code
71
- warn "[relaton-gb] The provided document part may not exist, or the document "\
72
- "may no longer be published in parts."
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 reference, "\
75
- "use \"#{code} (all parts)\".\nIf the document is not a standard, "\
76
- "use its document type abbreviation (TS, TR, PAS, Guide)."
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 not).
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 reporting
110
- def results_filter(result, year)
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).each_with_index do |r, i|
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.year
122
+ return { ret: r } if year.to_i == d.on(:year)
118
123
 
119
- missed_years << d.on.year
124
+ missed_years << d.on(:year)
120
125
  end
121
126
  end
122
127
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonGb
4
- VERSION = "1.4.0"
4
+ VERSION = "1.7.0"
5
5
  end
@@ -37,5 +37,5 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_dependency "cnccs", "~> 0.1.1"
39
39
  spec.add_dependency "gb-agencies", "~> 0.0.1"
40
- spec.add_dependency "relaton-iso-bib", ">= 1.4.0"
40
+ spec.add_dependency "relaton-iso-bib", ">= 1.7.0"
41
41
  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.0
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-09-18 00:00:00.000000000 Z
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.4.0
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.4.0
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: