relaton-gb 1.3.0 → 1.6.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: 272eba99fd1d47cd23a6cd3c6bef9e9f4ee9da3b92f67609a36125829ca3177c
4
- data.tar.gz: ea2242879a194e9660662407fb35dd5cb7024b5b107c93b5c88fea24a67539b1
3
+ metadata.gz: 19cab58160d0b9d1d2bfc979612edb9958c160cda6ad14ef47a3aba68933b231
4
+ data.tar.gz: f8e3dd6b24c773dc3aefe66ec0613d203b37d7dac407b6d36e99a0eb835d01cc
5
5
  SHA512:
6
- metadata.gz: 1c94507bc12aed5456d3a4cc886f1fec4285e06b2446a75098c7842ddb018526ea619557fbda8641b41fd22a43ea0bea9167d71902085295071fc2de2a7eb402
7
- data.tar.gz: 4cfa54290c430b6a10156017862e0730b29f743f673bb265226c5e628747592f2f0465f648c63c4a21a26ce2e2eb1c280eb8466c9c6c9de2d53443dfa0cc8a97
6
+ metadata.gz: f848d7a993c27fa0565ef878b1351970f8f843f14c9a2e3d705d2ce1d31a2d96cafd04bbfe808a12cb656e96e06e9b796f62b060c59a78284f75fb6eda16629e
7
+ data.tar.gz: 4f0b774620da5d03d182189c09dbad460fe9abb3406652a95c91fc1c049d13c5a95321cd6b39c12dafb23fbadd91e64ce6d943cc6062c4358d735a8d77687a6f
@@ -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: |
@@ -46,28 +46,10 @@ Or install it yourself as:
46
46
  require 'relaton_gb'
47
47
 
48
48
  hit_collection = RelatonGb::GbBibliography.search "GB/T 20223-2006"
49
- => [<RelatonGb::Hit:0x007f97572b7348 @fullIdentifier="" @title="GB/T 20223-2006  棉短绒">,
50
- <RelatonGb::Hit:0x007f97572b7208 @fullIdentifier="" @title="20010320-T-424  棉短绒">,
51
- <RelatonGb::Hit:0x007f97572b70c8 @fullIdentifier="" @title="GB/T 20223-2018  棉短绒">,
52
- <RelatonGb::Hit:0x007f97572b6fb0 @fullIdentifier="" @title="NB/T 20223-2013  核电厂安全重要机械设备维修指南">,
53
- <RelatonGb::Hit:0x007f97572b6e98 @fullIdentifier="" @title="20130458-T-424  棉短绒">,
54
- <RelatonGb::Hit:0x007f97572b6d80 @fullIdentifier="" @title="GB 12995-2006  机动轮椅车">,
55
- <RelatonGb::Hit:0x007f97572b6c68 @fullIdentifier="" @title="GB 14866-2006  个人用眼护具技术要求">,
56
- <RelatonGb::Hit:0x007f97572b6b28 @fullIdentifier="" @title="GB/T 20788-2006  饲草揉碎机">,
57
- <RelatonGb::Hit:0x007f97572b6a10 @fullIdentifier="" @title="GB/T 20707-2006  可可脂">,
58
- <RelatonGb::Hit:0x007f97572b68f8 @fullIdentifier="" @title="GB/T 20706-2006  可可粉">]
59
-
60
- hit_collection.size
61
- => 10
49
+ => <RelatonGb::HitCollection:0x007fc8d8a26d10 @ref= @fetched=false>
62
50
 
63
51
  hit_collection.first
64
- => <RelatonGb::Hit:0x007f97572b7348 @fullIdentifier="" @title="GB/T 20223-2006  棉短绒">
65
-
66
- hit_collection[1]
67
- => <RelatonGb::Hit:0x007f97572b7208 @fullIdentifier="" @title="20010320-T-424  棉短绒">
68
-
69
- hit_collection.first.title
70
- => "GB/T 20223-2006  棉短绒"
52
+ => <RelatonGb::Hit:0x007fc8d8a27c88 @fullIdentifier="" @docref="GB/T 20223-2006">
71
53
  ----
72
54
 
73
55
  === Scrape document form collection
