relaton-iec 1.14.4 → 1.16.1

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: 7830e8be677e5014f3d20ad93e21a603ca91e9e5e091ec479cafb60819ca550d
4
- data.tar.gz: 4689ce387b5c991f4d8ca0461c4eeb37a5f76df03e979d715d0c574c12602305
3
+ metadata.gz: 22c30d32d348985a90f88d21872741162ebef459ccff4fc118597f196e53f4b9
4
+ data.tar.gz: 5a265ce8efceee119c822824eb347ace8aeedd9f695b23b7270a22d150da3678
5
5
  SHA512:
6
- metadata.gz: 5e1d2ad522df02eb85df1b8e84f24d44e7de3e476019ddcc8b65db5b3105b699b6213bef67e6e543039c48ed62fb6806a434b1feb35618059cdc9aa0a78009f4
7
- data.tar.gz: 97963e6ce622bf1c6ee27847e935339d4582689658cb31f6d875d11aa8049680b1237e73bfa8c1f52ccdbcd03bc218e5b79ffd27afed7524a6e9461ac2d5bf72
6
+ metadata.gz: f6f4575283e266b8f35c28b88ff70ec1653c35222e6283d62385c883c459a3a65b096b5ed7495b68a40f4b99760f2e741d59ce4c370556180d0e41bc3d04f529
7
+ data.tar.gz: 76d9702d3434cf7a7c3b1dfc4e03e9be53ca2e49c801c5dc2060b7574e3d3c023ade59074daeb628a00eb57e1792860d8d35073228594baf0e897917d2b3c9d1
@@ -7,7 +7,8 @@ on:
7
7
  inputs:
8
8
  next_version:
9
9
  description: |
10
- Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
10
+ Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
11
+ Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
11
12
  required: true
12
13
  default: 'skip'
13
14
  repository_dispatch:
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  .vscode/
10
+ /vendor/
10
11
  .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
11
12
 
12
13
  # rspec failure tracking
data/.rubocop.yml CHANGED
@@ -7,6 +7,6 @@ require: rubocop-rails
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 2.5
10
+ TargetRubyVersion: 2.7
11
11
  Rails:
12
12
  Enabled: false
data/Gemfile CHANGED
@@ -5,7 +5,10 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in relaton_iec.gemspec
6
6
  gemspec
7
7
 
8
+ gem "equivalent-xml", "~> 0.6"
8
9
  gem "pry-byebug"
10
+ gem "rake", "~> 13.0"
11
+ gem "rspec", "~> 3.0"
9
12
  gem "ruby-jing"
10
13
  gem "simplecov"
11
14
  gem "vcr"
data/grammars/biblio.rng CHANGED
@@ -1283,7 +1283,7 @@
1283
1283
  <value>mergedInto</value>
1284
1284
  <value>splits</value>
1285
1285
  <value>splitInto</value>
1286
- <value>instance</value>
1286
+ <value>instanceOf</value>
1287
1287
  <value>hasInstance</value>
1288
1288
  <value>exemplarOf</value>
1289
1289
  <value>hasExemplar</value>
@@ -0,0 +1,10 @@
1
+ module RelatonIec
2
+ module Config
3
+ include RelatonBib::Config
4
+ end
5
+ extend Config
6
+
7
+ class Configuration < RelatonBib::Configuration
8
+ PROGNAME = "relaton-iec".freeze
9
+ end
10
+ end
@@ -238,7 +238,7 @@ module RelatonIec
238
238
  when "TR" then "technical-report"
239
239
  when "TS" then "technical-specification"
240
240
  when "PAS" then "publicly-available-specification"
241
- when "SRD" then "system-reference-delivrabble"
241
+ when "SRD" then "system-reference-deliverable"
242
242
  else @pub["stdType"].downcase
243
243
  end
244
244
  end
@@ -6,7 +6,7 @@ module RelatonIec
6
6
  guide industry-technical-agreement system-reference-deliverable
7
7
  ].freeze
8
8
 
9
- DOCSUBTYPES = %w[specification method-of-test vocabulary code-of-practice].freeze
9
+ SUBDOCTYPES = %w[specification method-of-test vocabulary code-of-practice].freeze
10
10
 
11
11
  FUNCTION = %w[emc safety enviroment quality-assurance].freeze
12
12
 
