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 +4 -4
- data/.github/workflows/release.yml +2 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/Gemfile +3 -0
- data/grammars/biblio.rng +1 -1
- data/lib/relaton_iec/config.rb +10 -0
- data/lib/relaton_iec/data_parser.rb +1 -1
- data/lib/relaton_iec/iec_bibliographic_item.rb +5 -7
- data/lib/relaton_iec/iec_bibliography.rb +90 -29
- data/lib/relaton_iec/index.rb +1 -1
- data/lib/relaton_iec/util.rb +9 -0
- data/lib/relaton_iec/version.rb +1 -1
- data/lib/relaton_iec/xml_parser.rb +1 -1
- data/lib/relaton_iec.rb +6 -4
- data/relaton_iec.gemspec +2 -6
- metadata +7 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22c30d32d348985a90f88d21872741162ebef459ccff4fc118597f196e53f4b9
|
4
|
+
data.tar.gz: 5a265ce8efceee119c822824eb347ace8aeedd9f695b23b7270a22d150da3678
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/.rubocop.yml
CHANGED
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
@@ -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-
|
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
|
-
|
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 "
|
38
|
-
warn "
|
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 "
|
43
|
-
|
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 =
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
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 "
|
60
|
-
|
61
|
-
|
62
|
-
|
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 "
|
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(
|
188
|
-
result = search_filter(
|
189
|
-
ret = results_filter(result,
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
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
|
data/lib/relaton_iec/index.rb
CHANGED
data/lib/relaton_iec/version.rb
CHANGED
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.
|
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.
|
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.
|
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-
|
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.
|
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.
|
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.
|
140
|
+
version: 2.7.0
|
181
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
142
|
requirements:
|
183
143
|
- - ">="
|