suma 0.1.1 → 0.1.2
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 +4 -4
- data/lib/suma/schema_attachment.rb +8 -7
- data/lib/suma/schema_collection.rb +0 -2
- data/lib/suma/schema_config/config.rb +35 -25
- data/lib/suma/schema_config/schema.rb +6 -0
- data/lib/suma/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: 7d5ebe81c947831dfcd9c94b3eeea2a34f33d29c548a59a55347b35adecaecc7
|
4
|
+
data.tar.gz: '085a461362248532759fe4d47ce5e0e7ff510147a97537c17e039878ae2e503a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df8f83de715f1dfe7bff547a539717841f0595f02c003caa69a2b09f24e50c02d9a7c1372dce6f7cfe4055e0c05ecd023b8b3033b966dd4e1016f4768bbf5b0c
|
7
|
+
data.tar.gz: 323215a01e582ad8d223bf76916454ca8ee23dd8d2a8f4bde78c1f57631b50da65cf05d83b6c94e9f94052fed943dfed73bfd05434a94f70414e1054652bc722
|
@@ -68,13 +68,14 @@ module Suma
|
|
68
68
|
File.join(@output_path, "schema_#{@schema.id}.yaml")
|
69
69
|
end
|
70
70
|
|
71
|
-
def to_config
|
71
|
+
def to_config(path: nil)
|
72
72
|
# return @config unless @config
|
73
73
|
@config = SchemaConfig::Config.new
|
74
74
|
@config.schemas << SchemaConfig::Schema.new(
|
75
75
|
id: @schema.id,
|
76
|
-
path: @schema.path
|
76
|
+
path: @schema.path,
|
77
77
|
)
|
78
|
+
path and @config.path = path
|
78
79
|
|
79
80
|
@config
|
80
81
|
end
|
@@ -83,16 +84,16 @@ module Suma
|
|
83
84
|
relative_path = Pathname.new(filename_config).relative_path_from(Dir.pwd)
|
84
85
|
Utils.log "Save schema config: #{relative_path}"
|
85
86
|
|
87
|
+
# Still overwrite even if the file exists
|
86
88
|
# return if File.exist?(filename_config)
|
87
89
|
FileUtils.mkdir_p(File.dirname(filename_config))
|
88
90
|
|
89
|
-
|
90
|
-
file.write(to_config.to_yaml)
|
91
|
-
end
|
91
|
+
to_config.save_to_path(filename_config)
|
92
92
|
end
|
93
93
|
|
94
94
|
# Compile Metanorma adoc per EXPRESS schema
|
95
95
|
def compile
|
96
|
+
# TODO: Clean artifacts after compiling
|
96
97
|
# I am commenting out because I'm playing with the schemas-only status
|
97
98
|
# return self if File.exist?(output_xml_path)
|
98
99
|
|
@@ -104,7 +105,7 @@ module Suma
|
|
104
105
|
Metanorma::Compile.new.compile(
|
105
106
|
filename_adoc,
|
106
107
|
agree_to_terms: true,
|
107
|
-
install_fonts: false
|
108
|
+
install_fonts: false,
|
108
109
|
)
|
109
110
|
Utils.log "Compiling schema (id: #{id}, type: #{self.class}) => #{relative_path}... done!"
|
110
111
|
|
@@ -124,7 +125,7 @@ module Suma
|
|
124
125
|
filename_adoc,
|
125
126
|
filename_adoc("presentation.xml"),
|
126
127
|
filename_adoc("adoc.lutaml.log.txt"),
|
127
|
-
filename_adoc("err.html")
|
128
|
+
filename_adoc("err.html"),
|
128
129
|
].each do |filename|
|
129
130
|
FileUtils.rm_rf(filename)
|
130
131
|
end
|
@@ -9,6 +9,7 @@ module Suma
|
|
9
9
|
class Config < Shale::Mapper
|
10
10
|
attribute :schemas, Schema, collection: true
|
11
11
|
attribute :path, Shale::Type::String
|
12
|
+
attr_accessor :output_path
|
12
13
|
|
13
14
|
def initialize(**args)
|
14
15
|
@path = path_relative_to_absolute(path) if path
|
@@ -39,6 +40,7 @@ module Suma
|
|
39
40
|
@path = path_relative_to_absolute(new_path)
|
40
41
|
schemas.each do |schema|
|
41
42
|
schema.path = path_relative_to_absolute(schema.path)
|
43
|
+
schema.container_path = File.expand_path(@path)
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
@@ -48,17 +50,25 @@ module Suma
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
|
-
# TODO: I can't get the relative path working. The schemas-*.yaml file is
|
52
|
-
# meant to contain the "path" key, which is a relative path to its
|
53
|
-
# location, then sets the base path to each schema path, which is supposed
|
54
|
-
# to be relative to "path" key. Somehow, the @path variable is always
|
55
|
-
# missing in to_yaml...
|
56
53
|
def schemas_to_yaml(model, doc)
|
57
|
-
# puts "^"*30
|
58
|
-
# pp self
|
59
|
-
# pp @path
|
60
54
|
doc["schemas"] = model.schemas.sort_by(&:id).to_h do |schema|
|
61
|
-
|
55
|
+
# We are outputting the schemas collection file to the directory where
|
56
|
+
# the collection config is at (assumed to be Dir.pwd), not to the
|
57
|
+
# directory we sourced the manifest from, e.g.
|
58
|
+
# documents/iso-10303-41/schemas.yaml.
|
59
|
+
|
60
|
+
# So the schema.container_path = @config.path is not
|
61
|
+
# in fact needed, as the files are already absolute. This notion of
|
62
|
+
# using @path to create relative paths was misconceived
|
63
|
+
[
|
64
|
+
schema.id,
|
65
|
+
{
|
66
|
+
"path" => path_absolute_to_relative(
|
67
|
+
schema.path,
|
68
|
+
model.output_path || Dir.pwd,
|
69
|
+
),
|
70
|
+
},
|
71
|
+
]
|
62
72
|
end
|
63
73
|
end
|
64
74
|
|
@@ -68,20 +78,18 @@ module Suma
|
|
68
78
|
|
69
79
|
# Or based on current working directory?
|
70
80
|
return relative_path unless @path
|
81
|
+
# ... but if this calculates path, we end up expanding it anyway
|
71
82
|
|
72
83
|
Pathname.new(File.dirname(@path)).join(eval_path).expand_path.to_s
|
73
84
|
end
|
74
85
|
|
75
|
-
def path_absolute_to_relative(absolute_path)
|
76
|
-
|
77
|
-
|
78
|
-
# pp path
|
79
|
-
# pp @hello
|
80
|
-
return absolute_path unless @path
|
86
|
+
def path_absolute_to_relative(absolute_path, container_path)
|
87
|
+
container_path ||= @path
|
88
|
+
return absolute_path unless container_path
|
81
89
|
|
82
|
-
|
83
|
-
|
84
|
-
|
90
|
+
p = Pathname.new(container_path)
|
91
|
+
container = p.directory? ? p.to_s : p.dirname
|
92
|
+
Pathname.new(absolute_path).relative_path_from(container).to_s
|
85
93
|
end
|
86
94
|
|
87
95
|
def update_path(new_path)
|
@@ -98,8 +106,8 @@ module Suma
|
|
98
106
|
next if schema_path.absolute?
|
99
107
|
|
100
108
|
schema_path = (Pathname.new(old_base_path) + schema_path).cleanpath
|
101
|
-
|
102
|
-
schema.path =
|
109
|
+
# This is the new relative schema_path
|
110
|
+
schema.path = schema_path.relative_path_from(new_base_path)
|
103
111
|
end
|
104
112
|
|
105
113
|
@path = new_path
|
@@ -107,7 +115,7 @@ module Suma
|
|
107
115
|
|
108
116
|
def concat(another_config)
|
109
117
|
unless another_config.is_a?(self.class)
|
110
|
-
raise StandardError, "Can only
|
118
|
+
raise StandardError, "Can only concat a SchemaConfig::Config object."
|
111
119
|
end
|
112
120
|
|
113
121
|
# We need to update the relative paths when paths exist
|
@@ -120,13 +128,15 @@ module Suma
|
|
120
128
|
end
|
121
129
|
|
122
130
|
def save_to_path(filename)
|
123
|
-
new_config = dup
|
124
|
-
|
125
|
-
|
131
|
+
new_config = dup.tap do |c|
|
132
|
+
c.path = filename
|
133
|
+
c.update_path(File.dirname(filename))
|
134
|
+
c.output_path = filename
|
135
|
+
end
|
126
136
|
|
127
137
|
File.open(filename, "w") do |f|
|
128
138
|
Utils.log "Writing #{filename}..."
|
129
|
-
f.write(to_yaml)
|
139
|
+
f.write(new_config.to_yaml)
|
130
140
|
Utils.log "Done."
|
131
141
|
end
|
132
142
|
end
|
@@ -8,6 +8,12 @@ module Suma
|
|
8
8
|
attribute :id, Shale::Type::String
|
9
9
|
attribute :path, Shale::Type::String
|
10
10
|
# attribute :schemas_only, Shale::Type::Boolean
|
11
|
+
|
12
|
+
# container_path is a copy of Suma::SchemaConfig::Config.path,
|
13
|
+
# used to resolve the path of each schema within
|
14
|
+
# Suma::SchemaConfig::Config.schemas,
|
15
|
+
# when Suma::SchemaConfig::Config.schemas is recursively flattened
|
16
|
+
attr_accessor :container_path
|
11
17
|
end
|
12
18
|
end
|
13
19
|
end
|
data/lib/suma/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: suma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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-06-
|
11
|
+
date: 2024-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expressir
|