@@ -34,15 +34,13 @@ module RelatonIec
34
34
  #
35
35
  def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
36
36
  if args[:function] && !FUNCTION.include?(args[:function])
37
- warn "[relaton-iec] WARNING: invalid function \"#{args[:function]}\""
38
- warn "[relaton-iec] allowed function values are: #{FUNCTION.join(', ')}"
37
+ Util.warn "WARNING: invalid function `#{args[:function]}`"
38
+ Util.warn "allowed function values are: `#{FUNCTION.join('`, `')}`"
39
39
  end
40
40
  if args[:updates_document_type] &&
41
41
  !DOCTYPES.include?(args[:updates_document_type])
42
- warn "[relaton-iec] WARNING: invalid updates_document_type "\
43
- "\"#{args[:updates_document_type]}\""
44
- warn "[relaton-iec] allowed updates_document_type values are: "\
45
- "#{DOCTYPES.join(', ')}"
42
+ Util.warn "WARNING: invalid updates_document_type `#{args[:updates_document_type]}`"
43
+ Util.warn "allowed updates_document_type values are: `#{DOCTYPES.join('`, `')}`"
46
44
  end
47
45
  @function = args.delete :function
48
46
  @updates_document_type = args.delete :updates_document_type
@@ -41,34 +41,91 @@ module RelatonIec
41
41
 
42
42
  private
43
43
 
44
+ # @param pubid [String]
45
+ # @param year [String]
46
+ # @param missed_years [Array<String>]
47
+ def warn_missing_years(pubid, year, missed_years)
48
+ id = ref_with_year(pubid, year)
49
+ Util.warn "(#{id}) TIP: No match for edition year `#{year}`, " \
50
+ "but matches exist for `#{missed_years.uniq.join('`, `')}`."
51
+ end
52
+
44
53
  # @param code [String]
45
54
  # @param year [String]
46
55
  # @param missed_years [Array<String>]
47
56
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
48
- id = year ? "#{code}:#{year}" : code
49
- warn "[relaton-iec] WARNING: no match found online for #{id}. " \
50
- "The code must be exactly like it is on the standards website."
51
- unless missed_years.empty?
52
- warn "[relaton-iec] (There was no match for #{year}, though there " \
53
- "were matches found for #{missed_years.join(', ')}.)"
57
+ id = ref_with_year(code, year)
58
+
59
+ Util.warn "(#{id}) Not found. The identifier must be exactly as shown on the IEC Webstore."
60
+
61
+ if year && missed_years.any?
62
+ warn_missing_years(code, year, missed_years)
54
63
  end
55
- if /\d-\d/.match? code
56
- warn "[relaton-iec] The provided document part may not exist, or " \
57
- "the document may no longer be published in parts."
64
+
65
+ # TODO: change this to pubid-iec
66
+ has_part = /\d-\d/.match?(code)
67
+ if has_part
68
+ Util.warn "(#{id}) TIP: If it cannot be found, the document may no longer be published in parts."
69
+
58
70
  else
59
- warn "[relaton-iec] If you wanted to cite all document parts for " \
60
- "the reference, use \"#{code} (all parts)\".\nIf the document " \
61
- "is not a standard, use its document type abbreviation (TS, " \
62
- "TR, PAS, Guide)."
71
+ Util.warn "(#{id}) TIP: If you wish to cite all document parts for " \
72
+ "the reference, use `#{code} (all parts)`."
73
+ end
74
+
75
+ # TODO: streamline after integration with pubid-iec
76
+ doctypes = %w(TS TR PAS SRD TEC STTR WP Guide OD CS CA)
77
+ selected_doctype = doctypes.select do |t|
78
+ code.include?("#{t} ")
63
79
  end
80
+ unless selected_doctype
81
+ Util.warn "(#{id}) TIP: If the document is not an International Standard, use its " \
82
+ "deliverable type abbreviation `#{doctypes.join('`, `')}`."
83
+ end
84
+
64
85
  nil
65
86
  end
66
87
 
67
88
  # @param ref [String]
