rbdantic 0.1.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 (40) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +245 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +5 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +852 -0
  8. data/README_CN.md +852 -0
  9. data/Rakefile +12 -0
  10. data/lib/rbdantic/base/access.rb +105 -0
  11. data/lib/rbdantic/base/dsl.rb +79 -0
  12. data/lib/rbdantic/base/validation.rb +152 -0
  13. data/lib/rbdantic/base.rb +30 -0
  14. data/lib/rbdantic/config.rb +60 -0
  15. data/lib/rbdantic/error_detail.rb +54 -0
  16. data/lib/rbdantic/field.rb +188 -0
  17. data/lib/rbdantic/json_schema/defs_registry.rb +79 -0
  18. data/lib/rbdantic/json_schema/generator.rb +148 -0
  19. data/lib/rbdantic/json_schema/types.rb +98 -0
  20. data/lib/rbdantic/serialization/dumper.rb +133 -0
  21. data/lib/rbdantic/serialization/json_serializer.rb +60 -0
  22. data/lib/rbdantic/validators/field_validator.rb +83 -0
  23. data/lib/rbdantic/validators/model_validator.rb +59 -0
  24. data/lib/rbdantic/validators/types/array.rb +77 -0
  25. data/lib/rbdantic/validators/types/base.rb +78 -0
  26. data/lib/rbdantic/validators/types/boolean.rb +37 -0
  27. data/lib/rbdantic/validators/types/float.rb +32 -0
  28. data/lib/rbdantic/validators/types/hash.rb +54 -0
  29. data/lib/rbdantic/validators/types/integer.rb +28 -0
  30. data/lib/rbdantic/validators/types/model.rb +75 -0
  31. data/lib/rbdantic/validators/types/number.rb +63 -0
  32. data/lib/rbdantic/validators/types/string.rb +70 -0
  33. data/lib/rbdantic/validators/types/symbol.rb +30 -0
  34. data/lib/rbdantic/validators/types/time.rb +33 -0
  35. data/lib/rbdantic/validators/types.rb +63 -0
  36. data/lib/rbdantic/validators/validator_context.rb +43 -0
  37. data/lib/rbdantic/version.rb +5 -0
  38. data/lib/rbdantic.rb +8 -0
  39. data/sig/rbdantic.rbs +4 -0
  40. metadata +84 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 37afa4a091552f16fc1f64e2d62d379bd951b3dad5629a89b0592830ca295040
