dry-core 0.4.7 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +15 -0
- data/.gitignore +1 -0
- data/.travis.yml +11 -8
- data/CHANGELOG.md +48 -18
- data/Gemfile +2 -3
- data/README.md +16 -1
- data/Rakefile +2 -0
- data/dry-core.gemspec +3 -1
- data/lib/dry-core.rb +2 -0
- data/lib/dry/core.rb +2 -0
- data/lib/dry/core/cache.rb +2 -0
- data/lib/dry/core/class_attributes.rb +2 -0
- data/lib/dry/core/class_builder.rb +2 -0
- data/lib/dry/core/constants.rb +43 -5
- data/lib/dry/core/deprecations.rb +2 -0
- data/lib/dry/core/descendants_tracker.rb +2 -0
- data/lib/dry/core/errors.rb +2 -0
- data/lib/dry/core/extensions.rb +2 -0
- data/lib/dry/core/inflector.rb +2 -0
- data/lib/dry/core/memoizable.rb +2 -0
- data/lib/dry/core/version.rb +3 -1
- metadata +8 -9
- data/.rubocop.yml +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfe5b98793bc0e200a3a226a60d8c0f5234de170f033c9c3f06fc779979a1f63
|
4
|
+
data.tar.gz: de24e4b5d0bead8d577c3594bea81986ea7e7cf8124f17ce471f734d143d7319
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46141cc708525532152db4c692b8d5ac413ded55ee6484d672c6974a41a6487776ef2aeba3bb3abde5e22fcf4c4d8ac42900a391dcd7a38a5ff95fd4c5d9b717
|
7
|
+
data.tar.gz: 4871d4b68086c1521424d2510b47ab0448fbe344beed3bc7fd1ee1f9115306d3893b751f882a942f9321183724c8aecea1b7e69b81cb2fe7794dbec07d5222a6
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,15 @@
|
|
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
CHANGED
data/.travis.yml
CHANGED
@@ -5,22 +5,25 @@ cache: bundler
|
|
5
5
|
bundler_args: --without benchmarks tools
|
6
6
|
after_success:
|
7
7
|
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
8
|
-
script:
|
9
|
-
- bundle exec rake
|
10
8
|
before_install:
|
11
|
-
- gem
|
9
|
+
- gem install bundler
|
12
10
|
after_success:
|
13
11
|
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
14
12
|
rvm:
|
15
|
-
- 2.
|
16
|
-
- 2.
|
17
|
-
- 2.
|
18
|
-
-
|
19
|
-
- jruby-9.1.15.0
|
13
|
+
- 2.4.6
|
14
|
+
- 2.5.5
|
15
|
+
- 2.6.3
|
16
|
+
- truffleruby
|
20
17
|
env:
|
21
18
|
global:
|
22
19
|
- COVERAGE=true
|
23
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
|
24
27
|
notifications:
|
25
28
|
email: false
|
26
29
|
webhooks:
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,38 @@
|
|
1
|
+
# v0.4.9
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
- `Undefined.coalesce` takes a variable number of arguments and returns the first non-`Undefined` value (flash-gordon)
|
6
|
+
```ruby
|
7
|
+
Undefined.coalesce(Undefined, Undefined, :foo) # => :foo
|
8
|
+
```
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- `Undefined.{dup,clone}` returns `Undefined` back, `Undefined` is a singleton (flash-gordon)
|
13
|
+
|
14
|
+
[Compare v0.4.8...v0.4.9](https://github.com/dry-rb/dry-core/compare/v0.4.8...v0.4.9)
|
15
|
+
|
16
|
+
# v0.4.8 2019-06-23
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
- `Undefined.map` for mapping non-undefined values (flash-gordon):
|
21
|
+
|
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
|
+
|
29
|
+
[Compare v0.4.7...v0.4.8](https://github.com/dry-rb/dry-core/compare/v0.4.7...v0.4.8)
|
30
|
+
|
1
31
|
# v0.4.7 2018-06-25
|
2
32
|
|
3
33
|
### Fixed
|
4
34
|
|
5
|
-
|
35
|
+
- Fix default logger for deprecations, it now uses `$stderr` by default, as it should (flash-gordon)
|
6
36
|
|
7
37
|
[Compare v0.4.6...v0.4.7](https://github.com/dry-rb/dry-core/compare/v0.4.6...v0.4.7)
|
8
38
|
|
@@ -10,7 +40,7 @@
|
|
10
40
|
|
11
41
|
### Changed
|
12
42
|
|
13
|
-
|
43
|
+
- Trigger constant autoloading in the class builder (radar)
|
14
44
|
|
15
45
|
[Compare v0.4.5...v0.4.6](https://github.com/dry-rb/dry-core/compare/v0.4.5...v0.4.6)
|
16
46
|
|
@@ -18,7 +48,7 @@
|
|
18
48
|
|
19
49
|
### Added
|
20
50
|
|
21
|
-
|
51
|
+
- `Dry::Core::Memoizable`, which provides a `memoize` macro for memoizing results of instance methods (timriley)
|
22
52
|
|
23
53
|
[Compare v0.4.4...v0.4.5](https://github.com/dry-rb/dry-core/compare/v0.4.4...v0.4.5)
|
24
54
|
|
@@ -26,8 +56,8 @@
|
|
26
56
|
|
27
57
|
### Added
|
28
58
|
|
29
|
-
|
30
|
-
|
59
|
+
- `deprecate_constant` overrides `Module#deprecate_constant` and issues a labeled message on accessing a deprecated constant (flash-gordon)
|
60
|
+
- `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)
|
31
61
|
|
32
62
|
[Compare v0.4.3...v0.4.4](https://github.com/dry-rb/dry-core/compare/v0.4.3...v0.4.4)
|
33
63
|
|
@@ -35,7 +65,7 @@
|
|
35
65
|
|
36
66
|
### Added
|
37
67
|
|
38
|
-
|
68
|
+
- `Dry::Core::DescendantsTracker` which is a maintained version of the [`descendants_tracker`](https://github.com/dkubb/descendants_tracker) gem (flash-gordon)
|
39
69
|
|
40
70
|
[Compare v0.4.2...v0.4.3](https://github.com/dry-rb/dry-core/compare/v0.4.2...0.4.3)
|
41
71
|
|
@@ -43,7 +73,7 @@
|
|
43
73
|
|
44
74
|
### Fixed
|
45
75
|
|
46
|
-
|
76
|
+
- Class attributes now support private setters/getters (flash-gordon)
|
47
77
|
|
48
78
|
[Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-core/compare/v0.4.1...v0.4.2)
|
49
79
|
|
@@ -51,7 +81,7 @@
|
|
51
81
|
|
52
82
|
### Changed
|
53
83
|
|
54
|
-
|
84
|
+
- Improved error message on invalid attribute value (GustavoCaso)
|
55
85
|
|
56
86
|
[Compare v0.4.0...v0.4.1](https://github.com/dry-rb/dry-core/compare/v0.4.0...v0.4.1)
|
57
87
|
|
@@ -59,7 +89,7 @@
|
|
59
89
|
|
60
90
|
### Added
|
61
91
|
|
62
|
-
|
92
|
+
- 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)
|
63
93
|
|
64
94
|
```ruby
|
65
95
|
class Foo
|
@@ -76,7 +106,7 @@
|
|
76
106
|
|
77
107
|
### Fixed
|
78
108
|
|
79
|
-
|
109
|
+
- `Deprecations` output is set to `$stderr` by default now (solnic)
|
80
110
|
|
81
111
|
[Compare v0.3.3...v0.3.4](https://github.com/dry-rb/dry-core/compare/v0.3.3...v0.3.4)
|
82
112
|
|
@@ -84,7 +114,7 @@
|
|
84
114
|
|
85
115
|
### Fixed
|
86
116
|
|
87
|
-
|
117
|
+
- The Deprecations module now shows the right caller line (flash-gordon)
|
88
118
|
|
89
119
|
[Compare v0.3.2...v0.3.3](https://github.com/dry-rb/dry-core/compare/v0.3.2...v0.3.3)
|
90
120
|
|
@@ -92,7 +122,7 @@
|
|
92
122
|
|
93
123
|
### Added
|
94
124
|
|
95
|
-
|
125
|
+
- Accept an existing logger object in `Dry::Core::Deprecations.set_logger!` (flash-gordon)
|
96
126
|
|
97
127
|
[Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-core/compare/v0.3.1...v0.3.2)
|
98
128
|
|
@@ -100,7 +130,7 @@
|
|
100
130
|
|
101
131
|
### Added
|
102
132
|
|
103
|
-
|
133
|
+
- Support for building classes within an existing namespace (flash-gordon)
|
104
134
|
|
105
135
|
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-core/compare/v0.3.0...v0.3.1)
|
106
136
|
|
@@ -108,7 +138,7 @@
|
|
108
138
|
|
109
139
|
### Changed
|
110
140
|
|
111
|
-
|
141
|
+
- Class attributes are initialized _before_ running the `inherited` hook. It's slightly more convenient behavior and it's very unlikely anyone will be affected by this, but technically this is a breaking change (flash-gordon)
|
112
142
|
|
113
143
|
[Compare v0.2.4...v0.3.0](https://github.com/dry-rb/dry-core/compare/v0.2.4...v0.3.0)
|
114
144
|
|
@@ -116,7 +146,7 @@
|
|
116
146
|
|
117
147
|
### Fixed
|
118
148
|
|
119
|
-
|
149
|
+
- Do not require deprecated method to be defined (flash-gordon)
|
120
150
|
|
121
151
|
[Compare v0.2.3...v0.2.4](https://github.com/dry-rb/dry-core/compare/v0.2.3...v0.2.4)
|
122
152
|
|
@@ -124,7 +154,7 @@
|
|
124
154
|
|
125
155
|
### Fixed
|
126
156
|
|
127
|
-
|
157
|
+
- Fix warnings on using uninitialized class attributes (flash-gordon)
|
128
158
|
|
129
159
|
[Compare v0.2.2...v0.2.3](https://github.com/dry-rb/dry-core/compare/v0.2.2...v0.2.3)
|
130
160
|
|
@@ -132,7 +162,7 @@
|
|
132
162
|
|
133
163
|
### Added
|
134
164
|
|
135
|
-
|
165
|
+
- `ClassAttributes` which provides `defines` method for defining get-or-set methods (flash-gordon)
|
136
166
|
|
137
167
|
[Compare v0.2.1...v0.2.2](https://github.com/dry-rb/dry-core/compare/v0.2.1...v0.2.2)
|
138
168
|
|
@@ -140,7 +170,7 @@
|
|
140
170
|
|
141
171
|
### Added
|
142
172
|
|
143
|
-
|
173
|
+
- `Constants` are now available in nested scopes (flash-gordon)
|
144
174
|
|
145
175
|
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-core/compare/v0.2.0...v0.2.1)
|
146
176
|
|
data/Gemfile
CHANGED
@@ -11,12 +11,11 @@ group :test do
|
|
11
11
|
gem 'inflecto', '~> 0.0', '>= 0.0.2'
|
12
12
|
gem 'codeclimate-test-reporter', require: false
|
13
13
|
gem 'simplecov', require: false
|
14
|
-
gem 'dry-types'
|
15
|
-
gem 'dry-inflector'
|
14
|
+
gem 'dry-types', '~> 1.0'
|
15
|
+
gem 'dry-inflector'
|
16
16
|
end
|
17
17
|
|
18
18
|
group :tools do
|
19
19
|
gem 'pry-byebug', platform: :mri
|
20
20
|
gem 'pry', platform: :jruby
|
21
|
-
gem 'rubocop'
|
22
21
|
end
|
data/README.md
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
[travis]: https://travis-ci.org/dry-rb/dry-core
|
4
4
|
[code_climate]: https://codeclimate.com/github/dry-rb/dry-core
|
5
5
|
[inch]: http://inch-ci.org/github/dry-rb/dry-core
|
6
|
+
[chat]: https://dry-rb.zulipchat.com
|
6
7
|
|
7
|
-
# dry-core
|
8
|
+
# dry-core [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
|
8
9
|
|
9
10
|
[![Gem Version](https://img.shields.io/gem/v/dry-core.svg)][gem]
|
10
11
|
[![Build Status](https://img.shields.io/travis/dry-rb/dry-core.svg)][travis]
|
@@ -15,6 +16,20 @@
|
|
15
16
|
|
16
17
|
A collection of small modules used in the dry-rb ecosystem.
|
17
18
|
|
19
|
+
## Links
|
20
|
+
|
21
|
+
* [User docs](https://dry-rb.org/gems/dry-core)
|
22
|
+
* [API docs](http://rubydoc.info/gems/dry-core)
|
23
|
+
|
24
|
+
## Supported Ruby versions
|
25
|
+
|
26
|
+
This library officially supports following Ruby versions:
|
27
|
+
|
28
|
+
* MRI >= `2.4`
|
29
|
+
* jruby >= `9.2`
|
30
|
+
|
31
|
+
It **should** work on MRI `2.3.x` too, but there's no official support for this version.
|
32
|
+
|
18
33
|
## Installation
|
19
34
|
|
20
35
|
Add this line to your application's Gemfile:
|
data/Rakefile
CHANGED
data/dry-core.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('../lib', __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'dry/core/version'
|
@@ -28,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
28
30
|
spec.required_ruby_version = '>= 2.1.0'
|
29
31
|
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
|
30
32
|
|
31
|
-
spec.add_development_dependency 'bundler'
|
33
|
+
spec.add_development_dependency 'bundler'
|
32
34
|
spec.add_development_dependency 'rake', '~> 10.0'
|
33
35
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
36
|
end
|
data/lib/dry-core.rb
CHANGED
data/lib/dry/core.rb
CHANGED
data/lib/dry/core/cache.rb
CHANGED
data/lib/dry/core/constants.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'set'
|
2
4
|
|
3
5
|
module Dry
|
@@ -6,6 +8,7 @@ module Dry
|
|
6
8
|
#
|
7
9
|
# @example Just include this module to your class or module
|
8
10
|
# class Foo
|
11
|
+
# include Dry::Core::Constants
|
9
12
|
# def call(value = EMPTY_ARRAY)
|
10
13
|
# value.map(&:to_s)
|
11
14
|
# end
|
@@ -36,10 +39,15 @@ module Dry
|
|
36
39
|
# end
|
37
40
|
# end
|
38
41
|
Undefined = Object.new.tap do |undefined|
|
42
|
+
# @api private
|
43
|
+
Self = -> { Undefined }
|
44
|
+
|
45
|
+
# @api public
|
39
46
|
def undefined.to_s
|
40
47
|
'Undefined'
|
41
48
|
end
|
42
49
|
|
50
|
+
# @api public
|
43
51
|
def undefined.inspect
|
44
52
|
'Undefined'
|
45
53
|
end
|
@@ -48,13 +56,13 @@ module Dry
|
|
48
56
|
# otherwise return the second arg or yield the block.
|
49
57
|
#
|
50
58
|
# @example
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
59
|
+
# def method(val = Undefined)
|
60
|
+
# 1 + Undefined.default(val, 2)
|
61
|
+
# end
|
54
62
|
#
|
55
63
|
def undefined.default(x, y = self)
|
56
|
-
if
|
57
|
-
if
|
64
|
+
if equal?(x)
|
65
|
+
if equal?(y)
|
58
66
|
yield
|
59
67
|
else
|
60
68
|
y
|
@@ -63,6 +71,36 @@ module Dry
|
|
63
71
|
x
|
64
72
|
end
|
65
73
|
end
|
74
|
+
|
75
|
+
# Map a non-undefined value
|
76
|
+
#
|
77
|
+
# @example
|
78
|
+
# def add_five(val = Undefined)
|
79
|
+
# Undefined.map(val) { |x| x + 5 }
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
def undefined.map(value)
|
83
|
+
if equal?(value)
|
84
|
+
self
|
85
|
+
else
|
86
|
+
yield(value)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# @api public
|
91
|
+
def undefined.dup
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
# @api public
|
96
|
+
def undefined.clone
|
97
|
+
self
|
98
|
+
end
|
99
|
+
|
100
|
+
# @api public
|
101
|
+
def undefined.coalesce(*args)
|
102
|
+
args.find(Self) { |x| !equal?(x) }
|
103
|
+
end
|
66
104
|
end.freeze
|
67
105
|
|
68
106
|
def self.included(base)
|
data/lib/dry/core/errors.rb
CHANGED
data/lib/dry/core/extensions.rb
CHANGED
data/lib/dry/core/inflector.rb
CHANGED
data/lib/dry/core/memoizable.rb
CHANGED
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Shilnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,10 +73,10 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".codeclimate.yml"
|
76
77
|
- ".gitignore"
|
77
78
|
- ".inch.yml"
|
78
79
|
- ".rspec"
|
79
|
-
- ".rubocop.yml"
|
80
80
|
- ".travis.yml"
|
81
81
|
- CHANGELOG.md
|
82
82
|
- CONTRIBUTING.md
|
@@ -118,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.7.6
|
121
|
+
rubygems_version: 3.0.3
|
123
122
|
signing_key:
|
124
123
|
specification_version: 4
|
125
124
|
summary: A toolset of small support modules used throughout the dry-rb ecosystem.
|
data/.rubocop.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.1
|
3
|
-
Exclude:
|
4
|
-
- 'dry-core.gemspec'
|
5
|
-
- 'spec/spec_helper.rb'
|
6
|
-
|
7
|
-
Style/SignalException:
|
8
|
-
Exclude:
|
9
|
-
- 'spec/**/*'
|
10
|
-
|
11
|
-
Style/RedundantSelf:
|
12
|
-
Exclude:
|
13
|
-
- 'lib/dry/core/deprecations.rb'
|
14
|
-
|
15
|
-
Metrics/LineLength:
|
16
|
-
Max: 110
|
17
|
-
|
18
|
-
Metrics/MethodLength:
|
19
|
-
Enabled: false
|
20
|
-
|
21
|
-
Style/FileName:
|
22
|
-
Exclude:
|
23
|
-
- 'lib/dry-core.rb'
|
24
|
-
|
25
|
-
Lint/AmbiguousRegexpLiteral:
|
26
|
-
Exclude:
|
27
|
-
- 'spec/**/*'
|
28
|
-
|
29
|
-
Style/BlockDelimiters:
|
30
|
-
Exclude:
|
31
|
-
- 'spec/**/*'
|