relaton-iec 1.7.6 → 1.7.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08ac0e0f5df714485be57354b74b7e172758ffe218467667a63c670ea33ea068'
4
- data.tar.gz: e2887cb6b9346fc7d1eb9941fe759dc2d3dd90c9c4826d977e1d9b191ea3ddf8
3
+ metadata.gz: 6adf6dcf2372c1e9dff549a4d4145fcbbd9bd1aced1924183a30d5253a760757
4
+ data.tar.gz: 26065c6b757cd9e1818568f6ef07b83041ea3e10cf4f6c331925c807a8c22c50
5
5
  SHA512:
6
- metadata.gz: 77bb3d3b8f2c829147434bec3dbcff6840ef1048c24613c9eca3b4b3c1013f6b58d100b987b36713a200de918b240ba8ee4dd461b8887ba5e234b2b7f56eef13
7
- data.tar.gz: 93d012040298e5570b91730a260a50009c79889d905daac3fa274660a740b997c50f1914f243fa7c964207061e4d21b60a48ecc0a6b808a555a8688f6598ab4f
6
+ metadata.gz: d6c2a5cb8df0993d39c2d150f1f1abc6cddfe0b6ddc88e0ff3f309603de964eccf4242dc273c89659fcfd4323a73b8ecbcc152d9203bcdadc618df5171313f47
7
+ data.tar.gz: b76ea74bdf8204c525d8db77b03d53157a26ae0f797edfb5be908b33c28c426add2de763e51ee92a98b778e64084230ea699b4c2a79420cb3166c72be7308b9f
@@ -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
@@ -7,7 +7,7 @@ module RelatonIec
7
7
  # @param item [Hash]
8
8
  # @retirn [RelatonIec::IecBibliographicItem]
9
9
  def bib_item(item)
10
- IecBibliographicItem.new(item)
10
+ IecBibliographicItem.new(**item)
11
11
  end
12
12
  end
13
13
  end
@@ -21,7 +21,7 @@ module RelatonIec
21
21
  # @param part [String, nil] search for packaged stndard if not nil
22
22
  # @return [RelatonIec::HitCollection]
23
23
  def search(text, year = nil, part = nil)
