expressir 1.3.2-x64-mingw32 → 1.4.0-x64-mingw32

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: be14f65cfc48a20241142f352355408685482fc5c707b68572dda4d9094f8b91
4
- data.tar.gz: aed04c65641a99f426fd4cf65c856024ffe56340c424c4cc54ba5c91543ce7db
3
+ metadata.gz: 1fa3bd98fd6c122e1f67ba646d214c36a1e7f39ba46b5760eb4e8db843b332c3
4
+ data.tar.gz: 0e3e4e3caf499171d67b186caad52598186fd87d19977d726ab78078fd8137bf
5
5
  SHA512:
6
- metadata.gz: a31aa776ca48285885e960eb998723bed82f4152394c3caef9ba3720b498a33f3ff9437615312aa099b3fc0d5d43e9d2d326f8b669c0d6f75ef0064e3e4c2717
7
- data.tar.gz: b7573313135702b9c3a12236a6df9f172aac23e2d2b48c83e04d39d8ae93727ea550f22cf3a6e95f3d1febbb90fe492c428b8067b880d1e01b8cc314023fc603
6
+ metadata.gz: 8c266400458db0e62193a85af435807f81f1ca147cc2730852d5bef06851dfd00bbe60984794446ec7498496911370c0e756bf67acb97ff629ba32dc63fdb4fe
7
+ data.tar.gz: bd8409e32deb0d79ffc2170cb3ff3f41b855b39594a5671c32842ede9e8b3bed26ed58459c546a874726766610e3b03d0de0d6391a440d2461db8d3f0706ff33
@@ -44,7 +44,7 @@ jobs:
44
44
  strategy:
45
45
  fail-fast: false
46
46
  matrix:
47
- platform: [ linux-gnu, windows, darwin ]
47
+ platform: [ linux-gnu, linux-musl, windows, darwin ]
48
48
  steps:
49
49
  - uses: actions/checkout@v4
50
50
  with:
@@ -106,6 +106,11 @@ jobs:
106
106
  name: pkg-linux-gnu
107
107
  path: pkg
108
108
 
109
+ - uses: actions/download-artifact@v4
110
+ with:
111
+ name: pkg-linux-musl
112
+ path: pkg
113
+
109
114
  - uses: actions/download-artifact@v4
110
115
  with:
111
116
  name: pkg-windows
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,19 @@
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
8
- end
9
-
10
- def self.start(args)
11
- Base.start(args)
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
12
12
  end
13
13
 
14
- class Base < Thor
15
- desc "version", "The Expressir Version"
16
- def version
17
- Cli.ui.say("Version #{Expressir::VERSION}")
18
- end
14
+ desc "version", "Expressir Version"
15
+ def version
16
+ say(Expressir::VERSION)
19
17
  end
20
18
  end
21
19
  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.2".freeze
2
+ VERSION = "1.4.0".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.2
4
+ version: 1.4.0
5
5
  platform: x64-mingw32
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-23 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