dry-types 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +306 -225
- data/LICENSE +1 -1
- data/README.md +14 -12
- data/dry-types.gemspec +27 -31
- data/lib/dry/types.rb +0 -9
- data/lib/dry/types/builder.rb +4 -0
- data/lib/dry/types/constructor/function.rb +17 -31
- data/lib/dry/types/core.rb +3 -1
- data/lib/dry/types/decorator.rb +0 -7
- data/lib/dry/types/extensions/maybe.rb +14 -14
- data/lib/dry/types/lax.rb +1 -4
- data/lib/dry/types/meta.rb +2 -2
- data/lib/dry/types/params.rb +1 -0
- data/lib/dry/types/result.rb +2 -2
- data/lib/dry/types/schema.rb +23 -2
- data/lib/dry/types/schema/key.rb +11 -2
- data/lib/dry/types/spec/types.rb +11 -0
- data/lib/dry/types/sum.rb +2 -2
- data/lib/dry/types/version.rb +1 -1
- metadata +21 -59
- data/.codeclimate.yml +0 -12
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
- data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -30
- data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
- data/.github/workflows/custom_ci.yml +0 -76
- data/.github/workflows/docsite.yml +0 -34
- data/.github/workflows/sync_configs.yml +0 -34
- data/.gitignore +0 -11
- data/.rspec +0 -4
- data/.rubocop.yml +0 -92
- data/.yardopts +0 -9
- data/CODE_OF_CONDUCT.md +0 -13
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -34
- data/Rakefile +0 -22
- data/benchmarks/hash_schemas.rb +0 -55
- data/benchmarks/lax_schema.rb +0 -15
- data/benchmarks/profile_invalid_input.rb +0 -15
- data/benchmarks/profile_lax_schema_valid.rb +0 -16
- data/benchmarks/profile_valid_input.rb +0 -15
- data/benchmarks/schema_valid_vs_invalid.rb +0 -21
- data/benchmarks/setup.rb +0 -17
- data/docsite/source/array-with-member.html.md +0 -13
- data/docsite/source/built-in-types.html.md +0 -116
- data/docsite/source/constraints.html.md +0 -31
- data/docsite/source/custom-types.html.md +0 -93
- data/docsite/source/default-values.html.md +0 -91
- data/docsite/source/enum.html.md +0 -69
- data/docsite/source/extensions.html.md +0 -15
- data/docsite/source/extensions/maybe.html.md +0 -57
- data/docsite/source/extensions/monads.html.md +0 -61
- data/docsite/source/getting-started.html.md +0 -57
- data/docsite/source/hash-schemas.html.md +0 -169
- data/docsite/source/index.html.md +0 -156
- data/docsite/source/map.html.md +0 -17
- data/docsite/source/optional-values.html.md +0 -35
- data/docsite/source/sum.html.md +0 -21
data/lib/dry/types/schema/key.rb
CHANGED
@@ -103,6 +103,15 @@ module Dry
|
|
103
103
|
__new__(type.lax).required(false)
|
104
104
|
end
|
105
105
|
|
106
|
+
# Make wrapped type optional
|
107
|
+
#
|
108
|
+
# @return [Key]
|
109
|
+
#
|
110
|
+
# @api public
|
111
|
+
def optional
|
112
|
+
__new__(type.optional)
|
113
|
+
end
|
114
|
+
|
106
115
|
# Dump to internal AST representation
|
107
116
|
#
|
108
117
|
# @return [Array]
|
@@ -122,8 +131,8 @@ module Dry
|
|
122
131
|
# @see Dry::Types::Meta#meta
|
123
132
|
#
|
124
133
|
# @api public
|
125
|
-
def meta(data =
|
126
|
-
if
|
134
|
+
def meta(data = Undefined)
|
135
|
+
if Undefined.equal?(data) || !data.key?(:omittable)
|
127
136
|
super
|
128
137
|
else
|
129
138
|
self.class.warn(
|
data/lib/dry/types/spec/types.rb
CHANGED
@@ -139,3 +139,14 @@ RSpec.shared_examples_for 'a nominal type' do |inputs: Object.new|
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
142
|
+
|
143
|
+
RSpec.shared_examples_for 'a composable constructor' do
|
144
|
+
describe '#constructor' do
|
145
|
+
it 'has aliases for composition' do
|
146
|
+
expect(type.method(:append)).to eql(type.method(:constructor))
|
147
|
+
expect(type.method(:prepend)).to eql(type.method(:constructor))
|
148
|
+
expect(type.method(:<<)).to eql(type.method(:constructor))
|
149
|
+
expect(type.method(:>>)).to eql(type.method(:constructor))
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
data/lib/dry/types/sum.rb
CHANGED
@@ -142,8 +142,8 @@ module Dry
|
|
142
142
|
# @see [Meta#meta]
|
143
143
|
#
|
144
144
|
# @api public
|
145
|
-
def meta(data =
|
146
|
-
if
|
145
|
+
def meta(data = Undefined)
|
146
|
+
if Undefined.equal?(data)
|
147
147
|
optional? ? right.meta : super
|
148
148
|
elsif optional?
|
149
149
|
self.class.new(left, right.meta(data), **options)
|
data/lib/dry/types/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.3.0
|
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: 2020-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -132,104 +132,67 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - "~>"
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: '0
|
135
|
+
version: '1.0'
|
136
136
|
type: :development
|
137
137
|
prerelease: false
|
138
138
|
version_requirements: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
140
|
- - "~>"
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: '0
|
142
|
+
version: '1.0'
|
143
143
|
- !ruby/object:Gem::Dependency
|
144
144
|
name: rake
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
|
-
- - "
|
147
|
+
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: '
|
149
|
+
version: '0'
|
150
150
|
type: :development
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
153
|
requirements:
|
154
|
-
- - "
|
154
|
+
- - ">="
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version: '
|
156
|
+
version: '0'
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: rspec
|
159
159
|
requirement: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
|
-
- - "
|
161
|
+
- - ">="
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version: '
|
163
|
+
version: '0'
|
164
164
|
type: :development
|
165
165
|
prerelease: false
|
166
166
|
version_requirements: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- - "
|
168
|
+
- - ">="
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version: '
|
170
|
+
version: '0'
|
171
171
|
- !ruby/object:Gem::Dependency
|
172
172
|
name: yard
|
173
173
|
requirement: !ruby/object:Gem::Requirement
|
174
174
|
requirements:
|
175
|
-
- - "
|
175
|
+
- - ">="
|
176
176
|
- !ruby/object:Gem::Version
|
177
|
-
version: 0
|
177
|
+
version: '0'
|
178
178
|
type: :development
|
179
179
|
prerelease: false
|
180
180
|
version_requirements: !ruby/object:Gem::Requirement
|
181
181
|
requirements:
|
182
|
-
- - "
|
182
|
+
- - ">="
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version: 0
|
184
|
+
version: '0'
|
185
185
|
description: Type system for Ruby supporting coercions, constraints and complex types
|
186
|
-
like structs, value objects, enums etc
|
186
|
+
like structs, value objects, enums etc
|
187
187
|
email:
|
188
188
|
- piotr.solnica@gmail.com
|
189
189
|
executables: []
|
190
190
|
extensions: []
|
191
191
|
extra_rdoc_files: []
|
192
192
|
files:
|
193
|
-
- ".codeclimate.yml"
|
194
|
-
- ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
|
195
|
-
- ".github/ISSUE_TEMPLATE/---bug-report.md"
|
196
|
-
- ".github/ISSUE_TEMPLATE/---feature-request.md"
|
197
|
-
- ".github/workflows/custom_ci.yml"
|
198
|
-
- ".github/workflows/docsite.yml"
|
199
|
-
- ".github/workflows/sync_configs.yml"
|
200
|
-
- ".gitignore"
|
201
|
-
- ".rspec"
|
202
|
-
- ".rubocop.yml"
|
203
|
-
- ".yardopts"
|
204
193
|
- CHANGELOG.md
|
205
|
-
- CODE_OF_CONDUCT.md
|
206
|
-
- CONTRIBUTING.md
|
207
|
-
- Gemfile
|
208
194
|
- LICENSE
|
209
195
|
- README.md
|
210
|
-
- Rakefile
|
211
|
-
- benchmarks/hash_schemas.rb
|
212
|
-
- benchmarks/lax_schema.rb
|
213
|
-
- benchmarks/profile_invalid_input.rb
|
214
|
-
- benchmarks/profile_lax_schema_valid.rb
|
215
|
-
- benchmarks/profile_valid_input.rb
|
216
|
-
- benchmarks/schema_valid_vs_invalid.rb
|
217
|
-
- benchmarks/setup.rb
|
218
|
-
- docsite/source/array-with-member.html.md
|
219
|
-
- docsite/source/built-in-types.html.md
|
220
|
-
- docsite/source/constraints.html.md
|
221
|
-
- docsite/source/custom-types.html.md
|
222
|
-
- docsite/source/default-values.html.md
|
223
|
-
- docsite/source/enum.html.md
|
224
|
-
- docsite/source/extensions.html.md
|
225
|
-
- docsite/source/extensions/maybe.html.md
|
226
|
-
- docsite/source/extensions/monads.html.md
|
227
|
-
- docsite/source/getting-started.html.md
|
228
|
-
- docsite/source/hash-schemas.html.md
|
229
|
-
- docsite/source/index.html.md
|
230
|
-
- docsite/source/map.html.md
|
231
|
-
- docsite/source/optional-values.html.md
|
232
|
-
- docsite/source/sum.html.md
|
233
196
|
- dry-types.gemspec
|
234
197
|
- lib/dry-types.rb
|
235
198
|
- lib/dry/types.rb
|
@@ -282,8 +245,7 @@ files:
|
|
282
245
|
- lib/dry/types/sum.rb
|
283
246
|
- lib/dry/types/type.rb
|
284
247
|
- lib/dry/types/version.rb
|
285
|
-
-
|
286
|
-
homepage: https://github.com/dry-rb/dry-types
|
248
|
+
homepage: https://dry-rb.org/gems/dry-types
|
287
249
|
licenses:
|
288
250
|
- MIT
|
289
251
|
metadata:
|
@@ -306,9 +268,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
306
268
|
- !ruby/object:Gem::Version
|
307
269
|
version: '0'
|
308
270
|
requirements: []
|
309
|
-
rubygems_version: 3.0.
|
271
|
+
rubygems_version: 3.0.3
|
310
272
|
signing_key:
|
311
273
|
specification_version: 4
|
312
274
|
summary: Type system for Ruby supporting coercions, constraints and complex types
|
313
|
-
like structs, value objects, enums etc
|
275
|
+
like structs, value objects, enums etc
|
314
276
|
test_files: []
|
data/.codeclimate.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: "\U0001F41B Bug report"
|
3
|
-
about: See CONTRIBUTING.md for more information
|
4
|
-
title: ''
|
5
|
-
labels: bug
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
**Before you submit this: WE ONLY ACCEPT BUG REPORTS AND FEATURE REQUESTS**
|
11
|
-
|
12
|
-
For more information see `CONTRIBUTING.md`.
|
13
|
-
|
14
|
-
**Describe the bug**
|
15
|
-
|
16
|
-
A clear and concise description of what the bug is.
|
17
|
-
|
18
|
-
**To Reproduce**
|
19
|
-
|
20
|
-
Provide detailed steps to reproduce, an executable script would be best.
|
21
|
-
|
22
|
-
**Expected behavior**
|
23
|
-
|
24
|
-
A clear and concise description of what you expected to happen.
|
25
|
-
|
26
|
-
**Your environment**
|
27
|
-
|
28
|
-
- Affects my production application: **YES/NO**
|
29
|
-
- Ruby version: ...
|
30
|
-
- OS: ...
|
@@ -1,18 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: "\U0001F6E0 Feature request"
|
3
|
-
about: See CONTRIBUTING.md for more information
|
4
|
-
title: ''
|
5
|
-
labels: feature
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
Summary of what the feature is supposed to do.
|
11
|
-
|
12
|
-
## Examples
|
13
|
-
|
14
|
-
Code examples showing how the feature could be used.
|
15
|
-
|
16
|
-
## Resources
|
17
|
-
|
18
|
-
Additional information, like a link to the discussion forum thread where the feature was discussed etc.
|
@@ -1,76 +0,0 @@
|
|
1
|
-
name: ci
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
paths:
|
6
|
-
- .github/workflows/custom_ci.yml
|
7
|
-
- lib/**
|
8
|
-
- spec/**
|
9
|
-
|
10
|
-
jobs:
|
11
|
-
tests-mri:
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
strategy:
|
14
|
-
fail-fast: false
|
15
|
-
matrix:
|
16
|
-
ruby: ["2.6.x", "2.5.x", "2.4.x"]
|
17
|
-
dry_logic_from_master: ["true", "false"]
|
18
|
-
include:
|
19
|
-
- ruby: "2.6.x"
|
20
|
-
dry_logic_from_master: "false"
|
21
|
-
coverage: "true"
|
22
|
-
steps:
|
23
|
-
- uses: actions/checkout@v1
|
24
|
-
- name: Set up Ruby
|
25
|
-
uses: actions/setup-ruby@v1
|
26
|
-
with:
|
27
|
-
ruby-version: ${{matrix.ruby}}
|
28
|
-
- name: Download test reporter
|
29
|
-
if: "matrix.coverage == 'true'"
|
30
|
-
run: |
|
31
|
-
mkdir -p tmp/
|
32
|
-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
|
33
|
-
chmod +x ./tmp/cc-test-reporter
|
34
|
-
./tmp/cc-test-reporter before-build
|
35
|
-
- name: Run all tests
|
36
|
-
env:
|
37
|
-
COVERAGE: ${{matrix.coverage}}
|
38
|
-
DRY_LOGIC_FROM_MASTER: ${{matrix.dry_logic_from_master}}
|
39
|
-
run: |
|
40
|
-
gem install bundler
|
41
|
-
bundle install --jobs 4 --retry 3 --without tools docs
|
42
|
-
bundle exec rake
|
43
|
-
- name: Send coverage results
|
44
|
-
if: "matrix.coverage == 'true'"
|
45
|
-
env:
|
46
|
-
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
|
47
|
-
GIT_COMMIT_SHA: ${{github.sha}}
|
48
|
-
GIT_BRANCH: ${{github.ref}}
|
49
|
-
GIT_COMMITTED_AT: ${{github.event.head_commit.timestamp}}
|
50
|
-
run: |
|
51
|
-
GIT_BRANCH=`ruby -e "puts ENV['GITHUB_REF'].split('/', 3).last"` \
|
52
|
-
GIT_COMMITTED_AT=`ruby -r time -e "puts Time.iso8601(ENV['GIT_COMMITTED_AT']).to_i"` \
|
53
|
-
./tmp/cc-test-reporter after-build
|
54
|
-
|
55
|
-
tests-others:
|
56
|
-
runs-on: ubuntu-latest
|
57
|
-
strategy:
|
58
|
-
fail-fast: false
|
59
|
-
matrix:
|
60
|
-
image: ["jruby:9.2.9", "ruby:rc"]
|
61
|
-
dry_logic_from_master: ["true", "false"]
|
62
|
-
container:
|
63
|
-
image: ${{matrix.image}}
|
64
|
-
steps:
|
65
|
-
- uses: actions/checkout@v1
|
66
|
-
- name: Install git
|
67
|
-
run: |
|
68
|
-
apt-get update
|
69
|
-
apt-get install -y --no-install-recommends git
|
70
|
-
- name: Run all tests
|
71
|
-
env:
|
72
|
-
DRY_LOGIC_FROM_MASTER: ${{matrix.dry_logic_from_master}}
|
73
|
-
run: |
|
74
|
-
gem install bundler
|
75
|
-
bundle install --jobs 4 --retry 3 --without tools docs
|
76
|
-
bundle exec rspec
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: docsite
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
paths:
|
8
|
-
- docsite/**
|
9
|
-
- .github/workflows/docsite.yml
|
10
|
-
branches:
|
11
|
-
- master
|
12
|
-
- release-**
|
13
|
-
tags:
|
14
|
-
|
15
|
-
jobs:
|
16
|
-
update-docs:
|
17
|
-
runs-on: ubuntu-latest
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@v1
|
20
|
-
- name: Set up Ruby
|
21
|
-
uses: actions/setup-ruby@v1
|
22
|
-
with:
|
23
|
-
ruby-version: "2.6.x"
|
24
|
-
- name: Install dependencies
|
25
|
-
run: |
|
26
|
-
gem install bundler
|
27
|
-
bundle install --jobs 4 --retry 3 --without benchmarks sql
|
28
|
-
- name: Symlink ossy
|
29
|
-
run: mkdir -p bin && ln -sf "$(bundle show ossy)/bin/ossy" bin/ossy
|
30
|
-
- name: Trigger dry-rb.org deploy
|
31
|
-
env:
|
32
|
-
GITHUB_LOGIN: dry-bot
|
33
|
-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
34
|
-
run: bin/ossy github workflow dry-rb/dry-rb.org ci
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: sync_configs
|
4
|
-
|
5
|
-
on:
|
6
|
-
repository_dispatch:
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
sync-configs:
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
if: github.event.action == 'sync_configs'
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v1
|
14
|
-
- name: Update configuration files from devtools
|
15
|
-
env:
|
16
|
-
GITHUB_LOGIN: dry-bot
|
17
|
-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
18
|
-
run: |
|
19
|
-
git clone https://github.com/dry-rb/devtools.git tmp/devtools
|
20
|
-
|
21
|
-
if [ -f ".github/workflows/custom_ci.yml" ]; then
|
22
|
-
rsync -av --exclude '.github/workflows/ci.yml' tmp/devtools/shared/ . ;
|
23
|
-
else
|
24
|
-
rsync -av tmp/devtools/shared/ . ;
|
25
|
-
fi
|
26
|
-
|
27
|
-
git config --local user.email "dry-bot@dry-rb.org"
|
28
|
-
git config --local user.name "dry-bot"
|
29
|
-
git add -A
|
30
|
-
git commit -m "[devtools] config sync" || echo "nothing changed"
|
31
|
-
- name: Push changes
|
32
|
-
uses: ad-m/github-push-action@master
|
33
|
-
with:
|
34
|
-
github_token: ${{ secrets.GH_PAT }}
|