suma 0.1.9 → 0.1.11
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/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +9 -57
- data/README.adoc +36 -0
- data/lib/suma/cli/build.rb +2 -9
- data/lib/suma/cli/reformat.rb +89 -0
- data/lib/suma/cli.rb +20 -6
- data/lib/suma/version.rb +1 -1
- data/suma.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91d8fb8b814f47412c1374e7c12c9d3fb5368a5275c409355c6cc02a728305b6
|
4
|
+
data.tar.gz: 3cdf5da9b7c251df88f6434222e3a575e6f1cf3839f83ab7cb47091180807510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55422c9b98ac260feb77bc8937aff2d45196ba369850a5166b82fec88e7318007c2a6e3d345a441b0ea7e6e3c6df3854432a56ab33012079ababa0fae8a0f6ab
|
7
|
+
data.tar.gz: 50e1425e0bb51cff0866dbb4f7de66c03fc72772660aa253eafa5f25ebcd072e6d7f4c4b5006ad84c78fbd9364eb8cf5494498fc1c6747efe9e2b50a9de8757a
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
inherit_from:
|
2
|
-
- https://raw.githubusercontent.com/riboseinc/oss-guides/
|
2
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
|
3
3
|
- .rubocop_todo.yml
|
4
4
|
|
5
|
-
|
5
|
+
plugins:
|
6
6
|
- rubocop-performance
|
7
7
|
- rubocop-rake
|
8
8
|
- rubocop-rspec
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2025-03-
|
3
|
+
# on 2025-03-23 10:59:23 UTC using RuboCop version 1.74.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -13,47 +13,6 @@ Gemspec/DuplicatedAssignment:
|
|
13
13
|
Exclude:
|
14
14
|
- 'suma.gemspec'
|
15
15
|
|
16
|
-
# Offense count: 2
|
17
|
-
# This cop supports safe autocorrection (--autocorrect).
|
18
|
-
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
19
|
-
# SupportedStyles: outdent, indent
|
20
|
-
Layout/AccessModifierIndentation:
|
21
|
-
Exclude:
|
22
|
-
- 'lib/suma/cli/build.rb'
|
23
|
-
- 'lib/suma/cli/links.rb'
|
24
|
-
|
25
|
-
# Offense count: 1
|
26
|
-
# This cop supports safe autocorrection (--autocorrect).
|
27
|
-
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
28
|
-
# SupportedStyles: with_first_argument, with_fixed_indentation
|
29
|
-
Layout/ArgumentAlignment:
|
30
|
-
Exclude:
|
31
|
-
- 'lib/suma/cli/links.rb'
|
32
|
-
|
33
|
-
# Offense count: 19
|
34
|
-
# This cop supports safe autocorrection (--autocorrect).
|
35
|
-
# Configuration parameters: AllowForAlignment.
|
36
|
-
Layout/CommentIndentation:
|
37
|
-
Exclude:
|
38
|
-
- 'lib/suma/cli/build.rb'
|
39
|
-
- 'lib/suma/cli/links.rb'
|
40
|
-
|
41
|
-
# Offense count: 1
|
42
|
-
# This cop supports safe autocorrection (--autocorrect).
|
43
|
-
# Configuration parameters: EnforcedStyleAlignWith, Severity.
|
44
|
-
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
45
|
-
Layout/EndAlignment:
|
46
|
-
Exclude:
|
47
|
-
- 'lib/suma/cli/build.rb'
|
48
|
-
|
49
|
-
# Offense count: 28
|
50
|
-
# This cop supports safe autocorrection (--autocorrect).
|
51
|
-
# Configuration parameters: Width, AllowedPatterns.
|
52
|
-
Layout/IndentationWidth:
|
53
|
-
Exclude:
|
54
|
-
- 'lib/suma/cli/build.rb'
|
55
|
-
- 'lib/suma/cli/links.rb'
|
56
|
-
|
57
16
|
# Offense count: 43
|
58
17
|
# This cop supports safe autocorrection (--autocorrect).
|
59
18
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
@@ -71,18 +30,19 @@ Layout/LineLength:
|
|
71
30
|
- 'lib/suma/thor_ext.rb'
|
72
31
|
- 'suma.gemspec'
|
73
32
|
|
74
|
-
# Offense count: 1
|
75
|
-
# This cop supports safe autocorrection (--autocorrect).
|
76
|
-
# Configuration parameters: AllowInHeredoc.
|
77
|
-
Layout/TrailingWhitespace:
|
78
|
-
Exclude:
|
79
|
-
- 'lib/suma/cli/links.rb'
|
80
|
-
|
81
33
|
# Offense count: 1
|
82
34
|
Lint/DuplicateMethods:
|
83
35
|
Exclude:
|
84
36
|
- 'lib/suma/express_schema.rb'
|
85
37
|
|
38
|
+
# Offense count: 2
|
39
|
+
# This cop supports safe autocorrection (--autocorrect).
|
40
|
+
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
|
41
|
+
# NotImplementedExceptions: NotImplementedError
|
42
|
+
Lint/UnusedMethodArgument:
|
43
|
+
Exclude:
|
44
|
+
- 'lib/suma/cli.rb'
|
45
|
+
|
86
46
|
# Offense count: 11
|
87
47
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
88
48
|
Metrics/AbcSize:
|
@@ -127,14 +87,6 @@ Performance/CollectionLiteralInLoop:
|
|
127
87
|
Exclude:
|
128
88
|
- 'spec/suma/cli_spec.rb'
|
129
89
|
|
130
|
-
# Offense count: 1
|
131
|
-
# This cop supports safe autocorrection (--autocorrect).
|
132
|
-
# Configuration parameters: EnforcedStyle.
|
133
|
-
# SupportedStyles: implicit, each, example
|
134
|
-
RSpec/HookArgument:
|
135
|
-
Exclude:
|
136
|
-
- 'spec/suma/cli_spec.rb'
|
137
|
-
|
138
90
|
# Offense count: 1
|
139
91
|
RSpec/MultipleExpectations:
|
140
92
|
Max: 2
|
data/README.adoc
CHANGED
@@ -130,6 +130,42 @@ This command:
|
|
130
130
|
* Provides progress bars to track schema loading and link validation
|
131
131
|
|
132
132
|
|
133
|
+
=== Reformat command
|
134
|
+
|
135
|
+
==== General
|
136
|
+
|
137
|
+
The `reformat` command provides utilities for reformatting EXPRESS files.
|
138
|
+
|
139
|
+
[source,sh]
|
140
|
+
----
|
141
|
+
$ suma reformat EXPRESS_FILE_PATH [options]
|
142
|
+
----
|
143
|
+
|
144
|
+
Parameters:
|
145
|
+
|
146
|
+
`EXPRESS_FILE_PATH`:: Path to an EXPRESS file or a folder containing EXPRESS
|
147
|
+
files
|
148
|
+
|
149
|
+
Options:
|
150
|
+
|
151
|
+
`--[no-]recursive`:: Select EXPRESS files recursively based on the specified
|
152
|
+
folder path (default: false)
|
153
|
+
|
154
|
+
[example]
|
155
|
+
====
|
156
|
+
.To reformat all EXPRESS files under the current directory recursively
|
157
|
+
[source,sh]
|
158
|
+
----
|
159
|
+
$ bundle exec suma reformat `pwd` -r
|
160
|
+
----
|
161
|
+
====
|
162
|
+
|
163
|
+
This command:
|
164
|
+
|
165
|
+
* Loads the EXPRESS files specified in the `EXPRESS_FILE_PATH`
|
166
|
+
* Reformats and saves the loaded EXPRESS files
|
167
|
+
|
168
|
+
|
133
169
|
== Usage: Ruby
|
134
170
|
|
135
171
|
=== General
|
data/lib/suma/cli/build.rb
CHANGED
@@ -7,21 +7,14 @@ module Suma
|
|
7
7
|
module Cli
|
8
8
|
# Build command for building collections
|
9
9
|
class Build < Thor
|
10
|
-
|
11
|
-
def self.exit_on_failure?
|
12
|
-
true
|
13
|
-
end
|
14
|
-
|
15
|
-
default_command :default_build
|
16
|
-
|
17
|
-
desc "default_build METANORMA_SITE_MANIFEST",
|
10
|
+
desc "build METANORMA_SITE_MANIFEST",
|
18
11
|
"Build collection specified in site manifest (`metanorma*.yml`)"
|
19
12
|
option :compile, type: :boolean, default: true,
|
20
13
|
desc: "Compile or skip compile of collection"
|
21
14
|
option :schemas_all_path, type: :string, aliases: "-s",
|
22
15
|
desc: "Generate file that contains all schemas in the collection."
|
23
16
|
|
24
|
-
def
|
17
|
+
def build(metanorma_site_manifest)
|
25
18
|
# Lazy-load dependencies only when this command is actually used
|
26
19
|
require_relative "../processor"
|
27
20
|
require_relative "../utils"
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require_relative "../thor_ext"
|
5
|
+
|
6
|
+
module Suma
|
7
|
+
module Cli
|
8
|
+
# Reformat command for reformatting EXPRESS files
|
9
|
+
class Reformat < Thor
|
10
|
+
desc "reformat EXPRESS_FILE_PATH",
|
11
|
+
"Reformat EXPRESS files"
|
12
|
+
option :recursive, type: :boolean, default: false, aliases: "-r",
|
13
|
+
desc: "Reformat EXPRESS files under the specified " \
|
14
|
+
"path recursively"
|
15
|
+
|
16
|
+
def reformat(express_file_path) # rubocop:disable Metrics/AbcSize
|
17
|
+
if File.file?(express_file_path)
|
18
|
+
unless File.exist?(express_file_path)
|
19
|
+
raise Errno::ENOENT, "Specified EXPRESS file " \
|
20
|
+
"`#{express_file_path}` not found."
|
21
|
+
end
|
22
|
+
|
23
|
+
if File.extname(express_file_path) != ".exp"
|
24
|
+
raise ArgumentError, "Specified file `#{express_file_path}` is " \
|
25
|
+
"not an EXPRESS file."
|
26
|
+
end
|
27
|
+
|
28
|
+
exp_files = [express_file_path]
|
29
|
+
elsif options[:recursive]
|
30
|
+
exp_files = Dir.glob("#{express_file_path}/**/*.exp")
|
31
|
+
else
|
32
|
+
exp_files = Dir.glob("#{express_file_path}/*.exp")
|
33
|
+
end
|
34
|
+
|
35
|
+
if exp_files.empty?
|
36
|
+
raise Errno::ENOENT, "No EXPRESS files found in " \
|
37
|
+
"`#{express_file_path}`."
|
38
|
+
end
|
39
|
+
|
40
|
+
run(exp_files)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def run(exp_files)
|
46
|
+
exp_files.each do |exp_file|
|
47
|
+
reformat_exp(exp_file)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def reformat_exp(file) # rubocop:disable Metrics/AbcSize
|
52
|
+
# Read the file content
|
53
|
+
file_content = File.read(file)
|
54
|
+
|
55
|
+
# Extract all comments between '(*"' and '\n*)'
|
56
|
+
# Avoid incorrect selection of some comment blocks
|
57
|
+
# containing '(*text*)' inside
|
58
|
+
comments = file_content.scan(/\(\*"(.*?)\n\*\)/m).map(&:first)
|
59
|
+
|
60
|
+
if comments.count.positive?
|
61
|
+
content_without_comments = file_content.gsub(/\(\*".*?\n\*\)/m, "")
|
62
|
+
|
63
|
+
# remove extra newlines
|
64
|
+
new_content = content_without_comments.gsub(/(\n\n+)/, "\n\n")
|
65
|
+
# Add '(*"' and '\n*)' to enclose the comment block
|
66
|
+
new_comments = comments.map { |c| "(*\"#{c}\n*)" }.join("\n\n")
|
67
|
+
# Append the comments to the end of the file
|
68
|
+
new_content = "#{new_content}\n\n#{new_comments}\n"
|
69
|
+
|
70
|
+
# Compare the changes between the original content with the modified
|
71
|
+
# content, if the changes are just whitespaces, skip modifying the
|
72
|
+
# file
|
73
|
+
if file_content.gsub(/(\n+)/, "\n") == new_content.gsub(/(\n+)/, "\n")
|
74
|
+
puts "No changes made to #{file}"
|
75
|
+
return
|
76
|
+
end
|
77
|
+
|
78
|
+
update_exp(file, new_content)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def update_exp(file, content)
|
83
|
+
# Write the modified content to a new file
|
84
|
+
File.write(file, content)
|
85
|
+
puts "Reformatted EXPRESS file and saved to #{file}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/suma/cli.rb
CHANGED
@@ -11,17 +11,31 @@ module Suma
|
|
11
11
|
|
12
12
|
desc "build METANORMA_SITE_MANIFEST",
|
13
13
|
"Build collection specified in site manifest (`metanorma*.yml`)"
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
option :compile, type: :boolean, default: true,
|
15
|
+
desc: "Compile or skip compile of collection"
|
16
|
+
option :schemas_all_path, type: :string, aliases: "-s",
|
17
|
+
desc: "Generate file that contains all schemas in the collection."
|
18
|
+
def build(_site_manifest)
|
19
|
+
# # If no arguments, add an empty array to ensure the default command is triggered
|
20
|
+
# args = [] if args.empty?
|
17
21
|
require_relative "cli/build"
|
18
|
-
Cli::Build.start
|
22
|
+
Cli::Build.start
|
19
23
|
end
|
20
24
|
|
21
25
|
desc "links SUBCOMMAND ...ARGS", "Manage EXPRESS links"
|
22
|
-
def links(*
|
26
|
+
def links(*_args)
|
23
27
|
require_relative "cli/links"
|
24
|
-
Cli::Links.start
|
28
|
+
Cli::Links.start
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "reformat EXPRESS_FILE_PATH",
|
32
|
+
"Reformat EXPRESS files"
|
33
|
+
option :recursive, type: :boolean, default: false, aliases: "-r",
|
34
|
+
desc: "Reformat EXPRESS files under the specified " \
|
35
|
+
"path recursively"
|
36
|
+
def reformat(_express_file_path)
|
37
|
+
require_relative "cli/reformat"
|
38
|
+
Cli::Reformat.start
|
25
39
|
end
|
26
40
|
end
|
27
41
|
end
|
data/lib/suma/version.rb
CHANGED
data/suma.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
33
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ["lib"]
|
35
35
|
|
36
|
-
spec.add_dependency "expressir", "~> 2.1
|
36
|
+
spec.add_dependency "expressir", "~> 2.1"
|
37
37
|
spec.add_dependency "lutaml-model", "~> 0.7"
|
38
38
|
spec.add_dependency "metanorma-cli"
|
39
39
|
spec.add_dependency "ruby-progressbar"
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expressir
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.1
|
19
|
+
version: '2.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: lutaml-model
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/suma/cli.rb
|
108
108
|
- lib/suma/cli/build.rb
|
109
109
|
- lib/suma/cli/links.rb
|
110
|
+
- lib/suma/cli/reformat.rb
|
110
111
|
- lib/suma/collection_config.rb
|
111
112
|
- lib/suma/collection_manifest.rb
|
112
113
|
- lib/suma/express_schema.rb
|