@@ -111,7 +93,7 @@ hit_collection.first.fetch.date
111
93
  => [#<RelatonBib::BibliographicDate:0x007f975a0207d0 @from=nil, @on=2006-03-10 00:00:00 +0100, @to=nil, @type="published">]
112
94
  ----
113
95
 
114
- === Create bibliographic item form YAML
96
+ === Create bibliographic item from YAML
115
97
  [source,ruby]
116
98
  ----
117
99
  hash = YAML.load_file 'spec/examples/gb_bib_item.yml'
@@ -131,7 +113,7 @@ RelatonGb::GbBibliographicItem.new bib_hash
131
113
  [source,ruby]
132
114
  ----
133
115
  hit_collection.first.fetch.to_xml
134
- =>"<bibitem id="GB/T20223-2006" type="international-standard">
116
+ =>"<bibitem id="GB/T20223-2006" type="standard\">
135
117
  <title type="title-main" format="text/plain" language="zh" script="Hans">棉短绒</title>
136
118
  <title type="main" format="text/plain" language="zh" script="Hans">棉短绒</title>
137
119
  <title type="title-main" format="text/plain" language="en" script="Latn">Cotton linter</title>
@@ -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"/>
@@ -43,7 +43,9 @@
43
43
  <define name="xref">
44
44
  <element name="xref">
45
45
  <attribute name="target">
46
- <data type="IDREF"/>
46
+ <data type="string">
47
+ <param name="pattern">\i\c*|\c+#\c+</param>
48
+ </data>
47
49
  </attribute>
48
50
  <optional>
49
51
  <attribute name="type">
@@ -61,6 +63,11 @@
61
63
  </choice>
62
64
  </attribute>
63
65
  </optional>
66
+ <optional>
67
+ <attribute name="droploc">
68
+ <data type="boolean"/>
69
+ </attribute>
70
+ </optional>
64
71
  <text/>
65
72
  </element>
66
73
  </define>
@@ -578,6 +585,8 @@
578
585
  <ref name="ol"/>
579
586
  <ref name="dl"/>
580
587
  <ref name="formula"/>
588
+ <ref name="quote"/>
589
+ <ref name="sourcecode"/>
581
590
  </choice>
582
591
  </oneOrMore>
583
592
  </element>
@@ -661,6 +670,16 @@
661
670
  </choice>
662
671
  </attribute>
663
672
  </optional>
673
+ <optional>
674
+ <attribute name="valign">
675
+ <choice>
676
+ <value>top</value>
677
+ <value>middle</value>
678
+ <value>bottom</value>
679
+ <value>baseline</value>
680
+ </choice>
681
+ </attribute>
682
+ </optional>
664
683
  <choice>
665
684
  <zeroOrMore>
666
685
  <choice>
@@ -697,6 +716,16 @@
697
716
  </choice>
698
717
  </attribute>
699
718
  </optional>
719
+ <optional>
720
+ <attribute name="valign">
721
+ <choice>
722
+ <value>top</value>
723
+ <value>middle</value>
724
+ <value>bottom</value>
725
+ <value>baseline</value>
726
+ </choice>
727
+ </attribute>
728
+ </optional>
700
729
  <choice>
701
730
  <zeroOrMore>
702
731
  <choice>
@@ -834,6 +863,13 @@
834
863
  </define>
835
864
  <define name="standard-document">
836
865
  <element name="standard-document">
866
+ <attribute name="version"/>
867
+ <attribute name="type">
868
+ <choice>
869
+ <value>semantic</value>
870
+ <value>presentation</value>
871
+ </choice>
872
+ </attribute>
837
873
  <ref name="bibdata"/>
838
874
  <optional>
839
875
  <ref name="boilerplate"/>
@@ -855,7 +891,7 @@
855
891
  <oneOrMore>
856
892
  <choice>
857
893
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
894
+ <ref name="abstract"/>
859
895
  <ref name="foreword"/>
860
896
  <ref name="introduction"/>
861
897
  <ref name="acknowledgements"/>
@@ -922,6 +958,9 @@
922
958
  <optional>
923
959
  <attribute name="script"/>
924
960
  </optional>
961
+ <optional>
962
+ <attribute name="type"/>
963
+ </optional>
925
964
  <optional>
926
965
  <attribute name="obligation">
927
966
  <choice>
@@ -961,9 +1000,6 @@
961
1000
  </define>
962
1001
  <define name="content-subsection">
963
1002
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
1003
  <ref name="Content-Section"/>
968
1004
  </element>
969
1005
  </define>
@@ -992,6 +1028,9 @@
992
1028
  </choice>
993
1029
  </attribute>
994
1030
  </optional>
1031
+ <optional>
1032
+ <attribute name="type"/>
1033
+ </optional>
995
1034
  <optional>
996
1035
  <ref name="section-title"/>
997
1036
  </optional>
@@ -1011,9 +1050,6 @@
1011
1050
  </define>
1012
1051
  <define name="clause">
1013
1052
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1053
  <ref name="Clause-Section"/>
1018
1054
  </element>
1019
1055
  </define>
@@ -1042,18 +1078,24 @@
1042
1078
  </choice>
1043
1079
  </attribute>
1044
1080
  </optional>
1081
+ <optional>
1082
+ <attribute name="type"/>
1083
+ </optional>
1045
1084
  <optional>
1046
1085
  <ref name="section-title"/>
1047
1086
  </optional>
1048
1087
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1088
+ <choice>
1089
+ <group>
1090
+ <zeroOrMore>
1091
+ <ref name="BasicBlock"/>
1092
+ </zeroOrMore>
1093
+ <zeroOrMore>
1094
+ <ref name="note"/>
1095
+ </zeroOrMore>
1096
+ </group>
1097
+ <ref name="amend"/>
1098
+ </choice>
1057
1099
  <zeroOrMore>
1058
1100
  <choice>
1059
1101
  <ref name="clause-subsection"/>
@@ -1180,6 +1222,9 @@
1180
1222
  <optional>
1181
1223
  <attribute name="script"/>
1182
1224
  </optional>
1225
+ <optional>
1226
+ <attribute name="type"/>
1227
+ </optional>
1183
1228
  <optional>
1184
1229
  <attribute name="obligation">
1185
1230
  <choice>
@@ -1447,11 +1492,6 @@
1447
1492
  </optional>
1448
1493
  </element>
1449
1494
  </define>
1450
- <define name="preface_abstract">
1451
- <element name="abstract">
1452
- <ref name="Basic-Section"/>
1453
- </element>
1454
- </define>
1455
1495
  <define name="term-clause">
1456
1496
  <element name="clause">
1457
1497
  <optional>
@@ -1501,4 +1541,79 @@
1501
1541
  <ref name="CitationType"/>
1502
1542
  </element>
1503
1543
  </define>
1544
+ <define name="amend">
1545
+ <element name="amend">
1546
+ <optional>
1547
+ <attribute name="id">
1548
+ <data type="ID"/>
1549
+ </attribute>
1550
+ </optional>
1551
+ <attribute name="change">
1552
+ <choice>
1553
+ <value>add</value>
1554
+ <value>modify</value>
1555
+ <value>delete</value>
1556
+ </choice>
1557
+ </attribute>
1558
+ <optional>
1559
+ <attribute name="path"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <attribute name="path_end"/>
1563
+ </optional>
1564
+ <optional>
1565
+ <attribute name="title"/>
1566
+ </optional>
1567
+ <optional>
1568
+ <element name="location">
1569
+ <zeroOrMore>
1570
+ <ref name="locality"/>
1571
+ </zeroOrMore>
1572
+ </element>
1573
+ </optional>
1574
+ <zeroOrMore>
1575
+ <ref name="autonumber"/>
1576
+ </zeroOrMore>
1577
+ <optional>
1578
+ <element name="description">
1579
+ <zeroOrMore>
1580
+ <ref name="BasicBlock"/>
1581
+ </zeroOrMore>
1582
+ </element>
1583
+ </optional>
1584
+ <optional>
1585
+ <element name="newcontent">
1586
+ <zeroOrMore>
1587
+ <ref name="BasicBlock"/>
1588
+ </zeroOrMore>
1589
+ </element>
1590
+ </optional>
1591
+ <optional>
1592
+ <element name="description">
1593
+ <zeroOrMore>
1594
+ <ref name="BasicBlock"/>
1595
+ </zeroOrMore>
1596
+ </element>
1597
+ </optional>
1598
+ </element>
1599
+ </define>
1600
+ <define name="autonumber">
1601
+ <element name="autonumber">
1602
+ <attribute name="type">
1603
+ <choice>
1604
+ <value>requirement</value>
1605
+ <value>recommendation</value>
1606
+ <value>permission</value>
1607
+ <value>table</value>
1608
+ <value>figure</value>
1609
+ <value>admonition</value>
1610
+ <value>formula</value>
1611
+ <value>sourcecode</value>
1612
+ <value>example</value>
1613
+ <value>note</value>
1614
+ </choice>
1615
+ </attribute>
1616
+ <text/>
1617
+ </element>
1618
+ </define>
1504
1619
  </grammar>
@@ -253,7 +253,7 @@
253
253
  <define name="preface">
254
254
  <element name="preface">
255
255
  <optional>
256
- <ref name="preface_abstract"/>
256
+ <ref name="abstract"/>
257
257
  </optional>
258
258
  <ref name="foreword"/>
259
259
  <optional>
@@ -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.3.0"
4
+ VERSION = "1.6.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.3.0"
40
+ spec.add_dependency "relaton-iso-bib", ">= 1.6.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.3.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
11
+ date: 2020-11-13 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.3.0
187
+ version: 1.6.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.3.0
194
+ version: 1.6.0
195
195
  description: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using
196
196
  the BibliographicItem model.'
197
197
  email:
@@ -241,7 +241,7 @@ homepage: https://github.com/metanorma/relaton_gb
241
241
  licenses:
242
242
  - BSD-2-Clause
243
243
  metadata: {}
244
- post_install_message:
244
+ post_install_message:
245
245
  rdoc_options: []
246
246
  require_paths:
247
247
  - lib
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  version: '0'
258
258
  requirements: []
259
259
  rubygems_version: 3.0.6
260
- signing_key:
260
+ signing_key:
261
261
  specification_version: 4
262
262
  summary: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using the
263
263
  BibliographicItem model.'