smart_schema 0.11.0 → 0.12.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +11 -0
  4. data/Gemfile.lock +226 -66
  5. data/LICENSE.txt +1 -1
  6. data/README.md +69 -0
  7. data/bin/console +1 -1
  8. data/lib/smart_core/schema/checker/rules/optional.rb +2 -0
  9. data/lib/smart_core/schema/checker/rules/options/type.rb +6 -4
  10. data/lib/smart_core/schema/checker/rules/required.rb +2 -0
  11. data/lib/smart_core/schema/configuration.rb +33 -0
  12. data/lib/smart_core/schema/errors.rb +52 -0
  13. data/lib/smart_core/schema/plugins/abstract.rb +55 -0
  14. data/lib/smart_core/schema/plugins/access_mixin.rb +47 -0
  15. data/lib/smart_core/schema/plugins/dry_types/dry_types/abstract_factory.rb +91 -0
  16. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation/base.rb +9 -0
  17. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation/cast.rb +21 -0
  18. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation/valid.rb +16 -0
  19. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation/validate.rb +19 -0
  20. data/lib/smart_core/schema/plugins/dry_types/dry_types/operation.rb +12 -0
  21. data/lib/smart_core/schema/plugins/dry_types/dry_types.rb +10 -0
  22. data/lib/smart_core/schema/plugins/dry_types/errors.rb +13 -0
  23. data/lib/smart_core/schema/plugins/dry_types.rb +27 -0
  24. data/lib/smart_core/schema/plugins/registry.rb +158 -0
  25. data/lib/smart_core/schema/plugins/registry_interface.rb +63 -0
  26. data/lib/smart_core/schema/plugins.rb +17 -0
  27. data/lib/smart_core/schema/type_system/interop/abstract_factory.rb +80 -0
  28. data/lib/smart_core/schema/type_system/interop/aliasing/alias_list.rb +131 -0
  29. data/lib/smart_core/schema/type_system/interop/aliasing.rb +72 -0
  30. data/lib/smart_core/schema/type_system/interop/operation.rb +30 -0
  31. data/lib/smart_core/schema/type_system/interop.rb +120 -0
  32. data/lib/smart_core/schema/type_system/registry.rb +162 -0
  33. data/lib/smart_core/schema/type_system/registry_interface.rb +87 -0
  34. data/lib/smart_core/schema/type_system/smart_types/abstract_factory.rb +91 -0
  35. data/lib/smart_core/schema/type_system/smart_types/operation/base.rb +8 -0
  36. data/lib/smart_core/schema/type_system/smart_types/operation/cast.rb +16 -0
  37. data/lib/smart_core/schema/type_system/smart_types/operation/valid.rb +16 -0
  38. data/lib/smart_core/schema/type_system/smart_types/operation/validate.rb +16 -0
  39. data/lib/smart_core/schema/type_system/smart_types/operation.rb +13 -0
  40. data/lib/smart_core/schema/type_system/smart_types.rb +48 -0
  41. data/lib/smart_core/schema/type_system.rb +16 -0
  42. data/lib/smart_core/schema/version.rb +2 -2
  43. data/lib/smart_core/schema.rb +16 -1
  44. data/smart_schema.gemspec +18 -14
  45. metadata +89 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d11dda1a68409b32b4256ea9b364e83eea9aba1bbf1eb83dccc346dbffa92eb
4
- data.tar.gz: 8db348ce6ca9c2332fe7e5dc3a21c29101bd7c3eea2202d6e67d04322d523286
3
+ metadata.gz: 74e134abfe38db899c619e5774e6ec099ee6da07093f5f2fb9bdf4ba197da792
4
+ data.tar.gz: 07056cc72455f22f343208dfe96ebefac3fcd11b5396188f23e365de026f08ad
5
5
  SHA512:
