suma 0.1.2 → 0.1.4

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: 7d5ebe81c947831dfcd9c94b3eeea2a34f33d29c548a59a55347b35adecaecc7
4
- data.tar.gz: '085a461362248532759fe4d47ce5e0e7ff510147a97537c17e039878ae2e503a'
3
+ metadata.gz: 22e731545f38d062a61abb1972e6967d29a8b1ac15a732425bb0dc95dc598020
4
+ data.tar.gz: 90e7518fc1d20861c7565e1efe6909bf279974254bd82e9f7d288f41dfcc937c
5
5
  SHA512:
6
- metadata.gz: df8f83de715f1dfe7bff547a539717841f0595f02c003caa69a2b09f24e50c02d9a7c1372dce6f7cfe4055e0c05ecd023b8b3033b966dd4e1016f4768bbf5b0c
7
- data.tar.gz: 323215a01e582ad8d223bf76916454ca8ee23dd8d2a8f4bde78c1f57631b50da65cf05d83b6c94e9f94052fed943dfed73bfd05434a94f70414e1054652bc722
6
+ metadata.gz: 8b052a8b6032dca39ab5acbd6af00b2343e6da8faa490b4c0c95788a2cc29b7845e0be5dd4ebdc4da6c42cf64afc56e43e3a014a0d18b093ed0deaeec6b86ebe
7
+ data.tar.gz: 31cfef34ad68ee4ada47e5ad15746c7aae91fd5e90f73f7a68067db1461a61482e8c48d4f7d14b00349674667e719c7fdc4b7c7844051e4182dafb8b7ba47473
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  # Auto-generated by Cimas: Do not edit it manually!
2
2
  # See https://github.com/metanorma/cimas
3
3
  inherit_from:
4
+ - .rubocop_todo.yml
4
5
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
6
 
6
7
  # local repo-specific modifications
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", "Build collection specified in site manifest (`metanorma*.yml`)"
13
- option :compile, type: :boolean, default: true, desc: "Compile or skip compile of collection"
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,20 +24,20 @@ 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
- metanorma_site_manifest.gsub("metanorma", "schemas")
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."
36
38
  Utils.log e
37
39
  Utils.log e.inspect
38
- Utils.log e.backtrace
40
+ Utils.log e.backtrace.join("\n")
39
41
  end
40
42
  end
41
43
  end
@@ -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) == 'collection.yml'
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: "collection",
103
- identifier: self.identifier + "_"
102
+ type: "collection",
103
+ identifier: "#{identifier}_",
104
104
  )
105
105
 
106
106
  added.entry = [
@@ -12,8 +12,8 @@ require "metanorma/collection/collection"
12
12
  module Suma
13
13
  class Processor
14
14
  class << self
15
-
16
- def run(metanorma_yaml_path:, schemas_all_path:, compile:, output_directory: "_site")
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,51 +52,12 @@ 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
 
94
- # TODO: Why will defining a collection immediately compile??
95
58
  metanorma_collection = Metanorma::Collection.parse(new_collection_config_path)
96
59
 
97
- # TODO: Somehow this is no longer used
98
60
  collection_opts = {
99
- format: [:html],
100
61
  output_folder: output_directory,
101
62
  compile: {
102
63
  install_fonts: false,
@@ -105,9 +66,11 @@ module Suma
105
66
  }
106
67
  metanorma_collection.render(collection_opts)
107
68
 
108
- # remove xml files
109
- Dir.glob(File.join(Dir.getwd, output_directory, "*.xml")).each do |file|
110
- File.delete(file)
69
+ # TODO: Temporarily disable removal of XML files
70
+ Dir.glob(File.join(Dir.getwd, output_directory,
71
+ "*.xml")).each do |file|
72
+ puts "NOT DELETING ANY FILE #{file.inspect}"
73
+ # File.delete(file)
111
74
  end
112
75
  else
113
76
  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
- .relative_path_from(Pathname.new(File.dirname(filename_adoc)))
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
- :manifest
12
+ :manifest
13
13
 
14
- def initialize(config: nil, config_yaml: nil, output_path_docs: nil, output_path_schemas: nil, manifest: 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 |schema_id, entry|
78
+ schemas.each_pair do |_schema_id, entry|
78
79
  entry.save_exp
79
80
  end
80
81
 
81
- docs.each_pair do |schema_id, entry|
82
+ docs.each_pair do |_schema_id, entry|
82
83
  entry.compile
83
84
  end
84
85
 
@@ -78,6 +78,7 @@ module Suma
78
78
 
79
79
  # Or based on current working directory?
80
80
  return relative_path unless @path
81
+
81
82
  # ... but if this calculates path, we end up expanding it anyway
82
83
 
83
84
  Pathname.new(File.dirname(@path)).join(eval_path).expand_path.to_s
@@ -16,23 +16,23 @@ module Suma
16
16
 
17
17
  // _constants.liquid
18
18
  {% if schema.constants.size > 0 %}
19
- #{bookmark("constants")}
19
+ #{bookmark('constants')}
20
20
  {% for thing in schema.constants %}
21
- #{bookmark("{{thing.id}}")}
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("types")}
27
+ #{bookmark('types')}
28
28
  // _type.liquid
29
29
  {% for thing in schema.types %}
30
- #{bookmark("{{thing.id}}")}
30
+ #{bookmark('{{thing.id}}')}
31
31
  {% if thing.items.size > 0 %}
32
32
  // _type_items.liquid
33
- #{bookmark("{{thing.id}}.items")}
33
+ #{bookmark('{{thing.id}}.items')}
34
34
  {% for item in thing.items %}
35
- #{bookmark("{{thing.id}}.items.{{item.id}}")}
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("entities")}
43
+ #{bookmark('entities')}
44
44
  {% for thing in schema.entities %}
45
45
  // _entity.liquid
46
- #{bookmark("{{thing.id}}")}
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]+}, "").gsub(/[\n\r]+/, "").gsub(/^[\n\r]/, "")}
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Suma
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
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.2
4
+ version: 0.1.4
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-22 00:00:00.000000000 Z
11
+ date: 2024-10-19 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