dry-core 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +95 -34
- data/LICENSE +20 -0
- data/README.md +13 -46
- data/dry-core.gemspec +23 -23
- data/lib/dry/core/class_attributes.rb +28 -8
- data/lib/dry/core/class_builder.rb +1 -3
- data/lib/dry/core/constants.rb +5 -3
- data/lib/dry/core/deprecations.rb +8 -8
- data/lib/dry/core/inflector.rb +3 -2
- data/lib/dry/core/version.rb +1 -1
- metadata +20 -25
- data/.codeclimate.yml +0 -15
- data/.gitignore +0 -11
- data/.inch.yml +0 -4
- data/.rspec +0 -3
- data/.travis.yml +0 -34
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -21
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 538785d6f230fed2829eb31c2eed7b4f878db06f3d69703329e571327abea700
|
4
|
+
data.tar.gz: 6df94708151283cf120d590581171931141f999d8bdace6a825d80f61ac220e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ab27069408443161d3bed839e061e35ff0c683d3d9023d6834b1d45e48d44eb13eba350b3c7760312ace4eac3d83b8c008eada7878338fa017c96b195c02acc
|
7
|
+
data.tar.gz: 73c828d5271872b6b5a2b0cbf1d53075b3845ad36e82a90c7d12e35f7154a807c1320de5233eb9c26eeba35cf4078ed0b3fa5deb2b9bc7306adb26c10174d13a
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,32 @@
|
|
1
|
-
|
1
|
+
## 0.4.10 2020-11-19
|
2
|
+
|
3
|
+
|
4
|
+
### Added
|
5
|
+
|
6
|
+
- `ClassAttributes.defines` gets a new option for coercing values (tallica)
|
7
|
+
```ruby
|
8
|
+
class Builder
|
9
|
+
extend Dry::Core::ClassAttributes
|
10
|
+
|
11
|
+
defines :nodes, coerce: -> value { Integer(value) }
|
12
|
+
end
|
13
|
+
```
|
14
|
+
`:coerce` works with any callable as well as types from dry-types
|
15
|
+
```ruby
|
16
|
+
defines :nodes, coerce: Dry::Types['coercible.integer']
|
17
|
+
```
|
18
|
+
- `Constants::IDENTITY` which is the identity function (flash-gordon)
|
19
|
+
|
20
|
+
|
21
|
+
[Compare v0.4.9...v0.4.10](https://github.com/dry-rb/dry-core/compare/v0.4.9...v0.4.10)
|
22
|
+
|
23
|
+
## 0.4.9 2019-08-09
|
24
|
+
|
2
25
|
|
3
26
|
### Added
|
4
27
|
|
5
28
|
- `Undefined.coalesce` takes a variable number of arguments and returns the first non-`Undefined` value (flash-gordon)
|
29
|
+
|
6
30
|
```ruby
|
7
31
|
Undefined.coalesce(Undefined, Undefined, :foo) # => :foo
|
8
32
|
```
|
@@ -11,32 +35,39 @@
|
|
11
35
|
|
12
36
|
- `Undefined.{dup,clone}` returns `Undefined` back, `Undefined` is a singleton (flash-gordon)
|
13
37
|
|
38
|
+
|
14
39
|
[Compare v0.4.8...v0.4.9](https://github.com/dry-rb/dry-core/compare/v0.4.8...v0.4.9)
|
15
40
|
|
16
|
-
|
41
|
+
## 0.4.8 2019-06-23
|
42
|
+
|
17
43
|
|
18
44
|
### Added
|
19
45
|
|
20
|
-
- `Undefined.map` for mapping non-undefined values (flash-gordon)
|
46
|
+
- `Undefined.map` for mapping non-undefined values (flash-gordon)
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
something = 1
|
50
|
+
Undefined.map(something) { |v| v + 1 } # => 2
|
51
|
+
|
52
|
+
something = Undefined
|
53
|
+
Undefined.map(something) { |v| v + 1 } # => Undefined
|
54
|
+
```
|
21
55
|
|
22
|
-
```ruby
|
23
|
-
something = 1
|
24
|
-
Undefined.map(something) { |v| v + 1 } # => 2
|
25
|
-
something = Undefined
|
26
|
-
Undefined.map(something) { |v| v + 1 } # => Undefined
|
27
|
-
```
|
28
56
|
|
29
57
|
[Compare v0.4.7...v0.4.8](https://github.com/dry-rb/dry-core/compare/v0.4.7...v0.4.8)
|
30
58
|
|
31
|
-
|
59
|
+
## 0.4.7 2018-06-25
|
60
|
+
|
32
61
|
|
33
62
|
### Fixed
|
34
63
|
|
35
64
|
- Fix default logger for deprecations, it now uses `$stderr` by default, as it should (flash-gordon)
|
36
65
|
|
66
|
+
|
37
67
|
[Compare v0.4.6...v0.4.7](https://github.com/dry-rb/dry-core/compare/v0.4.6...v0.4.7)
|
38
68
|
|
39
|
-
|
69
|
+
## 0.4.6 2018-05-15
|
70
|
+
|
40
71
|
|
41
72
|
### Changed
|
42
73
|
|
@@ -44,40 +75,49 @@ Undefined.map(something) { |v| v + 1 } # => Undefined
|
|
44
75
|
|
45
76
|
[Compare v0.4.5...v0.4.6](https://github.com/dry-rb/dry-core/compare/v0.4.5...v0.4.6)
|
46
77
|
|
47
|
-
|
78
|
+
## 0.4.5 2018-03-14
|
79
|
+
|
48
80
|
|
49
81
|
### Added
|
50
82
|
|
51
83
|
- `Dry::Core::Memoizable`, which provides a `memoize` macro for memoizing results of instance methods (timriley)
|
52
84
|
|
85
|
+
|
53
86
|
[Compare v0.4.4...v0.4.5](https://github.com/dry-rb/dry-core/compare/v0.4.4...v0.4.5)
|
54
87
|
|
55
|
-
|
88
|
+
## 0.4.4 2018-02-10
|
89
|
+
|
56
90
|
|
57
91
|
### Added
|
58
92
|
|
59
93
|
- `deprecate_constant` overrides `Module#deprecate_constant` and issues a labeled message on accessing a deprecated constant (flash-gordon)
|
60
94
|
- `Undefined.default` which accepts two arguments and returns the first if it's not `Undefined`; otherwise, returns the second one or yields a block (flash-gordon)
|
61
95
|
|
96
|
+
|
62
97
|
[Compare v0.4.3...v0.4.4](https://github.com/dry-rb/dry-core/compare/v0.4.3...v0.4.4)
|
63
98
|
|
64
|
-
|
99
|
+
## 0.4.3 2018-02-03
|
100
|
+
|
65
101
|
|
66
102
|
### Added
|
67
103
|
|
68
104
|
- `Dry::Core::DescendantsTracker` which is a maintained version of the [`descendants_tracker`](https://github.com/dkubb/descendants_tracker) gem (flash-gordon)
|
69
105
|
|
70
|
-
[Compare v0.4.2...v0.4.3](https://github.com/dry-rb/dry-core/compare/v0.4.2...0.4.3)
|
71
106
|
|
72
|
-
|
107
|
+
[Compare v0.4.2...v0.4.3](https://github.com/dry-rb/dry-core/compare/v0.4.2...v0.4.3)
|
108
|
+
|
109
|
+
## 0.4.2 2017-12-16
|
110
|
+
|
73
111
|
|
74
112
|
### Fixed
|
75
113
|
|
76
114
|
- Class attributes now support private setters/getters (flash-gordon)
|
77
115
|
|
116
|
+
|
78
117
|
[Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-core/compare/v0.4.1...v0.4.2)
|
79
118
|
|
80
|
-
|
119
|
+
## 0.4.1 2017-11-04
|
120
|
+
|
81
121
|
|
82
122
|
### Changed
|
83
123
|
|
@@ -85,56 +125,67 @@ Undefined.map(something) { |v| v + 1 } # => Undefined
|
|
85
125
|
|
86
126
|
[Compare v0.4.0...v0.4.1](https://github.com/dry-rb/dry-core/compare/v0.4.0...v0.4.1)
|
87
127
|
|
88
|
-
|
128
|
+
## 0.4.0 2017-11-02
|
129
|
+
|
89
130
|
|
90
131
|
### Added
|
91
132
|
|
92
133
|
- Added the `:type` option to class attributes, you can now restrict attribute values with a type. You can either use plain ruby types (`Integer`, `String`, etc) or `dry-types` (GustavoCaso)
|
93
134
|
|
94
135
|
```ruby
|
95
|
-
|
96
|
-
|
136
|
+
class Foo
|
137
|
+
extend Dry::Core::ClassAttributes
|
97
138
|
|
98
|
-
|
99
|
-
|
100
|
-
|
139
|
+
defines :ruby_attr, type: Integer
|
140
|
+
defines :dry_attr, type: Dry::Types['strict.int']
|
141
|
+
end
|
101
142
|
```
|
102
143
|
|
144
|
+
|
103
145
|
[Compare v0.3.4...v0.4.0](https://github.com/dry-rb/dry-core/compare/v0.3.4...v0.4.0)
|
104
146
|
|
105
|
-
|
147
|
+
## 0.3.4 2017-09-29
|
148
|
+
|
106
149
|
|
107
150
|
### Fixed
|
108
151
|
|
109
152
|
- `Deprecations` output is set to `$stderr` by default now (solnic)
|
110
153
|
|
154
|
+
|
111
155
|
[Compare v0.3.3...v0.3.4](https://github.com/dry-rb/dry-core/compare/v0.3.3...v0.3.4)
|
112
156
|
|
113
|
-
|
157
|
+
## 0.3.3 2017-08-31
|
158
|
+
|
114
159
|
|
115
160
|
### Fixed
|
116
161
|
|
117
162
|
- The Deprecations module now shows the right caller line (flash-gordon)
|
118
163
|
|
164
|
+
|
119
165
|
[Compare v0.3.2...v0.3.3](https://github.com/dry-rb/dry-core/compare/v0.3.2...v0.3.3)
|
120
166
|
|
121
|
-
|
167
|
+
## 0.3.2 2017-08-31
|
168
|
+
|
122
169
|
|
123
170
|
### Added
|
124
171
|
|
125
172
|
- Accept an existing logger object in `Dry::Core::Deprecations.set_logger!` (flash-gordon)
|
126
173
|
|
174
|
+
|
127
175
|
[Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-core/compare/v0.3.1...v0.3.2)
|
128
176
|
|
129
|
-
|
177
|
+
## 0.3.1 2017-05-27
|
178
|
+
|
130
179
|
|
131
180
|
### Added
|
132
181
|
|
133
182
|
- Support for building classes within an existing namespace (flash-gordon)
|
134
183
|
|
184
|
+
|
135
185
|
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-core/compare/v0.3.0...v0.3.1)
|
136
186
|
|
137
|
-
|
187
|
+
## 0.3.0 2017-05-05
|
188
|
+
|
138
189
|
|
139
190
|
### Changed
|
140
191
|
|
@@ -142,42 +193,52 @@ Undefined.map(something) { |v| v + 1 } # => Undefined
|
|
142
193
|
|
143
194
|
[Compare v0.2.4...v0.3.0](https://github.com/dry-rb/dry-core/compare/v0.2.4...v0.3.0)
|
144
195
|
|
145
|
-
|
196
|
+
## 0.2.4 2017-01-26
|
197
|
+
|
146
198
|
|
147
199
|
### Fixed
|
148
200
|
|
149
201
|
- Do not require deprecated method to be defined (flash-gordon)
|
150
202
|
|
203
|
+
|
151
204
|
[Compare v0.2.3...v0.2.4](https://github.com/dry-rb/dry-core/compare/v0.2.3...v0.2.4)
|
152
205
|
|
153
|
-
|
206
|
+
## 0.2.3 2016-12-30
|
207
|
+
|
154
208
|
|
155
209
|
### Fixed
|
156
210
|
|
157
211
|
- Fix warnings on using uninitialized class attributes (flash-gordon)
|
158
212
|
|
213
|
+
|
159
214
|
[Compare v0.2.2...v0.2.3](https://github.com/dry-rb/dry-core/compare/v0.2.2...v0.2.3)
|
160
215
|
|
161
|
-
|
216
|
+
## 0.2.2 2016-12-30
|
217
|
+
|
162
218
|
|
163
219
|
### Added
|
164
220
|
|
165
221
|
- `ClassAttributes` which provides `defines` method for defining get-or-set methods (flash-gordon)
|
166
222
|
|
223
|
+
|
167
224
|
[Compare v0.2.1...v0.2.2](https://github.com/dry-rb/dry-core/compare/v0.2.1...v0.2.2)
|
168
225
|
|
169
|
-
|
226
|
+
## 0.2.1 2016-11-18
|
227
|
+
|
170
228
|
|
171
229
|
### Added
|
172
230
|
|
173
231
|
- `Constants` are now available in nested scopes (flash-gordon)
|
174
232
|
|
233
|
+
|
175
234
|
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-core/compare/v0.2.0...v0.2.1)
|
176
235
|
|
177
|
-
|
236
|
+
## 0.2.0 2016-11-01
|
237
|
+
|
238
|
+
|
178
239
|
|
179
240
|
[Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-core/compare/v0.1.0...v0.2.0)
|
180
241
|
|
181
|
-
|
242
|
+
## 0.1.0 2016-09-17
|
182
243
|
|
183
244
|
Initial release
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-2020 dry-rb team
|
4
|
+
|
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:
|
11
|
+
|
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.
|
data/README.md
CHANGED
@@ -1,62 +1,29 @@
|
|
1
|
-
[gitter]: https://gitter.im/dry-rb/chat
|
2
1
|
[gem]: https://rubygems.org/gems/dry-core
|
3
|
-
[
|
4
|
-
[
|
5
|
-
[inch]: http://inch-ci.org/github/dry-rb/dry-core
|
2
|
+
[actions]: https://github.com/dry-rb/dry-core/actions
|
3
|
+
[codacy]: https://www.codacy.com/gh/dry-rb/dry-core
|
6
4
|
[chat]: https://dry-rb.zulipchat.com
|
5
|
+
[inchpages]: http://inch-ci.org/github/dry-rb/dry-core
|
7
6
|
|
8
7
|
# dry-core [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
|
9
8
|
|
10
|
-
[![Gem Version](https://
|
11
|
-
[![
|
12
|
-
[![
|
13
|
-
[![
|
14
|
-
[![
|
15
|
-
![No monkey-patches](https://img.shields.io/badge/monkey--patches-0-brightgreen.svg)
|
16
|
-
|
17
|
-
A collection of small modules used in the dry-rb ecosystem.
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/dry-core.svg)][gem]
|
10
|
+
[![CI Status](https://github.com/dry-rb/dry-core/workflows/ci/badge.svg)][actions]
|
11
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/40946292b9094624beec604a149a6023)][codacy]
|
12
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/40946292b9094624beec604a149a6023)][codacy]
|
13
|
+
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-core.svg?branch=master)][inchpages]
|
18
14
|
|
19
15
|
## Links
|
20
16
|
|
21
|
-
* [User
|
22
|
-
* [API
|
17
|
+
* [User documentation](http://dry-rb.org/gems/dry-core)
|
18
|
+
* [API documentation](http://rubydoc.info/gems/dry-core)
|
23
19
|
|
24
20
|
## Supported Ruby versions
|
25
21
|
|
26
|
-
This library officially supports following Ruby versions:
|
22
|
+
This library officially supports the following Ruby versions:
|
27
23
|
|
28
|
-
* MRI >= `2.
|
24
|
+
* MRI >= `2.5`
|
29
25
|
* jruby >= `9.2`
|
30
26
|
|
31
|
-
It **should** work on MRI `2.3.x` too, but there's no official support for this version.
|
32
|
-
|
33
|
-
## Installation
|
34
|
-
|
35
|
-
Add this line to your application's Gemfile:
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
gem 'dry-core'
|
39
|
-
```
|
40
|
-
|
41
|
-
And then execute:
|
42
|
-
|
43
|
-
$ bundle
|
44
|
-
|
45
|
-
Or install it yourself as:
|
46
|
-
|
47
|
-
$ gem install dry-core
|
48
|
-
|
49
|
-
## Development
|
50
|
-
|
51
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
52
|
-
|
53
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
54
|
-
|
55
|
-
## Contributing
|
56
|
-
|
57
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/dry-rb/dry-core.
|
58
|
-
|
59
|
-
|
60
27
|
## License
|
61
28
|
|
62
|
-
|
29
|
+
See `LICENSE` file.
|
data/dry-core.gemspec
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
# this file is managed by dry-rb/devtools project
|
2
3
|
|
3
|
-
lib = File.expand_path('
|
4
|
+
lib = File.expand_path('lib', __dir__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
6
|
require 'dry/core/version'
|
6
7
|
|
7
8
|
Gem::Specification.new do |spec|
|
8
9
|
spec.name = 'dry-core'
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
10
|
+
spec.authors = ["Nikita Shilnikov"]
|
11
|
+
spec.email = ["fg@flashgordon.ru"]
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.version = Dry::Core::VERSION.dup
|
12
14
|
|
13
|
-
spec.summary =
|
15
|
+
spec.summary = "A toolset of small support modules used throughout the dry-rb ecosystem"
|
14
16
|
spec.description = spec.summary
|
15
|
-
spec.homepage = 'https://
|
16
|
-
spec.
|
17
|
+
spec.homepage = 'https://dry-rb.org/gems/dry-core'
|
18
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-core.gemspec", "lib/**/*"]
|
19
|
+
spec.bindir = 'bin'
|
20
|
+
spec.executables = []
|
21
|
+
spec.require_paths = ['lib']
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
else
|
23
|
-
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
24
|
-
end
|
23
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
24
|
+
spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-core/blob/master/CHANGELOG.md'
|
25
|
+
spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-core'
|
26
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-core/issues'
|
25
27
|
|
26
|
-
spec.
|
27
|
-
|
28
|
-
|
29
|
-
spec.
|
30
|
-
spec.required_ruby_version = '>= 2.1.0'
|
31
|
-
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
|
28
|
+
spec.required_ruby_version = ">= 2.5.0"
|
29
|
+
|
30
|
+
# to update dependencies edit project.yml
|
31
|
+
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
32
32
|
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
33
|
+
spec.add_development_dependency "bundler"
|
34
|
+
spec.add_development_dependency "rake"
|
35
|
+
spec.add_development_dependency "rspec"
|
36
36
|
end
|
@@ -51,22 +51,42 @@ module Dry
|
|
51
51
|
# defines :one, :two, type: Dry::Types['strict.int']
|
52
52
|
# end
|
53
53
|
#
|
54
|
-
|
55
|
-
|
54
|
+
# @example with coercion using Proc
|
55
|
+
#
|
56
|
+
# class Bar
|
57
|
+
# extend Dry::Core::ClassAttributes
|
58
|
+
#
|
59
|
+
# defines :one, coerce: proc { |value| value.to_s }
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# @example with coercion using dry-types
|
63
|
+
#
|
64
|
+
# class Bar
|
65
|
+
# extend Dry::Core::ClassAttributes
|
66
|
+
#
|
67
|
+
# defines :one, coerce: Dry::Types['coercible.string']
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
def defines(*args, type: ::Object, coerce: IDENTITY)
|
71
|
+
unless coerce.respond_to?(:call)
|
72
|
+
raise ::ArgumentError, "Non-callable coerce option: #{coerce.inspect}"
|
73
|
+
end
|
74
|
+
|
75
|
+
mod = ::Module.new do
|
56
76
|
args.each do |name|
|
57
|
-
|
58
|
-
ivar = "@#{name}"
|
77
|
+
ivar = :"@#{name}"
|
59
78
|
|
60
|
-
|
79
|
+
define_method(name) do |value = Undefined|
|
80
|
+
if Undefined.equal?(value)
|
61
81
|
if instance_variable_defined?(ivar)
|
62
82
|
instance_variable_get(ivar)
|
63
83
|
else
|
64
84
|
nil
|
65
85
|
end
|
86
|
+
elsif type === value
|
87
|
+
instance_variable_set(ivar, coerce.call(value))
|
66
88
|
else
|
67
|
-
raise InvalidClassAttributeValue.new(name, value)
|
68
|
-
|
69
|
-
instance_variable_set(ivar, value)
|
89
|
+
raise InvalidClassAttributeValue.new(name, value)
|
70
90
|
end
|
71
91
|
end
|
72
92
|
end
|
@@ -72,8 +72,6 @@ module Dry
|
|
72
72
|
remove_const(name)
|
73
73
|
const_set(name, klass)
|
74
74
|
|
75
|
-
const_get(name).name if RUBY_VERSION < '2.4'
|
76
|
-
|
77
75
|
remove_const(name)
|
78
76
|
const_set(name, base)
|
79
77
|
end
|
@@ -92,7 +90,7 @@ module Dry
|
|
92
90
|
existing = namespace.const_get(name)
|
93
91
|
|
94
92
|
unless existing <= parent
|
95
|
-
raise ParentClassMismatch, "#{
|
93
|
+
raise ParentClassMismatch, "#{existing.name} must be a subclass of #{parent.name}"
|
96
94
|
end
|
97
95
|
|
98
96
|
existing
|
data/lib/dry/core/constants.rb
CHANGED
@@ -23,16 +23,18 @@ module Dry
|
|
23
23
|
# An empty list of options
|
24
24
|
EMPTY_OPTS = {}.freeze
|
25
25
|
# An empty set
|
26
|
-
EMPTY_SET = Set.new.freeze
|
26
|
+
EMPTY_SET = ::Set.new.freeze
|
27
27
|
# An empty string
|
28
28
|
EMPTY_STRING = ''.freeze
|
29
|
+
# Identity function
|
30
|
+
IDENTITY = (-> x { x }).freeze
|
29
31
|
|
30
32
|
# A special value you can use as a default to know if no arguments
|
31
|
-
# were passed to
|
33
|
+
# were passed to the method
|
32
34
|
#
|
33
35
|
# @example
|
34
36
|
# def method(value = Undefined)
|
35
|
-
# if value
|
37
|
+
# if Undefined.equal?(value)
|
36
38
|
# puts 'no args'
|
37
39
|
# else
|
38
40
|
# puts value
|
@@ -17,7 +17,7 @@ module Dry
|
|
17
17
|
# def old_api; end
|
18
18
|
# def new_api; end
|
19
19
|
#
|
20
|
-
#
|
20
|
+
# deprecate :old_api, :new_api, message: "old_api is no-no"
|
21
21
|
# end
|
22
22
|
#
|
23
23
|
# @example You also can use this module for your custom messages
|
@@ -49,8 +49,8 @@ module Dry
|
|
49
49
|
# @api private
|
50
50
|
def deprecation_message(name, msg)
|
51
51
|
<<-MSG
|
52
|
-
#{
|
53
|
-
#{
|
52
|
+
#{name} is deprecated and will be removed in the next major version
|
53
|
+
#{msg}
|
54
54
|
MSG
|
55
55
|
end
|
56
56
|
|
@@ -97,7 +97,7 @@ module Dry
|
|
97
97
|
@logger = output
|
98
98
|
else
|
99
99
|
@logger = Logger.new(output).tap do |logger|
|
100
|
-
logger.formatter = proc { |_, _, _, msg| "#{
|
100
|
+
logger.formatter = proc { |_, _, _, msg| "#{msg}\n" }
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -155,7 +155,7 @@ module Dry
|
|
155
155
|
undef_method old_name if method_defined?(old_name)
|
156
156
|
|
157
157
|
define_method(old_name) do |*args, &block|
|
158
|
-
mod.warn("#{
|
158
|
+
mod.warn("#{full_msg}\n#{STACK.()}")
|
159
159
|
__send__(new_name, *args, &block)
|
160
160
|
end
|
161
161
|
else
|
@@ -165,7 +165,7 @@ module Dry
|
|
165
165
|
undef_method old_name
|
166
166
|
|
167
167
|
define_method(old_name) do |*args, &block|
|
168
|
-
mod.warn("#{
|
168
|
+
mod.warn("#{full_msg}\n#{STACK.()}")
|
169
169
|
__send__(aliased_name, *args, &block)
|
170
170
|
end
|
171
171
|
end
|
@@ -189,7 +189,7 @@ module Dry
|
|
189
189
|
undef_method old_name if method_defined?(old_name)
|
190
190
|
|
191
191
|
define_method(old_name) do |*args, &block|
|
192
|
-
warn("#{
|
192
|
+
warn("#{full_msg}\n#{STACK.()}")
|
193
193
|
meth.call(*args, &block)
|
194
194
|
end
|
195
195
|
end
|
@@ -210,7 +210,7 @@ module Dry
|
|
210
210
|
mod = Module.new do
|
211
211
|
define_method(:const_missing) do |missing|
|
212
212
|
if missing == constant_name
|
213
|
-
warn("#{
|
213
|
+
warn("#{full_msg}\n#{STACK.()}")
|
214
214
|
value
|
215
215
|
else
|
216
216
|
super(missing)
|
data/lib/dry/core/inflector.rb
CHANGED
@@ -38,8 +38,8 @@ module Dry
|
|
38
38
|
BACKENDS.inject(nil) do |backend, (_, (path, factory))|
|
39
39
|
backend || realize_backend(path, factory)
|
40
40
|
end || raise(LoadError,
|
41
|
-
|
42
|
-
|
41
|
+
'No inflector library could be found: '\
|
42
|
+
'please install either the `inflecto` or `activesupport` gem.')
|
43
43
|
end
|
44
44
|
|
45
45
|
# Set preferred backend
|
@@ -49,6 +49,7 @@ module Dry
|
|
49
49
|
if name && !BACKENDS.key?(name)
|
50
50
|
raise NameError, "Invalid inflector library selection: '#{name}'"
|
51
51
|
end
|
52
|
+
|
52
53
|
@inflector = name ? realize_backend(*BACKENDS[name]) : detect_backend
|
53
54
|
end
|
54
55
|
|
data/lib/dry/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Shilnikov
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -42,48 +42,40 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
description: A toolset of small support modules used throughout the dry-rb ecosystem
|
68
|
+
version: '0'
|
69
|
+
description: A toolset of small support modules used throughout the dry-rb ecosystem
|
70
70
|
email:
|
71
71
|
- fg@flashgordon.ru
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- ".codeclimate.yml"
|
77
|
-
- ".gitignore"
|
78
|
-
- ".inch.yml"
|
79
|
-
- ".rspec"
|
80
|
-
- ".travis.yml"
|
81
76
|
- CHANGELOG.md
|
82
|
-
-
|
83
|
-
- Gemfile
|
84
|
-
- LICENSE.txt
|
77
|
+
- LICENSE
|
85
78
|
- README.md
|
86
|
-
- Rakefile
|
87
79
|
- dry-core.gemspec
|
88
80
|
- lib/dry-core.rb
|
89
81
|
- lib/dry/core.rb
|
@@ -98,11 +90,14 @@ files:
|
|
98
90
|
- lib/dry/core/inflector.rb
|
99
91
|
- lib/dry/core/memoizable.rb
|
100
92
|
- lib/dry/core/version.rb
|
101
|
-
homepage: https://
|
93
|
+
homepage: https://dry-rb.org/gems/dry-core
|
102
94
|
licenses:
|
103
95
|
- MIT
|
104
96
|
metadata:
|
105
97
|
allowed_push_host: https://rubygems.org
|
98
|
+
changelog_uri: https://github.com/dry-rb/dry-core/blob/master/CHANGELOG.md
|
99
|
+
source_code_uri: https://github.com/dry-rb/dry-core
|
100
|
+
bug_tracker_uri: https://github.com/dry-rb/dry-core/issues
|
106
101
|
post_install_message:
|
107
102
|
rdoc_options: []
|
108
103
|
require_paths:
|
@@ -111,15 +106,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
106
|
requirements:
|
112
107
|
- - ">="
|
113
108
|
- !ruby/object:Gem::Version
|
114
|
-
version: 2.
|
109
|
+
version: 2.5.0
|
115
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
111
|
requirements:
|
117
112
|
- - ">="
|
118
113
|
- !ruby/object:Gem::Version
|
119
114
|
version: '0'
|
120
115
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.1.4
|
122
117
|
signing_key:
|
123
118
|
specification_version: 4
|
124
|
-
summary: A toolset of small support modules used throughout the dry-rb ecosystem
|
119
|
+
summary: A toolset of small support modules used throughout the dry-rb ecosystem
|
125
120
|
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/.inch.yml
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: trusty
|
3
|
-
sudo: required
|
4
|
-
cache: bundler
|
5
|
-
bundler_args: --without benchmarks tools
|
6
|
-
after_success:
|
7
|
-
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
8
|
-
before_install:
|
9
|
-
- gem install bundler
|
10
|
-
after_success:
|
11
|
-
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
12
|
-
rvm:
|
13
|
-
- 2.4.6
|
14
|
-
- 2.5.5
|
15
|
-
- 2.6.3
|
16
|
-
- truffleruby
|
17
|
-
env:
|
18
|
-
global:
|
19
|
-
- COVERAGE=true
|
20
|
-
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
21
|
-
matrix:
|
22
|
-
allow_failures:
|
23
|
-
- rvm: truffleruby
|
24
|
-
include:
|
25
|
-
- rvm: jruby-9.2.7.0
|
26
|
-
jdk: openjdk8
|
27
|
-
notifications:
|
28
|
-
email: false
|
29
|
-
webhooks:
|
30
|
-
urls:
|
31
|
-
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
32
|
-
on_success: change # options: [always|never|change] default: always
|
33
|
-
on_failure: always # options: [always|never|change] default: always
|
34
|
-
on_start: false # default: false
|
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 discourseing 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 discourseion thread, and instead summarize what was discourseed.
|
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,21 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
group :test do
|
6
|
-
if RUBY_VERSION >= '2.4'
|
7
|
-
gem 'activesupport'
|
8
|
-
else
|
9
|
-
gem 'activesupport', '~> 4.2'
|
10
|
-
end
|
11
|
-
gem 'inflecto', '~> 0.0', '>= 0.0.2'
|
12
|
-
gem 'codeclimate-test-reporter', require: false
|
13
|
-
gem 'simplecov', require: false
|
14
|
-
gem 'dry-types', '~> 1.0'
|
15
|
-
gem 'dry-inflector'
|
16
|
-
end
|
17
|
-
|
18
|
-
group :tools do
|
19
|
-
gem 'pry-byebug', platform: :mri
|
20
|
-
gem 'pry', platform: :jruby
|
21
|
-
end
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2016 Nikita Shilnikov
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all 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,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|