data_model 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +6 -2
- data/.rubocop.yml +11 -2
- data/.ruby-version +2 -0
- data/Gemfile.lock +91 -54
- data/Guardfile +20 -0
- data/Rakefile +32 -0
- data/data_model.gemspec +52 -0
- data/lib/data_model/boolean.rb +7 -0
- data/lib/data_model/builtin/array.rb +73 -0
- data/lib/data_model/builtin/big_decimal.rb +64 -0
- data/lib/data_model/builtin/boolean.rb +37 -0
- data/lib/data_model/builtin/date.rb +60 -0
- data/lib/data_model/builtin/float.rb +64 -0
- data/lib/data_model/builtin/hash.rb +119 -0
- data/lib/data_model/builtin/integer.rb +64 -0
- data/lib/data_model/builtin/string.rb +67 -0
- data/lib/data_model/builtin/symbol.rb +64 -0
- data/lib/data_model/builtin/time.rb +60 -0
- data/lib/data_model/builtin.rb +23 -0
- data/lib/data_model/error.rb +107 -0
- data/lib/data_model/errors.rb +278 -0
- data/lib/data_model/fixtures/array.rb +61 -0
- data/lib/data_model/fixtures/big_decimal.rb +55 -0
- data/lib/data_model/fixtures/boolean.rb +35 -0
- data/lib/data_model/fixtures/date.rb +53 -0
- data/lib/data_model/fixtures/example.rb +29 -0
- data/lib/data_model/fixtures/float.rb +53 -0
- data/lib/data_model/fixtures/hash.rb +66 -0
- data/lib/data_model/fixtures/integer.rb +53 -0
- data/lib/data_model/fixtures/string.rb +77 -0
- data/lib/data_model/fixtures/symbol.rb +56 -0
- data/lib/data_model/fixtures/time.rb +53 -0
- data/lib/data_model/logging.rb +23 -0
- data/lib/data_model/model.rb +21 -44
- data/lib/data_model/scanner.rb +92 -56
- data/lib/data_model/testing/minitest.rb +79 -0
- data/lib/data_model/testing.rb +6 -0
- data/lib/data_model/type.rb +41 -39
- data/lib/data_model/type_registry.rb +68 -0
- data/lib/data_model/version.rb +3 -1
- data/lib/data_model.rb +32 -16
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/minitest@5.18.0.rbi +1491 -0
- data/sorbet/rbi/gems/zeitwerk.rbi +196 -0
- data/sorbet/rbi/gems/zeitwerk@2.6.7.rbi +966 -0
- data/sorbet/rbi/todo.rbi +5 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +139 -17
- data/config/sus.rb +0 -2
- data/fixtures/schema.rb +0 -14
- data/lib/data_model/registry.rb +0 -44
data/sorbet/rbi/todo.rbi
ADDED
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
|
4
|
+
version: 0.1.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:
|
11
|
+
date: 2023-05-09 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: '
|
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: '
|
82
|
+
version: '0'
|
27
83
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
84
|
+
name: rake
|
29
85
|
requirement: !ruby/object:Gem::Requirement
|
30
86
|
requirements:
|
31
|
-
- - "
|
87
|
+
- - ">="
|
32
88
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
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
|
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:
|
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
|
-
-
|
67
|
-
-
|
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: '
|
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.
|
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
data/fixtures/schema.rb
DELETED
data/lib/data_model/registry.rb
DELETED
@@ -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
|