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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfe5b98793bc0e200a3a226a60d8c0f5234de170f033c9c3f06fc779979a1f63
4
- data.tar.gz: de24e4b5d0bead8d577c3594bea81986ea7e7cf8124f17ce471f734d143d7319
3
+ metadata.gz: 538785d6f230fed2829eb31c2eed7b4f878db06f3d69703329e571327abea700
4
+ data.tar.gz: 6df94708151283cf120d590581171931141f999d8bdace6a825d80f61ac220e4
5
5
  SHA512:
6
- metadata.gz: 46141cc708525532152db4c692b8d5ac413ded55ee6484d672c6974a41a6487776ef2aeba3bb3abde5e22fcf4c4d8ac42900a391dcd7a38a5ff95fd4c5d9b717
7
- data.tar.gz: 4871d4b68086c1521424d2510b47ab0448fbe344beed3bc7fd1ee1f9115306d3893b751f882a942f9321183724c8aecea1b7e69b81cb2fe7794dbec07d5222a6
6
+ metadata.gz: 4ab27069408443161d3bed839e061e35ff0c683d3d9023d6834b1d45e48d44eb13eba350b3c7760312ace4eac3d83b8c008eada7878338fa017c96b195c02acc
7
+ data.tar.gz: 73c828d5271872b6b5a2b0cbf1d53075b3845ad36e82a90c7d12e35f7154a807c1320de5233eb9c26eeba35cf4078ed0b3fa5deb2b9bc7306adb26c10174d13a
@@ -1,8 +1,32 @@
1
- # v0.4.9
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
- # v0.4.8 2019-06-23
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
- # v0.4.7 2018-06-25
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
- # v0.4.6 2018-05-15
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
- # v0.4.5 2018-03-14
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
- # v0.4.4 2018-02-10
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
- # v0.4.3 2018-02-03
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
- # v0.4.2 2017-12-16
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
- # v0.4.1 2017-11-04
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
- # v0.4.0 2017-11-02
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
- class Foo
96
- extend Dry::Core::ClassAttributes
136
+ class Foo
137
+ extend Dry::Core::ClassAttributes
97
138
 
98
- defines :ruby_attr, type: Integer
99
- defines :dry_attr, type: Dry::Types['strict.int']
100
- end
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
- # v0.3.4 2017-09-29
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
- # v0.3.3 2017-08-31
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
- # v0.3.2 2017-08-31
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
- # v0.3.1 2017-05-27
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
- # v0.3.0 2017-05-05
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
- # v0.2.4 2017-01-26
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
- # v0.2.3 2016-12-30
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
- # v0.2.2 2016-12-30
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
- # v0.2.1 2016-11-18
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
- # v0.2.0 2016-11-01
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
- # v0.1.0 2016-09-17
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
- [travis]: https://travis-ci.org/dry-rb/dry-core
4
- [code_climate]: https://codeclimate.com/github/dry-rb/dry-core
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://img.shields.io/gem/v/dry-core.svg)][gem]
11
- [![Build Status](https://img.shields.io/travis/dry-rb/dry-core.svg)][travis]
12
- [![Code Climate](https://api.codeclimate.com/v1/badges/eebb0e969814744231e4/maintainability)][code_climate]
13
- [![Test Coverage](https://api.codeclimate.com/v1/badges/eebb0e969814744231e4/test_coverage)][code_climate]
14
- [![API Documentation Coverage](http://inch-ci.org/github/dry-rb/dry-core.svg)][inch]
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 docs](https://dry-rb.org/gems/dry-core)
22
- * [API docs](http://rubydoc.info/gems/dry-core)
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.4`
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
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
29
+ See `LICENSE` file.
@@ -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('../lib', __FILE__)
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.version = Dry::Core::VERSION
10
- spec.authors = ['Nikita Shilnikov']
11
- spec.email = ['fg@flashgordon.ru']
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 = 'A toolset of small support modules used throughout the dry-rb ecosystem.'
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://github.com/dry-rb/dry-core'
16
- spec.license = 'MIT'
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
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
- # to allow pushing to a single host or delete this section to allow pushing to any host.
20
- if spec.respond_to?(:metadata)
21
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
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.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bin)/}) }
27
- spec.bindir = 'exe'
28
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ['lib']
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 'bundler'
34
- spec.add_development_dependency 'rake', '~> 10.0'
35
- spec.add_development_dependency 'rspec', '~> 3.0'
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
- def defines(*args, type: Object)
55
- mod = Module.new do
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
- define_method(name) do |value = Undefined|
58
- ivar = "@#{name}"
77
+ ivar = :"@#{name}"
59
78
 
60
- if value == Undefined
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) unless type === 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, "#{ existing.name } must be a subclass of #{ parent.name }"
93
+ raise ParentClassMismatch, "#{existing.name} must be a subclass of #{parent.name}"
96
94
  end
97
95
 
98
96
  existing
@@ -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 you method
33
+ # were passed to the method
32
34
  #
33
35
  # @example
34
36
  # def method(value = Undefined)
35
- # if value == Undefined
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
- # deprecate_method :old_api, :new_api, "old_api is no-no"
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
- #{ name } is deprecated and will be removed in the next major version
53
- #{ msg }
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| "#{ msg }\n" }
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("#{ full_msg }\n#{ STACK.() }")
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("#{ full_msg }\n#{ STACK.() }")
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("#{ full_msg }\n#{ STACK.() }")
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("#{ full_msg }\n#{ STACK.() }")
213
+ warn("#{full_msg}\n#{STACK.()}")
214
214
  value
215
215
  else
216
216
  super(missing)
@@ -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
- "No inflector library could be found: "\
42
- "please install either the `inflecto` or `activesupport` gem.")
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Core
5
- VERSION = '0.4.9'.freeze
5
+ VERSION = '0.4.10'.freeze
6
6
  end
7
7
  end
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.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Shilnikov
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-09 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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: '3.0'
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: '3.0'
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
- - CONTRIBUTING.md
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://github.com/dry-rb/dry-core
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.1.0
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.0.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: []
@@ -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
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- spec/examples.txt
11
- .rubocop.yml
data/.inch.yml DELETED
@@ -1,4 +0,0 @@
1
- files:
2
- excluded:
3
- - lib/dry/core.rb
4
- - lib/dry/core/version.rb
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format progress
2
- --color
3
- --require ./spec/spec_helper.rb
@@ -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
@@ -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
@@ -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.
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec