stepmod-utils 0.4.12 → 0.4.14
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e899495da23543691f64da8ac653723b58d18d6c56dc3079d03de2ff4c82b76d
|
|
4
|
+
data.tar.gz: c7c95af88056dc3afccdd7e2a627539027fafe58b984e55f89f4d4e84d5d5466
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 599a6815246bc9a9242be9bafd86e9adb0ad16d29f93295b2772eeceffe5773a6560a23a563890f7ef8d1a1a3e23e849b9f2f3d6abfc3f7a3de55d554c17491e
|
|
7
|
+
data.tar.gz: af84267ff33afbb543de2b491b7c4bbc1ecd7c837235a75a5cee8e4136d4b8fffb89b5778a6b9448a5f787fffbe31775a6e5c800c057375189dfb031f9957e4d
|
data/exe/stepmod-srl-migrate
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
require "pathname"
|
|
6
6
|
require "fileutils"
|
|
7
|
+
require "nokogiri"
|
|
7
8
|
bin_file = Pathname.new(__FILE__).realpath
|
|
8
9
|
|
|
9
10
|
# add self to libpath
|
|
@@ -17,11 +18,11 @@ def log(message, indent = 0)
|
|
|
17
18
|
puts "[stepmod-utils] #{message}"
|
|
18
19
|
end
|
|
19
20
|
|
|
20
|
-
def copy_files_to_schemas(path, stepmod_path,
|
|
21
|
+
def copy_files_to_schemas(path, stepmod_path, srl_output_schemas_dir)
|
|
21
22
|
base_path = path.dirname.relative_path_from(File.join(stepmod_path, "data"))
|
|
22
23
|
file_name = path.basename
|
|
23
24
|
|
|
24
|
-
new_dir = File.join(
|
|
25
|
+
new_dir = File.join(srl_output_schemas_dir, base_path.to_s)
|
|
25
26
|
new_file_path = File.join(new_dir, file_name)
|
|
26
27
|
|
|
27
28
|
unless Dir.exist?(new_dir)
|
|
@@ -32,6 +33,29 @@ def copy_files_to_schemas(path, stepmod_path, srl_output_docs_dir)
|
|
|
32
33
|
log("Copied #{path.basename} to #{new_file_path}", 1)
|
|
33
34
|
end
|
|
34
35
|
|
|
36
|
+
def copy_files_to_document(path, stepmod_path, srl_output_docs_dir)
|
|
37
|
+
base_path = path.dirname.relative_path_from(File.join(stepmod_path, "data"))
|
|
38
|
+
file_name = path.basename
|
|
39
|
+
module_xml_path = path.dirname.join('module.xml')
|
|
40
|
+
# puts "module_xml_path #{module_xml_path}"
|
|
41
|
+
module_xml = Nokogiri::XML(IO.read(module_xml_path)).root
|
|
42
|
+
|
|
43
|
+
part_number = module_xml.xpath('//module').first.attr('part')
|
|
44
|
+
# module_name = module_xml.xpath('//module').first.attr('name')
|
|
45
|
+
|
|
46
|
+
new_dir = File.join(srl_output_docs_dir, "iso-10303-#{part_number}")
|
|
47
|
+
new_file_path = File.join(new_dir, file_name)
|
|
48
|
+
# new_file_path = File.join(new_dir, "#{module_name}.#{file_name}")
|
|
49
|
+
|
|
50
|
+
## The document directory should already exist.
|
|
51
|
+
# unless Dir.exist?(new_dir)
|
|
52
|
+
# FileUtils.mkdir_p(new_dir)
|
|
53
|
+
# end
|
|
54
|
+
|
|
55
|
+
FileUtils.copy_file(path, new_file_path)
|
|
56
|
+
log("Copied #{path.basename} to #{new_file_path}", 1)
|
|
57
|
+
end
|
|
58
|
+
|
|
35
59
|
options = {}
|
|
36
60
|
OptionParser.new do |opts|
|
|
37
61
|
opts.banner = "Usage: #{$0} [options]"
|
|
@@ -171,10 +195,19 @@ log("[SRL MIGRATION: stepmod-utils] COMPLETE Annotated EXPRESS generation.")
|
|
|
171
195
|
log("*"*30)
|
|
172
196
|
log("[SRL MIGRATION: stepmod-utils] START EXPRESS change YAML extraction.")
|
|
173
197
|
system "stepmod-extract-changes -p #{stepmod_dir}"
|
|
198
|
+
|
|
199
|
+
# Move arm/mim/arm_lf/mim_lf/mapping changes into schema directories
|
|
174
200
|
Dir.glob("#{stepmod_dir}/data/**/*.changes.yaml").each do |filepath|
|
|
175
201
|
path = Pathname.new(filepath)
|
|
176
202
|
copy_files_to_schemas(path, stepmod_dir, srl_output_schemas_dir)
|
|
177
203
|
end
|
|
204
|
+
|
|
205
|
+
# Move document changes into document directories
|
|
206
|
+
Dir.glob("#{stepmod_dir}/data/**/changes.yaml").each do |filepath|
|
|
207
|
+
path = Pathname.new(filepath)
|
|
208
|
+
copy_files_to_document(path, stepmod_dir, srl_output_docs_dir)
|
|
209
|
+
end
|
|
210
|
+
|
|
178
211
|
log("*"*30)
|
|
179
212
|
log("[SRL MIGRATION: stepmod-utils] COMPLETE EXPRESS change YAML extraction.")
|
|
180
213
|
|
data/lib/stepmod/utils/change.rb
CHANGED
|
@@ -13,6 +13,8 @@ module Stepmod
|
|
|
13
13
|
mim: "mim",
|
|
14
14
|
arm_longform: "arm_lf",
|
|
15
15
|
mim_longform: "mim_lf",
|
|
16
|
+
mapping: "mapping",
|
|
17
|
+
changes: "",
|
|
16
18
|
}.freeze
|
|
17
19
|
|
|
18
20
|
def initialize(stepmod_dir:, schema_name:, type:)
|
|
@@ -40,13 +42,20 @@ module Stepmod
|
|
|
40
42
|
alias_method :[], :fetch_change_edition
|
|
41
43
|
|
|
42
44
|
def save_to_file
|
|
43
|
-
|
|
45
|
+
change_hash = to_h
|
|
46
|
+
return if change_hash.empty?
|
|
47
|
+
|
|
48
|
+
File.write(filepath(@type), Psych.dump(change_hash))
|
|
44
49
|
end
|
|
45
50
|
|
|
46
51
|
def to_h
|
|
52
|
+
change_editions_list = change_editions.to_h
|
|
53
|
+
|
|
54
|
+
return {} if change_editions_list.empty?
|
|
55
|
+
|
|
47
56
|
{
|
|
48
57
|
"schema" => schema_name,
|
|
49
|
-
"change_edition" =>
|
|
58
|
+
"change_edition" => change_editions_list,
|
|
50
59
|
}
|
|
51
60
|
end
|
|
52
61
|
|
|
@@ -58,10 +67,16 @@ module Stepmod
|
|
|
58
67
|
"data",
|
|
59
68
|
base_folder,
|
|
60
69
|
schema_name,
|
|
61
|
-
|
|
70
|
+
filename(type),
|
|
62
71
|
)
|
|
63
72
|
end
|
|
64
73
|
|
|
74
|
+
def filename(type)
|
|
75
|
+
return "changes.yaml" if type.to_s == "changes"
|
|
76
|
+
|
|
77
|
+
"#{MODULE_TYPES[type.to_sym] || schema_name}.changes.yaml"
|
|
78
|
+
end
|
|
79
|
+
|
|
65
80
|
def base_folder
|
|
66
81
|
if resource?
|
|
67
82
|
"resources"
|
|
@@ -2,7 +2,7 @@ module Stepmod
|
|
|
2
2
|
module Utils
|
|
3
3
|
class ChangeEdition
|
|
4
4
|
attr_accessor :version, :description
|
|
5
|
-
attr_reader :additions, :modifications, :deletions, :
|
|
5
|
+
attr_reader :additions, :modifications, :deletions, :changes
|
|
6
6
|
|
|
7
7
|
def initialize(options)
|
|
8
8
|
@version = options[:version]
|
|
@@ -10,7 +10,7 @@ module Stepmod
|
|
|
10
10
|
self.additions = options[:additions] || []
|
|
11
11
|
self.modifications = options[:modifications] || []
|
|
12
12
|
self.deletions = options[:deletions] || []
|
|
13
|
-
self.
|
|
13
|
+
self.changes = options[:changes] || []
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def additions=(additions)
|
|
@@ -31,10 +31,10 @@ module Stepmod
|
|
|
31
31
|
@deletions = deletions
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def
|
|
35
|
-
validate_type("
|
|
34
|
+
def changes=(changes)
|
|
35
|
+
validate_type("changes", changes, Array)
|
|
36
36
|
|
|
37
|
-
@
|
|
37
|
+
@changes = changes
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def to_h
|
|
@@ -44,7 +44,7 @@ module Stepmod
|
|
|
44
44
|
"additions" => additions,
|
|
45
45
|
"modifications" => modifications,
|
|
46
46
|
"deletions" => deletions,
|
|
47
|
-
"
|
|
47
|
+
"changes" => changes,
|
|
48
48
|
}.reject { |_k, v| v.nil? || v.empty? }
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -64,9 +64,12 @@ module Stepmod
|
|
|
64
64
|
options = {
|
|
65
65
|
schema_name: schema_name,
|
|
66
66
|
version: change_node.attr("version"),
|
|
67
|
-
description: converted_description(change_node.
|
|
67
|
+
# description: converted_description(change_node.xpath("description").first),
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
add_mapping_changes(collection, change_node, options)
|
|
71
|
+
add_changes(collection, change_node, options)
|
|
72
|
+
|
|
70
73
|
MODULE_TYPES.each do |type|
|
|
71
74
|
add_module_changes(
|
|
72
75
|
collection,
|
|
@@ -97,21 +100,34 @@ module Stepmod
|
|
|
97
100
|
schema_name = options[:schema_name]
|
|
98
101
|
change = collection.fetch_or_initialize(schema_name, type)
|
|
99
102
|
|
|
103
|
+
return if changes.nil?
|
|
104
|
+
|
|
100
105
|
change_edition = extract_change_edition(changes, options)
|
|
101
106
|
change.add_change_edition(change_edition)
|
|
102
|
-
|
|
103
|
-
if type == "arm"
|
|
104
|
-
add_mapping_changes(collection, change_node, options)
|
|
105
|
-
end
|
|
106
107
|
end
|
|
107
108
|
|
|
108
109
|
def add_mapping_changes(collection, change_node, options)
|
|
110
|
+
mapping_changes = extract_mapping_changes(change_node)
|
|
111
|
+
return if mapping_changes.empty?
|
|
112
|
+
|
|
109
113
|
change_edition = collection
|
|
110
|
-
.fetch_or_initialize(options[:schema_name], "
|
|
114
|
+
.fetch_or_initialize(options[:schema_name], "mapping")
|
|
111
115
|
.change_editions
|
|
112
116
|
.fetch_or_initialize(options[:version])
|
|
113
117
|
|
|
114
|
-
change_edition.
|
|
118
|
+
change_edition.changes = mapping_changes
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def add_changes(collection, change_node, options)
|
|
122
|
+
description = converted_description(change_node.xpath("description").first)
|
|
123
|
+
return if description.nil? || description.empty?
|
|
124
|
+
|
|
125
|
+
change_edition = collection
|
|
126
|
+
.fetch_or_initialize(options[:schema_name], "changes")
|
|
127
|
+
.change_editions
|
|
128
|
+
.fetch_or_initialize(options[:version])
|
|
129
|
+
|
|
130
|
+
change_edition.description = description
|
|
115
131
|
end
|
|
116
132
|
|
|
117
133
|
def extract_mapping_changes(change_node)
|
|
@@ -132,9 +148,11 @@ module Stepmod
|
|
|
132
148
|
|
|
133
149
|
def extract_change_edition(schema_changes, options)
|
|
134
150
|
type = options[:type] || "schema"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
151
|
+
node_type = type.gsub("_longform", "")
|
|
152
|
+
|
|
153
|
+
addition_nodes = schema_changes&.xpath("#{node_type}.additions") || []
|
|
154
|
+
modification_nodes = schema_changes&.xpath("#{node_type}.modifications") || []
|
|
155
|
+
deletion_nodes = schema_changes&.xpath("#{node_type}.deletions") || []
|
|
138
156
|
|
|
139
157
|
{
|
|
140
158
|
version: options[:version],
|
|
@@ -36,6 +36,7 @@ module Stepmod
|
|
|
36
36
|
text = preserve_keychars_within_backticks(text)
|
|
37
37
|
|
|
38
38
|
text = preserve_pipes_within_tables(text, state)
|
|
39
|
+
text = wrap_if_contains_spaces(text, state)
|
|
39
40
|
preserve_tags(text, state)
|
|
40
41
|
end
|
|
41
42
|
|
|
@@ -53,6 +54,12 @@ module Stepmod
|
|
|
53
54
|
text.gsub(/\A\n+/, "").gsub(/\n+\z/, "")
|
|
54
55
|
end
|
|
55
56
|
|
|
57
|
+
def wrap_if_contains_spaces(text, state)
|
|
58
|
+
return "(#{text})" if state[:equation] && text.strip.match?(/\s/) && text.match?(/^[A-Za-z ]+$/)
|
|
59
|
+
|
|
60
|
+
text
|
|
61
|
+
end
|
|
62
|
+
|
|
56
63
|
def remove_inner_newlines(text)
|
|
57
64
|
text.tr("\n\t", " ").squeeze(" ")
|
|
58
65
|
end
|
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.4.
|
|
4
|
+
version: 0.4.14
|
|
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-
|
|
11
|
+
date: 2024-02-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|