6
- metadata.gz: f82f40dccd57d8e1a5b392ff6ea2ae235c32a455b048b2016759ce049d74cfa402c16066213c50d60aa0da49918e503cab211728cb0f6673ed7410e8c7aa477a
7
- data.tar.gz: c497d9ebd6154b00b42933cf08871af4122428271a13de366f2123a77923130d57fe4e842e922fddc270cdfd9fdbd8489fe9cf5df567aac2479ff99e5af29df3
6
+ metadata.gz: 5f1af5c3b2ca36297867ff1f4717ceb677b21d231907af7e3cd58a50be963ff11cb861d1180d48917e3407fcf3fc670b96ae6ba072da7362d3fb725619874e50
7
+ data.tar.gz: f8f0f90241e1cc2505ca27ada6257b5cadfff10c6216b99a9b66b63d85e864e17d1576a4cb720e847e8589f7eeaed3726f94f1dfcf249c2b417d6651da0efcae
data/.rubocop.yml CHANGED
@@ -5,7 +5,7 @@ inherit_gem:
5
5
  - lib/rubocop.rspec.yml
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 3.0.0
8
+ TargetRubyVersion: 3.3
9
9
  NewCops: enable
10
10
  Include:
11
11
  - lib/**/*.rb
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ # [0.12.0] - 2026-02-17
5
+ ## Added
6
+ - Plugin ecosystem;
7
+ - Support for **Ruby@4.x**;
8
+ - Support for `dry-types` type system;
9
+ - An ability to chose the preferred type system (globally at the moment):
10
+ - supports `smart-types` (by default);
11
+ - supports `dry-types` (as a plugin);
12
+ ## Changed
13
+ - *Ruby@3.3* is a minimal ruby version at the moment;
14
+
4
15
  # [0.11.0] - 2022-11-25
5
16
  ## Changed
6
17
  - Reduced object allocation count inside the type validation logic (updated `smart_types` to `~> 0.8`);
data/Gemfile.lock CHANGED
@@ -1,106 +1,266 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_schema (0.10.0)
4
+ smart_schema (0.12.0)
5
+ qonfig (~> 0.30)
5
6
  smart_engine (~> 0.17)
6
7
  smart_types (~> 0.8)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- activesupport (7.0.4)
12
- concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ activesupport (8.1.2)
13
+ base64
14
+ bigdecimal
15
+ concurrent-ruby (~> 1.0, >= 1.3.1)
16
+ connection_pool (>= 2.2.5)
17
+ drb
13
18
  i18n (>= 1.6, < 2)
19
+ json
20
+ logger (>= 1.4.2)
14
21
  minitest (>= 5.1)
15
- tzinfo (~> 2.0)
16
- armitage-rubocop (1.36.0)
17
- rubocop (= 1.36.0)
18
- rubocop-performance (= 1.15.0)
19
- rubocop-rails (= 2.16.1)
20
- rubocop-rake (= 0.6.0)
21
- rubocop-rspec (= 2.13.2)
22
- ast (2.4.2)
22
+ securerandom (>= 0.3)
23
+ tzinfo (~> 2.0, >= 2.0.5)
24
+ uri (>= 0.13.1)
25
+ armitage-rubocop (1.81.7.0)
26
+ rubocop (= 1.81.7)
27
+ rubocop-capybara (= 2.22.1)
28
+ rubocop-factory_bot (= 2.28.0)
29
+ rubocop-on-rbs (= 1.8.0)
30
+ rubocop-performance (= 1.26.1)
31
+ rubocop-rails (= 2.33.4)
32
+ rubocop-rake (= 0.7.1)
33
+ rubocop-rspec (= 3.8.0)
34
+ rubocop-rspec_rails (= 2.32.0)
35
+ rubocop-thread_safety (= 0.7.3)
36
+ ast (2.4.3)
37
+ base64 (0.3.0)
38
+ bigdecimal (4.0.1)
23
39
  coderay (1.1.3)
24
- concurrent-ruby (1.1.10)
25
- diff-lcs (1.5.0)
26
- docile (1.4.0)
27
- i18n (1.12.0)
40
+ concurrent-ruby (1.3.6)
41
+ connection_pool (3.0.2)
42
+ diff-lcs (1.6.2)
43
+ docile (1.4.1)
44
+ drb (2.2.3)
45
+ dry-core (1.2.0)
28
46
  concurrent-ruby (~> 1.0)
