stepmod-utils 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/stepmod-annotate-all +2 -0
- data/exe/stepmod-srl-migrate +8 -1
- data/lib/stepmod/utils/stepmod_file_annotator.rb +106 -13
- data/lib/stepmod/utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f618abd79f952547eed2824f74873d2082d40803479f02a129974150305aa37e
|
4
|
+
data.tar.gz: c10d4c33ec8df86673f94402cddd84776cd3915f7230c3d931655c29c67ca144
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4da2323b7b031f79c5e48e4421846dfaae68bccd3bd2b7549534b8ee251642099d7d28645e351c4a20ed6a8242741e341adc5b72b7871eeadafa1451ada3c72a
|
7
|
+
data.tar.gz: d3546c0c7f062bcfc5b0793c164f16f348ed90e86668bef426d6125bfb3e0a220f334b07e54225d62fede2bf41bba754cec2f369b3e5790d931d848129814f3a
|
data/exe/stepmod-annotate-all
CHANGED
@@ -124,6 +124,8 @@ def all_express_files(stepmod_dir)
|
|
124
124
|
index.xpath("modules/module").each do |item|
|
125
125
|
files << "#{stepmod_dir}/data/modules/#{item['name']}/arm.exp"
|
126
126
|
files << "#{stepmod_dir}/data/modules/#{item['name']}/mim.exp"
|
127
|
+
files << "#{stepmod_dir}/data/modules/#{item['name']}/arm_lf.exp"
|
128
|
+
files << "#{stepmod_dir}/data/modules/#{item['name']}/mim_lf.exp"
|
127
129
|
end
|
128
130
|
|
129
131
|
# Skip resource schemas
|
data/exe/stepmod-srl-migrate
CHANGED
@@ -169,6 +169,13 @@ log "SRL output documents directory path: `#{srl_output_docs_dir}`"
|
|
169
169
|
log("*" * 30)
|
170
170
|
log("[SRL MIGRATION] Migration starts!")
|
171
171
|
|
172
|
+
# Excludes migration of originally detached documents
|
173
|
+
# See https://github.com/metanorma/iso-10303-srl/issues/67
|
174
|
+
STEPMOD2MN_ARGS_EXCLUDE_PARTS = %w(
|
175
|
+
49 50 52 55 104 108 109 110 111 112
|
176
|
+
501 502 505 507 508 509 510 511 512 513 514 519
|
177
|
+
).join(" ")
|
178
|
+
|
172
179
|
log("*" * 30)
|
173
180
|
log("[SRL MIGRATION: stepmod2mn.jar] START SVG generation.")
|
174
181
|
log("*" * 30)
|
@@ -180,7 +187,7 @@ log("[SRL MIGRATION: stepmod2mn.jar] COMPLETE SVG generation.")
|
|
180
187
|
log("*" * 30)
|
181
188
|
log("[SRL MIGRATION: stepmod2mn.jar] START document migration and SVG generation.")
|
182
189
|
log("*" * 30)
|
183
|
-
system "java -Xss5m -jar #{stepmod2mn_path} #{stepmod_dir} --output-documents #{srl_output_docs_dir} --output-schemas #{srl_output_schemas_dir}"
|
190
|
+
system "java -Xss5m -jar #{stepmod2mn_path} #{stepmod_dir} --output-documents #{srl_output_docs_dir} --output-schemas #{srl_output_schemas_dir} --exclude '#{STEPMOD2MN_ARGS_EXCLUDE_PARTS}'"
|
184
191
|
log("*" * 30)
|
185
192
|
log("[SRL MIGRATION: stepmod2mn.jar] COMPLETE document migration and SVG generation.")
|
186
193
|
|
@@ -12,7 +12,7 @@ require "pubid-iso"
|
|
12
12
|
module Stepmod
|
13
13
|
module Utils
|
14
14
|
class StepmodFileAnnotator
|
15
|
-
attr_reader :express_file, :resource_docs_cache, :stepmod_dir
|
15
|
+
attr_reader :express_file, :resource_docs_cache, :stepmod_dir, :schema_name
|
16
16
|
|
17
17
|
# @param express_file [String] path to the exp file needed to annotate
|
18
18
|
# @param resource_docs_cache [String] output of ./stepmod-build-resource-docs-cache
|
@@ -27,6 +27,65 @@ module Stepmod
|
|
27
27
|
.schemas
|
28
28
|
.first
|
29
29
|
.id
|
30
|
+
@schema_name = normalize_schema_name(@schema_name)
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
# Needed to fix scheme casing issues, e.g. xxx_LF => xxx_lf
|
35
|
+
def normalize_schema_name(name)
|
36
|
+
case name.downcase
|
37
|
+
# module schemas have first letter capitalized, rest in lowercase
|
38
|
+
when /_arm_lf\Z/i, /_mim_lf\Z/i, /_arm\Z/i, /_mim\Z/i
|
39
|
+
name.downcase.capitalize
|
40
|
+
# resource schemas are all in lowercase
|
41
|
+
else
|
42
|
+
name.downcase
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
SCHEMA_VERSION_MATCH_REGEX = /^SCHEMA [0-9a-zA-Z_]+;\s*$/
|
47
|
+
def is_missing_version(schema_content)
|
48
|
+
m = schema_content.match(SCHEMA_VERSION_MATCH_REGEX)
|
49
|
+
if m.nil?
|
50
|
+
false
|
51
|
+
elsif m[0] # match
|
52
|
+
true
|
53
|
+
else
|
54
|
+
false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_schema_string_with_version
|
59
|
+
# Geometric_tolerance_arm => geometric-tolarance-arm
|
60
|
+
name_in_asn1 = @schema_name.downcase.gsub("_", "-")
|
61
|
+
schema_type, type_number = case @schema_name.downcase
|
62
|
+
when /_arm\Z/i
|
63
|
+
[:module, 1]
|
64
|
+
when /_mim\Z/i
|
65
|
+
[:module, 2]
|
66
|
+
when /_arm_lf\Z/i
|
67
|
+
[:module, 3]
|
68
|
+
when /_mim_lf\Z/i
|
69
|
+
[:module, @module_has_arm_lf ? 4 : 3]
|
70
|
+
else # any resource schema without version strings
|
71
|
+
puts "[annotator-WARNING] this resource schema is missing a version string: #{@schema_name}"
|
72
|
+
[:resource, 1]
|
73
|
+
end
|
74
|
+
|
75
|
+
# TODO there are schemas with only arm, arm_lf:
|
76
|
+
# schemas/modules/reference_schema_for_sysml_mapping/arm_lf.exp
|
77
|
+
# TODO there are schemas with only arm, mim, mim_lf:
|
78
|
+
# schemas/modules/limited_length_or_area_indicator_assignment/mim_lf.exp
|
79
|
+
part = @identifier.part
|
80
|
+
edition = @identifier.edition
|
81
|
+
schema_or_object = (schema_type == :module) ? "schema" : "object"
|
82
|
+
|
83
|
+
"SCHEMA #{@schema_name} '{ " \
|
84
|
+
"iso standard 10303 part(#{part}) " \
|
85
|
+
"version(#{edition}) " \
|
86
|
+
"#{schema_or_object}(1) " \
|
87
|
+
"#{name_in_asn1}(#{type_number}) " \
|
88
|
+
"}';\n"
|
30
89
|
end
|
31
90
|
|
32
91
|
def resource_docs_schemas(stepmod_dir)
|
@@ -48,7 +107,7 @@ module Stepmod
|
|
48
107
|
end
|
49
108
|
|
50
109
|
def call
|
51
|
-
match = File.basename(express_file).match('^(arm|mim|bom)\.exp$')
|
110
|
+
match = File.basename(express_file).match('^(arm|mim|bom|arm_lf|mim_lf|DomainModel)\.exp$')
|
52
111
|
descriptions_base = match ? "#{match.captures[0]}_descriptions.xml" : "descriptions.xml"
|
53
112
|
|
54
113
|
descriptions_file = File.join(File.dirname(express_file),
|
@@ -107,8 +166,13 @@ module Stepmod
|
|
107
166
|
resource_docs_file_path(stepmod_dir, bib_file_name)
|
108
167
|
end
|
109
168
|
|
110
|
-
|
111
|
-
|
169
|
+
unless bib_file && File.exist?(bib_file)
|
170
|
+
raise StandardError.new(
|
171
|
+
"bib_file for #{schema_name} does not exist: #{bib_file}"
|
172
|
+
)
|
173
|
+
end
|
174
|
+
|
175
|
+
output_express << prepend_bibdata(
|
112
176
|
converted_description || "",
|
113
177
|
# bib_file will not be present for resouces
|
114
178
|
# that are not in resource_docs cache.
|
@@ -117,9 +181,16 @@ module Stepmod
|
|
117
181
|
@schema_name,
|
118
182
|
match,
|
119
183
|
)
|
120
|
-
|
121
|
-
|
122
|
-
|
184
|
+
|
185
|
+
if is_missing_version(output_express)
|
186
|
+
puts "[annotator-WARNING] schema (#{@schema_name}) missing version string. "\
|
187
|
+
"Adding: `#{build_schema_string_with_version}` to schema."
|
188
|
+
|
189
|
+
output_express.gsub!(
|
190
|
+
SCHEMA_VERSION_MATCH_REGEX,
|
191
|
+
build_schema_string_with_version
|
192
|
+
)
|
193
|
+
end
|
123
194
|
|
124
195
|
{
|
125
196
|
annotated_text: sanitize(output_express),
|
@@ -171,7 +242,11 @@ processed_images_cache)
|
|
171
242
|
|
172
243
|
converted_description = <<~DESCRIPTION
|
173
244
|
|
174
|
-
#{Stepmod::Utils::SmrlDescriptionConverter.convert(
|
245
|
+
#{Stepmod::Utils::SmrlDescriptionConverter.convert(
|
246
|
+
wrapper,
|
247
|
+
no_notes_examples: true,
|
248
|
+
descriptions_file: descriptions_file
|
249
|
+
)}
|
175
250
|
DESCRIPTION
|
176
251
|
|
177
252
|
if description["linkend"].nil?
|
@@ -216,12 +291,15 @@ processed_images_cache)
|
|
216
291
|
bib = Nokogiri::XML(File.read(bibdata_file)).root
|
217
292
|
bibdata = extract_bib_data(match, bib, schema_and_entity)
|
218
293
|
|
294
|
+
# for schema version string generation
|
295
|
+
@identifier = bibdata[:identifier]
|
296
|
+
|
219
297
|
return description.to_s if @added_bibdata[schema_and_entity]
|
220
298
|
|
221
299
|
published_in = <<~PUBLISHED_IN
|
222
300
|
|
223
301
|
(*"#{schema_and_entity}.__published_in"
|
224
|
-
#{bibdata[:identifier]}
|
302
|
+
#{bibdata[:identifier].to_s(with_edition: true)}
|
225
303
|
*)
|
226
304
|
PUBLISHED_IN
|
227
305
|
|
@@ -269,17 +347,17 @@ processed_images_cache)
|
|
269
347
|
end
|
270
348
|
|
271
349
|
def module?(match)
|
272
|
-
match && %w[arm mim].include?(match.captures[0])
|
350
|
+
match && %w[arm mim arm_lf mim_lf].include?(match.captures[0])
|
273
351
|
end
|
274
352
|
|
275
353
|
def bom?(match)
|
276
|
-
match && %w[bom].include?(match.captures[0])
|
354
|
+
match && %w[bom DomainModel].include?(match.captures[0])
|
277
355
|
end
|
278
356
|
|
279
357
|
def extract_bib_file_name(match, default_file_name = "")
|
280
358
|
return default_file_name || "" unless match
|
281
359
|
|
282
|
-
if %w[arm mim].include?(match.captures[0])
|
360
|
+
if %w[arm mim arm_lf mim_lf].include?(match.captures[0])
|
283
361
|
"module.xml"
|
284
362
|
else
|
285
363
|
"business_object_model.xml"
|
@@ -287,9 +365,21 @@ processed_images_cache)
|
|
287
365
|
end
|
288
366
|
|
289
367
|
def extract_bib_data(match, bib, schema_and_entity)
|
368
|
+
# for schema version string generation
|
369
|
+
@identifier = identifier(bib)
|
370
|
+
|
290
371
|
return resource_bib_data(bib, schema_and_entity) unless match
|
291
372
|
|
292
373
|
if module?(match)
|
374
|
+
@module_has_arm = !bib.xpath("arm").first.nil?
|
375
|
+
@module_has_mim = !bib.xpath("mim").first.nil?
|
376
|
+
@module_has_arm_lf = !bib.xpath("arm_lf").first.nil?
|
377
|
+
@module_has_mim_lf = !bib.xpath("mim_lf").first.nil?
|
378
|
+
|
379
|
+
puts "[annotator] module has schemas: " \
|
380
|
+
"ARM(#{@module_has_arm}) MIM(#{@module_has_mim}) " \
|
381
|
+
"ARM_LF(#{@module_has_arm_lf}) MIM_LF(#{@module_has_mim_lf})"
|
382
|
+
|
293
383
|
module_bib_data(bib, match.captures[0])
|
294
384
|
elsif bom?(match)
|
295
385
|
bom_bib_data(bib)
|
@@ -314,7 +404,7 @@ processed_images_cache)
|
|
314
404
|
pubid.year = year.split("-").first if year && !year.empty?
|
315
405
|
pubid.edition = edition if edition && !edition.empty?
|
316
406
|
|
317
|
-
pubid
|
407
|
+
pubid
|
318
408
|
end
|
319
409
|
|
320
410
|
def resource_bib_data(bib, schema_and_entity)
|
@@ -322,6 +412,7 @@ processed_images_cache)
|
|
322
412
|
|
323
413
|
{
|
324
414
|
identifier: identifier(bib),
|
415
|
+
edition: bib.attributes["version"],
|
325
416
|
number: schema.attributes["number"],
|
326
417
|
supersedes_concept: schema.attributes["number.supersedes"],
|
327
418
|
status: bib.attributes["status"],
|
@@ -332,6 +423,7 @@ processed_images_cache)
|
|
332
423
|
def module_bib_data(bib, type)
|
333
424
|
{
|
334
425
|
identifier: identifier(bib),
|
426
|
+
edition: bib.attributes["version"],
|
335
427
|
number: bib.attributes["wg.number.#{type}"],
|
336
428
|
supersedes_concept: bib.attributes["wg.number.#{type}.supersedes"],
|
337
429
|
status: bib.attributes["status"],
|
@@ -342,6 +434,7 @@ processed_images_cache)
|
|
342
434
|
def bom_bib_data(bib)
|
343
435
|
{
|
344
436
|
identifier: identifier(bib),
|
437
|
+
edition: bib.attributes["version"],
|
345
438
|
number: bib.attributes["wg.number.bom.exp"],
|
346
439
|
supersedes_concept: bib.attributes["wg.number.bom.supersedes"],
|
347
440
|
status: bib.attributes["status"],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stepmod-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.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: 2024-04-
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|