89
+ # @param year [String]
90
+ # @return [String]
91
+ def ref_with_year(ref, year)
92
+ year ? [ref, year].join(":") : ref
93
+ end
94
+
95
+ # @param ref [String]
96
+ # @param year [String, nil]
97
+ # @return [RelatonIec::HitCollection]
98
+ # def search_filter(ref, year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
99
+ # rp1 = ref_parts ref.upcase
100
+ # year ||= rp1[:year]
101
+ # corr = rp1[:corr]&.sub " ", ""
102
+ # warn "[relaton-iec] (\"#{ref_with_year(ref, year)}\") Fetching from IEC..."
103
+ # result = search(rp1[:code], year)
104
+ # code = result.text.dup
105
+ # if result.empty? && /(?<=\d-)(?<part>[\w-]+)/ =~ rp1[:code]
106
+ # # try to search packaged standard
107
+ # result = search rp1[:code], year, part
108
+ # pkg_std = result.any?
109
+ # end
110
+ # result = search rp1[:code] if result.empty?
111
+ # if pkg_std
112
+ # code.sub!(/(?<=\d-)#{part}/, part[0])
113
+ # else
114
+ # code.sub!(/-[-\d]+/, "")
115
+ # end
116
+ # result.select do |i|
117
+ # rp2 = ref_parts i.hit[:code]
118
+ # code2 = if pkg_std
119
+ # rp2[:code].sub(/(?<=\d-\d)\d+/, "")
120
+ # else
121
+ # rp2[:code].sub(/-[-\d]+/, "")
122
+ # end
123
+ # code == code2 && rp1[:bundle] == rp2[:bundle] && corr == rp2[:corr]
124
+ # end
68
125
  # @return [RelatonIec::HitCollection]
69
- def search_filter(ref)
126
+ def search_filter(ref, year)
70
127
  code = ref.split(":").first
71
- warn "[relaton-iec] (\"#{ref}\") fetching..."
128
+ Util.warn "(#{ref_with_year(ref, year)}) Fetching from IEC..."
72
129
  search(code)
73
130
  end
74
131
 
@@ -184,21 +241,25 @@ module RelatonIec
184
241
  # @param year [String, nil]
185
242
  # @param opts [Hash]
186
243
  # @return [RelatonIec::IecBibliographicItem, nil]
