kind 5.9.0 → 5.10.0

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: 195bae736a96e62b9320b209bc7845d6e8c39714342ccb34dfe5bf1ea7c169d8
4
- data.tar.gz: 2cbf9ba591a62456ff1faf3f8e8e8b1052b9f2c61d96a9a8df62b7ba595a5ac4
3
+ metadata.gz: db0a2008eeb0137d93f74239fc4731ee7cc217a5714a30b9e57305e0d2a5b10a
4
+ data.tar.gz: 3b5efef522cc08fdd856ea4a9e3197eaef10c887a335479cac3a70cc67012ec6
5
5
  SHA512:
6
- metadata.gz: 37e37d949dda2c0bbe11642742473200ff42d4300d63642819532fd32beec8485c953588ad100b2c771ec0e8528281d5535180aa21ceb1e53dfe45f992ad7141
7
- data.tar.gz: 93e92d5db75442cb9c637924d731eec70f7324d50f9c2da91100b1bc916ef8a8ab8c7ea1bbf7590107141a1fc9e81181f51bc5c2848500f0ed7bc940adbaa36f
6
+ metadata.gz: 2ded2725b6df3fee68cb30df6aa3172d2b16493f7071314a8be8dc0345dd450461ba899defad6af62073569e83348108f6ac6bbd7699ddc3c47c9e4ea9107069
7
+ data.tar.gz: d724177aa2643868ef4ff5700c51d228209aa1f40ca756a3670f8ddb5f769af61a8a14f7433a04a9d7f9451deda73b60b91739c0e7a153a03d4eabde20ba24b3
data/CHANGELOG.md CHANGED
@@ -3,91 +3,93 @@
3
3
  This project follows [semver 2.0.0](http://semver.org/spec/v2.0.0.html) and the recommendations of [keepachangelog.com](http://keepachangelog.com/).
4
4
 
5
5
  - [Unreleased](#unreleased)
6
- - [5.9.0 (2021-09-22)](#590-2021-09-22)
6
+ - [5.10.0 (2021-09-23)](#5100-2021-09-23)
7
7
  - [Added](#added)
8
+ - [5.9.0 (2021-09-22)](#590-2021-09-22)
9
+ - [Added](#added-1)
8
10
  - [5.8.1 (2021-09-22)](#581-2021-09-22)
9
11
  - [Fixed](#fixed)
10
12
  - [5.8.0 (2021-09-22)](#580-2021-09-22)
11
- - [Added](#added-1)
12
- - [5.7.0 (2021-06-22)](#570-2021-06-22)
13
13
  - [Added](#added-2)
14
- - [5.6.0 (2021-05-14)](#560-2021-05-14)
14
+ - [5.7.0 (2021-06-22)](#570-2021-06-22)
15
15
  - [Added](#added-3)
16
- - [5.5.0 (2021-04-05)](#550-2021-04-05)
16
+ - [5.6.0 (2021-05-14)](#560-2021-05-14)
17
17
  - [Added](#added-4)
18
+ - [5.5.0 (2021-04-05)](#550-2021-04-05)
19
+ - [Added](#added-5)
18
20
  - [5.4.1 (2021-03-26)](#541-2021-03-26)
19
21
  - [Fixed](#fixed-1)
20
22
  - [5.4.0 (2021-03-25)](#540-2021-03-25)
21
- - [Added](#added-5)
22
- - [5.3.0 (2021-03-23)](#530-2021-03-23)
23
23
  - [Added](#added-6)
24
- - [5.2.0 (2021-03-17)](#520-2021-03-17)
24
+ - [5.3.0 (2021-03-23)](#530-2021-03-23)
25
25
  - [Added](#added-7)
26
+ - [5.2.0 (2021-03-17)](#520-2021-03-17)
27
+ - [Added](#added-8)
26
28
  - [Deprecated](#deprecated)
27
29
  - [Changes](#changes)
28
30
  - [5.1.0 (2021-02-23)](#510-2021-02-23)
29
- - [Added](#added-8)
31
+ - [Added](#added-9)
30
32
  - [Deprecated](#deprecated-1)
31
33
  - [5.0.0 (2021-02-22)](#500-2021-02-22)
32
34
  - [Breaking Changes](#breaking-changes)
33
35
  - [Removed](#removed)
34
36
  - [4.1.0 (2021-02-22)](#410-2021-02-22)
35
- - [Added](#added-9)
36
- - [4.0.0 (2021-02-22)](#400-2021-02-22)
37
37
  - [Added](#added-10)
38
+ - [4.0.0 (2021-02-22)](#400-2021-02-22)
39
+ - [Added](#added-11)
38
40
  - [Deprecated](#deprecated-2)
39
41
  - [Fixed](#fixed-2)
40
42
  - [3.1.0 (2020-07-08)](#310-2020-07-08)
41
- - [Added](#added-11)
43
+ - [Added](#added-12)
42
44
  - [3.0.0 (2020-06-25)](#300-2020-06-25)
43
45
  - [Breaking Changes](#breaking-changes-1)
44
- - [Added](#added-12)
45
- - [2.3.0 (2020-06-24)](#230-2020-06-24)
46
46
  - [Added](#added-13)
47
- - [2.2.0 (2020-06-23)](#220-2020-06-23)
47
+ - [2.3.0 (2020-06-24)](#230-2020-06-24)
48
48
  - [Added](#added-14)
49
- - [2.1.0 (2020-05-12)](#210-2020-05-12)
49
+ - [2.2.0 (2020-06-23)](#220-2020-06-23)
50
50
  - [Added](#added-15)
51
+ - [2.1.0 (2020-05-12)](#210-2020-05-12)
52
+ - [Added](#added-16)
51
53
  - [Breaking Changes](#breaking-changes-2)
52
54
  - [2.0.0 (2020-05-07)](#200-2020-05-07)
53
- - [Added](#added-16)
55
+ - [Added](#added-17)
54
56
  - [Breaking Changes](#breaking-changes-3)
55
57
  - [Removed](#removed-1)
56
58
  - [1.9.0 (2020-05-06)](#190-2020-05-06)
57
- - [Added](#added-17)
58
- - [1.8.0 (2020-05-03)](#180-2020-05-03)
59
59
  - [Added](#added-18)
60
+ - [1.8.0 (2020-05-03)](#180-2020-05-03)
61
+ - [Added](#added-19)
60
62
  - [1.7.0 (2020-05-03)](#170-2020-05-03)
61
63
  - [Fixed](#fixed-3)
62
64
  - [1.6.0 (2020-04-17)](#160-2020-04-17)
63
- - [Added](#added-19)
65
+ - [Added](#added-20)
64
66
  - [Changes](#changes-1)
65
67
  - [1.5.0 (2020-04-12)](#150-2020-04-12)
66
- - [Added](#added-20)
67
- - [1.4.0 (2020-04-12)](#140-2020-04-12)
68
68
  - [Added](#added-21)
69
- - [1.3.0 (2020-04-12)](#130-2020-04-12)
69
+ - [1.4.0 (2020-04-12)](#140-2020-04-12)
70
70
  - [Added](#added-22)
71
- - [1.2.0 (2020-04-12)](#120-2020-04-12)
71
+ - [1.3.0 (2020-04-12)](#130-2020-04-12)
72
72
  - [Added](#added-23)
73
- - [1.1.0 (2020-04-09)](#110-2020-04-09)
73
+ - [1.2.0 (2020-04-12)](#120-2020-04-12)
74
74
  - [Added](#added-24)
75
+ - [1.1.0 (2020-04-09)](#110-2020-04-09)
76
+ - [Added](#added-25)
75
77
  - [Fixed](#fixed-4)
76
78
  - [1.0.0 (2020-03-16)](#100-2020-03-16)
77
- - [Added](#added-25)
78
- - [0.6.0 (2020-01-06)](#060-2020-01-06)
79
79
  - [Added](#added-26)
80
- - [0.5.0 (2020-01-04)](#050-2020-01-04)
80
+ - [0.6.0 (2020-01-06)](#060-2020-01-06)
81
81
  - [Added](#added-27)
82
- - [0.4.0 (2020-01-03)](#040-2020-01-03)
82
+ - [0.5.0 (2020-01-04)](#050-2020-01-04)
83
83
  - [Added](#added-28)
84
- - [0.3.0 (2020-01-03)](#030-2020-01-03)
84
+ - [0.4.0 (2020-01-03)](#040-2020-01-03)
85
85
  - [Added](#added-29)
86
+ - [0.3.0 (2020-01-03)](#030-2020-01-03)
87
+ - [Added](#added-30)
86
88
  - [Breaking Changes](#breaking-changes-4)
87
89
  - [0.2.0 (2020-01-02)](#020-2020-01-02)
88
- - [Added](#added-30)
89
- - [0.1.0 (2019-12-26)](#010-2019-12-26)
90
90
  - [Added](#added-31)
91
+ - [0.1.0 (2019-12-26)](#010-2019-12-26)
92
+ - [Added](#added-32)
91
93
 
92
94
  ## Unreleased
93
95
 
@@ -99,6 +101,22 @@ This project follows [semver 2.0.0](http://semver.org/spec/v2.0.0.html) and the
99
101
  ### Fixed
100
102
  -->
101
103
 
104
+ 5.10.0 (2021-09-23)
105
+ ------------------
106
+
107
+ ### Added
108
+
109
+ * [#69](https://github.com/serradura/kind/pull/69) - Make `Kind::Any` works with a `Set`.
110
+ ```ruby
111
+ require 'kind/any'
112
+
113
+ Kind::Any.new(Set[:low, :high]).inspect # Kind::Any{:low, :high}
114
+
115
+ Kind::Any.new(Array['open', 'close']).inspect # Kind::Any["open", "close"]
116
+ ```
117
+
118
+ [⬆️  Back to Top](#changelog-)
119
+
102
120
  5.9.0 (2021-09-22)
103
121
  ------------------
104
122
 
@@ -219,7 +237,7 @@ Kind.assert_hash!({level: :medium}, schema: {level: Level})
219
237
  Level.values # [:low, :high]
220
238
  ```
221
239
 
222
- * [#66](https://github.com/serradura/kind/pull/66) - Make `Kind.assert_hash!(hash, schema:)` works with a `Kind::Object`.
240
+ * [#66](https://github.com/serradura/kind/pull/66) - Add `Kind::Enum.from_array(arg, use_index_as_value:)` to allow the creation of enums where its values will be the array values.
223
241
  ```ruby
224
242
  require 'kind/enum'
225
243
 
data/README.md CHANGED
@@ -42,7 +42,7 @@ So, I invite you to check out these features to see how they could be useful for
42
42
  Version | Documentation
43
43
  ---------- | -------------
44
44
  unreleased | https://github.com/serradura/kind/blob/main/README.md
45
- 5.9.0 | https://github.com/serradura/kind/blob/v5.x/README.md
45
+ 5.10.0 | https://github.com/serradura/kind/blob/v5.x/README.md
46
46
  4.1.0 | https://github.com/serradura/kind/blob/v4.x/README.md
47
47
  3.1.0 | https://github.com/serradura/kind/blob/v3.x/README.md
48
48
  2.3.0 | https://github.com/serradura/kind/blob/v2.x/README.md
@@ -69,7 +69,7 @@ unreleased | https://github.com/serradura/kind/blob/main/README.md
69
69
  - [Creating type handlers](#creating-type-handlers)
70
70
  - [Dynamic creation](#dynamic-creation)
71
71
  - [Using a class or a module](#using-a-class-or-a-module)
72
- - [Using Kind.object(name:, &block) ===](#using-kindobjectname-block-)
72
+ - [Using Kind.object(name:, &block)](#using-kindobjectname-block)
73
73
  - [Kind::<Type> object](#kindtype-object)
74
74
  - [Utility methods](#utility-methods)
75
75
  - [Kind.of_class?()](#kindof_class)
@@ -125,7 +125,7 @@ unreleased | https://github.com/serradura/kind/blob/main/README.md
125
125
  | kind | branch | ruby | activemodel |
126
126
  | -------------- | ------- | ------------------ | -------------- |
127
127
  | unreleased | main | >= 2.1.0, <= 3.0.0 | >= 3.2, < 7.0 |
128
- | 5.9.0 | v5.x | >= 2.1.0, <= 3.0.0 | >= 3.2, < 7.0 |
128
+ | 5.10.0 | v5.x | >= 2.1.0, <= 3.0.0 | >= 3.2, < 7.0 |
129
129
  | 4.1.0 | v4.x | >= 2.2.0, <= 3.0.0 | >= 3.2, < 7.0 |
130
130
  | 3.1.0 | v3.x | >= 2.2.0, <= 2.7 | >= 3.2, < 7.0 |
131
131
  | 2.3.0 | v2.x | >= 2.2.0, <= 2.7 | >= 3.2, <= 6.0 |
@@ -455,7 +455,7 @@ kind_of_user.maybe('1').value_or(User.new) # #<User:0x0000...>
455
455
 
456
456
  [⬆️ &nbsp;Back to Top](#table-of-contents-)
457
457
 
458
- ##### Using Kind.object(name:, &block) ===
458
+ ##### Using Kind.object(name:, &block)
459
459
 
460
460
  ```ruby
461
461
  PositiveInteger = Kind.object(name: 'PositiveInteger') do |value|
data/lib/kind/any.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Kind
4
4
  class Any
5
- FilledArray = ->(value) {value.is_a?(::Array) && !value.empty?}
5
+ FilledList = ->(val) {(val.is_a?(::Array) || val.is_a?(::Set)) && !val.empty?}
6
6
 
7
7
  singleton_class.send(:alias_method, :[], :new)
8
8
 
@@ -11,11 +11,11 @@ module Kind
11
11
  def initialize(*args)
12
12
  array = args.size == 1 ? args[0] : args
13
13
 
14
- @values = Kind.of(FilledArray, array, expected: 'filled array')
14
+ @values = Kind.of(FilledList, array, expected: 'filled array or set')
15
15
  end
16
16
 
17
- def ===(other)
18
- @values.any? { |value| value == other }
17
+ def ===(value)
18
+ @values.include?(value)
19
19
  end
20
20
 
21
21
  def [](value, label: nil)
@@ -27,11 +27,18 @@ module Kind
27
27
  end
28
28
 
29
29
  def name
30
- "Kind::Any#{@values}"
30
+ str = @values.inspect
31
+
32
+ if @values.is_a?(::Set)
33
+ str.sub!(/\A#<Set: /, '')
34
+ str.chomp!('>')
35
+ end
36
+
37
+ "Kind::Any#{str}"
31
38
  end
32
39
 
33
40
  alias inspect name
34
41
 
35
- private_constant :FilledArray
42
+ private_constant :FilledList
36
43
  end
37
44
  end
data/lib/kind/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kind
4
- VERSION = '5.9.0'
4
+ VERSION = '5.10.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kind
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.9.0
4
+ version: 5.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-22 00:00:00.000000000 Z
11
+ date: 2021-09-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A development toolkit for Ruby with several small/cohesive abstractions
14
14
  (monads, enums, business logic, data validation...) to empower your development