29
- json (2.6.2)
30
- method_source (1.0.0)
31
- minitest (5.16.3)
32
- parallel (1.22.1)
33
- parser (3.1.2.1)
47
+ logger
48
+ zeitwerk (~> 2.6)
49
+ dry-inflector (1.3.1)
50
+ dry-logic (1.6.0)
51
+ bigdecimal
52
+ concurrent-ruby (~> 1.0)
53
+ dry-core (~> 1.1)
54
+ zeitwerk (~> 2.6)
55
+ dry-types (1.9.1)
56
+ bigdecimal (>= 3.0)
57
+ concurrent-ruby (~> 1.0)
58
+ dry-core (~> 1.0)
59
+ dry-inflector (~> 1.0)
60
+ dry-logic (~> 1.4)
61
+ zeitwerk (~> 2.6)
62
+ i18n (1.14.8)
63
+ concurrent-ruby (~> 1.0)
64
+ io-console (0.8.2)
65
+ json (2.18.1)
66
+ language_server-protocol (3.17.0.5)
67
+ lint_roller (1.1.0)
68
+ logger (1.7.0)
69
+ method_source (1.1.0)
70
+ minitest (6.0.1)
71
+ prism (~> 1.5)
72
+ parallel (1.27.0)
73
+ parser (3.3.10.2)
34
74
  ast (~> 2.4.1)
35
- pry (0.14.1)
75
+ racc
76
+ prism (1.9.0)
77
+ pry (0.16.0)
36
78
  coderay (~> 1.1)
37
79
  method_source (~> 1.0)
38
- rack (3.0.1)
80
+ reline (>= 0.6.0)
81
+ pry-doc (1.7.0)
82
+ pry (~> 0.11)
83
+ yard (~> 0.9.21)
84
+ qonfig (0.30.0)
85
+ base64 (>= 0.2)
86
+ racc (1.8.1)
87
+ rack (3.2.5)
39
88
  rainbow (3.1.1)
40
- rake (13.0.6)
41
- regexp_parser (2.6.1)
42
- rexml (3.2.5)
43
- rspec (3.12.0)
44
- rspec-core (~> 3.12.0)
45
- rspec-expectations (~> 3.12.0)
46
- rspec-mocks (~> 3.12.0)
47
- rspec-core (3.12.0)
48
- rspec-support (~> 3.12.0)
49
- rspec-expectations (3.12.0)
89
+ rake (13.3.1)
90
+ rbs (3.10.3)
91
+ logger
92
+ tsort
93
+ regexp_parser (2.11.3)
94
+ reline (0.6.3)
95
+ io-console (~> 0.5)
96
+ rspec (3.13.2)
97
+ rspec-core (~> 3.13.0)
98
+ rspec-expectations (~> 3.13.0)
99
+ rspec-mocks (~> 3.13.0)
100
+ rspec-core (3.13.6)
101
+ rspec-support (~> 3.13.0)
102
+ rspec-expectations (3.13.5)
50
103
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.12.0)
52
- rspec-mocks (3.12.0)
104
+ rspec-support (~> 3.13.0)
105
+ rspec-mocks (3.13.7)
53
106
  diff-lcs (>= 1.2.0, < 2.0)
54
- rspec-support (~> 3.12.0)
55
- rspec-support (3.12.0)
56
- rubocop (1.36.0)
107
+ rspec-support (~> 3.13.0)
108
+ rspec-support (3.13.7)
109
+ rubocop (1.81.7)
57
110
  json (~> 2.3)
111
+ language_server-protocol (~> 3.17.0.2)
112
+ lint_roller (~> 1.1.0)
58
113
  parallel (~> 1.10)
59
- parser (>= 3.1.2.1)
114
+ parser (>= 3.3.0.2)
60
115
  rainbow (>= 2.2.2, < 4.0)
61
- regexp_parser (>= 1.8, < 3.0)
62
- rexml (>= 3.2.5, < 4.0)
63
- rubocop-ast (>= 1.20.1, < 2.0)
116
+ regexp_parser (>= 2.9.3, < 3.0)
117
+ rubocop-ast (>= 1.47.1, < 2.0)
64
118
  ruby-progressbar (~> 1.7)
