stepmod-utils 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/stepmod-srl-migrate +35 -2
- data/lib/stepmod/utils/change.rb +18 -3
- data/lib/stepmod/utils/change_edition.rb +6 -6
- data/lib/stepmod/utils/changes_extractor.rb +23 -7
- 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: 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.xpath("description").first),
|
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
|
+
|
113
|
+
change_edition = collection
|
114
|
+
.fetch_or_initialize(options[:schema_name], "mapping")
|
115
|
+
.change_editions
|
116
|
+
.fetch_or_initialize(options[:version])
|
117
|
+
|
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
|
+
|
109
125
|
change_edition = collection
|
110
|
-
.fetch_or_initialize(options[:schema_name], "
|
126
|
+
.fetch_or_initialize(options[:schema_name], "changes")
|
111
127
|
.change_editions
|
112
128
|
.fetch_or_initialize(options[:version])
|
113
129
|
|
114
|
-
change_edition.
|
130
|
+
change_edition.description = description
|
115
131
|
end
|
116
132
|
|
117
133
|
def extract_mapping_changes(change_node)
|
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
|