data_model 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +6 -2
  3. data/.rubocop.yml +11 -2
  4. data/.ruby-version +2 -0
  5. data/Gemfile.lock +91 -54
  6. data/Guardfile +20 -0
  7. data/Rakefile +32 -0
  8. data/data_model.gemspec +52 -0
  9. data/lib/data_model/boolean.rb +7 -0
  10. data/lib/data_model/builtin/array.rb +73 -0
  11. data/lib/data_model/builtin/big_decimal.rb +64 -0
  12. data/lib/data_model/builtin/boolean.rb +37 -0
  13. data/lib/data_model/builtin/date.rb +60 -0
  14. data/lib/data_model/builtin/float.rb +64 -0
  15. data/lib/data_model/builtin/hash.rb +119 -0
  16. data/lib/data_model/builtin/integer.rb +64 -0
  17. data/lib/data_model/builtin/string.rb +88 -0
  18. data/lib/data_model/builtin/symbol.rb +64 -0
  19. data/lib/data_model/builtin/time.rb +60 -0
  20. data/lib/data_model/builtin.rb +23 -0
  21. data/lib/data_model/error.rb +107 -0
  22. data/lib/data_model/errors.rb +296 -0
  23. data/lib/data_model/fixtures/array.rb +61 -0
  24. data/lib/data_model/fixtures/big_decimal.rb +55 -0
  25. data/lib/data_model/fixtures/boolean.rb +35 -0
  26. data/lib/data_model/fixtures/date.rb +53 -0
  27. data/lib/data_model/fixtures/example.rb +29 -0
  28. data/lib/data_model/fixtures/float.rb +53 -0
  29. data/lib/data_model/fixtures/hash.rb +66 -0
  30. data/lib/data_model/fixtures/integer.rb +53 -0
  31. data/lib/data_model/fixtures/string.rb +110 -0
  32. data/lib/data_model/fixtures/symbol.rb +56 -0
  33. data/lib/data_model/fixtures/time.rb +53 -0
  34. data/lib/data_model/logging.rb +23 -0
  35. data/lib/data_model/model.rb +21 -44
  36. data/lib/data_model/scanner.rb +92 -56
  37. data/lib/data_model/testing/minitest.rb +79 -0
  38. data/lib/data_model/testing.rb +6 -0
  39. data/lib/data_model/type.rb +41 -39
  40. data/lib/data_model/type_registry.rb +68 -0
  41. data/lib/data_model/version.rb +3 -1
  42. data/lib/data_model.rb +32 -16
  43. data/sorbet/config +4 -0
  44. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  45. data/sorbet/rbi/gems/minitest@5.18.0.rbi +1491 -0
  46. data/sorbet/rbi/gems/zeitwerk.rbi +196 -0
  47. data/sorbet/rbi/gems/zeitwerk@2.6.7.rbi +966 -0
  48. data/sorbet/rbi/todo.rbi +5 -0
  49. data/sorbet/tapioca/config.yml +13 -0
  50. data/sorbet/tapioca/require.rb +4 -0
  51. metadata +139 -17
  52. data/config/sus.rb +0 -2
  53. data/fixtures/schema.rb +0 -14
  54. data/lib/data_model/registry.rb +0 -44
@@ -0,0 +1,5 @@
1
+ # DO NOT EDIT MANUALLY
2
+ # This is an autogenerated file for unresolved constants.
3
+ # Please instead update this file by running `bin/tapioca todo`.
4
+
5
+ # typed: false
@@ -0,0 +1,13 @@
1
+ gem:
2
+ # Add your `gem` command parameters here:
3
+ #
4
+ # exclude:
5
+ # - gem_name
6
+ # doc: true
7
+ # workers: 5
8
+ dsl:
9
+ # Add your `dsl` command parameters here:
10
+ #
11
+ # exclude:
12
+ # - SomeGeneratorName
13
+ # workers: 5
@@ -0,0 +1,4 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ # Add your extra requires here (`bin/tapioca require` can be used to bootstrap this list)
metadata CHANGED
@@ -1,45 +1,129 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Briggs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-14 00:00:00.000000000 Z
11
+ date: 2023-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sorbet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: zeitwerk
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - "~>"
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: '2.6'
33
+ version: '0'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - "~>"
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
25
81
  - !ruby/object:Gem::Version
26
- version: '2.6'
82
+ version: '0'
27
83
  - !ruby/object:Gem::Dependency
28
- name: sus
84
+ name: rake
29
85
  requirement: !ruby/object:Gem::Requirement
30
86
  requirements:
31
- - - "~>"
87
+ - - ">="
32
88
  - !ruby/object:Gem::Version
33
- version: '0.14'
89
+ version: '0'
34
90
  type: :development
35
91
  prerelease: false
36
92
  version_requirements: !ruby/object:Gem::Requirement
37
93
  requirements:
38
- - - "~>"
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
39
102
  - !ruby/object:Gem::Version
40
- version: '0.14'
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sorbet-runtime
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
41
125
  - !ruby/object:Gem::Dependency
42
- name: solargraph
126
+ name: tapioca
43
127
  requirement: !ruby/object:Gem::Requirement
