expressir 1.3.3-x86_64-linux-musl → 1.4.1-x86_64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +25 -7
- data/exe/format +3 -7
- data/exe/format-test +1 -1
- data/lib/expressir/cli.rb +62 -10
- data/lib/expressir/model/model_element.rb +32 -16
- data/lib/expressir/model/repository.rb +1 -0
- data/lib/expressir/version.rb +1 -1
- data/lib/expressir.rb +4 -8
- data/spec/acceptance/version_spec.rb +1 -1
- metadata +2 -3
- data/lib/expressir/cli/ui.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef40390e8b4dab30bc836664c83755698cbe99490e7fb70bf2145efd240517a9
|
4
|
+
data.tar.gz: 8dca4d394056a680e20391a63c339a14ae013509f1e44af988a3aa498d752ff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd64ed51cba5fbe241d99839fcfcada35a23ce69bfb79ec75657ed64daae8c0b03171a38414a8dbe43ac2941d578b1015e812b23f9364fc7a2216cc889c98e51
|
7
|
+
data.tar.gz: 9ad87b3a5adc08155b7452102e89a03d3cad390991f50d9cde0cad90d7563fa8425146a5855cf04f5fd57179f9381fb058ac478b4c543344dffa4be1ac28e7f1
|
data/README.adoc
CHANGED
@@ -38,13 +38,22 @@ instructions.
|
|
38
38
|
|
39
39
|
[source, sh]
|
40
40
|
----
|
41
|
-
|
41
|
+
$ expressir
|
42
42
|
|
43
43
|
Commands:
|
44
|
+
expressir format PATH # pretty print EXPRESS schema located at PATH
|
44
45
|
expressir help [COMMAND] # Describe available commands or one specific command
|
45
46
|
expressir version # The Expressir Version
|
46
47
|
----
|
47
48
|
|
49
|
+
=== Pretty print
|
50
|
+
|
51
|
+
[source, sh]
|
52
|
+
----
|
53
|
+
expressir format schemas/resources/action_schema/action_schema.exp
|
54
|
+
----
|
55
|
+
|
56
|
+
|
48
57
|
== Development
|
49
58
|
|
50
59
|
We are following Sandi Metz's Rules for this gem, you can read
|
@@ -66,22 +75,31 @@ Setup your environment.
|
|
66
75
|
[source, sh]
|
67
76
|
----
|
68
77
|
bin/setup
|
78
|
+
git submodule update --init
|
79
|
+
bundle exec rake generate
|
80
|
+
bundle exec rake compile
|
69
81
|
----
|
70
82
|
|
71
83
|
Run the test suite
|
72
84
|
|
73
85
|
[source, sh]
|
74
86
|
----
|
75
|
-
|
87
|
+
bundle exec rake
|
76
88
|
----
|
77
89
|
|
78
90
|
=== Grammar updates
|
79
|
-
EXPRESS grammar is lined as git submodule to ext/express-grammar
|
80
|
-
Shoudl you update it, run ```rake generate```. This command will generate source code for updated native extension using antlr4-native gem.
|
81
|
-
Please note that we create several classes on top of antlr4-native output so using embedded rake task is a real requirement.
|
82
91
|
|
83
|
-
|
84
|
-
|
92
|
+
THe EXPRESS grammar is lined as Git submodule at `ext/express-grammar`.
|
93
|
+
|
94
|
+
Should you update it, please run `rake generate`. This command will generate
|
95
|
+
source code for updated native extension using the `antlr4-native` gem. Please
|
96
|
+
note that we create several classes on top of `antlr4-native` output so using
|
97
|
+
embedded rake task is a real requirement.
|
98
|
+
|
99
|
+
When a new extension is generated and tested, please check in updated C++ files
|
100
|
+
to git (`rake generate` is NOT a CI step, extension source files are pulled from
|
101
|
+
the repo).
|
102
|
+
|
85
103
|
|
86
104
|
== Installation
|
87
105
|
|
data/exe/format
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "yaml"
|
4
|
-
require "expressir
|
4
|
+
require "expressir"
|
5
5
|
require "expressir/express/formatter"
|
6
6
|
require "expressir/express/schema_head_formatter"
|
7
7
|
require "expressir/express/hyperlink_formatter"
|
@@ -9,10 +9,6 @@ require "expressir/express/hyperlink_formatter"
|
|
9
9
|
exp_files = ARGV
|
10
10
|
|
11
11
|
repository = Expressir::Express::Parser.from_files(exp_files)
|
12
|
-
|
13
|
-
|
14
|
-
include Expressir::Express::HyperlinkFormatter
|
12
|
+
repository.schemas.each do |schema|
|
13
|
+
puts schema.to_s(no_remarks: true)
|
15
14
|
end
|
16
|
-
result = repository.to_hash(formatter: formatter, skip_empty: true)
|
17
|
-
|
18
|
-
puts YAML.dump(result)
|
data/exe/format-test
CHANGED
@@ -75,7 +75,7 @@ formatter = Class.new(Expressir::Express::Formatter) do
|
|
75
75
|
include Expressir::Express::SchemaHeadFormatter
|
76
76
|
include Expressir::Express::HyperlinkFormatter
|
77
77
|
end
|
78
|
-
result = repository.to_hash(formatter: formatter
|
78
|
+
result = repository.to_hash(formatter: formatter)
|
79
79
|
puts "Repository.to_hash time: #{(Time.now - start).round(2)}s"
|
80
80
|
|
81
81
|
# puts YAML.dump(result)
|
data/lib/expressir/cli.rb
CHANGED
@@ -1,21 +1,73 @@
|
|
1
1
|
require "thor"
|
2
|
-
require "expressir/cli/ui"
|
3
2
|
|
4
3
|
module Expressir
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
class Cli < Thor
|
5
|
+
desc "format PATH", "pretty print EXPRESS schema located at PATH"
|
6
|
+
def format(path)
|
7
|
+
repository = Expressir::Express::Parser.from_file(path)
|
8
|
+
repository.schemas.each do |schema|
|
9
|
+
puts "\n(* Expressir formatted schema: #{schema.id} *)\n"
|
10
|
+
puts schema.to_s(no_remarks: true)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
no_commands do
|
15
|
+
def _validate_schema(path)
|
16
|
+
repository = Expressir::Express::Parser.from_file(path)
|
17
|
+
repository.schemas.inject([]) do |acc, schema|
|
18
|
+
acc << schema.id unless schema.version&.value
|
19
|
+
acc
|
20
|
+
end
|
21
|
+
rescue StandardError => e
|
22
|
+
# pp e
|
23
|
+
nil
|
24
|
+
end
|
12
25
|
end
|
13
26
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
27
|
+
desc "validate *PATH", "validate EXPRESS schema located at PATH"
|
28
|
+
def validate(*paths)
|
29
|
+
no_version = []
|
30
|
+
no_valid = []
|
31
|
+
|
32
|
+
paths.each do |path|
|
33
|
+
x = Pathname.new(path).realpath.relative_path_from(Dir.pwd)
|
34
|
+
puts "Validating #{x}"
|
35
|
+
ret = _validate_schema(path)
|
36
|
+
|
37
|
+
if ret.nil?
|
38
|
+
no_valid << "Failed to parse: #{x}"
|
39
|
+
next
|
40
|
+
end
|
41
|
+
|
42
|
+
if ret.size
|
43
|
+
ret.each do |schema_id|
|
44
|
+
no_version << "Missing version string: schema `#{schema_id}` | #{x}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
if !no_valid.empty?
|
50
|
+
puts "#{"*" * 20} RESULTS: FAILED TO PARSE #{"*" * 20}"
|
51
|
+
no_valid.each do |msg|
|
52
|
+
puts msg
|
53
|
+
end
|
18
54
|
end
|
55
|
+
|
56
|
+
if !no_version.empty?
|
57
|
+
puts "#{"*" * 20} RESULTS: MISSING VERSION STRING #{"*" * 20}"
|
58
|
+
no_version.each do |msg|
|
59
|
+
puts msg
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if no_valid.size || no_version.size
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "version", "Expressir Version"
|
69
|
+
def version
|
70
|
+
say(Expressir::VERSION)
|
19
71
|
end
|
20
72
|
end
|
21
73
|
end
|
@@ -104,20 +104,21 @@ module Expressir
|
|
104
104
|
empty = value.nil? || (value.is_a?(Array) && value.count == 0)
|
105
105
|
|
106
106
|
# skip empty values
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
107
|
+
next unless !empty or include_empty
|
108
|
+
|
109
|
+
hash[variable.to_s] = case value
|
110
|
+
when Array
|
111
|
+
value.map do |value|
|
112
|
+
if value.is_a? ModelElement
|
113
|
+
value.to_hash(root_path: root_path, formatter: formatter, include_empty: include_empty)
|
114
|
+
else
|
115
|
+
value
|
115
116
|
end
|
116
|
-
elsif value.is_a? ModelElement
|
117
|
-
value.to_hash(root_path: root_path, formatter: formatter, include_empty: include_empty)
|
118
|
-
else
|
119
|
-
value
|
120
117
|
end
|
118
|
+
when ModelElement
|
119
|
+
value.to_hash(root_path: root_path, formatter: formatter, include_empty: include_empty)
|
120
|
+
else
|
121
|
+
value
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
@@ -132,6 +133,19 @@ module Expressir
|
|
132
133
|
hash
|
133
134
|
end
|
134
135
|
|
136
|
+
def to_s
|
137
|
+
to_s(no_remarks: false, formatter: nil)
|
138
|
+
end
|
139
|
+
|
140
|
+
def to_s(no_remarks: false, formatter: nil)
|
141
|
+
formatter ||= Class.new(Expressir::Express::Formatter) do
|
142
|
+
if no_remarks
|
143
|
+
def format_remarks(node); []; end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
formatter.format(self)
|
147
|
+
end
|
148
|
+
|
135
149
|
# @param [Hash] hash
|
136
150
|
# @param [String] root_path
|
137
151
|
# @return [ModelElement]
|
@@ -142,7 +156,8 @@ module Expressir
|
|
142
156
|
node_class.model_attrs.each do |variable|
|
143
157
|
value = hash[variable.to_s]
|
144
158
|
|
145
|
-
node_options[variable] =
|
159
|
+
node_options[variable] = case value
|
160
|
+
when Array
|
146
161
|
value.map do |value|
|
147
162
|
if value.is_a? Hash
|
148
163
|
self.from_hash(value, root_path: root_path)
|
@@ -150,7 +165,7 @@ module Expressir
|
|
150
165
|
value
|
151
166
|
end
|
152
167
|
end
|
153
|
-
|
168
|
+
when Hash
|
154
169
|
self.from_hash(value, root_path: root_path)
|
155
170
|
else
|
156
171
|
value
|
@@ -191,13 +206,14 @@ module Expressir
|
|
191
206
|
self.class.model_attrs.each do |variable|
|
192
207
|
value = self.send(variable)
|
193
208
|
|
194
|
-
|
209
|
+
case value
|
210
|
+
when Array
|
195
211
|
value.each do |value|
|
196
212
|
if value.is_a? ModelElement
|
197
213
|
value.parent = self
|
198
214
|
end
|
199
215
|
end
|
200
|
-
|
216
|
+
when ModelElement
|
201
217
|
value.parent = self
|
202
218
|
end
|
203
219
|
end
|
data/lib/expressir/version.rb
CHANGED
data/lib/expressir.rb
CHANGED
@@ -3,10 +3,6 @@ require "expressir/version"
|
|
3
3
|
require "expressir/cli"
|
4
4
|
require "expressir/config"
|
5
5
|
|
6
|
-
Dir[File.join(__dir__, "expressir", "express", "*.rb")].sort.each do |fea|
|
7
|
-
require fea
|
8
|
-
end
|
9
|
-
|
10
6
|
# ..........................................................
|
11
7
|
# https://bugs.ruby-lang.org/issues/19319
|
12
8
|
# The issue is that this bug is fixed for 3.1 and above,
|
@@ -30,10 +26,6 @@ end
|
|
30
26
|
module Expressir
|
31
27
|
class Error < StandardError; end
|
32
28
|
|
33
|
-
def self.ui
|
34
|
-
Expressir::Cli::UI
|
35
|
-
end
|
36
|
-
|
37
29
|
def self.root
|
38
30
|
File.dirname(__dir__)
|
39
31
|
end
|
@@ -42,3 +34,7 @@ module Expressir
|
|
42
34
|
@root_path ||= Pathname.new(Expressir.root)
|
43
35
|
end
|
44
36
|
end
|
37
|
+
|
38
|
+
Dir[File.join(__dir__, "expressir", "express", "*.rb")].sort.each do |fea|
|
39
|
+
require fea
|
40
|
+
end
|
@@ -19,7 +19,7 @@ RSpec.describe "Expressir" do
|
|
19
19
|
print "\n[#{example.description}] "
|
20
20
|
command = %w(version)
|
21
21
|
output = capture_stdout { Expressir::Cli.start(command) }
|
22
|
-
expect(output).to include(
|
22
|
+
expect(output).to include(Expressir::VERSION)
|
23
23
|
|
24
24
|
# Validate Object Space
|
25
25
|
GC.start
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expressir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: x86_64-linux-musl
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -240,7 +240,6 @@ files:
|
|
240
240
|
- expressir.gemspec
|
241
241
|
- lib/expressir.rb
|
242
242
|
- lib/expressir/cli.rb
|
243
|
-
- lib/expressir/cli/ui.rb
|
244
243
|
- lib/expressir/config.rb
|
245
244
|
- lib/expressir/express/2.7/express_parser.so
|
246
245
|
- lib/expressir/express/3.0/express_parser.so
|
data/lib/expressir/cli/ui.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require "thor"
|
2
|
-
|
3
|
-
module Expressir
|
4
|
-
module Cli
|
5
|
-
class UI < Thor
|
6
|
-
def self.ask(message)
|
7
|
-
new.ask(message)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.say(message)
|
11
|
-
new.say(message)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.error(message)
|
15
|
-
if log_types.include?("error")
|
16
|
-
new.error(message)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.info(message)
|
21
|
-
if log_types.include?("info")
|
22
|
-
new.say(message)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.run(command)
|
27
|
-
require "open3"
|
28
|
-
Open3.capture3(command)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.log_types
|
32
|
-
Expressir.configuration.logs.map(&:to_s) || []
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|