65
- unicode-display_width (>= 1.4.0, < 3.0)
66
- rubocop-ast (1.23.0)
67
- parser (>= 3.1.1.0)
68
- rubocop-performance (1.15.0)
69
- rubocop (>= 1.7.0, < 2.0)
70
- rubocop-ast (>= 0.4.0)
71
- rubocop-rails (2.16.1)
119
+ unicode-display_width (>= 2.4.0, < 4.0)
120
+ rubocop-ast (1.49.0)
121
+ parser (>= 3.3.7.2)
122
+ prism (~> 1.7)
123
+ rubocop-capybara (2.22.1)
124
+ lint_roller (~> 1.1)
125
+ rubocop (~> 1.72, >= 1.72.1)
126
+ rubocop-factory_bot (2.28.0)
127
+ lint_roller (~> 1.1)
128
+ rubocop (~> 1.72, >= 1.72.1)
129
+ rubocop-on-rbs (1.8.0)
130
+ lint_roller (~> 1.1)
131
+ rbs (~> 3.5)
132
+ rubocop (>= 1.72.1, < 2.0)
133
+ zlib
134
+ rubocop-performance (1.26.1)
135
+ lint_roller (~> 1.1)
136
+ rubocop (>= 1.75.0, < 2.0)
137
+ rubocop-ast (>= 1.47.1, < 2.0)
138
+ rubocop-rails (2.33.4)
72
139
  activesupport (>= 4.2.0)
140
+ lint_roller (~> 1.1)
73
141
  rack (>= 1.1)
74
- rubocop (>= 1.33.0, < 2.0)
75
- rubocop-rake (0.6.0)
76
- rubocop (~> 1.0)
77
- rubocop-rspec (2.13.2)
78
- rubocop (~> 1.33)
79
- ruby-progressbar (1.11.0)
80
- simplecov (0.21.2)
142
+ rubocop (>= 1.75.0, < 2.0)
143
+ rubocop-ast (>= 1.44.0, < 2.0)
144
+ rubocop-rake (0.7.1)
145
+ lint_roller (~> 1.1)
146
+ rubocop (>= 1.72.1)
147
+ rubocop-rspec (3.8.0)
148
+ lint_roller (~> 1.1)
149
+ rubocop (~> 1.81)
150
+ rubocop-rspec_rails (2.32.0)
151
+ lint_roller (~> 1.1)
152
+ rubocop (~> 1.72, >= 1.72.1)
153
+ rubocop-rspec (~> 3.5)
154
+ rubocop-thread_safety (0.7.3)
155
+ lint_roller (~> 1.1)
156
+ rubocop (~> 1.72, >= 1.72.1)
157
+ rubocop-ast (>= 1.44.0, < 2.0)
158
+ ruby-progressbar (1.13.0)
159
+ securerandom (0.4.1)
160
+ simplecov (0.22.0)
81
161
  docile (~> 1.1)
82
162
  simplecov-html (~> 0.11)
83
163
  simplecov_json_formatter (~> 0.1)
84
- simplecov-html (0.12.3)
164
+ simplecov-html (0.13.2)
85
165
  simplecov_json_formatter (0.1.4)
86
166
  smart_engine (0.17.0)
87
167
  smart_types (0.8.0)
88
168
  smart_engine (~> 0.11)
89
- tzinfo (2.0.5)
169
+ tsort (0.2.0)
170
+ tzinfo (2.0.6)
90
171
  concurrent-ruby (~> 1.0)
91
- unicode-display_width (2.3.0)
172
+ unicode-display_width (3.2.0)
173
+ unicode-emoji (~> 4.1)
174
+ unicode-emoji (4.2.0)
175
+ uri (1.1.1)
176
+ yard (0.9.38)
177
+ zeitwerk (2.7.4)
178
+ zlib (3.2.2)
92
179
 
93
180
  PLATFORMS
94
- arm64-darwin-21
181
+ arm64-darwin-25
182
+ ruby
95
183
 
96
184
  DEPENDENCIES
97
- armitage-rubocop (~> 1.7)
98
- bundler (~> 2.2)
99
- pry (~> 0.13)
100
- rake (~> 13.0)
101
- rspec (~> 3.10)
102
- simplecov (~> 0.21)
185
+ armitage-rubocop (~> 1.81)
186
+ bundler
187
+ dry-types
188
+ pry (~> 0.16)
189
+ pry-doc (~> 1.7)
190
+ rake (~> 13.3)
191
+ rspec (~> 3.13)
192
+ simplecov (~> 0.22)
103
193
  smart_schema!
