dry-struct 1.2.0 → 1.3.0
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 +105 -61
- data/LICENSE +1 -1
- data/README.md +16 -12
- data/dry-struct.gemspec +26 -27
- data/lib/dry-struct.rb +2 -0
- data/lib/dry/struct.rb +14 -3
- data/lib/dry/struct/class_interface.rb +91 -34
- data/lib/dry/struct/compiler.rb +22 -0
- data/lib/dry/struct/constructor.rb +4 -24
- data/lib/dry/struct/errors.rb +13 -3
- data/lib/dry/struct/extensions.rb +2 -0
- data/lib/dry/struct/extensions/pretty_print.rb +3 -1
- data/lib/dry/struct/hashify.rb +5 -1
- data/lib/dry/struct/printer.rb +5 -0
- data/lib/dry/struct/struct_builder.rb +18 -11
- data/lib/dry/struct/sum.rb +3 -0
- data/lib/dry/struct/value.rb +4 -6
- data/lib/dry/struct/version.rb +3 -1
- metadata +36 -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/ci.yml +0 -74
- data/.github/workflows/docsite.yml +0 -34
- data/.github/workflows/sync_configs.yml +0 -34
- data/.gitignore +0 -12
- data/.rspec +0 -4
- data/.rubocop.yml +0 -95
- data/.yardopts +0 -4
- data/CODE_OF_CONDUCT.md +0 -13
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -28
- data/Rakefile +0 -10
- data/benchmarks/basic.rb +0 -57
- data/benchmarks/constrained.rb +0 -37
- data/benchmarks/profile_instantiation.rb +0 -19
- data/benchmarks/setup.rb +0 -11
- data/bin/console +0 -12
- data/bin/setup +0 -7
- data/docsite/source/index.html.md +0 -103
- data/docsite/source/nested-structs.html.md +0 -49
- data/docsite/source/recipes.html.md +0 -143
- data/log/.gitkeep +0 -0
data/lib/dry/struct/sum.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'dry/types/sum'
|
2
4
|
require 'dry/types/printer'
|
3
5
|
|
@@ -12,6 +14,7 @@ module Dry
|
|
12
14
|
right.try_struct(input) { super }
|
13
15
|
end
|
14
16
|
end
|
17
|
+
|
15
18
|
# @param [Hash{Symbol => Object},Dry::Struct] input
|
16
19
|
# @yieldparam [Dry::Types::Result::Failure] failure
|
17
20
|
# @yieldreturn [Dry::Types::ResultResult]
|
data/lib/dry/struct/value.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ice_nine'
|
2
4
|
require 'dry/core/deprecations'
|
3
5
|
|
@@ -23,18 +25,14 @@ module Dry
|
|
23
25
|
#
|
24
26
|
# @see https://github.com/dkubb/ice_nine
|
25
27
|
class Value < self
|
28
|
+
abstract
|
29
|
+
|
26
30
|
# @param (see ClassInterface#new)
|
27
31
|
# @return [Value]
|
28
32
|
# @see https://github.com/dkubb/ice_nine
|
29
33
|
def self.new(*)
|
30
34
|
::IceNine.deep_freeze(super)
|
31
35
|
end
|
32
|
-
|
33
|
-
# @api private
|
34
|
-
# @return [Boolean]
|
35
|
-
def self.value?
|
36
|
-
true
|
37
|
-
end
|
38
36
|
end
|
39
37
|
|
40
38
|
deprecate_constant :Value
|
data/lib/dry/struct/version.rb
CHANGED
metadata
CHANGED
@@ -1,63 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-struct
|
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
|
-
name: dry-
|
14
|
+
name: dry-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.4.4
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
29
|
+
version: '0.4'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.4.4
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: dry-
|
34
|
+
name: dry-equalizer
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
39
|
+
version: '0.3'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '0.3'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: dry-
|
48
|
+
name: dry-types
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 0.4.3
|
53
|
+
version: '1.3'
|
51
54
|
type: :runtime
|
52
55
|
prerelease: false
|
53
56
|
version_requirements: !ruby/object:Gem::Requirement
|
54
57
|
requirements:
|
55
58
|
- - "~>"
|
56
59
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 0.4.3
|
60
|
+
version: '1.3'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: ice_nine
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,82 +90,59 @@ dependencies:
|
|
90
90
|
name: rake
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - "
|
93
|
+
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - "
|
100
|
+
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rspec
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- - "
|
107
|
+
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
109
|
+
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - "
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
116
|
+
version: '0'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: yard
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- - "
|
121
|
+
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0
|
123
|
+
version: '0'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- - "
|
128
|
+
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0
|
131
|
-
description: Typed structs and value objects
|
130
|
+
version: '0'
|
131
|
+
description: Typed structs and value objects
|
132
132
|
email:
|
133
133
|
- piotr.solnica@gmail.com
|
134
134
|
executables: []
|
135
135
|
extensions: []
|
136
136
|
extra_rdoc_files: []
|
137
137
|
files:
|
138
|
-
- ".codeclimate.yml"
|
139
|
-
- ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
|
140
|
-
- ".github/ISSUE_TEMPLATE/---bug-report.md"
|
141
|
-
- ".github/ISSUE_TEMPLATE/---feature-request.md"
|
142
|
-
- ".github/workflows/ci.yml"
|
143
|
-
- ".github/workflows/docsite.yml"
|
144
|
-
- ".github/workflows/sync_configs.yml"
|
145
|
-
- ".gitignore"
|
146
|
-
- ".rspec"
|
147
|
-
- ".rubocop.yml"
|
148
|
-
- ".yardopts"
|
149
138
|
- CHANGELOG.md
|
150
|
-
- CODE_OF_CONDUCT.md
|
151
|
-
- CONTRIBUTING.md
|
152
|
-
- Gemfile
|
153
139
|
- LICENSE
|
154
140
|
- README.md
|
155
|
-
- Rakefile
|
156
|
-
- benchmarks/basic.rb
|
157
|
-
- benchmarks/constrained.rb
|
158
|
-
- benchmarks/profile_instantiation.rb
|
159
|
-
- benchmarks/setup.rb
|
160
|
-
- bin/console
|
161
|
-
- bin/setup
|
162
|
-
- docsite/source/index.html.md
|
163
|
-
- docsite/source/nested-structs.html.md
|
164
|
-
- docsite/source/recipes.html.md
|
165
141
|
- dry-struct.gemspec
|
166
142
|
- lib/dry-struct.rb
|
167
143
|
- lib/dry/struct.rb
|
168
144
|
- lib/dry/struct/class_interface.rb
|
145
|
+
- lib/dry/struct/compiler.rb
|
169
146
|
- lib/dry/struct/constructor.rb
|
170
147
|
- lib/dry/struct/errors.rb
|
171
148
|
- lib/dry/struct/extensions.rb
|
@@ -176,14 +153,14 @@ files:
|
|
176
153
|
- lib/dry/struct/sum.rb
|
177
154
|
- lib/dry/struct/value.rb
|
178
155
|
- lib/dry/struct/version.rb
|
179
|
-
-
|
180
|
-
homepage: https://github.com/dry-rb/dry-struct
|
156
|
+
homepage: https://dry-rb.org/gems/dry-struct
|
181
157
|
licenses:
|
182
158
|
- MIT
|
183
159
|
metadata:
|
184
160
|
allowed_push_host: https://rubygems.org
|
185
161
|
changelog_uri: https://github.com/dry-rb/dry-struct/blob/master/CHANGELOG.md
|
186
162
|
source_code_uri: https://github.com/dry-rb/dry-struct
|
163
|
+
bug_tracker_uri: https://github.com/dry-rb/dry-struct/issues
|
187
164
|
post_install_message:
|
188
165
|
rdoc_options: []
|
189
166
|
require_paths:
|
@@ -199,8 +176,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
176
|
- !ruby/object:Gem::Version
|
200
177
|
version: '0'
|
201
178
|
requirements: []
|
202
|
-
rubygems_version: 3.0.
|
179
|
+
rubygems_version: 3.0.3
|
203
180
|
signing_key:
|
204
181
|
specification_version: 4
|
205
|
-
summary: Typed structs and value objects
|
182
|
+
summary: Typed structs and value objects
|
206
183
|
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.
|
data/.github/workflows/ci.yml
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: ci
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
paths:
|
8
|
-
- .github/workflows/ci.yml
|
9
|
-
- lib/**
|
10
|
-
- spec/**
|
11
|
-
- Gemfile
|
12
|
-
- "*.gemspec"
|
13
|
-
|
14
|
-
jobs:
|
15
|
-
tests-mri:
|
16
|
-
runs-on: ubuntu-latest
|
17
|
-
strategy:
|
18
|
-
fail-fast: false
|
19
|
-
matrix:
|
20
|
-
ruby: ["2.6.x", "2.5.x", "2.4.x"]
|
21
|
-
include:
|
22
|
-
- ruby: "2.6.x"
|
23
|
-
coverage: "true"
|
24
|
-
steps:
|
25
|
-
- uses: actions/checkout@v1
|
26
|
-
- name: Set up Ruby
|
27
|
-
uses: actions/setup-ruby@v1
|
28
|
-
with:
|
29
|
-
ruby-version: ${{matrix.ruby}}
|
30
|
-
- name: Download test reporter
|
31
|
-
if: "matrix.coverage == 'true'"
|
32
|
-
run: |
|
33
|
-
mkdir -p tmp/
|
34
|
-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
|
35
|
-
chmod +x ./tmp/cc-test-reporter
|
36
|
-
./tmp/cc-test-reporter before-build
|
37
|
-
- name: Run all tests
|
38
|
-
env:
|
39
|
-
COVERAGE: ${{matrix.coverage}}
|
40
|
-
run: |
|
41
|
-
gem install bundler
|
42
|
-
bundle install --jobs 4 --retry 3 --without tools docs benchmarks
|
43
|
-
bundle exec rake
|
44
|
-
- name: Send coverage results
|
45
|
-
if: "matrix.coverage == 'true'"
|
46
|
-
env:
|
47
|
-
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
|
48
|
-
GIT_COMMIT_SHA: ${{github.sha}}
|
49
|
-
GIT_BRANCH: ${{github.ref}}
|
50
|
-
GIT_COMMITTED_AT: ${{github.event.head_commit.timestamp}}
|
51
|
-
run: |
|
52
|
-
GIT_BRANCH=`ruby -e "puts ENV['GITHUB_REF'].split('/', 3).last"` \
|
53
|
-
GIT_COMMITTED_AT=`ruby -r time -e "puts Time.iso8601(ENV['GIT_COMMITTED_AT']).to_i"` \
|
54
|
-
./tmp/cc-test-reporter after-build
|
55
|
-
|
56
|
-
tests-others:
|
57
|
-
runs-on: ubuntu-latest
|
58
|
-
strategy:
|
59
|
-
fail-fast: false
|
60
|
-
matrix:
|
61
|
-
image: ["jruby:9.2.8", "ruby:rc"]
|
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
|
-
run: |
|
72
|
-
gem install bundler
|
73
|
-
bundle install --jobs 4 --retry 3 --without tools docs benchmarks
|
74
|
-
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 }}
|