4
+ data.tar.gz: 76a92811bedd13a1ebb80e07e0f64ea49304dab9e05254830b28aeb70259d120
5
+ SHA512:
6
+ metadata.gz: 135f2987d799a19605d12ea4cdde9965bc5e8b26b73fb5ecd10c41b4bfd77505a3db12d5bc81a69cb4b842a675d20f8ce3511a390866cb95f4d4fc7eee144266
7
+ data.tar.gz: b7006c98da7cd021f722d38b16461a36bbf168bfbeb9ff8612d88130f733802d6054ba32b03a5d92d2228b0e93983a8de32234750e49a19be62d3b8c656c946e
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,245 @@
1
+ ---
2
+ AllCops:
3
+ TargetRubyVersion: 2.7
4
+ NewCops: enable
5
+ SuggestExtensions: false
6
+
7
+ Style/StringLiterals:
8
+ EnforcedStyle: double_quotes
9
+
10
+ Style/StringLiteralsInInterpolation:
11
+ EnforcedStyle: double_quotes
12
+
13
+ # RSpec DSL naturally has long blocks
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - spec/**/*.rb
17
+
18
+ # RSpec uses do..end for describe/it blocks
19
+ Style/BlockDelimiters:
20
+ Exclude:
21
+ - spec/**/*.rb
22
+
23
+ # RSpec describe blocks often chain
24
+ Style/MultilineBlockChain:
25
+ Exclude:
26
+ - spec/**/*.rb
27
+
28
+ # Trailing underscores in block args are idiomatic for unused vars
29
+ Style/TrailingUnderscoreVariable:
30
+ Enabled: false
31
+
32
+ # RSpec often defines classes inside blocks for testing
33
+ Lint/ConstantDefinitionInBlock:
34
+ Exclude:
35
+ - spec/**/*.rb
36
+
37
+ # Unused block/method args in specs are common
38
+ Lint/UnusedBlockArgument:
39
+ Exclude:
40
+ - spec/**/*.rb
41
+
42
+ Lint/UnusedMethodArgument:
43
+ Enabled: false
44
+
45
+ # One-line methods can be concise
46
+ Style/SingleLineMethods:
47
+ Enabled: false
48
+
49
+ # Documentation not required for all classes
50
+ Style/Documentation:
51
+ Enabled: false
52
+
53
+ # Allow longer lines for readability
54
+ Layout/LineLength:
55
+ Max: 150
56
+
57
+ # Methods can be reasonably long
58
+ Metrics/MethodLength:
59
+ Max: 35
60
+ Exclude:
61
+ - lib/rbdantic/base.rb
62
+ - lib/rbdantic/json_schema/generator.rb
63
+
64
+ # Allow some complexity
65
+ Metrics/AbcSize:
66
+ Max: 35
67
+ Exclude:
68
+ - lib/rbdantic/base.rb
69
+ - lib/rbdantic/json_schema/generator.rb
70
+
71
+ Metrics/CyclomaticComplexity:
72
+ Max: 20
73
+ Exclude:
74
+ - lib/rbdantic/base.rb
75
+
76
+ Metrics/PerceivedComplexity:
77
+ Max: 20
78
+ Exclude:
79
+ - lib/rbdantic/base.rb
80
+
81
+ # Allow single-line if/unless for simple cases
82
+ Style/IfUnlessModifier:
83
+ Enabled: false
84
+
85
+ # Guard clauses aren't always better
86
+ Style/GuardClause:
87
+ Enabled: false
88
+
89
+ # Allow empty else (explicit nil returns)
90
+ Style/EmptyElse:
91
+ Enabled: false
92
+
93
+ # Symbol/Word arrays are fine either way
94
+ Style/SymbolArray:
95
+ Enabled: false
96
+
97
+ Style/WordArray:
98
+ Enabled: false
99
+
100
+ # Allow trailing empty lines
101
+ Layout/TrailingEmptyLines:
102
+ Enabled: false
103
+
104
+ # Allow extra spacing for alignment
105
+ Layout/ExtraSpacing:
106
+ Enabled: false
107
+
108
+ # Trailing whitespace is cosmetic
109
+ Layout/TrailingWhitespace:
110
+ Enabled: false
111
+
112
+ # Allow semicolons for one-liners
113
+ Style/Semicolon:
114
+ Enabled: false
115
+
116
+ # Raise args style is flexible
117
+ Style/RaiseArgs:
118
+ Enabled: false
119
+
120
+ # Multiple comparisons are sometimes needed
121
+ Style/MultipleComparison:
122
+ Enabled: false
123
+
124
+ # Safe navigation isn't always better
125
+ Style/SafeNavigation:
126
+ Enabled: false
127
+
128
+ # Identical conditional branches sometimes make sense
129
+ Style/IdenticalConditionalBranches:
130
+ Enabled: false
131
+
132
+ # Parallel assignment is fine
133
+ Style/ParallelAssignment:
134
+ Enabled: false
135
+
136
+ # Redundant begin is sometimes clearer
137
+ Style/RedundantBegin:
138
+ Enabled: false
139
+
140
+ # Rescue modifier for simple cases
141
+ Style/RescueModifier:
142
+ Enabled: false
143
+
144
+ # Ternary parentheses for readability
145
+ Style/TernaryParentheses:
146
+ Enabled: false
147
+
148
+ # Even/odd check is fine either way
149
+ Style/EvenOdd:
150
+ Enabled: false
151
+
152
+ # Predicate prefix (is_ vs has_) is flexible
153
+ Naming/PredicatePrefix:
154
+ Enabled: false
155
+
156
+ # Memoized instance variable name (_var vs @var)
157
+ Naming/MemoizedInstanceVariableName:
158
+ Enabled: false
159
+
160
+ # Accessor method names (get_/set_) are fine
161
+ Naming/AccessorMethodName:
162
+ Enabled: false
163
+
164
+ # Allow conditional assignment
165
+ Style/ConditionalAssignment:
166
+ Enabled: false
167
+
168
+ # Hash each methods are fine
169
+ Style/HashEachMethods:
170
+ Enabled: false
171
+
172
+ # Numeric predicate (zero? vs == 0)
173
+ Style/NumericPredicate:
174
+ Enabled: false
175
+
176
+ # Redundant parentheses for clarity
177
+ Style/RedundantParentheses:
178
+ Enabled: false
179
+
180
+ # Regexp literal style is flexible
181
+ Style/RegexpLiteral:
182
+ Enabled: false
183
+
184
+ # Sole nested conditional is fine
185
+ Style/SoleNestedConditional:
186
+ Enabled: false
187
+
188
+ # Allow class/module to be reasonably long
189
+ Metrics/ClassLength:
190
+ Max: 200
191
+ Exclude:
192
+ - lib/rbdantic/base.rb
193
+
194
+ Metrics/ModuleLength:
195
+ Max: 200
196
+ Exclude:
197
+ - lib/rbdantic/base.rb
198
+
199
+ # Parameter lists - some methods need many params
200
+ Metrics/ParameterLists:
201
+ Max: 10
202
+
203
+ # Layout indentation - follow project style
204
+ Layout/FirstHashElementIndentation:
205
+ Enabled: false
206
+
207
+ Layout/FirstArrayElementIndentation:
208
+ Enabled: false
209
+
210
+ # Useless assignment in specs is common
211
+ Lint/UselessAssignment:
212
+ Exclude:
213
+ - spec/**/*.rb
214
+
215
+ # Empty line after guard clause - cosmetic
216
+ Layout/EmptyLineAfterGuardClause:
217
+ Enabled: false
218
+
219
+ # Suppressed exception in number conversion
220
+ Lint/SuppressedExceptionInNumberConversion:
221
+ Enabled: false
222
+
223
+ # Duplicate branch - sometimes intentional for clarity
224
+ Lint/DuplicateBranch:
225
+ Enabled: false
226
+
227
+ # Empty class - used for testing
228
+ Lint/EmptyClass:
229
+ Enabled: false
230
+
231
+ # Require MFA in gemspec - not needed for this project
232
+ Gemspec/RequireMFA:
233
+ Enabled: false
234
+
235
+ # Method name style - snake_case is standard but allow flexibility
236
+ Naming/MethodName:
237
+ Enabled: false
238
+
239
+ # Predicate method naming
240
+ Naming/PredicateMethod:
241
+ Enabled: false
242
+
243
+ # Reduce to hash - sometimes cleaner
244
+ Style/ReduceToHash:
245
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-04-04
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 cp5670681
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.