relaton-gb 1.5.0 → 1.7.2

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: cdcf6f4c449c467339bf697fcd6aa713605e7ff91ac5ba9879b7221a63b0aa84
4
- data.tar.gz: b04b5b64cef0b79870c502d697bab4e78868b4e7730dae283aae4c10b1ec5b84
3
+ metadata.gz: 7ac8b9933487805e76e9a8f6b6665bb9676d20a2db80ea40ccca2c5e2adda200
4
+ data.tar.gz: fbafee3ab69c7f5f39eb902e6378d185b80aa187c8a737f87b38d280db77da3d
5
5
  SHA512:
6
- metadata.gz: 4c13f6d1a6667403fe2c49662d49455e4a29fe7e039f7abb8b3fc73ff7122bab44eb2b8185b4e8aaee19d9388556465896904651685158e74688a4645951f102
7
- data.tar.gz: e2c1eb2ff01e25cc136df5ee920d5eaed3055eecdcc13ef2d24534aaad50c357ff220560ac591d944442f0f8d7abad0221ed404886922b6330939a2d9fbe2b67
6
+ metadata.gz: d3f8fc4e6f4b4bd50c8c4f6f744e2b48b7b26d13855135a3198254c245fe1d7004932e3d77edb00a7c67a80a2bc058d256cbb6694c55caf79bbe815488568e8e
7
+ data.tar.gz: d55ce1c07766a9a1d80b116aeff2c0efedbf161afbc8ae47bcafc47f3db0a2ec68660239b8449aba15157a5eecb3f4ed3a94364a30c636aaf000b26319b64d09
@@ -0,0 +1,46 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '2.7', '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '3.0'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '3.0'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '3.0'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ with:
35
+ submodules: true
36
+
37
+ # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
38
+ - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
39
+ run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
40
+
41
+ - uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: ${{ matrix.ruby }}
44
+ bundler-cache: true
45
+
46
+ - run: bundle exec rake
data/README.adoc CHANGED
@@ -100,11 +100,7 @@ hash = YAML.load_file 'spec/examples/gb_bib_item.yml'
100
100
  => {"id"=>"JB/T13368",
101
101
  ...
102
102
 
103
- bib_hash = RelatonGb::HashConverter.hash_to_bib hash
104
- => {:id=>"JB/T13368",
105
- ...
106
-
107
- RelatonGb::GbBibliographicItem.new bib_hash
103
+ RelatonGb::GbBibliographicItem.from_hash hash
108
104
  => <RelatonGb::GbBibliographicItem:0x007fc680802700>
109
105
  ----
110
106
 
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">
@@ -141,6 +149,11 @@
141
149
  <data type="boolean"/>
142
150
  </attribute>
143
151
  </optional>
152
+ <optional>
153
+ <attribute name="key">
154
+ <data type="boolean"/>
155
+ </attribute>
156
+ </optional>
144
157
  <oneOrMore>
145
158
  <ref name="dt"/>
146
159
  <ref name="dd"/>
@@ -1164,49 +1177,7 @@
1164
1177
  </define>
1165
1178
  <define name="annex">
1166
1179
  <element name="annex">
1167
- <optional>
1168
- <attribute name="id">
1169
- <data type="ID"/>
1170
- </attribute>
1171
- </optional>
1172
- <optional>
1173
- <attribute name="language"/>
1174
- </optional>
1175
- <optional>
1176
- <attribute name="script"/>
1177
- </optional>
1178
- <optional>
1179
- <attribute name="inline-header">
1180
- <data type="boolean"/>
1181
- </attribute>
1182
- </optional>
1183
- <attribute name="obligation">
1184
- <choice>
1185
- <value>normative</value>
1186
- <value>informative</value>
1187
- </choice>
1188
- </attribute>
1189
- <optional>
1190
- <ref name="section-title"/>
1191
- </optional>
1192
- <group>
1193
- <group>
1194
- <zeroOrMore>
1195
- <ref name="BasicBlock"/>
1196
- </zeroOrMore>
1197
- <zeroOrMore>
1198
- <ref name="note"/>
1199
- </zeroOrMore>
1200
- </group>
1201
- <zeroOrMore>
1202
- <choice>
1203
- <ref name="annex-subsection"/>
1204
- <ref name="terms"/>
1205
- <ref name="definitions"/>
1206
- <ref name="references"/>
1207
- </choice>
1208
- </zeroOrMore>
1209
- </group>
1180
+ <ref name="Annex-Section"/>
1210
1181
  </element>
1211
1182
  </define>
1212
1183
  <define name="terms">
@@ -31,13 +31,20 @@ module RelatonGb
31
31
 
32
32
  def initialize(**args)
33
33
  super
34
- @committee = GbTechnicalCommittee.new args[:committee] if 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
- @gbtype = GbStandardType.new args[:gbtype]
36
+ @gbtype = GbStandardType.new **args[:gbtype]
37
37
  @gbplannumber = args[:gbplannumber] ||
38
38
  structuredidentifier&.project_number
39
39
  end
40
40
 
41
+ # @param hash [Hash]
42
+ # @return [RelatonGb::GbBibliographicItem]
43
+ def self.from_hash(hash)
44
+ item_hash = ::RelatonGb::HashConverter.hash_to_bib(hash)
45
+ new **item_hash
46
+ end
47
+
41
48
  # @param opts [Hash]
42
49
  # @option opts [Nokogiri::XML::Builder] :builder XML builder
43
50
  # @option opts [Boolean] :bibdata
@@ -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
@@ -37,7 +37,7 @@ module RelatonGb
37
37
  def scrape_doc(hit)
38
38
  src = "http://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=" + hit.pid
39
39
  doc = Nokogiri::HTML OpenURI.open_uri(src)
40
- GbBibliographicItem.new scrapped_data(doc, src, hit)
40
+ GbBibliographicItem.new **scrapped_data(doc, src, hit)
41
41
  rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError
42
42
  raise RelatonBib::RequestError, "Cannot access #{src}"
43
43
  end
@@ -28,8 +28,7 @@ module RelatonGb
28
28
  # @param hash [Hash]
29
29
  # @return [RelatonGb::GbBibliographicItem]
30
30
  def hash_to_bib(hash)
31
- item_hash = ::RelatonGb::HashConverter.hash_to_bib(hash)
32
- ::RelatonGb::GbBibliographicItem.new item_hash
31
+ ::RelatonGb::GbBibliographicItem.new hash
33
32
  end
34
33
 
35
34
  # Returns hash of XML grammar
@@ -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 scrapped_data(doc, src, hit)
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
@@ -43,7 +43,7 @@ module RelatonGb
43
43
  def scrape_doc(hit)
44
44
  src = "http://www.ttbz.org.cn#{hit.pid}"
45
45
  doc = Nokogiri::HTML OpenURI.open_uri(src), nil, Encoding::UTF_8.to_s
46
- GbBibliographicItem.new scrapped_data(doc, src, hit)
46
+ GbBibliographicItem.new **scrapped_data(doc, src, hit)
47
47
  rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError
48
48
  raise RelatonBib::RequestError, "Cannot access #{src}"
49
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonGb
4
- VERSION = "1.5.0"
4
+ VERSION = "1.7.2"
5
5
  end
@@ -9,7 +9,7 @@ module RelatonGb
9
9
  # @param item_hash [Hash]
10
10
  # @return [RelatonGb::GbBibliographicItem]
11
11
  def bib_item(item_hash)
12
- GbBibliographicItem.new item_hash
12
+ GbBibliographicItem.new **item_hash
13
13
  end
14
14
 
15
15
  def item_data(gbitem)
data/relaton_gb.gemspec CHANGED
@@ -24,12 +24,12 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
26
26
 
27
- spec.add_development_dependency "debase"
27
+ # spec.add_development_dependency "debase"
28
28
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
29
29
  spec.add_development_dependency "pry-byebug"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
- spec.add_development_dependency "ruby-debug-ide"
32
+ # spec.add_development_dependency "ruby-debug-ide"
33
33
  spec.add_development_dependency "ruby-jing"
34
34
  spec.add_development_dependency "simplecov"
35
35
  spec.add_development_dependency "vcr"
@@ -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.5.0"
40
+ spec.add_dependency "relaton-iso-bib", ">= 1.7.0"
41
41
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-gb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.7.2
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-10-09 00:00:00.000000000 Z
11
+ date: 2021-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: debase
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: equivalent-xml
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +66,6 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: ruby-debug-ide
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: ruby-jing
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +156,14 @@ dependencies:
184
156
  requirements:
185
157
  - - ">="
186
158
  - !ruby/object:Gem::Version
187
- version: 1.5.0
159
+ version: 1.7.0
188
160
  type: :runtime
189
161
  prerelease: false
190
162
  version_requirements: !ruby/object:Gem::Requirement
191
163
  requirements:
192
164
  - - ">="
193
165
  - !ruby/object:Gem::Version
194
- version: 1.5.0
166
+ version: 1.7.0
195
167
  description: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using
196
168
  the BibliographicItem model.'
197
169
  email:
@@ -200,9 +172,7 @@ executables: []
200
172
  extensions: []
201
173
  extra_rdoc_files: []
202
174
  files:
203
- - ".github/workflows/macos.yml"
204
- - ".github/workflows/ubuntu.yml"
205
- - ".github/workflows/windows.yml"
175
+ - ".github/workflows/rake.yml"
206
176
  - ".gitignore"
207
177
  - ".hound.yml"
208
178
  - ".rspec"
@@ -1,32 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- branches: [ '**' ]
10
-
11
- jobs:
12
- test-macos:
13
- name: Test on Ruby ${{ matrix.ruby }} macOS
14
- runs-on: macos-latest
15
- strategy:
16
- fail-fast: false
17
- matrix:
18
- ruby: [ '2.6', '2.5', '2.4' ]
19
- steps:
20
- - uses: actions/checkout@master
21
- - name: Use Ruby
22
- uses: actions/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
- - name: Update gems
27
- run: |
28
- sudo gem install bundler --force
29
- bundle install --jobs 4 --retry 3
30
- - name: Run specs
31
- run: |
32
- bundle exec rake
@@ -1,33 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: ubuntu
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- branches: [ '**' ]
10
-
11
- jobs:
12
- test-linux:
13
- name: Test on Ruby ${{ matrix.ruby }} Ubuntu
14
- runs-on: ubuntu-latest
15
- strategy:
16
- fail-fast: false
17
- matrix:
18
- ruby: [ '2.6', '2.5', '2.4' ]
19
- steps:
20
- - uses: actions/checkout@master
21
- - name: Use Ruby
22
- uses: actions/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
- - name: Update gems
27
- run: |
28
- gem install bundler
29
- bundle install --jobs 4 --retry 3
30
- - name: Run specs
31
- run: |
32
- unset JAVA_TOOL_OPTIONS
33
- bundle exec rake
@@ -1,35 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: windows
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- branches: [ '**' ]
10
-
11
- jobs:
12
- test-windows:
13
- name: Test on Ruby ${{ matrix.ruby }} Windows
14
- runs-on: windows-latest
15
- strategy:
16
- fail-fast: false
17
- matrix:
18
- ruby: [ '2.6', '2.5', '2.4' ]
19
- steps:
20
- - uses: actions/checkout@master
21
- - name: Use Ruby
22
- uses: actions/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
- - name: Update gems
27
- shell: pwsh
28
- run: |
29
- gem install bundler
30
- bundle config --local path vendor/bundle
31
- bundle update
32
- bundle install --jobs 4 --retry 3
33
- - name: Run specs
34
- run: |
35
- bundle exec rake