104
194
 
195
+ CHECKSUMS
196
+ activesupport (8.1.2) sha256=88842578ccd0d40f658289b0e8c842acfe9af751afee2e0744a7873f50b6fdae
197
+ armitage-rubocop (1.81.7.0) sha256=7ee404a2fea0f6dac5e12bda0d152851e90f0f6c9eb661064ea1c0f22e3511a9
198
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
199
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
200
+ bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
201
+ coderay (1.1.3) sha256=dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b
202
+ concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
203
+ connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
204
+ diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
205
+ docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
206
+ drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
207
+ dry-core (1.2.0) sha256=0cc5a7da88df397f153947eeeae42e876e999c1e30900f3c536fb173854e96a1
208
+ dry-inflector (1.3.1) sha256=7fb0c2bb04f67638f25c52e7ba39ab435d922a3a5c3cd196120f63accb682dcc
209
+ dry-logic (1.6.0) sha256=da6fedbc0f90fc41f9b0cc7e6f05f5d529d1efaef6c8dcc8e0733f685745cea2
210
+ dry-types (1.9.1) sha256=baebeecdb9f8395d6c9d227b62011279440943e3ef2468fe8ccc1ba11467f178
211
+ i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
212
+ io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
213
+ json (2.18.1) sha256=fe112755501b8d0466b5ada6cf50c8c3f41e897fa128ac5d263ec09eedc9f986
214
+ language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
215
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
216
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
217
+ method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
218
+ minitest (6.0.1) sha256=7854c74f48e2e975969062833adc4013f249a4b212f5e7b9d5c040bf838d54bb
219
+ parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
220
+ parser (3.3.10.2) sha256=6f60c84aa4bdcedb6d1a2434b738fe8a8136807b6adc8f7f53b97da9bc4e9357
221
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
222
+ pry (0.16.0) sha256=d76c69065698ed1f85e717bd33d7942c38a50868f6b0673c636192b3d1b6054e
223
+ pry-doc (1.7.0) sha256=6ada9fec062b54441c6444e44f94c345e5c8c0af499d654e40d5a581eb222d8e
224
+ qonfig (0.30.0) sha256=c6b9cd02fb707e919b72e17c866a69f16018c3f8c5e0faca4127f15deab29e19
225
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
226
+ rack (3.2.5) sha256=4cbd0974c0b79f7a139b4812004a62e4c60b145cba76422e288ee670601ed6d3
227
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
228
+ rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
229
+ rbs (3.10.3) sha256=70627f3919016134d554e6c99195552ae3ef6020fe034c8e983facc9c192daa6
230
+ regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
231
+ reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
232
+ rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
233
+ rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
234
+ rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
235
+ rspec-mocks (3.13.7) sha256=0979034e64b1d7a838aaaddf12bf065ea4dc40ef3d4c39f01f93ae2c66c62b1c
236
+ rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
237
+ rubocop (1.81.7) sha256=6fb5cc298c731691e2a414fe0041a13eb1beed7bab23aec131da1bcc527af094
238
+ rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd
239
+ rubocop-capybara (2.22.1) sha256=ced88caef23efea53f46e098ff352f8fc1068c649606ca75cb74650970f51c0c
240
+ rubocop-factory_bot (2.28.0) sha256=4b17fc02124444173317e131759d195b0d762844a71a29fe8139c1105d92f0cb
241
+ rubocop-on-rbs (1.8.0) sha256=ee8b734cd5bc0371fae32c8ff95082440cde562f52e1b74b5dfbe488de004643
242
+ rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
243
+ rubocop-rails (2.33.4) sha256=34ec8f6637706dc224483d949ccc88b3e41596a81a11a1ec0c7d74ecbea356b5
244
+ rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
245
+ rubocop-rspec (3.8.0) sha256=28440dccb3f223a9938ca1f946bd3438275b8c6c156dab909e2cb8bc424cab33
246
+ rubocop-rspec_rails (2.32.0) sha256=4a0d641c72f6ebb957534f539d9d0a62c47abd8ce0d0aeee1ef4701e892a9100
247
+ rubocop-thread_safety (0.7.3) sha256=067cdd52fbf5deffc18995437e45b5194236eaff4f71de3375a1f6052e48f431
248
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
249
+ securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
250
+ simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
251
+ simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
252
+ simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
253
+ smart_engine (0.17.0) sha256=33321745063737a9262f53ef7b5b040d65f8d8f5a5230ac6d3c2461b0404a52b
254
+ smart_schema (0.12.0)
255
+ smart_types (0.8.0) sha256=87879face377e4738e887f4b34657f8ed9572b8d22bd2deb6028bb45261a5bb7
256
+ tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
257
+ tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
258
+ unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
259
+ unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
260
+ uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
261
+ yard (0.9.38) sha256=721fb82afb10532aa49860655f6cc2eaa7130889df291b052e1e6b268283010f
262
+ zeitwerk (2.7.4) sha256=2bef90f356bdafe9a6c2bd32bcd804f83a4f9b8bc27f3600fff051eb3edcec8b
263
+ zlib (3.2.2) sha256=908e61263f99c1371b5422581e2d6663bd37c6b04ae13b5f8cb10b0d09379f40
264
+
105
265
  BUNDLED WITH