24
- HitCollection.new text, year&.strip, part
24
+ HitCollection.new text.sub(/(^\w+)\//, '\1 '), year&.strip, part
25
25
  rescue SocketError, OpenURI::HTTPError, OpenSSL::SSL::SSLError
26
26
  raise RelatonBib::RequestError, "Could not access http://www.iec.ch"
27
27
  end
@@ -105,6 +105,7 @@ module RelatonIec
105
105
  result = search code, year, part
106
106
  end
107
107
  result = search code if result.empty?
108
+ code = result.text.dup
108
109
  code&.sub! /((?:-\w+)+)/, ""
109
110
  result.select do |i|
110
111
  %r{
@@ -158,8 +159,8 @@ module RelatonIec
158
159
  # Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
159
160
  # If no match, returns any years which caused mismatch, for error
160
161
  # reporting
161
- def results_filter(result, ref, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
162
- r_code, r_year = code_year ref, result.part
162
+ def results_filter(result, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
163
+ r_code, r_year = code_year result.text, result.part
163
164
  r_year ||= year
164
165
  missed_years = []
165
166
  missed_parts = false
@@ -186,7 +187,7 @@ module RelatonIec
186
187
  { ret: ret, years: missed_years, missed_parts: missed_parts }
187
188
  end
188
189
 
189
- # @param ref [string]
190
+ # @param ref [String]
190
191
  # @param part [String, nil]
191
192
  # @return [Array<String, nil>]
192
193
  def code_year(ref, part)
@@ -204,7 +205,7 @@ module RelatonIec
204
205
  # @return [RelatonIec::IecBibliographicItem, nil]
205
206
  def iecbib_get(code, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
206
207
  result = search_filter(code, year) || return
207
- ret = results_filter(result, code, year, opts)
208
+ ret = results_filter(result, year, opts)
208
209
  if ret[:ret]
209
210
  if ret[:missed_parts]
210
211
  warn "[relaton-iec] WARNING: #{code} found as #{ret[:ret].docidentifier.first.id} "\
@@ -241,14 +241,7 @@ module RelatonIec
241
241
 
242
242
  def fetch_contributors(code)
243
243
  code.sub(/\s.*/, "").split("/").map do |abbrev|
244
- case abbrev
245
- when "ISO"
246
- name = "International Organization for Standardization"
247
- url = "www.iso.org"
248
- when "IEC"
249
- name = "International Electrotechnical Commission"
250
- url = "www.iec.ch"
251
- end
244
+ name, url = name_url abbrev
252
245
  { entity: { name: name, url: url, abbreviation: abbrev },
253
246
  role: [type: "publisher"] }
254
247
  end
@@ -285,11 +278,7 @@ module RelatonIec
285
278
  # @return [Array<Hash>]
286
279
  def fetch_copyright(code, doc)
287
280
  abbreviation = code.match(/.*?(?=\s)/).to_s
288
- case abbreviation
289
- when "IEC"
290
- name = "International Electrotechnical Commission"
291
- url = "www.iec.ch"
292
- end
281
+ name, url = name_url abbreviation
293
282
  from = code.match(/(?<=:)\d{4}/).to_s
294
283
  if from.empty?
295
284
  from = doc.xpath("//span[@itemprop='releaseDate']").text
@@ -301,6 +290,14 @@ module RelatonIec
301
290
  }]
302
291
  end
303
292
  # rubocop:enable Metrics/MethodLength
293
+
294
+ def name_url(abbrev)
295
+ case abbrev
296
+ when "ISO" then ["International Organization for Standardization", "www.iso.org"]
297
+ when "IEC" then ["International Electrotechnical Commission", "www.iec.ch"]
298
+ when "CISPR" then ["International special committee on radio interference", "www.iec.ch"]
299
+ end
300
+ end
304
301
  end
305
302
  end
306
303
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.7.6".freeze
2
+ VERSION = "1.7.7".freeze
3
3
  end
@@ -7,7 +7,7 @@ module RelatonIec
7
7
  # @param item_hash [Hash]
8
8
  # @return [RelatonIec::IecBibliographicItem]
9
9
  def bib_item(item_hash)
10
- IecBibliographicItem.new item_hash
10
+ IecBibliographicItem.new **item_hash
11
11
  end
12
12
  end
13
13
  end
data/relaton_iec.gemspec CHANGED
@@ -23,12 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
25
25
 
26
- spec.add_development_dependency "debase"
26
+ # spec.add_development_dependency "debase"
27
27
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
28
28
  spec.add_development_dependency "pry-byebug"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "ruby-debug-ide"
31
+ # spec.add_development_dependency "ruby-debug-ide"
32
32
  spec.add_development_dependency "ruby-jing"
33
33
  spec.add_development_dependency "simplecov"
34
34
  spec.add_development_dependency "vcr"
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.6
4
+ version: 1.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-03 00:00:00.000000000 Z
11
+ date: 2021-03-17 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
@@ -186,9 +158,7 @@ executables: []
186
158
  extensions: []
187
159
  extra_rdoc_files: []
188
160
  files:
189
- - ".github/workflows/macos.yml"
190
- - ".github/workflows/ubuntu.yml"
191
- - ".github/workflows/windows.yml"
161
+ - ".github/workflows/rake.yml"
192
162
  - ".gitignore"
193
163
  - ".rspec"
194
164
  - ".rubocop.yml"
@@ -236,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
206
  - !ruby/object:Gem::Version
237
207
  version: '0'
238
208
  requirements: []
239
- rubygems_version: 3.0.6
209
+ rubygems_version: 3.2.3
240
210
  signing_key:
241
211
  specification_version: 4
242
212
  summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
@@ -1,34 +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
- 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"
31
- bundle install --jobs 4 --retry 3
32
- - name: Run specs
33
- run: |
34
- 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