44
128
  requirements:
45
129
  - - ">="
@@ -61,16 +145,54 @@ extra_rdoc_files: []
61
145
  files:
62
146
  - ".editorconfig"
63
147
  - ".rubocop.yml"
148
+ - ".ruby-version"
64
149
  - Gemfile
65
150
  - Gemfile.lock
66
- - config/sus.rb
67
- - fixtures/schema.rb
151
+ - Guardfile
152
+ - Rakefile
153
+ - data_model.gemspec
68
154
  - lib/data_model.rb
155
+ - lib/data_model/boolean.rb
156
+ - lib/data_model/builtin.rb
157
+ - lib/data_model/builtin/array.rb
158
+ - lib/data_model/builtin/big_decimal.rb
159
+ - lib/data_model/builtin/boolean.rb
160
+ - lib/data_model/builtin/date.rb
161
+ - lib/data_model/builtin/float.rb
162
+ - lib/data_model/builtin/hash.rb
163
+ - lib/data_model/builtin/integer.rb
164
+ - lib/data_model/builtin/string.rb
165
+ - lib/data_model/builtin/symbol.rb
166
+ - lib/data_model/builtin/time.rb
167
+ - lib/data_model/error.rb
168
+ - lib/data_model/errors.rb
169
+ - lib/data_model/fixtures/array.rb
170
+ - lib/data_model/fixtures/big_decimal.rb
171
+ - lib/data_model/fixtures/boolean.rb
172
+ - lib/data_model/fixtures/date.rb
173
+ - lib/data_model/fixtures/example.rb
174
+ - lib/data_model/fixtures/float.rb
175
+ - lib/data_model/fixtures/hash.rb
176
+ - lib/data_model/fixtures/integer.rb
177
+ - lib/data_model/fixtures/string.rb
178
+ - lib/data_model/fixtures/symbol.rb
179
+ - lib/data_model/fixtures/time.rb
180
+ - lib/data_model/logging.rb
69
181
  - lib/data_model/model.rb
70
- - lib/data_model/registry.rb
71
182
  - lib/data_model/scanner.rb
183
+ - lib/data_model/testing.rb
184
+ - lib/data_model/testing/minitest.rb
72
185
  - lib/data_model/type.rb
186
+ - lib/data_model/type_registry.rb
73
187
  - lib/data_model/version.rb
188
+ - sorbet/config
189
+ - sorbet/rbi/annotations/rainbow.rbi
190
+ - sorbet/rbi/gems/minitest@5.18.0.rbi
191
+ - sorbet/rbi/gems/zeitwerk.rbi
192
+ - sorbet/rbi/gems/zeitwerk@2.6.7.rbi
193
+ - sorbet/rbi/todo.rbi
194
+ - sorbet/tapioca/config.yml
195
+ - sorbet/tapioca/require.rb
74
196
  homepage: https://github.com/mbriggs/data_model
75
197
  licenses:
76
198
  - MIT
@@ -88,14 +210,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
210
  requirements:
89
211
  - - ">="
90
212
  - !ruby/object:Gem::Version
91
- version: '2.7'
213
+ version: '3.1'
92
214
  required_rubygems_version: !ruby/object:Gem::Requirement
93
215
  requirements:
94
216
  - - ">="
95
217
  - !ruby/object:Gem::Version
96
218
  version: '0'
97
219
  requirements: []
98
- rubygems_version: 3.3.7
220
+ rubygems_version: 3.4.12
99
221
  signing_key:
100
222
  specification_version: 4
101
223
  summary: Define a model for your data
data/config/sus.rb DELETED
@@ -1,2 +0,0 @@
1
- require "pp"
2
- require_relative "../lib/data_model"
data/fixtures/schema.rb DELETED
@@ -1,14 +0,0 @@
1
- module Schema
2
- extend self
3
-
4
- def string
5
- [:string]
6
- end
7
-
8
- def contact
9
- [:hash, { open?: false },
10
- [[:first_name, :string],
11
- [:last_name, :string],
12
- [:email, :string]]]
13
- end
14
- end
@@ -1,44 +0,0 @@
1
- module DataModel
2
- class Registry
3
- def self.instance
4
- @instance ||= new(defaults)
5
- end
6
-
7
- def self.register(name, type)
8
- instance.register(name, type)
9
- end
10
-
11
- def self.defaults
12
- {
13
- string: Type.string,
14
- hash: Type.hash
15
- }
16
- end
17
-
18
- def initialize(*defaults)
19
- @types = {}
20
-
21
- defaults.each do |d|
22
- d.each do |k, s|
23
- register(k, s)
24
- end
25
- end
26
- end
27
-
28
- def register(name, type)
29
- @types[name] = Model.defaults.merge(type)
30
- end
31
-
32
- def type?(name)
33
- @types.key?(name)
34
- end
35
-
36
- def type(name, property = nil)
37
- unless @types.key?(name)
38
- raise "#{name} is not registered as a type"
39
- end
40
-
41
- @types.fetch(name).merge(property:)
42
- end
43
- end
44
- end