dry-types 0.15.0 → 1.5.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +547 -161
- data/LICENSE +17 -17
- data/README.md +15 -13
- data/dry-types.gemspec +27 -30
- data/lib/dry/types/any.rb +23 -12
- data/lib/dry/types/array/constructor.rb +32 -0
- data/lib/dry/types/array/member.rb +74 -15
- data/lib/dry/types/array.rb +18 -2
- data/lib/dry/types/builder.rb +118 -22
- data/lib/dry/types/builder_methods.rb +46 -16
- data/lib/dry/types/coercions/json.rb +43 -7
- data/lib/dry/types/coercions/params.rb +117 -32
- data/lib/dry/types/coercions.rb +76 -22
- data/lib/dry/types/compiler.rb +44 -21
- data/lib/dry/types/constrained/coercible.rb +36 -6
- data/lib/dry/types/constrained.rb +79 -31
- data/lib/dry/types/constraints.rb +18 -4
- data/lib/dry/types/constructor/function.rb +216 -0
- data/lib/dry/types/constructor/wrapper.rb +94 -0
- data/lib/dry/types/constructor.rb +110 -61
- data/lib/dry/types/container.rb +6 -1
- data/lib/dry/types/core.rb +34 -11
- data/lib/dry/types/decorator.rb +38 -17
- data/lib/dry/types/default.rb +61 -16
- data/lib/dry/types/enum.rb +36 -20
- data/lib/dry/types/errors.rb +74 -8
- data/lib/dry/types/extensions/maybe.rb +65 -17
- data/lib/dry/types/extensions/monads.rb +29 -0
- data/lib/dry/types/extensions.rb +7 -1
- data/lib/dry/types/fn_container.rb +6 -1
- data/lib/dry/types/hash/constructor.rb +17 -4
- data/lib/dry/types/hash.rb +32 -20
- data/lib/dry/types/inflector.rb +3 -1
- data/lib/dry/types/json.rb +18 -16
- data/lib/dry/types/lax.rb +75 -0
- data/lib/dry/types/map.rb +70 -32
- data/lib/dry/types/meta.rb +51 -0
- data/lib/dry/types/module.rb +16 -11
- data/lib/dry/types/nominal.rb +113 -22
- data/lib/dry/types/options.rb +12 -25
- data/lib/dry/types/params.rb +39 -25
- data/lib/dry/types/predicate_inferrer.rb +238 -0
- data/lib/dry/types/predicate_registry.rb +34 -0
- data/lib/dry/types/primitive_inferrer.rb +97 -0
- data/lib/dry/types/printable.rb +5 -1
- data/lib/dry/types/printer.rb +63 -57
- data/lib/dry/types/result.rb +29 -3
- data/lib/dry/types/schema/key.rb +62 -36
- data/lib/dry/types/schema.rb +201 -91
- data/lib/dry/types/spec/types.rb +99 -37
- data/lib/dry/types/sum.rb +75 -25
- data/lib/dry/types/type.rb +49 -0
- data/lib/dry/types/version.rb +3 -1
- data/lib/dry/types.rb +106 -48
- data/lib/dry-types.rb +3 -1
- metadata +55 -78
- data/.codeclimate.yml +0 -15
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.rubocop.yml +0 -43
- data/.travis.yml +0 -28
- data/.yardopts +0 -5
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -23
- data/Rakefile +0 -20
- data/benchmarks/hash_schemas.rb +0 -51
- data/lib/dry/types/safe.rb +0 -61
- data/log/.gitkeep +0 -0
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -25,99 +25,79 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: dry-
|
28
|
+
name: dry-container
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 0.4.4
|
33
|
+
version: '0.3'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0.
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.4.4
|
40
|
+
version: '0.3'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
|
-
name: dry-
|
42
|
+
name: dry-core
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
47
|
+
version: '0.5'
|
54
48
|
- - ">="
|
55
49
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
50
|
+
version: '0.5'
|
57
51
|
type: :runtime
|
58
52
|
prerelease: false
|
59
53
|
version_requirements: !ruby/object:Gem::Requirement
|
60
54
|
requirements:
|
61
55
|
- - "~>"
|
62
56
|
- !ruby/object:Gem::Version
|
63
|
-
version: '0.
|
57
|
+
version: '0.5'
|
64
58
|
- - ">="
|
65
59
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: dry-container
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '0.3'
|
74
|
-
type: :runtime
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '0.3'
|
60
|
+
version: '0.5'
|
81
61
|
- !ruby/object:Gem::Dependency
|
82
|
-
name: dry-
|
62
|
+
name: dry-inflector
|
83
63
|
requirement: !ruby/object:Gem::Requirement
|
84
64
|
requirements:
|
85
65
|
- - "~>"
|
86
66
|
- !ruby/object:Gem::Version
|
87
|
-
version: '0.
|
67
|
+
version: '0.1'
|
88
68
|
- - ">="
|
89
69
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
70
|
+
version: 0.1.2
|
91
71
|
type: :runtime
|
92
72
|
prerelease: false
|
93
73
|
version_requirements: !ruby/object:Gem::Requirement
|
94
74
|
requirements:
|
95
75
|
- - "~>"
|
96
76
|
- !ruby/object:Gem::Version
|
97
|
-
version: '0.
|
77
|
+
version: '0.1'
|
98
78
|
- - ">="
|
99
79
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.
|
80
|
+
version: 0.1.2
|
101
81
|
- !ruby/object:Gem::Dependency
|
102
82
|
name: dry-logic
|
103
83
|
requirement: !ruby/object:Gem::Requirement
|
104
84
|
requirements:
|
105
|
-
- - ">="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '0.5'
|
108
85
|
- - "~>"
|
109
86
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
87
|
+
version: '1.0'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.0.2
|
111
91
|
type: :runtime
|
112
92
|
prerelease: false
|
113
93
|
version_requirements: !ruby/object:Gem::Requirement
|
114
94
|
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.5'
|
118
95
|
- - "~>"
|
119
96
|
- !ruby/object:Gem::Version
|
120
|
-
version: '0
|
97
|
+
version: '1.0'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.0.2
|
121
101
|
- !ruby/object:Gem::Dependency
|
122
102
|
name: bundler
|
123
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,87 +113,78 @@ dependencies:
|
|
133
113
|
- !ruby/object:Gem::Version
|
134
114
|
version: '0'
|
135
115
|
- !ruby/object:Gem::Dependency
|
136
|
-
name:
|
116
|
+
name: dry-monads
|
137
117
|
requirement: !ruby/object:Gem::Requirement
|
138
118
|
requirements:
|
139
119
|
- - "~>"
|
140
120
|
- !ruby/object:Gem::Version
|
141
|
-
version: '
|
121
|
+
version: '1.0'
|
142
122
|
type: :development
|
143
123
|
prerelease: false
|
144
124
|
version_requirements: !ruby/object:Gem::Requirement
|
145
125
|
requirements:
|
146
126
|
- - "~>"
|
147
127
|
- !ruby/object:Gem::Version
|
148
|
-
version: '
|
128
|
+
version: '1.0'
|
149
129
|
- !ruby/object:Gem::Dependency
|
150
|
-
name:
|
130
|
+
name: rake
|
151
131
|
requirement: !ruby/object:Gem::Requirement
|
152
132
|
requirements:
|
153
|
-
- - "
|
133
|
+
- - ">="
|
154
134
|
- !ruby/object:Gem::Version
|
155
|
-
version: '
|
135
|
+
version: '0'
|
156
136
|
type: :development
|
157
137
|
prerelease: false
|
158
138
|
version_requirements: !ruby/object:Gem::Requirement
|
159
139
|
requirements:
|
160
|
-
- - "
|
140
|
+
- - ">="
|
161
141
|
- !ruby/object:Gem::Version
|
162
|
-
version: '
|
142
|
+
version: '0'
|
163
143
|
- !ruby/object:Gem::Dependency
|
164
|
-
name:
|
144
|
+
name: rspec
|
165
145
|
requirement: !ruby/object:Gem::Requirement
|
166
146
|
requirements:
|
167
|
-
- - "
|
147
|
+
- - ">="
|
168
148
|
- !ruby/object:Gem::Version
|
169
|
-
version: '0
|
149
|
+
version: '0'
|
170
150
|
type: :development
|
171
151
|
prerelease: false
|
172
152
|
version_requirements: !ruby/object:Gem::Requirement
|
173
153
|
requirements:
|
174
|
-
- - "
|
154
|
+
- - ">="
|
175
155
|
- !ruby/object:Gem::Version
|
176
|
-
version: '0
|
156
|
+
version: '0'
|
177
157
|
- !ruby/object:Gem::Dependency
|
178
158
|
name: yard
|
179
159
|
requirement: !ruby/object:Gem::Requirement
|
180
160
|
requirements:
|
181
|
-
- - "
|
161
|
+
- - ">="
|
182
162
|
- !ruby/object:Gem::Version
|
183
|
-
version: 0
|
163
|
+
version: '0'
|
184
164
|
type: :development
|
185
165
|
prerelease: false
|
186
166
|
version_requirements: !ruby/object:Gem::Requirement
|
187
167
|
requirements:
|
188
|
-
- - "
|
168
|
+
- - ">="
|
189
169
|
- !ruby/object:Gem::Version
|
190
|
-
version: 0
|
170
|
+
version: '0'
|
191
171
|
description: Type system for Ruby supporting coercions, constraints and complex types
|
192
|
-
like structs, value objects, enums etc
|
172
|
+
like structs, value objects, enums etc
|
193
173
|
email:
|
194
174
|
- piotr.solnica@gmail.com
|
195
175
|
executables: []
|
196
176
|
extensions: []
|
197
177
|
extra_rdoc_files: []
|
198
178
|
files:
|
199
|
-
- ".codeclimate.yml"
|
200
|
-
- ".gitignore"
|
201
|
-
- ".rspec"
|
202
|
-
- ".rubocop.yml"
|
203
|
-
- ".travis.yml"
|
204
|
-
- ".yardopts"
|
205
179
|
- CHANGELOG.md
|
206
|
-
- CONTRIBUTING.md
|
207
|
-
- Gemfile
|
208
180
|
- LICENSE
|
209
181
|
- README.md
|
210
|
-
- Rakefile
|
211
|
-
- benchmarks/hash_schemas.rb
|
212
182
|
- dry-types.gemspec
|
213
183
|
- lib/dry-types.rb
|
214
184
|
- lib/dry/types.rb
|
215
185
|
- lib/dry/types/any.rb
|
216
186
|
- lib/dry/types/array.rb
|
187
|
+
- lib/dry/types/array/constructor.rb
|
217
188
|
- lib/dry/types/array/member.rb
|
218
189
|
- lib/dry/types/builder.rb
|
219
190
|
- lib/dry/types/builder_methods.rb
|
@@ -226,6 +197,8 @@ files:
|
|
226
197
|
- lib/dry/types/constrained/coercible.rb
|
227
198
|
- lib/dry/types/constraints.rb
|
228
199
|
- lib/dry/types/constructor.rb
|
200
|
+
- lib/dry/types/constructor/function.rb
|
201
|
+
- lib/dry/types/constructor/wrapper.rb
|
229
202
|
- lib/dry/types/container.rb
|
230
203
|
- lib/dry/types/core.rb
|
231
204
|
- lib/dry/types/decorator.rb
|
@@ -234,28 +207,32 @@ files:
|
|
234
207
|
- lib/dry/types/errors.rb
|
235
208
|
- lib/dry/types/extensions.rb
|
236
209
|
- lib/dry/types/extensions/maybe.rb
|
210
|
+
- lib/dry/types/extensions/monads.rb
|
237
211
|
- lib/dry/types/fn_container.rb
|
238
212
|
- lib/dry/types/hash.rb
|
239
213
|
- lib/dry/types/hash/constructor.rb
|
240
214
|
- lib/dry/types/inflector.rb
|
241
215
|
- lib/dry/types/json.rb
|
216
|
+
- lib/dry/types/lax.rb
|
242
217
|
- lib/dry/types/map.rb
|
218
|
+
- lib/dry/types/meta.rb
|
243
219
|
- lib/dry/types/module.rb
|
244
220
|
- lib/dry/types/nominal.rb
|
245
221
|
- lib/dry/types/options.rb
|
246
222
|
- lib/dry/types/params.rb
|
223
|
+
- lib/dry/types/predicate_inferrer.rb
|
224
|
+
- lib/dry/types/predicate_registry.rb
|
225
|
+
- lib/dry/types/primitive_inferrer.rb
|
247
226
|
- lib/dry/types/printable.rb
|
248
227
|
- lib/dry/types/printer.rb
|
249
228
|
- lib/dry/types/result.rb
|
250
|
-
- lib/dry/types/safe.rb
|
251
229
|
- lib/dry/types/schema.rb
|
252
230
|
- lib/dry/types/schema/key.rb
|
253
231
|
- lib/dry/types/spec/types.rb
|
254
232
|
- lib/dry/types/sum.rb
|
255
233
|
- lib/dry/types/type.rb
|
256
234
|
- lib/dry/types/version.rb
|
257
|
-
-
|
258
|
-
homepage: https://github.com/dry-rb/dry-types
|
235
|
+
homepage: https://dry-rb.org/gems/dry-types
|
259
236
|
licenses:
|
260
237
|
- MIT
|
261
238
|
metadata:
|
@@ -271,16 +248,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
271
248
|
requirements:
|
272
249
|
- - ">="
|
273
250
|
- !ruby/object:Gem::Version
|
274
|
-
version: 2.
|
251
|
+
version: 2.5.0
|
275
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
276
253
|
requirements:
|
277
254
|
- - ">="
|
278
255
|
- !ruby/object:Gem::Version
|
279
256
|
version: '0'
|
280
257
|
requirements: []
|
281
|
-
rubygems_version: 3.
|
258
|
+
rubygems_version: 3.1.4
|
282
259
|
signing_key:
|
283
260
|
specification_version: 4
|
284
261
|
summary: Type system for Ruby supporting coercions, constraints and complex types
|
285
|
-
like structs, value objects, enums etc
|
262
|
+
like structs, value objects, enums etc
|
286
263
|
test_files: []
|
data/.codeclimate.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
version: "2"
|
2
|
-
|
3
|
-
prepare:
|
4
|
-
fetch:
|
5
|
-
- url: "https://raw.githubusercontent.com/dry-rb/devtools/master/.rubocop.yml"
|
6
|
-
path: ".rubocop.yml"
|
7
|
-
|
8
|
-
exclude_patterns:
|
9
|
-
- "benchmarks/"
|
10
|
-
- "examples/"
|
11
|
-
- "spec/"
|
12
|
-
|
13
|
-
plugins:
|
14
|
-
rubocop:
|
15
|
-
enabled: true
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.4
|
3
|
-
|
4
|
-
Style/StringLiterals:
|
5
|
-
Enabled: true
|
6
|
-
EnforcedStyle: single_quotes
|
7
|
-
|
8
|
-
Style/Alias:
|
9
|
-
Enabled: false
|
10
|
-
|
11
|
-
Style/LambdaCall:
|
12
|
-
Enabled: false
|
13
|
-
|
14
|
-
Style/StabbyLambdaParentheses:
|
15
|
-
Enabled: false
|
16
|
-
|
17
|
-
Layout/MultilineMethodCallIndentation:
|
18
|
-
Enabled: true
|
19
|
-
EnforcedStyle: indented
|
20
|
-
|
21
|
-
Metrics/LineLength:
|
22
|
-
Max: 100
|
23
|
-
|
24
|
-
Metrics/MethodLength:
|
25
|
-
Max: 22
|
26
|
-
|
27
|
-
Metrics/ClassLength:
|
28
|
-
Max: 150
|
29
|
-
|
30
|
-
Metrics/AbcSize:
|
31
|
-
Max: 20
|
32
|
-
|
33
|
-
Metrics/BlockLength:
|
34
|
-
Enabled: true
|
35
|
-
Exclude:
|
36
|
-
- 'spec/**/*_spec.rb'
|
37
|
-
|
38
|
-
Metrics/CyclomaticComplexity:
|
39
|
-
Enabled: true
|
40
|
-
Max: 10
|
41
|
-
|
42
|
-
Lint/BooleanSymbol:
|
43
|
-
Enabled: false
|
data/.travis.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
sudo: false
|
4
|
-
bundler_args: --without benchmarks tools
|
5
|
-
before_script:
|
6
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
7
|
-
- chmod +x ./cc-test-reporter
|
8
|
-
- ./cc-test-reporter before-build
|
9
|
-
after_script:
|
10
|
-
- "[ -d coverage ] && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
11
|
-
script:
|
12
|
-
- bundle exec rake
|
13
|
-
rvm:
|
14
|
-
- 2.6.1
|
15
|
-
- 2.5.3
|
16
|
-
- 2.4.5
|
17
|
-
- jruby-9.2.6.0
|
18
|
-
env:
|
19
|
-
global:
|
20
|
-
- COVERAGE=true
|
21
|
-
notifications:
|
22
|
-
email: false
|
23
|
-
webhooks:
|
24
|
-
urls:
|
25
|
-
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
26
|
-
on_success: change # options: [always|never|change] default: always
|
27
|
-
on_failure: always # options: [always|never|change] default: always
|
28
|
-
on_start: false # default: false
|
data/.yardopts
DELETED
data/CONTRIBUTING.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Issue Guidelines
|
2
|
-
|
3
|
-
## Reporting bugs
|
4
|
-
|
5
|
-
If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
|
6
|
-
|
7
|
-
## Reporting feature requests
|
8
|
-
|
9
|
-
Report a feature request **only after discussing it first on [discourse.dry-rb.org](https://discourse.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
|
10
|
-
|
11
|
-
## Reporting questions, support requests, ideas, concerns etc.
|
12
|
-
|
13
|
-
**PLEASE DON'T** - use [discourse.dry-rb.org](https://discourse.dry-rb.org) instead.
|
14
|
-
|
15
|
-
# Pull Request Guidelines
|
16
|
-
|
17
|
-
A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
|
18
|
-
|
19
|
-
Other requirements:
|
20
|
-
|
21
|
-
1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
|
22
|
-
2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
|
23
|
-
3) Add API documentation if it's a new feature
|
24
|
-
4) Update API documentation if it changes an existing feature
|
25
|
-
5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
|
26
|
-
|
27
|
-
# Asking for help
|
28
|
-
|
29
|
-
If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.dry-rb.org](https://discourse.dry-rb.org).
|
data/Gemfile
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
platform :mri do
|
9
|
-
gem 'simplecov', require: false
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
group :tools do
|
14
|
-
gem 'pry-byebug', platform: :mri
|
15
|
-
end
|
16
|
-
|
17
|
-
group :benchmarks do
|
18
|
-
gem 'benchmark-ips'
|
19
|
-
gem 'virtus'
|
20
|
-
gem 'fast_attributes'
|
21
|
-
gem 'attrio'
|
22
|
-
gem 'dry-struct'
|
23
|
-
end
|
data/Rakefile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
|
4
|
-
task :run_specs do
|
5
|
-
require 'rspec/core'
|
6
|
-
|
7
|
-
types_result = RSpec::Core::Runner.run(['spec/dry'])
|
8
|
-
RSpec.clear_examples
|
9
|
-
|
10
|
-
Dry::Types.load_extensions(:maybe)
|
11
|
-
ext_result = RSpec::Core::Runner.run(['spec'])
|
12
|
-
|
13
|
-
exit [types_result, ext_result].max
|
14
|
-
end
|
15
|
-
|
16
|
-
task default: :run_specs
|
17
|
-
|
18
|
-
require 'yard'
|
19
|
-
require 'yard/rake/yardoc_task'
|
20
|
-
YARD::Rake::YardocTask.new(:doc)
|
data/benchmarks/hash_schemas.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift('lib')
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'dry-types'
|
5
|
-
|
6
|
-
module SchemaBench
|
7
|
-
def self.hash_schema(type)
|
8
|
-
Dry::Types['nominal.hash'].public_send(type,
|
9
|
-
email: Dry::Types['nominal.string'],
|
10
|
-
age: Dry::Types['params.integer'],
|
11
|
-
admin: Dry::Types['params.bool'],
|
12
|
-
address: Dry::Types['nominal.hash'].public_send(type,
|
13
|
-
city: Dry::Types['nominal.string'],
|
14
|
-
street: Dry::Types['nominal.string']
|
15
|
-
)
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
private_class_method(:hash_schema)
|
20
|
-
|
21
|
-
SCHEMAS =
|
22
|
-
Dry::Types::Hash
|
23
|
-
.public_instance_methods(false)
|
24
|
-
.map { |schema_type| [schema_type, hash_schema(schema_type)] }
|
25
|
-
.to_h
|
26
|
-
|
27
|
-
INPUT = {
|
28
|
-
email: 'jane@doe.org',
|
29
|
-
age: '20',
|
30
|
-
admin: '1',
|
31
|
-
address: { city: 'NYC', street: 'Street 1/2' }
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
require 'benchmark/ips'
|
36
|
-
|
37
|
-
Benchmark.ips do |x|
|
38
|
-
SchemaBench::SCHEMAS.each do |schema_type, schema|
|
39
|
-
x.report("#{schema_type}#call") do
|
40
|
-
schema.call(SchemaBench::INPUT)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
SchemaBench::SCHEMAS.each do |schema_type, schema|
|
45
|
-
x.report("#{schema_type}#try") do
|
46
|
-
schema.try(SchemaBench::INPUT)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
x.compare!
|
51
|
-
end
|
data/lib/dry/types/safe.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'dry/types/decorator'
|
2
|
-
|
3
|
-
module Dry
|
4
|
-
module Types
|
5
|
-
class Safe
|
6
|
-
include Type
|
7
|
-
include Decorator
|
8
|
-
include Builder
|
9
|
-
include Printable
|
10
|
-
include Dry::Equalizer(:type, inspect: false)
|
11
|
-
|
12
|
-
private :options, :meta
|
13
|
-
|
14
|
-
# @param [Object] input
|
15
|
-
# @return [Object]
|
16
|
-
def call(input)
|
17
|
-
result = try(input)
|
18
|
-
|
19
|
-
if result.respond_to?(:input)
|
20
|
-
result.input
|
21
|
-
else
|
22
|
-
input
|
23
|
-
end
|
24
|
-
end
|
25
|
-
alias_method :[], :call
|
26
|
-
|
27
|
-
# @param [Object] input
|
28
|
-
# @param [#call,nil] block
|
29
|
-
# @yieldparam [Failure] failure
|
30
|
-
# @yieldreturn [Result]
|
31
|
-
# @return [Result,Logic::Result]
|
32
|
-
def try(input, &block)
|
33
|
-
type.try(input, &block)
|
34
|
-
rescue TypeError, ArgumentError => e
|
35
|
-
result = failure(input, e.message)
|
36
|
-
block ? yield(result) : result
|
37
|
-
end
|
38
|
-
|
39
|
-
# @api public
|
40
|
-
#
|
41
|
-
# @see Nominal#to_ast
|
42
|
-
def to_ast(meta: true)
|
43
|
-
[:safe, [type.to_ast(meta: meta), EMPTY_HASH]]
|
44
|
-
end
|
45
|
-
|
46
|
-
# @api public
|
47
|
-
# @return [Safe]
|
48
|
-
def safe
|
49
|
-
self
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
# @param [Object, Dry::Types::Constructor] response
|
55
|
-
# @return [Boolean]
|
56
|
-
def decorate?(response)
|
57
|
-
super || response.kind_of?(Constructor)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/log/.gitkeep
DELETED
File without changes
|