expressir 1.3.3-aarch64-linux-musl → 1.4.1-aarch64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aad412f92ba545d639802d4c66a511e38b198bb03b398eafa42fe5647f4f7757
4
- data.tar.gz: e2a0dbc27ae502f349818974942e79b4c74e0559ea6cd40aed0f2a56b7847a8f
3
+ metadata.gz: 9fb400415f0b9a4f590d9208fd235fa13ef9c82f04530022859515671526b3a9
4
+ data.tar.gz: 88d7b42bd1e8a8b7e6e9c1939a11a30e0e3239f603ee11fe75d58b2eb650e223
5
5
  SHA512:
6
- metadata.gz: 80953d43ee88f7c31aa6a7ffd603a91946308e16c8f6063d4a45532fec3db4a0dc2ec3fe3aa87f2c0b10c33728ba89abe6985f5cefaad6fba2fe1c1cb54feb03
7
- data.tar.gz: a118e440ede66924738e62816bb11d9220f439464d9d0482cca4ca1568e67cb38e80d30ef15a8b3d146e00ba75e78171f97063498e97994f777e88a96ccfd619
6
+ metadata.gz: e0c130a088be2af900585efd372348c2e5c10477904fc38c43063a293351d374884010b40bc28a8e4e81b970a9096c16e12ce696a2c8e758df9566745903561b
7
+ data.tar.gz: 694280ee151d894899ed46c7bc444a6e0ca90f9d854098cb32062e8d943441c3fc224e8bbd1f2ef538ce2df1808e95808d49959ca48223df997ea18839dcf58e
data/README.adoc CHANGED
@@ -38,13 +38,22 @@ instructions.
38
38
 
39
39
  [source, sh]
40
40
  ----
41
- ./exe/expressir
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
- bin/rspec
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
- When new extension is gnerated and tested plase check in updated C++ files to git (```rake generate``` is NOT a CI step,
84
- extension source files are pulled from the repo).
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/express/parser"
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
- formatter = Class.new(Expressir::Express::Formatter) do
13
- include Expressir::Express::SchemaHeadFormatter
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, skip_empty: true)
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
- module Cli
6
- def self.ui
7
- Expressir::Cli::UI
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
- def self.start(args)
11
- Base.start(args)
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
- class Base < Thor
15
- desc "version", "The Expressir Version"
16
- def version
17
- Cli.ui.say("Version #{Expressir::VERSION}")
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
- if !empty or include_empty
108
- hash[variable.to_s] = if value.is_a? Array
109
- value.map do |value|
110
- if value.is_a? ModelElement
111
- value.to_hash(root_path: root_path, formatter: formatter, include_empty: include_empty)
112
- else
113
- value
114
- end
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] = if value.is_a? Array
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
- elsif value.is_a? Hash
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
- if value.is_a? Array
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
- elsif value.is_a? ModelElement
216
+ when ModelElement
201
217
  value.parent = self
202
218
  end
203
219
  end
@@ -18,6 +18,7 @@ module Expressir
18
18
  *schemas
19
19
  ]
20
20
  end
21
+
21
22
  end
22
23
  end
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module Expressir
2
- VERSION = "1.3.3".freeze
2
+ VERSION = "1.4.1".freeze
3
3
  end
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("Version #{Expressir::VERSION}")
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.3.3
4
+ version: 1.4.1
5
5
  platform: aarch64-linux-musl
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-18 00:00:00.000000000 Z
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
@@ -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