106
- 2.3.17
266
+ 4.0.3
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020-2021 Rustam Ibragimov
3
+ Copyright (c) 2020-2026 Rustam Ibragimov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -168,10 +168,66 @@ Possible errors:
168
168
  - `:required_key_not_found` (required key does not exist);
169
169
  - `:extra_key` (concrete key does not exist in schema);
170
170
 
171
+ ## Type System Customization
172
+
173
+ - supports `smart-types` (pre-configured by default);
174
+ - supports `dry-types` (requires `dry-types` gem required in your project);
175
+ - configuration has a global effect (single type-config for all Schema instances/classes)
176
+ - **NOTE**: this behavior will be reworked in future (mutliple type system support at once);
177
+
178
+ ### Type System Configuration and Usage
179
+
180
+ ```ruby
181
+ # IMPORTANT: inn order to use dry-types:
182
+ # 1. you should install dry-types and require dry-types in your projecgts
183
+ # 2. require dry_types plugin
184
+
185
+ require 'dry-types'
186
+ SmartCore::Schema.plugin(:dry_types) # fails if you try to enable this plugin without a pre-isntalled dry-types;
187
+ ```
188
+
189
+ ```ruby
190
+ SmartCore::Schema::Configuration.configure do |config|
191
+ config.type_system = :dry_types # :smart_types (:smart_types is used by default)
192
+ end
193
+ ```
194
+
195
+ ```ruby
196
+ # configure type aliases
197
+
198
+ # - for smart-types
199
+ SmartCore::Schema.type_system.type_alias(:integer, SmartCore::Types::Value::Integer)
200
+ # smart-types has a list of pre-configured aliases. see lib/smart_core/schema/type_system/smart_types.rb
201
+
202
+ # - for dry-types
203
+ SmartCore::Schema.type_system.type_alias(:integer, Dry::Types['integer'])
204
+ # dry-types has no pre-configured aliases.
205
+ ```
206
+
207
+ ```ruby
208
+ # classic smart-types usage
209
+ class MySchemaWithSmartTypes < SmartCore::Schema
210
+ schema do
211
+ required(:date).type(SmartCore::Types::Value::String) # object-style
212
+ required(:count).type(:integer) # alias-style
213
+ end
214
+ end
215
+
216
+ # dry-types usage
217
+ class MySchemaWithDryTypes < SmartCore::Schema
218
+ schema do
219
+ required(:date).type(Dry::Types['string']) # object-style
220
+ required(:count).type(:integer) # alias-style
221
+ end
222
+ end
223
+ ```
224
+
171
225
  ---
172
226
 
173
227
  ## Roadmap
174
228
 
229
+ - **(x.x.x)** - **(As Soon As Possible)** support for schema inhertiance with schema redefinition ;
230
+ - **(x.x.x)** - support for `.cast` in type definitions;
175
231
  - **(x.x.x)** - mutable schemas (value convertion during schema checking with returning the new coerced data structure);
176
232
  - **(x.x.x)** - public interface for type aliasing (custom type alias registration API);
177
233
  - **(x.x.x)** - support for `Array`-like data structures;
