suma 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +77 -0
- data/lib/suma/cli.rb +6 -4
- data/lib/suma/collection_manifest.rb +3 -3
- data/lib/suma/processor.rb +7 -41
- data/lib/suma/schema_attachment.rb +1 -1
- data/lib/suma/schema_collection.rb +7 -6
- data/lib/suma/schema_config/config.rb +1 -0
- data/lib/suma/schema_document.rb +45 -9
- data/lib/suma/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3574bcc351316187d71e125e1ba19a8c3c275993b1a87d0c24cd050831507ca
|
4
|
+
data.tar.gz: cc8392459a664fcb6cf2202a8ebdc8346b2db0f4712e24e306cc2b805bd03c60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f83fdb2f934c410f4f434a98d49d46dc5a9d0ce619496a627c9803ed049e28a62b8a50c3c7eafddbbe2204f8486657927a5a2936a170292473ed939e6b5b471f
|
7
|
+
data.tar.gz: 7c2ed86bc187638f15957e53299b481563ae874e565bd8a92aedfb3cd30a5825dfb77a37122245132bc6feb9d869b67c8d023e0c6a51e29fd66dc069e6316a3d
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2024-10-17 02:50:55 UTC using RuboCop version 1.67.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 3
|
10
|
+
# Configuration parameters: Severity, Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/DuplicatedAssignment:
|
13
|
+
Exclude:
|
14
|
+
- 'suma.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
# Configuration parameters: Severity, Include.
|
18
|
+
# Include: **/*.gemspec
|
19
|
+
Gemspec/RequiredRubyVersion:
|
20
|
+
Exclude:
|
21
|
+
- 'suma.gemspec'
|
22
|
+
|
23
|
+
# Offense count: 21
|
24
|
+
# This cop supports safe autocorrection (--autocorrect).
|
25
|
+
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
26
|
+
# URISchemes: http, https
|
27
|
+
Layout/LineLength:
|
28
|
+
Exclude:
|
29
|
+
- 'lib/suma/cli.rb'
|
30
|
+
- 'lib/suma/collection_manifest.rb'
|
31
|
+
- 'lib/suma/processor.rb'
|
32
|
+
- 'lib/suma/schema_attachment.rb'
|
33
|
+
- 'lib/suma/schema_collection.rb'
|
34
|
+
- 'lib/suma/schema_document.rb'
|
35
|
+
- 'lib/suma/thor_ext.rb'
|
36
|
+
- 'suma.gemspec'
|
37
|
+
|
38
|
+
# Offense count: 1
|
39
|
+
Lint/DuplicateMethods:
|
40
|
+
Exclude:
|
41
|
+
- 'lib/suma/express_schema.rb'
|
42
|
+
|
43
|
+
# Offense count: 8
|
44
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
45
|
+
Metrics/AbcSize:
|
46
|
+
Exclude:
|
47
|
+
- 'lib/suma/collection_manifest.rb'
|
48
|
+
- 'lib/suma/processor.rb'
|
49
|
+
- 'lib/suma/schema_attachment.rb'
|
50
|
+
- 'lib/suma/schema_collection.rb'
|
51
|
+
- 'lib/suma/schema_config/config.rb'
|
52
|
+
- 'lib/suma/schema_document.rb'
|
53
|
+
- 'lib/suma/thor_ext.rb'
|
54
|
+
|
55
|
+
# Offense count: 1
|
56
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
57
|
+
# AllowedMethods: refine
|
58
|
+
Metrics/BlockLength:
|
59
|
+
Max: 33
|
60
|
+
|
61
|
+
# Offense count: 2
|
62
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
63
|
+
Metrics/CyclomaticComplexity:
|
64
|
+
Exclude:
|
65
|
+
- 'lib/suma/collection_manifest.rb'
|
66
|
+
- 'lib/suma/thor_ext.rb'
|
67
|
+
|
68
|
+
# Offense count: 7
|
69
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
70
|
+
Metrics/MethodLength:
|
71
|
+
Max: 52
|
72
|
+
|
73
|
+
# Offense count: 1
|
74
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
75
|
+
Metrics/PerceivedComplexity:
|
76
|
+
Exclude:
|
77
|
+
- 'lib/suma/schema_collection.rb'
|
data/lib/suma/cli.rb
CHANGED
@@ -9,8 +9,10 @@ module Suma
|
|
9
9
|
class Cli < Thor
|
10
10
|
extend ThorExt::Start
|
11
11
|
|
12
|
-
desc "build METANORMA_SITE_MANIFEST",
|
13
|
-
|
12
|
+
desc "build METANORMA_SITE_MANIFEST",
|
13
|
+
"Build collection specified in site manifest (`metanorma*.yml`)"
|
14
|
+
option :compile, type: :boolean, default: true,
|
15
|
+
desc: "Compile or skip compile of collection"
|
14
16
|
option :schemas_all_path, type: :string, aliases: "-s",
|
15
17
|
desc: "Generate file that contains all schemas in the collection."
|
16
18
|
|
@@ -22,14 +24,14 @@ module Suma
|
|
22
24
|
|
23
25
|
# Set schemas_all_path to match metanorma_yaml_path
|
24
26
|
schemas_all_path = options[:schemas_all_path] ||
|
25
|
-
|
27
|
+
metanorma_site_manifest.gsub("metanorma", "schemas")
|
26
28
|
|
27
29
|
begin
|
28
30
|
Processor.run(
|
29
31
|
metanorma_yaml_path: metanorma_site_manifest,
|
30
32
|
schemas_all_path: schemas_all_path,
|
31
33
|
compile: options[:compile],
|
32
|
-
output_directory: "_site"
|
34
|
+
output_directory: "_site",
|
33
35
|
)
|
34
36
|
rescue StandardError => e
|
35
37
|
Utils.log "[ERROR] Error occurred during processing. See details below."
|
@@ -69,7 +69,7 @@ module Suma
|
|
69
69
|
|
70
70
|
# If there is collection.yml, this is a document collection, we process
|
71
71
|
# schemas.yaml.
|
72
|
-
if File.basename(file) ==
|
72
|
+
if File.basename(file) == "collection.yml"
|
73
73
|
schemas_yaml_path = File.join(File.dirname(file), "schemas.yaml")
|
74
74
|
if schemas_yaml_path && File.exist?(schemas_yaml_path)
|
75
75
|
@schema_config = Suma::SchemaConfig::Config.from_file(schemas_yaml_path)
|
@@ -99,8 +99,8 @@ module Suma
|
|
99
99
|
# we need to separate this file from the following new entries
|
100
100
|
added = CollectionManifest.new(
|
101
101
|
title: "Collection",
|
102
|
-
type:
|
103
|
-
identifier:
|
102
|
+
type: "collection",
|
103
|
+
identifier: "#{identifier}_",
|
104
104
|
)
|
105
105
|
|
106
106
|
added.entry = [
|
data/lib/suma/processor.rb
CHANGED
@@ -12,8 +12,8 @@ require "metanorma/collection/collection"
|
|
12
12
|
module Suma
|
13
13
|
class Processor
|
14
14
|
class << self
|
15
|
-
|
16
|
-
|
15
|
+
def run(metanorma_yaml_path:, schemas_all_path:, compile:,
|
16
|
+
output_directory: "_site")
|
17
17
|
Utils.log "Current directory: #{Dir.getwd}"
|
18
18
|
|
19
19
|
# This reads the metanorma.yml file
|
@@ -52,42 +52,6 @@ module Suma
|
|
52
52
|
collection_config.manifest.remove_schemas_only_sources
|
53
53
|
collection_config.to_file(new_collection_config_path)
|
54
54
|
|
55
|
-
# TODO: Do we still need this?
|
56
|
-
# Define Proc to resolve fileref
|
57
|
-
my_fileref_proc = proc do |ref_folder, fileref|
|
58
|
-
# move schemas to modified_schemas
|
59
|
-
if File.extname(fileref) == ".exp"
|
60
|
-
fileref.gsub!(
|
61
|
-
"../../schemas",
|
62
|
-
"modified_schemas"
|
63
|
-
)
|
64
|
-
end
|
65
|
-
File.join(ref_folder, fileref)
|
66
|
-
end
|
67
|
-
|
68
|
-
# TODO: Do we still need this?
|
69
|
-
# Define Proc to resolve identifier
|
70
|
-
my_identifier_proc = proc do |identifier|
|
71
|
-
case identifier
|
72
|
-
when %r{^documents/}
|
73
|
-
identifier.gsub("documents/", "")
|
74
|
-
else
|
75
|
-
identifier
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# TODO: Do we still need this?
|
80
|
-
# Define Proc to handle the compilation of express schemas
|
81
|
-
express_schemas_renderer = proc do |collection_model|
|
82
|
-
end
|
83
|
-
|
84
|
-
# TODO: Do we still need this?
|
85
|
-
Metanorma::Collection.tap do |mn|
|
86
|
-
mn.set_identifier_resolver(&my_identifier_proc)
|
87
|
-
mn.set_fileref_resolver(&my_fileref_proc)
|
88
|
-
mn.set_pre_parse_model(&express_schemas_renderer)
|
89
|
-
end
|
90
|
-
|
91
55
|
if compile
|
92
56
|
Utils.log "Compiling complete collection..."
|
93
57
|
|
@@ -105,9 +69,11 @@ module Suma
|
|
105
69
|
}
|
106
70
|
metanorma_collection.render(collection_opts)
|
107
71
|
|
108
|
-
#
|
109
|
-
Dir.glob(File.join(Dir.getwd, output_directory,
|
110
|
-
|
72
|
+
# TODO: Temporarily disable removal of XML files
|
73
|
+
Dir.glob(File.join(Dir.getwd, output_directory,
|
74
|
+
"*.xml")).each do |file|
|
75
|
+
puts "NOT DELETING ANY FILE #{file.inspect}"
|
76
|
+
# File.delete(file)
|
111
77
|
end
|
112
78
|
else
|
113
79
|
Utils.log "No compile option set. Skipping collection compilation."
|
@@ -55,7 +55,7 @@ module Suma
|
|
55
55
|
FileUtils.mkdir_p(File.dirname(filename_adoc))
|
56
56
|
|
57
57
|
relative_path = Pathname.new(filename_config)
|
58
|
-
|
58
|
+
.relative_path_from(Pathname.new(File.dirname(filename_adoc)))
|
59
59
|
|
60
60
|
# Utils.log "relative_path #{relative_path}"
|
61
61
|
|
@@ -9,9 +9,10 @@ require_relative "utils"
|
|
9
9
|
module Suma
|
10
10
|
class SchemaCollection
|
11
11
|
attr_accessor :config, :schemas, :docs, :output_path_docs, :output_path_schemas,
|
12
|
-
|
12
|
+
:manifest
|
13
13
|
|
14
|
-
def initialize(config: nil, config_yaml: nil, output_path_docs: nil,
|
14
|
+
def initialize(config: nil, config_yaml: nil, output_path_docs: nil,
|
15
|
+
output_path_schemas: nil, manifest: nil)
|
15
16
|
@schemas = {}
|
16
17
|
@docs = {}
|
17
18
|
@schema_name_to_docs = {}
|
@@ -44,12 +45,12 @@ module Suma
|
|
44
45
|
s = ExpressSchema.new(
|
45
46
|
id: config_schema.id,
|
46
47
|
path: config_schema.path.to_s,
|
47
|
-
output_path: @output_path_schemas.to_s
|
48
|
+
output_path: @output_path_schemas.to_s,
|
48
49
|
)
|
49
50
|
|
50
51
|
doc = klass.new(
|
51
52
|
schema: s,
|
52
|
-
output_path: @output_path_docs.join(s.id)
|
53
|
+
output_path: @output_path_docs.join(s.id),
|
53
54
|
)
|
54
55
|
|
55
56
|
@docs[s.id] = doc
|
@@ -74,11 +75,11 @@ module Suma
|
|
74
75
|
|
75
76
|
def compile
|
76
77
|
finalize
|
77
|
-
schemas.each_pair do |
|
78
|
+
schemas.each_pair do |_schema_id, entry|
|
78
79
|
entry.save_exp
|
79
80
|
end
|
80
81
|
|
81
|
-
docs.each_pair do |
|
82
|
+
docs.each_pair do |_schema_id, entry|
|
82
83
|
entry.compile
|
83
84
|
end
|
84
85
|
|
data/lib/suma/schema_document.rb
CHANGED
@@ -16,23 +16,23 @@ module Suma
|
|
16
16
|
|
17
17
|
// _constants.liquid
|
18
18
|
{% if schema.constants.size > 0 %}
|
19
|
-
#{bookmark(
|
19
|
+
#{bookmark('constants')}
|
20
20
|
{% for thing in schema.constants %}
|
21
|
-
#{bookmark(
|
21
|
+
#{bookmark('{{thing.id}}')}
|
22
22
|
{% endfor %}
|
23
23
|
{% endif %}
|
24
24
|
|
25
25
|
// _types.liquid
|
26
26
|
{% if schema.types.size > 0 %}
|
27
|
-
#{bookmark(
|
27
|
+
#{bookmark('types')}
|
28
28
|
// _type.liquid
|
29
29
|
{% for thing in schema.types %}
|
30
|
-
#{bookmark(
|
30
|
+
#{bookmark('{{thing.id}}')}
|
31
31
|
{% if thing.items.size > 0 %}
|
32
32
|
// _type_items.liquid
|
33
|
-
#{bookmark(
|
33
|
+
#{bookmark('{{thing.id}}.items')}
|
34
34
|
{% for item in thing.items %}
|
35
|
-
#{bookmark(
|
35
|
+
#{bookmark('{{thing.id}}.items.{{item.id}}')}
|
36
36
|
{% endfor %}
|
37
37
|
{% endif %}
|
38
38
|
{% endfor %}
|
@@ -40,10 +40,46 @@ module Suma
|
|
40
40
|
|
41
41
|
// _entities.liquid
|
42
42
|
{% if schema.entities.size > 0 %}
|
43
|
-
#{bookmark(
|
43
|
+
#{bookmark('entities')}
|
44
44
|
{% for thing in schema.entities %}
|
45
45
|
// _entity.liquid
|
46
|
-
#{bookmark(
|
46
|
+
#{bookmark('{{thing.id}}')}
|
47
|
+
{% endfor %}
|
48
|
+
{% endif %}
|
49
|
+
|
50
|
+
// _subtype_constraints.liquid
|
51
|
+
{% if schema.subtype_constraints.size > 0 %}
|
52
|
+
#{bookmark('subtype_constraints')}
|
53
|
+
// _subtype_constraint.liquid
|
54
|
+
{% for thing in schema.subtype_constraints %}
|
55
|
+
#{bookmark('{{thing.id}}')}
|
56
|
+
{% endfor %}
|
57
|
+
{% endif %}
|
58
|
+
|
59
|
+
// _functions.liquid
|
60
|
+
{% if schema.functions.size > 0 %}
|
61
|
+
#{bookmark('functions')}
|
62
|
+
// _function.liquid
|
63
|
+
{% for thing in schema.functions %}
|
64
|
+
#{bookmark('{{thing.id}}')}
|
65
|
+
{% endfor %}
|
66
|
+
{% endif %}
|
67
|
+
|
68
|
+
// _procedures.liquid
|
69
|
+
{% if schema.procedures.size > 0 %}
|
70
|
+
#{bookmark('procedures')}
|
71
|
+
// _procedure.liquid
|
72
|
+
{% for thing in schema.procedures %}
|
73
|
+
#{bookmark('{{thing.id}}')}
|
74
|
+
{% endfor %}
|
75
|
+
{% endif %}
|
76
|
+
|
77
|
+
// _rules.liquid
|
78
|
+
{% if schema.rules.size > 0 %}
|
79
|
+
#{bookmark('rules')}
|
80
|
+
// _rule.liquid
|
81
|
+
{% for thing in schema.rules %}
|
82
|
+
#{bookmark('{{thing.id}}')}
|
47
83
|
{% endfor %}
|
48
84
|
{% endif %}
|
49
85
|
HEREDOC
|
@@ -81,7 +117,7 @@ module Suma
|
|
81
117
|
|
82
118
|
[[#{@id}]]
|
83
119
|
[%unnumbered,type=express]
|
84
|
-
== #{@id} #{schema_anchors.gsub(%r{//[^\r\n]+},
|
120
|
+
== #{@id} #{schema_anchors.gsub(%r{//[^\r\n]+}, '').gsub(/[\n\r]+/, '').gsub(/^[\n\r]/, '')}
|
85
121
|
|
86
122
|
[source%unnumbered]
|
87
123
|
--
|
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.3
|
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-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expressir
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- ".gitignore"
|
124
124
|
- ".rspec"
|
125
125
|
- ".rubocop.yml"
|
126
|
+
- ".rubocop_todo.yml"
|
126
127
|
- CODE_OF_CONDUCT.md
|
127
128
|
- Gemfile
|
128
129
|
- README.adoc
|