dry-types 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -5
- data/.github/workflows/custom_ci.yml +76 -0
- data/.github/workflows/docsite.yml +34 -0
- data/.github/workflows/sync_configs.yml +34 -0
- data/.gitignore +1 -1
- data/.rspec +3 -1
- data/.rubocop.yml +89 -0
- data/CHANGELOG.md +10 -1
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +3 -0
- data/LICENSE +17 -17
- data/docsite/source/built-in-types.html.md +3 -3
- data/docsite/source/extensions.html.md +15 -0
- data/docsite/source/extensions/maybe.html.md +57 -0
- data/docsite/source/extensions/monads.html.md +61 -0
- data/docsite/source/getting-started.html.md +1 -1
- data/docsite/source/index.html.md +12 -11
- data/docsite/source/optional-values.html.md +1 -62
- data/lib/dry/types/any.rb +2 -2
- data/lib/dry/types/array/member.rb +3 -3
- data/lib/dry/types/builder.rb +1 -1
- data/lib/dry/types/compiler.rb +2 -2
- data/lib/dry/types/constrained.rb +1 -1
- data/lib/dry/types/constructor.rb +4 -4
- data/lib/dry/types/decorator.rb +2 -1
- data/lib/dry/types/enum.rb +1 -1
- data/lib/dry/types/hash.rb +1 -1
- data/lib/dry/types/meta.rb +1 -1
- data/lib/dry/types/module.rb +3 -3
- data/lib/dry/types/spec/types.rb +3 -1
- data/lib/dry/types/sum.rb +2 -2
- data/lib/dry/types/version.rb +1 -1
- metadata +35 -30
- data/.travis.yml +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a22d275ce9f27a5be0edd1ce02714dbf571ee95abab2ab8e127b88e61317ac3
|
4
|
+
data.tar.gz: 8708d3ceb67ff3a726ae0363fe04fd08da440f3fdf7ae4e2f5632104fdf33810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ff0c69309f200eef77442aef6e9452046f75394c16b00f0be12cdbad04a8c34a1a02e87e0347fb1875fc0241a83f79e1b70576ad4d4e5202cde40257af3e3bb
|
7
|
+
data.tar.gz: 6eef147d7238f8ead4f254f37a0f018d5fc932ea3dd87bf334c06c3f0eb4110372078c4dcfad27c80a1dcfe161cc6955942d1daeffda6cd8980f3770b7a3c8b1
|
data/.codeclimate.yml
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
paths:
|
6
|
+
- .github/workflows/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.8", "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
|
@@ -0,0 +1,34 @@
|
|
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
|
@@ -0,0 +1,34 @@
|
|
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 }}
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# this file is managed by dry-rb/devtools project
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
|
6
|
+
Style/EachWithObject:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Style/StringLiterals:
|
10
|
+
Enabled: true
|
11
|
+
EnforcedStyle: single_quotes
|
12
|
+
|
13
|
+
Style/Alias:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/LambdaCall:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/StabbyLambdaParentheses:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/FormatString:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/Documentation:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Layout/SpaceInLambdaLiteral:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Layout/MultilineMethodCallIndentation:
|
32
|
+
Enabled: true
|
33
|
+
EnforcedStyle: indented
|
34
|
+
|
35
|
+
Metrics/LineLength:
|
36
|
+
Max: 100
|
37
|
+
|
38
|
+
Metrics/MethodLength:
|
39
|
+
Max: 22
|
40
|
+
|
41
|
+
Metrics/ClassLength:
|
42
|
+
Max: 150
|
43
|
+
|
44
|
+
Metrics/AbcSize:
|
45
|
+
Max: 20
|
46
|
+
|
47
|
+
Metrics/BlockLength:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
Metrics/CyclomaticComplexity:
|
51
|
+
Enabled: true
|
52
|
+
Max: 10
|
53
|
+
|
54
|
+
Lint/BooleanSymbol:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Style/AccessModifierDeclarations:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Style/BlockDelimiters:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Layout/IndentFirstArrayElement:
|
64
|
+
EnforcedStyle: consistent
|
65
|
+
|
66
|
+
Style/ClassAndModuleChildren:
|
67
|
+
Exclude:
|
68
|
+
- "spec/**/*_spec.rb"
|
69
|
+
|
70
|
+
Lint/HandleExceptions:
|
71
|
+
Exclude:
|
72
|
+
- "spec/spec_helper.rb"
|
73
|
+
|
74
|
+
Naming/FileName:
|
75
|
+
Exclude:
|
76
|
+
- "lib/dry-*.rb"
|
77
|
+
|
78
|
+
Style/SymbolArray:
|
79
|
+
Exclude:
|
80
|
+
- "spec/**/*_spec.rb"
|
81
|
+
|
82
|
+
Style/ConditionalAssignment:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Naming/MethodName:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
Style/AsciiComments:
|
89
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 1.2.1 2019-11-07
|
2
|
+
|
3
|
+
## Fixed
|
4
|
+
|
5
|
+
- Fix keyword warnings reported by Ruby 2.7 (flash-gordon)
|
6
|
+
- Error type in failing case in `Array::Member` (esparta)
|
7
|
+
|
8
|
+
[Compare v1.2.0...v1.2.1](https://github.com/dry-rb/dry-types/compare/v1.2.0...v1.2.1)
|
9
|
+
|
1
10
|
# 1.2.0 2019-10-06
|
2
11
|
|
3
12
|
## Changed
|
@@ -18,7 +27,7 @@
|
|
18
27
|
Dry::Types['optional.params.integer'].('140') # => 140
|
19
28
|
Dry::Types['optional.params.integer'].('asd') # => exception!
|
20
29
|
```
|
21
|
-
Keep in mind, Dry::Types['optional.params.integer'] and Dry::Types['params.integer'].optional are not the same, the latter doesn't handle empty strings.
|
30
|
+
Keep in mind, `Dry::Types['optional.params.integer']` and `Dry::Types['params.integer'].optional` are not the same, the latter doesn't handle empty strings.
|
22
31
|
- Predicate inferrer was ported from dry-schema (authored by solnic)
|
23
32
|
```ruby
|
24
33
|
require 'dry/types/predicate_inferrer'
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.4.0, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct)
|
data/CONTRIBUTING.md
CHANGED
@@ -10,7 +10,7 @@ Report a feature request **only after discussing it first on [discourse.dry-rb.o
|
|
10
10
|
|
11
11
|
## Reporting questions, support requests, ideas, concerns etc.
|
12
12
|
|
13
|
-
**PLEASE DON'T** - use [discourse.dry-rb.org](
|
13
|
+
**PLEASE DON'T** - use [discourse.dry-rb.org](http://discourse.dry-rb.org) instead.
|
14
14
|
|
15
15
|
# Pull Request Guidelines
|
16
16
|
|
@@ -26,4 +26,4 @@ Other requirements:
|
|
26
26
|
|
27
27
|
# Asking for help
|
28
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).
|
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) or join [our chat](https://dry-rb.zulipchat.com).
|
data/Gemfile
CHANGED
@@ -6,6 +6,8 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
|
7
7
|
gemspec
|
8
8
|
|
9
|
+
gem 'dry-logic', github: 'dry-rb/dry-logic', branch: 'master' if ENV['DRY_LOGIC_FROM_MASTER'].eql?('true')
|
10
|
+
|
9
11
|
group :test do
|
10
12
|
platform :mri do
|
11
13
|
gem 'simplecov', require: false
|
@@ -15,6 +17,7 @@ end
|
|
15
17
|
group :tools do
|
16
18
|
gem 'pry-byebug', platform: :mri
|
17
19
|
gem 'rubocop'
|
20
|
+
gem 'ossy', github: 'solnic/ossy', branch: 'master'
|
18
21
|
end
|
19
22
|
|
20
23
|
group :benchmarks do
|
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
3
|
+
Copyright (c) 2015-2019 dry-rb team
|
10
4
|
|
11
|
-
|
12
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -15,7 +15,7 @@ Built-in types are grouped under 6 categories:
|
|
15
15
|
|
16
16
|
### Categories
|
17
17
|
|
18
|
-
Assuming you included `Dry::Types` ([see instructions](
|
18
|
+
Assuming you included `Dry::Types` ([see instructions](docs::getting-started)) in a module called `Types`:
|
19
19
|
|
20
20
|
* Nominal types:
|
21
21
|
- `Types::Nominal::Any`
|
@@ -52,7 +52,7 @@ Assuming you included `Dry::Types` ([see instructions](/gems/dry-types/1.0/getti
|
|
52
52
|
- `Types::Strict::Array`
|
53
53
|
- `Types::Strict::Hash`
|
54
54
|
|
55
|
-
> All types in the `strict` category are [constrained](
|
55
|
+
> All types in the `strict` category are [constrained](docs::constraints) by a type-check that is applied to make sure that the input is an instance of the primitive:
|
56
56
|
|
57
57
|
``` ruby
|
58
58
|
Types::Strict::Integer[1] # => 1
|
@@ -113,4 +113,4 @@ Types::Strict::Integer['1'] # => raises Dry::Types::ConstraintError
|
|
113
113
|
- `Types::Maybe::Coercible::Array`
|
114
114
|
- `Types::Maybe::Coercible::Hash`
|
115
115
|
|
116
|
-
> `Maybe` types are not available by default - they must be loaded using `Dry::Types.load_extensions(:maybe)`. See [
|
116
|
+
> `Maybe` types are not available by default - they must be loaded using `Dry::Types.load_extensions(:maybe)`. See [Maybe extension](docs::extensions/maybe) for more information.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
title: Extensions
|
3
|
+
layout: gem-single
|
4
|
+
name: dry-types
|
5
|
+
sections:
|
6
|
+
- maybe
|
7
|
+
- monads
|
8
|
+
---
|
9
|
+
|
10
|
+
`dry-types` can be extended with extension. Those extensions are loaded with `Dry::Types.load_extensions`.
|
11
|
+
|
12
|
+
Available extensions:
|
13
|
+
|
14
|
+
- [Maybe](docs::extensions/maybe)
|
15
|
+
- [Monads](docs::extensions/monads)
|
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
title: Maybe
|
3
|
+
layout: gem-single
|
4
|
+
name: dry-types
|
5
|
+
---
|
6
|
+
|
7
|
+
The [dry-monads gem](/gems/dry-monads/) provides approach to handling optional values by returning a [_Monad_](/gems/dry-monads/) object. This allows you to pass your type to a `Maybe(x)` block that only executes if `x` returns `Some` or `None`.
|
8
|
+
|
9
|
+
> NOTE: Requires the [dry-monads gem](/gems/dry-monads/) to be loaded.
|
10
|
+
1. Load the `:maybe` extension in your application.
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
require 'dry-types'
|
14
|
+
|
15
|
+
Dry::Types.load_extensions(:maybe)
|
16
|
+
module Types
|
17
|
+
include Dry.Types()
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
2. Append `.maybe` to a _Type_ to return a _Monad_ object
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
x = Types::Maybe::Strict::Integer[nil]
|
25
|
+
Maybe(x) { puts(x) }
|
26
|
+
x = Types::Maybe::Coercible::String[nil]
|
27
|
+
Maybe(x) { puts(x) }
|
28
|
+
x = Types::Maybe::Strict::Integer[123]
|
29
|
+
Maybe(x) { puts(x) }
|
30
|
+
x = Types::Maybe::Strict::String[123]
|
31
|
+
Maybe(x) { puts(x) }
|
32
|
+
```
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Types::Maybe::Strict::Integer[nil] # None
|
36
|
+
Types::Maybe::Strict::Integer[123] # Some(123)
|
37
|
+
Types::Maybe::Coercible::Float[nil] # None
|
38
|
+
Types::Maybe::Coercible::Float['12.3'] # Some(12.3)
|
39
|
+
# 'Maybe' types can also accessed by calling '.maybe' on a regular type:
|
40
|
+
Types::Strict::Integer.maybe # equivalent to Types::Maybe::Strict::Integer
|
41
|
+
```
|
42
|
+
|
43
|
+
You can define your own optional types:
|
44
|
+
|
45
|
+
``` ruby
|
46
|
+
maybe_string = Types::Strict::String.maybe
|
47
|
+
maybe_string[nil]
|
48
|
+
# => None
|
49
|
+
maybe_string[nil].fmap(&:upcase)
|
50
|
+
# => None
|
51
|
+
maybe_string['something']
|
52
|
+
# => Some('something')
|
53
|
+
maybe_string['something'].fmap(&:upcase)
|
54
|
+
# => Some('SOMETHING')
|
55
|
+
maybe_string['something'].fmap(&:upcase).value_or('NOTHING')
|
56
|
+
# => "SOMETHING"
|
57
|
+
```
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
title: Monads
|
3
|
+
layout: gem-single
|
4
|
+
name: dry-types
|
5
|
+
---
|
6
|
+
|
7
|
+
The monads extension makes `Dry::Types::Result` objects compatible with `dry-monads`.
|
8
|
+
|
9
|
+
To enable the extension:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require 'dry/types'
|
13
|
+
Dry::Types.load_extensions(:monads)
|
14
|
+
```
|
15
|
+
|
16
|
+
After loading the extension, you can leverage monad API:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
Types = Dry.Types()
|
20
|
+
|
21
|
+
result = Types::String.try('Jane')
|
22
|
+
result.class #=> Dry::Types::Result::Success
|
23
|
+
monad = result.to_monad
|
24
|
+
monad.class #=> Dry::Monads::Result::Success
|
25
|
+
monad.value! # => 'Jane'
|
26
|
+
result = Types::String.try(nil)
|
27
|
+
result.class #=> Dry::Types::Result::Failure
|
28
|
+
monad = result.to_monad
|
29
|
+
monad.class #=> Dry::Monads::Result::Failure
|
30
|
+
monad.failure # => [#<Dry::Types::ConstraintError>, nil]
|
31
|
+
Types::String.try(nil)
|
32
|
+
.to_monad
|
33
|
+
.fmap { |result| puts "passed: #{result.inspect}" }
|
34
|
+
.or { |error, input| puts "input '#{input.inspect}' failed with error: #{error.to_s}" }
|
35
|
+
```
|
36
|
+
|
37
|
+
This can be useful when used with `dry-monads` and the [`do` notation](/gems/dry-monads/1.0/do-notation/):
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require 'dry/types'
|
41
|
+
Types = Dry.Types()
|
42
|
+
Dry::Types.load_extensions(:monads)
|
43
|
+
|
44
|
+
class AddTen
|
45
|
+
include Dry::Monads[:result, :do]
|
46
|
+
|
47
|
+
def call(input)
|
48
|
+
integer = yield Types::Coercible::Integer.try(input)
|
49
|
+
|
50
|
+
Success(integer + 10)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
add_ten = AddTen.new
|
55
|
+
|
56
|
+
add_ten.call(10)
|
57
|
+
# => Success(20)
|
58
|
+
|
59
|
+
add_ten.call('integer')
|
60
|
+
# => Failure([#<Dry::Types::CoercionError: invalid value for Integer(): "integer">, "integer"])
|
61
|
+
```
|
@@ -31,7 +31,7 @@ name: dry-types
|
|
31
31
|
end
|
32
32
|
```
|
33
33
|
|
34
|
-
2. Define [Custom Types](
|
34
|
+
2. Define [Custom Types](docs::custom-types) in the `Types` module, then pass the name & type to `attribute`:
|
35
35
|
|
36
36
|
```ruby
|
37
37
|
module Types
|
@@ -15,6 +15,7 @@ sections:
|
|
15
15
|
- enum
|
16
16
|
- map
|
17
17
|
- custom-types
|
18
|
+
- extensions
|
18
19
|
---
|
19
20
|
|
20
21
|
`dry-types` is a simple and extendable type system for Ruby; useful for value coercions, applying constraints, defining complex structs or value objects and more. It was created as a successor to [Virtus](https://github.com/solnic/virtus).
|
@@ -35,7 +36,7 @@ User.new(name: 'Bob', age: 35)
|
|
35
36
|
# => #<User name="Bob" age=35>
|
36
37
|
```
|
37
38
|
|
38
|
-
See [Built-in Types](
|
39
|
+
See [Built-in Types](docs::built-in-types/) for a full list of available types.
|
39
40
|
|
40
41
|
By themselves, the basic type definitions like `Types::String` and `Types::Integer` don't do anything except provide documentation about which type an attribute is expected to have. However, there are many more advanced possibilities:
|
41
42
|
|
@@ -66,7 +67,7 @@ User.new(name: 'Bob', age: 'not coercible')
|
|
66
67
|
# => ArgumentError: invalid value for Integer(): "not coercible"
|
67
68
|
```
|
68
69
|
|
69
|
-
- Use `.optional` to denote that an attribute can be `nil` (see [Optional Values](
|
70
|
+
- Use `.optional` to denote that an attribute can be `nil` (see [Optional Values](docs::optional-values)):
|
70
71
|
|
71
72
|
```ruby
|
72
73
|
class User < Dry::Struct
|
@@ -84,7 +85,7 @@ User.new(name: 'Bob')
|
|
84
85
|
# => Dry::Struct::Error: [User.new] :age is missing in Hash input
|
85
86
|
```
|
86
87
|
|
87
|
-
- Add custom constraints (see [Constraints](
|
88
|
+
- Add custom constraints (see [Constraints](docs::constraints.html)):
|
88
89
|
|
89
90
|
```ruby
|
90
91
|
class User < Dry::Struct
|
@@ -120,16 +121,16 @@ Types::Strict::String[10000]
|
|
120
121
|
|
121
122
|
### Features
|
122
123
|
|
123
|
-
* Support for [constrained types](
|
124
|
-
* Support for [optional values](
|
125
|
-
* Support for [default values](
|
126
|
-
* Support for [sum types](
|
127
|
-
* Support for [enums](
|
128
|
-
* Support for [hash type with type schemas](
|
129
|
-
* Support for [array type with members](
|
124
|
+
* Support for [constrained types](docs::constraints)
|
125
|
+
* Support for [optional values](docs::optional-values)
|
126
|
+
* Support for [default values](docs::default-values)
|
127
|
+
* Support for [sum types](docs::sum)
|
128
|
+
* Support for [enums](docs::enum)
|
129
|
+
* Support for [hash type with type schemas](docs::hash-schemas)
|
130
|
+
* Support for [array type with members](docs::array-with-member)
|
130
131
|
* Support for arbitrary meta information
|
131
132
|
* Support for typed struct objects via [dry-struct](/gems/dry-struct)
|
132
|
-
* Types are [categorized](
|
133
|
+
* Types are [categorized](docs::built-in-types), which is especially important for optimized and dedicated coercion logic
|
133
134
|
* Types are composable and reusable objects
|
134
135
|
* No const-missing magic and complicated const lookups
|
135
136
|
* Roughly 6-10 x faster than Virtus
|
@@ -32,65 +32,4 @@ optional_string[123]
|
|
32
32
|
|
33
33
|
### Handle optional values using Monads
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
> NOTE: Requires the [dry-monads gem](/gems/dry-monads/) to be loaded.
|
38
|
-
|
39
|
-
1. Load the `:maybe` extension in your application.
|
40
|
-
|
41
|
-
```ruby
|
42
|
-
require 'dry-types'
|
43
|
-
|
44
|
-
Dry::Types.load_extensions(:maybe)
|
45
|
-
module Types
|
46
|
-
include Dry.Types()
|
47
|
-
end
|
48
|
-
```
|
49
|
-
|
50
|
-
2. Append `.maybe` to a _Type_ to return a _Monad_ object
|
51
|
-
|
52
|
-
```ruby
|
53
|
-
x = Types::Maybe::Strict::Integer[nil]
|
54
|
-
Maybe(x) { puts(x) }
|
55
|
-
|
56
|
-
x = Types::Maybe::Coercible::String[nil]
|
57
|
-
Maybe(x) { puts(x) }
|
58
|
-
|
59
|
-
x = Types::Maybe::Strict::Integer[123]
|
60
|
-
Maybe(x) { puts(x) }
|
61
|
-
|
62
|
-
x = Types::Maybe::Strict::String[123]
|
63
|
-
Maybe(x) { puts(x) }
|
64
|
-
```
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
Types::Maybe::Strict::Integer[nil] # None
|
68
|
-
Types::Maybe::Strict::Integer[123] # Some(123)
|
69
|
-
|
70
|
-
Types::Maybe::Coercible::Float[nil] # None
|
71
|
-
Types::Maybe::Coercible::Float['12.3'] # Some(12.3)
|
72
|
-
|
73
|
-
# 'Maybe' types can also accessed by calling '.maybe' on a regular type:
|
74
|
-
Types::Strict::Integer.maybe # equivalent to Types::Maybe::Strict::Integer
|
75
|
-
```
|
76
|
-
|
77
|
-
You can define your own optional types:
|
78
|
-
|
79
|
-
``` ruby
|
80
|
-
maybe_string = Types::Strict::String.maybe
|
81
|
-
|
82
|
-
maybe_string[nil]
|
83
|
-
# => None
|
84
|
-
|
85
|
-
maybe_string[nil].fmap(&:upcase)
|
86
|
-
# => None
|
87
|
-
|
88
|
-
maybe_string['something']
|
89
|
-
# => Some('something')
|
90
|
-
|
91
|
-
maybe_string['something'].fmap(&:upcase)
|
92
|
-
# => Some('SOMETHING')
|
93
|
-
|
94
|
-
maybe_string['something'].fmap(&:upcase).value_or('NOTHING')
|
95
|
-
# => "SOMETHING"
|
96
|
-
```
|
35
|
+
See [Maybe](docs::extensions/maybe) extension for another approach to handling optional values by returning a [_Monad_](/gems/dry-monads/) object.
|
data/lib/dry/types/any.rb
CHANGED
@@ -15,7 +15,7 @@ module Dry
|
|
15
15
|
|
16
16
|
# @api private
|
17
17
|
def initialize(**options)
|
18
|
-
super(::Object, options)
|
18
|
+
super(::Object, **options)
|
19
19
|
end
|
20
20
|
|
21
21
|
# @return [String]
|
@@ -30,7 +30,7 @@ module Dry
|
|
30
30
|
# @return [Type]
|
31
31
|
#
|
32
32
|
# @api public
|
33
|
-
def with(new_options)
|
33
|
+
def with(**new_options)
|
34
34
|
self.class.new(**options, meta: @meta, **new_options)
|
35
35
|
end
|
36
36
|
|
@@ -18,7 +18,7 @@ module Dry
|
|
18
18
|
# @option options [Type] :member
|
19
19
|
#
|
20
20
|
# @api private
|
21
|
-
def initialize(primitive, options
|
21
|
+
def initialize(primitive, **options)
|
22
22
|
@member = options.fetch(:member)
|
23
23
|
super
|
24
24
|
end
|
@@ -89,7 +89,7 @@ module Dry
|
|
89
89
|
block ? yield(failure) : failure
|
90
90
|
end
|
91
91
|
else
|
92
|
-
failure = failure(input, "#{input} is not an array")
|
92
|
+
failure = failure(input, CoercionError.new("#{input} is not an array"))
|
93
93
|
block ? yield(failure) : failure
|
94
94
|
end
|
95
95
|
end
|
@@ -100,7 +100,7 @@ module Dry
|
|
100
100
|
#
|
101
101
|
# @api public
|
102
102
|
def lax
|
103
|
-
Lax.new(Member.new(primitive,
|
103
|
+
Lax.new(Member.new(primitive, **options, member: member.lax, meta: meta))
|
104
104
|
end
|
105
105
|
|
106
106
|
# @see Nominal#to_ast
|
data/lib/dry/types/builder.rb
CHANGED
data/lib/dry/types/compiler.rb
CHANGED
@@ -68,12 +68,12 @@ module Dry
|
|
68
68
|
|
69
69
|
def visit_hash(node)
|
70
70
|
opts, meta = node
|
71
|
-
registry['nominal.hash'].with(opts
|
71
|
+
registry['nominal.hash'].with(**opts, meta: meta)
|
72
72
|
end
|
73
73
|
|
74
74
|
def visit_schema(node)
|
75
75
|
keys, options, meta = node
|
76
|
-
registry['nominal.hash'].schema(keys.map { |key| visit(key) }).with(options
|
76
|
+
registry['nominal.hash'].schema(keys.map { |key| visit(key) }).with(**options, meta: meta)
|
77
77
|
end
|
78
78
|
|
79
79
|
def visit_json_hash(node)
|
@@ -85,7 +85,7 @@ module Dry
|
|
85
85
|
#
|
86
86
|
# @api public
|
87
87
|
def constructor(new_fn = nil, **options, &block)
|
88
|
-
with(
|
88
|
+
with(**options, fn: fn >> (new_fn || block))
|
89
89
|
end
|
90
90
|
alias_method :append, :constructor
|
91
91
|
alias_method :>>, :constructor
|
@@ -114,7 +114,7 @@ module Dry
|
|
114
114
|
#
|
115
115
|
# @api public
|
116
116
|
def prepend(new_fn = nil, **options, &block)
|
117
|
-
with(
|
117
|
+
with(**options, fn: fn << (new_fn || block))
|
118
118
|
end
|
119
119
|
alias_method :<<, :prepend
|
120
120
|
|
@@ -123,7 +123,7 @@ module Dry
|
|
123
123
|
# @return [Lax]
|
124
124
|
# @api public
|
125
125
|
def lax
|
126
|
-
Lax.new(Constructor.new(type.lax, options))
|
126
|
+
Lax.new(Constructor.new(type.lax, **options))
|
127
127
|
end
|
128
128
|
|
129
129
|
# Wrap the type with a proc
|
@@ -158,7 +158,7 @@ module Dry
|
|
158
158
|
response = type.public_send(method, *args, &block)
|
159
159
|
|
160
160
|
if response.is_a?(Type) && type.class == response.class
|
161
|
-
response.constructor_type.new(response, options)
|
161
|
+
response.constructor_type.new(response, **options)
|
162
162
|
else
|
163
163
|
response
|
164
164
|
end
|
data/lib/dry/types/decorator.rb
CHANGED
@@ -14,7 +14,7 @@ module Dry
|
|
14
14
|
attr_reader :type
|
15
15
|
|
16
16
|
# @param [Type] type
|
17
|
-
def initialize(type,
|
17
|
+
def initialize(type, *, **)
|
18
18
|
super
|
19
19
|
@type = type
|
20
20
|
end
|
@@ -101,6 +101,7 @@ module Dry
|
|
101
101
|
super
|
102
102
|
end
|
103
103
|
end
|
104
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
104
105
|
|
105
106
|
# Replace underlying type
|
106
107
|
#
|
data/lib/dry/types/enum.rb
CHANGED
data/lib/dry/types/hash.rb
CHANGED
@@ -113,7 +113,7 @@ module Dry
|
|
113
113
|
|
114
114
|
type_map.map do |map_key, type|
|
115
115
|
name, options = key_name(map_key)
|
116
|
-
key = Schema::Key.new(resolve_type(type), name, options)
|
116
|
+
key = Schema::Key.new(resolve_type(type), name, **options)
|
117
117
|
type_transform.(key)
|
118
118
|
end
|
119
119
|
end
|
data/lib/dry/types/meta.rb
CHANGED
data/lib/dry/types/module.rb
CHANGED
@@ -18,10 +18,10 @@ module Dry
|
|
18
18
|
#
|
19
19
|
# @api public
|
20
20
|
class Module < ::Module
|
21
|
-
def initialize(registry, *args)
|
21
|
+
def initialize(registry, *args, **kwargs)
|
22
22
|
@registry = registry
|
23
|
-
check_parameters(*args)
|
24
|
-
constants = type_constants(*args)
|
23
|
+
check_parameters(*args, **kwargs)
|
24
|
+
constants = type_constants(*args, **kwargs)
|
25
25
|
define_constants(constants)
|
26
26
|
extend(BuilderMethods)
|
27
27
|
|
data/lib/dry/types/spec/types.rb
CHANGED
@@ -109,7 +109,9 @@ RSpec.shared_examples_for Dry::Types::Nominal do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
RSpec.shared_examples_for 'a constrained type' do |inputs: Object.new|
|
112
|
+
RSpec.shared_examples_for 'a constrained type' do |options = { inputs: Object.new }|
|
113
|
+
inputs = options[:inputs]
|
114
|
+
|
113
115
|
let(:fallback) { Object.new }
|
114
116
|
|
115
117
|
describe '#call' do
|
data/lib/dry/types/sum.rb
CHANGED
@@ -40,7 +40,7 @@ module Dry
|
|
40
40
|
# @param [Hash] options
|
41
41
|
#
|
42
42
|
# @api private
|
43
|
-
def initialize(left, right, options
|
43
|
+
def initialize(left, right, **options)
|
44
44
|
super
|
45
45
|
@left, @right = left, right
|
46
46
|
freeze
|
@@ -146,7 +146,7 @@ module Dry
|
|
146
146
|
if data.nil?
|
147
147
|
optional? ? right.meta : super
|
148
148
|
elsif optional?
|
149
|
-
self.class.new(left, right.meta(data), options)
|
149
|
+
self.class.new(left, right.meta(data), **options)
|
150
150
|
else
|
151
151
|
super
|
152
152
|
end
|
data/lib/dry/types/version.rb
CHANGED
metadata
CHANGED
@@ -1,44 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: concurrent-ruby
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - "~>"
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '1.0'
|
19
|
-
name: concurrent-ruby
|
20
|
-
prerelease: false
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-container
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - "~>"
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0.3'
|
33
|
-
name: dry-container
|
34
|
-
prerelease: false
|
35
34
|
type: :runtime
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-core
|
42
43
|
requirement: !ruby/object:Gem::Requirement
|
43
44
|
requirements:
|
44
45
|
- - "~>"
|
@@ -47,9 +48,8 @@ dependencies:
|
|
47
48
|
- - ">="
|
48
49
|
- !ruby/object:Gem::Version
|
49
50
|
version: 0.4.4
|
50
|
-
name: dry-core
|
51
|
-
prerelease: false
|
52
51
|
type: :runtime
|
52
|
+
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
@@ -59,6 +59,7 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 0.4.4
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
+
name: dry-equalizer
|
62
63
|
requirement: !ruby/object:Gem::Requirement
|
63
64
|
requirements:
|
64
65
|
- - "~>"
|
@@ -67,9 +68,8 @@ dependencies:
|
|
67
68
|
- - ">="
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: 0.2.2
|
70
|
-
name: dry-equalizer
|
71
|
-
prerelease: false
|
72
71
|
type: :runtime
|
72
|
+
prerelease: false
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
@@ -79,6 +79,7 @@ dependencies:
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: 0.2.2
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
|
+
name: dry-inflector
|
82
83
|
requirement: !ruby/object:Gem::Requirement
|
83
84
|
requirements:
|
84
85
|
- - "~>"
|
@@ -87,9 +88,8 @@ dependencies:
|
|
87
88
|
- - ">="
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: 0.1.2
|
90
|
-
name: dry-inflector
|
91
|
-
prerelease: false
|
92
91
|
type: :runtime
|
92
|
+
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
@@ -99,6 +99,7 @@ dependencies:
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 0.1.2
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
|
+
name: dry-logic
|
102
103
|
requirement: !ruby/object:Gem::Requirement
|
103
104
|
requirements:
|
104
105
|
- - "~>"
|
@@ -107,9 +108,8 @@ dependencies:
|
|
107
108
|
- - ">="
|
108
109
|
- !ruby/object:Gem::Version
|
109
110
|
version: 1.0.2
|
110
|
-
name: dry-logic
|
111
|
-
prerelease: false
|
112
111
|
type: :runtime
|
112
|
+
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
@@ -119,70 +119,70 @@ dependencies:
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: 1.0.2
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
|
+
name: bundler
|
122
123
|
requirement: !ruby/object:Gem::Requirement
|
123
124
|
requirements:
|
124
125
|
- - ">="
|
125
126
|
- !ruby/object:Gem::Version
|
126
127
|
version: '0'
|
127
|
-
name: bundler
|
128
|
-
prerelease: false
|
129
128
|
type: :development
|
129
|
+
prerelease: false
|
130
130
|
version_requirements: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
132
|
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
|
+
name: dry-monads
|
136
137
|
requirement: !ruby/object:Gem::Requirement
|
137
138
|
requirements:
|
138
139
|
- - "~>"
|
139
140
|
- !ruby/object:Gem::Version
|
140
141
|
version: '0.2'
|
141
|
-
name: dry-monads
|
142
|
-
prerelease: false
|
143
142
|
type: :development
|
143
|
+
prerelease: false
|
144
144
|
version_requirements: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
146
|
- - "~>"
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0.2'
|
149
149
|
- !ruby/object:Gem::Dependency
|
150
|
+
name: rake
|
150
151
|
requirement: !ruby/object:Gem::Requirement
|
151
152
|
requirements:
|
152
153
|
- - "~>"
|
153
154
|
- !ruby/object:Gem::Version
|
154
155
|
version: '11.0'
|
155
|
-
name: rake
|
156
|
-
prerelease: false
|
157
156
|
type: :development
|
157
|
+
prerelease: false
|
158
158
|
version_requirements: !ruby/object:Gem::Requirement
|
159
159
|
requirements:
|
160
160
|
- - "~>"
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '11.0'
|
163
163
|
- !ruby/object:Gem::Dependency
|
164
|
+
name: rspec
|
164
165
|
requirement: !ruby/object:Gem::Requirement
|
165
166
|
requirements:
|
166
167
|
- - "~>"
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '3.3'
|
169
|
-
name: rspec
|
170
|
-
prerelease: false
|
171
170
|
type: :development
|
171
|
+
prerelease: false
|
172
172
|
version_requirements: !ruby/object:Gem::Requirement
|
173
173
|
requirements:
|
174
174
|
- - "~>"
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '3.3'
|
177
177
|
- !ruby/object:Gem::Dependency
|
178
|
+
name: yard
|
178
179
|
requirement: !ruby/object:Gem::Requirement
|
179
180
|
requirements:
|
180
181
|
- - "~>"
|
181
182
|
- !ruby/object:Gem::Version
|
182
183
|
version: 0.9.5
|
183
|
-
name: yard
|
184
|
-
prerelease: false
|
185
184
|
type: :development
|
185
|
+
prerelease: false
|
186
186
|
version_requirements: !ruby/object:Gem::Requirement
|
187
187
|
requirements:
|
188
188
|
- - "~>"
|
@@ -200,12 +200,15 @@ files:
|
|
200
200
|
- ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
|
201
201
|
- ".github/ISSUE_TEMPLATE/---bug-report.md"
|
202
202
|
- ".github/ISSUE_TEMPLATE/---feature-request.md"
|
203
|
+
- ".github/workflows/custom_ci.yml"
|
204
|
+
- ".github/workflows/docsite.yml"
|
205
|
+
- ".github/workflows/sync_configs.yml"
|
203
206
|
- ".gitignore"
|
204
207
|
- ".rspec"
|
205
208
|
- ".rubocop.yml"
|
206
|
-
- ".travis.yml"
|
207
209
|
- ".yardopts"
|
208
210
|
- CHANGELOG.md
|
211
|
+
- CODE_OF_CONDUCT.md
|
209
212
|
- CONTRIBUTING.md
|
210
213
|
- Gemfile
|
211
214
|
- LICENSE
|
@@ -224,6 +227,9 @@ files:
|
|
224
227
|
- docsite/source/custom-types.html.md
|
225
228
|
- docsite/source/default-values.html.md
|
226
229
|
- docsite/source/enum.html.md
|
230
|
+
- docsite/source/extensions.html.md
|
231
|
+
- docsite/source/extensions/maybe.html.md
|
232
|
+
- docsite/source/extensions/monads.html.md
|
227
233
|
- docsite/source/getting-started.html.md
|
228
234
|
- docsite/source/hash-schemas.html.md
|
229
235
|
- docsite/source/index.html.md
|
@@ -291,7 +297,7 @@ metadata:
|
|
291
297
|
changelog_uri: https://github.com/dry-rb/dry-types/blob/master/CHANGELOG.md
|
292
298
|
source_code_uri: https://github.com/dry-rb/dry-types
|
293
299
|
bug_tracker_uri: https://github.com/dry-rb/dry-types/issues
|
294
|
-
post_install_message:
|
300
|
+
post_install_message:
|
295
301
|
rdoc_options: []
|
296
302
|
require_paths:
|
297
303
|
- lib
|
@@ -306,9 +312,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
306
312
|
- !ruby/object:Gem::Version
|
307
313
|
version: '0'
|
308
314
|
requirements: []
|
309
|
-
|
310
|
-
|
311
|
-
signing_key:
|
315
|
+
rubygems_version: 3.0.6
|
316
|
+
signing_key:
|
312
317
|
specification_version: 4
|
313
318
|
summary: Type system for Ruby supporting coercions, constraints and complex types
|
314
319
|
like structs, value objects, enums etc.
|
data/.travis.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
bundler_args: --without benchmarks tools
|
4
|
-
before_script:
|
5
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
6
|
-
- chmod +x ./cc-test-reporter
|
7
|
-
- ./cc-test-reporter before-build
|
8
|
-
after_script:
|
9
|
-
- "[ -d coverage ] && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
10
|
-
script:
|
11
|
-
- bundle exec rake
|
12
|
-
rvm:
|
13
|
-
- 2.6.5
|
14
|
-
- 2.5.7
|
15
|
-
- 2.4.9
|
16
|
-
- ruby-head
|
17
|
-
env:
|
18
|
-
global:
|
19
|
-
- COVERAGE=true
|
20
|
-
matrix:
|
21
|
-
allow_failures:
|
22
|
-
- rvm: ruby-head
|
23
|
-
include:
|
24
|
-
- rvm: jruby-9.2.8.0
|
25
|
-
jdk: openjdk8
|
26
|
-
notifications:
|
27
|
-
email: false
|
28
|
-
webhooks:
|
29
|
-
urls:
|
30
|
-
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
31
|
-
on_success: change # options: [always|never|change] default: always
|
32
|
-
on_failure: always # options: [always|never|change] default: always
|
33
|
-
on_start: false # default: false
|