@@ -188,6 +244,19 @@ Possible errors:
188
244
  - **(0.9.0)** - support for another data structures (such as YAML strings, JSON strings, `Struct`, `OpenStruct`s, custom `Object`s and etc);
189
245
  - **(0.10.0)** - mixin-based implementation;
190
246
  - **(0.x.0)** - think about pattern matching;
247
+ - **(0.x.0)** - dependable schema checks: we can conditionally check some parts of schema stracture that depends on schema key values;
248
+ - **(0.x.0)** - support for dynamic keys, when the key name can have any name and can be a value or a schema;
249
+ ```ruby
250
+ # PROPOSAL:
251
+
252
+ required(:some_key) do
253
+ dynamic do # dynamic schema
254
+ required(:kek).type(:string).filled
255
+ end
256
+
257
+ dynamic.type(:integer).filled # dynamic key
258
+ end
259
+ ```
191
260
 
192
261
  ---
193
262
 
data/bin/console CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
- require 'smart_core'
5
+ require 'smart_core/schema'
6
6
 
7
7
  require 'pry'
8
8
  Pry.start
@@ -18,8 +18,10 @@ class SmartCore::Schema::Checker::Rules::Optional < SmartCore::Schema::Checker::
18
18
  # @api private
19
19
  # @since 0.1.0
20
20
  # @version 0.3.0
21
+ # rubocop:disable Style/SuperArguments
21
22
  def initialize(root_reconciler, schema_key, &nested_definitions)
22
23
  super(root_reconciler, schema_key, &nested_definitions)
23
24
  @requirement = SmartCore::Schema::Checker::Rules::Requirement::Optional.new(self)
24
25
  end
26
+ # rubocop:enable Style/SuperArguments
25
27
  end
@@ -62,17 +62,19 @@ class SmartCore::Schema::Checker::Rules::Options
62
62
  def resolve_required_type(required_type)
63
63
  unless required_type.is_a?(String) ||
64
64
  required_type.is_a?(Symbol) ||
65
- required_type.is_a?(SmartCore::Types::Primitive)
65
+ required_type.is_a?(SmartCore::Schema.type_system.primitive_type_class)
66
66
  raise(SmartCore::Schema::ArgumentError, <<~ERROR_MESSAGE)