187
- def iecbib_get(ref, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
188
- result = search_filter(ref) || return
189
- ret = results_filter(result, ref, year, opts)
190
- if ret[:ret]
191
- if ret[:missed_parts] && !opts[:all_parts]
192
- warn "[relaton-iec] WARNING: #{ref} found as #{ret[:ret].docidentifier.first.id} " \
193
- "but also contain parts. If you wanted to cite all document " \
194
- "parts for the reference, use \"#{ref} (all parts)\""
195
- else
196
- warn "[relaton-iec] (\"#{ref}\") found #{ret[:ret].docidentifier.first.id}"
197
- end
198
- ret[:ret]
199
- else
200
- fetch_ref_err(ref, year, ret[:years])
244
+ def iecbib_get(code, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
245
+ result = search_filter(code, year) || return
246
+ ret = results_filter(result, code, year, opts)
247
+
248
+ return fetch_ref_err(code, year, ret[:years]) unless ret[:ret]
249
+
250
+ id = ref_with_year(code, year)
251
+ docid = ret[:ret].docidentifier.first.id
252
+
253
+ if id == docid then Util.warn "(#{id}) Found exact match."
254
+ else Util.warn "(#{id}) Found `#{docid}`."
201
255
  end
256
+
257
+ if ret[:missed_parts]
258
+ Util.warn "(#{id}) TIP: `#{code}` also contains other parts, " \
259
+ "if you want to cite all parts, use `#{code} (all parts)`."
260
+ end
261
+
262
+ ret[:ret]
202
263
  end
203
264
  end
204
265
  end
@@ -48,7 +48,7 @@ module RelatonIec
48
48
  #
49
49
  # Last change date
50
50
  #
51
- # @return [String] <description>
51
+ # @return [String, nil] last change date or nil if index is empty
52
52
  #
53
53
  def last_change
54
54
  return unless @index.any?
@@ -0,0 +1,9 @@
1
+ module RelatonIec
2
+ module Util
3
+ extend RelatonBib::Util
4
+
5
+ def self.logger
6
+ RelatonIec.configuration.logger
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.14.4".freeze
2
+ VERSION = "1.16.1".freeze
3
3
  end
@@ -27,7 +27,7 @@ module RelatonIec
27
27
  # @param item_hash [Hash]
28
28
  # @return [RelatonIec::IecBibliographicItem]
29
29
  def bib_item(item_hash)
30
- IecBibliographicItem.new **item_hash
30
+ IecBibliographicItem.new(**item_hash)
31
31
  end
32
32
  end
33
33
  end
data/lib/relaton_iec.rb CHANGED
@@ -7,6 +7,8 @@ require "relaton/index"
7
7
  require "relaton_iso_bib"
8
8
  require "relaton_iec/hit"
9
9
  require "relaton_iec/version"
10
+ require "relaton_iec/config"
11
+ require "relaton_iec/util"
10
12
  require "relaton_iec/iec_bibliography"
11
13
  require "relaton_iec/iec_bibliographic_item"
12
14
  require "relaton_iec/xml_parser"
@@ -20,10 +22,10 @@ module RelatonIec
20
22
  # Returns hash of XML reammar
21
23
  # @return [String]
22
24
  def grammar_hash
23
- gem_path = File.expand_path "..", __dir__
24
- grammars_path = File.join gem_path, "grammars", "*"
25
- grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
26
- Digest::MD5.hexdigest grammars
25
+ # gem_path = File.expand_path "..", __dir__
26
+ # grammars_path = File.join gem_path, "grammars", "*"
27
+ # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
28
+ Digest::MD5.hexdigest RelatonIec::VERSION + RelatonIsoBib::VERSION + RelatonBib::VERSION # grammars
27
29
  end
28
30
 
29
31
  # @param code [String]
data/relaton_iec.gemspec CHANGED
@@ -21,14 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
25
-
26
- spec.add_development_dependency "equivalent-xml", "~> 0.6"
27
- spec.add_development_dependency "rake", "~> 13.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
29
25
 
30
26
  spec.add_dependency "addressable"
31
27
  spec.add_dependency "relaton-index", "~> 0.2.0"
32
- spec.add_dependency "relaton-iso-bib", "~> 1.14.0"
28
+ spec.add_dependency "relaton-iso-bib", "~> 1.16.0"
33
29
  spec.add_dependency "rubyzip"
34
30
  end
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.4
4
+ version: 1.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-16 00:00:00.000000000 Z
11
+ date: 2023-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: equivalent-xml
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.6'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.6'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '13.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '13.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
13
  - !ruby/object:Gem::Dependency
56
14
  name: addressable
57
15
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +44,14 @@ dependencies:
86
44
  requirements:
87
45
  - - "~>"
88
46
  - !ruby/object:Gem::Version
89
- version: 1.14.0
47
+ version: 1.16.0
90
48
  type: :runtime
91
49
  prerelease: false
92
50
  version_requirements: !ruby/object:Gem::Requirement
93
51
  requirements:
94
52
  - - "~>"
95
53
  - !ruby/object:Gem::Version
96
- version: 1.14.0
54
+ version: 1.16.0
97
55
  - !ruby/object:Gem::Dependency
98
56
  name: rubyzip
99
57
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +109,7 @@ files:
151
109
  - lib/relaton_iec/basic_block/stem.rb
152
110
  - lib/relaton_iec/basic_block/table.rb
153
111
  - lib/relaton_iec/basic_block/text_element.rb
112
+ - lib/relaton_iec/config.rb
154
113
  - lib/relaton_iec/data_fetcher.rb
155
114
  - lib/relaton_iec/data_parser.rb
156
115
  - lib/relaton_iec/hash_converter.rb
@@ -162,6 +121,7 @@ files:
162
121
  - lib/relaton_iec/processor.rb
163
122
  - lib/relaton_iec/statuses.yml
164
123
  - lib/relaton_iec/tc_sc_officers_note.rb
124
+ - lib/relaton_iec/util.rb
165
125
  - lib/relaton_iec/version.rb
166
126
  - lib/relaton_iec/xml_parser.rb
167
127
  - relaton_iec.gemspec
@@ -177,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
137
  requirements:
178
138
  - - ">="
179
139
  - !ruby/object:Gem::Version
180
- version: 2.5.0
140
+ version: 2.7.0
181
141
  required_rubygems_version: !ruby/object:Gem::Requirement
182
142
  requirements:
183
143
  - - ">="