67
- Schema key type should be a type of string, symbol or SmartCore:Types::Primitive (got: #{required_type})
67
+ Schema key type should be a type of string, symbol or
68
+ #{SmartCore::Schema.type_system.primitive_type_class.name} (got: #{required_type})
68
69
  ERROR_MESSAGE
69
70
  end
70
71
 
71
- if required_type.is_a?(SmartCore::Types::Primitive)
72
+ if required_type.is_a?(SmartCore::Schema.type_system.primitive_type_class)
72
73
  required_type
73
74
  else
74
75
  begin
75
- SmartCore::Schema::Checker::Rules::TYPE_ALIASES.fetch(required_type.to_s)
76
+ SmartCore::Schema.type_system.type_from_alias(required_type)
77
+ # SmartCore::Schema::Checker::Rules::TYPE_ALIASES.fetch(required_type.to_s)
76
78
  rescue KeyError
77
79
  raise(SmartCore::Schema::ArgumentError, <<~ERROR_MESSAGE)
78
80
  Chosen schema key type is not supported or not registered (got #{required_type})
@@ -18,8 +18,10 @@ class SmartCore::Schema::Checker::Rules::Required < SmartCore::Schema::Checker::
18
18
  # @api private
19
19
  # @since 0.1.0
20
20
  # @version 0.3.0
21
+ # rubocop:disable Style/SuperArguments
21
22
  def initialize(root_reconciler, schema_key, &nested_definitions)
22
23
  super(root_reconciler, schema_key, &nested_definitions)
23
24
  @requirement = SmartCore::Schema::Checker::Rules::Requirement::Required.new(self)
24
25
  end
26
+ # rubocop:enable Style/SuperArguments
25
27
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'qonfig'
4
+
5
+ # @api public
6
+ # @since 0.12.0
7
+ module SmartCore::Schema::Configuration
8
+ # @since 0.12.0
9
+ include Qonfig::Configurable
10
+
11
+ # @api public
12
+ # @since 0.12.0
13
+ extend SmartCore::Schema::Plugins::AccessMixin
14
+
15
+ class << self
16
+ # @param setting_key [String, Symbol]
17
+ # @return [Qonfig::Settings, Any]
18
+ #
19
+ # @api private
20
+ # @since 0.12.0
21
+ def [](setting_key)
22
+ config[setting_key]
23
+ end
24
+ end
25
+
26
+ # @since 0.12.0
27
+ configuration do
28
+ setting :type_system, :smart_types
29
+ validate :default_type_system do |value|
30
+ SmartCore::Schema::TypeSystem.resolve(value) rescue false
31
+ end
32
+ end
33
+ end
@@ -9,5 +9,57 @@ class SmartCore::Schema
9
9
  # @api public
10
10
  # @since 0.1.0
11
11
  ArgumentError = Class.new(SmartCore::ArgumentError)
12
+
13
+ # @api public
14
+ # @since 0.12.0
15
+ NoTypeAliasError = Class.new(Error)
16
+
17
+ # @api public
18
+ # @since 0.12.0
19
+ PluginError = Class.new(Error)
20
+
21
+ # @api public
22
+ # @since 0.12.0
23
+ UnresolvedPluginDependencyError = Class.new(PluginError)
24
+
25
+ # @api public
26
+ # @since 0.12.0
27
+ AlreadyRegisteredPluginError = Class.new(PluginError)
28
+
29
+ # @api public
30
+ # @since 0.12.0
31
+ UnregisteredPluginError = Class.new(PluginError)
32
+
33
+ # @api public
34
+ # @since 0.12.0
35
+ TypeSystemError = Class.new(Error)
36
+
37
+ # @api public
38
+ # @since 0.5.1
39
+ IncorrectTypeError = Class.new(TypeSystemError)
40
+
41
+ # @api public
42
+ # @since 0.12.0
43
+ TypeAliasNotFoundError = Class.new(TypeSystemError)
44
+
45
+ # @api public
46
+ # @since 0.12.0
47
+ IncorrectTypeSystemInteropError = Class.new(TypeSystemError)
48
+
49
+ # @api public
50
+ # @since 0.12.0
51
+ IncorrectTypeObjectError = Class.new(TypeSystemError)
52
+
53
+ # @api public
54
+ # @since 0.12.0
55
+ UnsupportedTypeSystemError = Class.new(TypeSystemError)
56
+
57
+ # @api public
58
+ # @since 0.12.0
59
+ UnsupportedTypeOperationError = Class.new(TypeSystemError)
60
+
61
+ # @api public
62
+ # @since 0.12.0
63
+ TypeCastingUnsupportedError = Class.new(UnsupportedTypeOperationError)
12
64
  end
13
65
  # rubocop:enable Style/StaticClass
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ # @since 0.12.0
5
+ class SmartCore::Schema::Plugins::Abstract
6
+ class << self
7
+ # @param child_klass [Class]
8
+ # @return [void]
9
+ #
10
+ # @api private
11
+ # @since 0.12.0
12
+ def inherited(child_klass)
13
+ child_klass.instance_variable_set(:@__loaded__, false)
14
+ child_klass.instance_variable_set(:@__lock__, SmartCore::Engine::Lock.new)
15
+ super
16
+ end
17
+
18
+ # @return [void]
19
+ #
20
+ # @api private
21
+ # @since 0.12.0
22
+ def load!
23
+ __thread_safe__ do
24
+ unless @__loaded__
25
+ @__loaded__ = true
26
+ install!
27
+ end
28
+ end
29
+ end
30
+
31
+ # @return [Boolean]
32
+ #
33
+ # @api private
34
+ # @since 0.12.0
35
+ def loaded?
36
+ __thread_safe__ { @__loaded__ }
37
+ end
38
+
39
+ private
40
+
41
+ # @return [void]
42
+ #
43
+ # @api private
44
+ # @since 0.12.0
45
+ def install!; end
46
+
47
+ # @return [Any]
48
+ #
49
+ # @api private
50
+ # @since 0.12.0
51
+ def __thread_safe__(&block)
52
+ @__lock__.synchronize(&block)
53
+ end
54
+ end
55
+ end