kind 5.3.0 → 5.4.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: b826449cc89c4cd8dc3d58694a37914f7de37cb7000a2ba534ffa914f10f7677
4
- data.tar.gz: e2ed88bcf83d332de58a8516533a58f858494e7ac2ea60f58517e08cd11066c9
3
+ metadata.gz: e9a47a1176ad4b10eaad08e63af26b3067fd6d058c16e592b34f01c0f540bcbb
4
+ data.tar.gz: ef1859a67157e0e515213cf2e544d959df292eba3bb7371595de4df76d035379
5
5
  SHA512:
6
- metadata.gz: ac5f74a2ba85be82a6b9709745069047105ccdf8aacadbabdb7e96f66ff007dd0e7ce8e2001df206614c3bf852cb95f3c9d21d2f203490a39070a92bb2250afd
7
- data.tar.gz: 14b4f8b747a25b9c9535f40972dcfbc07116f97051090616053c663dbfe71cc5b8771bc5899da4e51a77168acb18a18a8c0b898a37c6730397d5c3a4afdc340b
6
+ metadata.gz: 3004e273ebd8aaa9807cbfe87e728d13f5a01792ab1206480618ff49bf1405938b8e62d5da10a3dbbcd81b49382eb0b684f55dd3e00f27ee7de97200c9496984
7
+ data.tar.gz: b42bc24083b5edb01409449f0222a525ba0106fca3afed8f43b2a21c10f597b9be6d8fcf8e4e0e4f5a73b706e8439affae3c14ef330258e4ef5adb630c1a9863
data/CHANGELOG.md CHANGED
@@ -3,75 +3,77 @@
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.3.0 (2021-03-23)](#530-2021-03-23)
6
+ - [5.4.0 (2021-03-25)](#540-2021-03-25)
7
7
  - [Added](#added)
8
- - [5.2.0 (2021-03-17)](#520-2021-03-17)
8
+ - [5.3.0 (2021-03-23)](#530-2021-03-23)
9
9
  - [Added](#added-1)
10
+ - [5.2.0 (2021-03-17)](#520-2021-03-17)
11
+ - [Added](#added-2)
10
12
  - [Deprecated](#deprecated)
11
13
  - [Changes](#changes)
12
14
  - [5.1.0 (2021-02-23)](#510-2021-02-23)
13
- - [Added](#added-2)
15
+ - [Added](#added-3)
14
16
  - [Deprecated](#deprecated-1)
15
17
  - [5.0.0 (2021-02-22)](#500-2021-02-22)
16
18
  - [Breaking Changes](#breaking-changes)
17
19
  - [Removed](#removed)
18
20
  - [4.1.0 (2021-02-22)](#410-2021-02-22)
19
- - [Added](#added-3)
20
- - [4.0.0 (2021-02-22)](#400-2021-02-22)
21
21
  - [Added](#added-4)
22
+ - [4.0.0 (2021-02-22)](#400-2021-02-22)
23
+ - [Added](#added-5)
22
24
  - [Deprecated](#deprecated-2)
23
25
  - [Fixed](#fixed)
24
26
  - [3.1.0 (2020-07-08)](#310-2020-07-08)
25
- - [Added](#added-5)
27
+ - [Added](#added-6)
26
28
  - [3.0.0 (2020-06-25)](#300-2020-06-25)
27
29
  - [Breaking Changes](#breaking-changes-1)
28
- - [Added](#added-6)
29
- - [2.3.0 (2020-06-24)](#230-2020-06-24)
30
30
  - [Added](#added-7)
31
- - [2.2.0 (2020-06-23)](#220-2020-06-23)
31
+ - [2.3.0 (2020-06-24)](#230-2020-06-24)
32
32
  - [Added](#added-8)
33
- - [2.1.0 (2020-05-12)](#210-2020-05-12)
33
+ - [2.2.0 (2020-06-23)](#220-2020-06-23)
34
34
  - [Added](#added-9)
35
+ - [2.1.0 (2020-05-12)](#210-2020-05-12)
36
+ - [Added](#added-10)
35
37
  - [Breaking Changes](#breaking-changes-2)
36
38
  - [2.0.0 (2020-05-07)](#200-2020-05-07)
37
- - [Added](#added-10)
39
+ - [Added](#added-11)
38
40
  - [Breaking Changes](#breaking-changes-3)
39
41
  - [Removed](#removed-1)
40
42
  - [1.9.0 (2020-05-06)](#190-2020-05-06)
41
- - [Added](#added-11)
42
- - [1.8.0 (2020-05-03)](#180-2020-05-03)
43
43
  - [Added](#added-12)
44
+ - [1.8.0 (2020-05-03)](#180-2020-05-03)
45
+ - [Added](#added-13)
44
46
  - [1.7.0 (2020-05-03)](#170-2020-05-03)
45
47
  - [Fixed](#fixed-1)
46
48
  - [1.6.0 (2020-04-17)](#160-2020-04-17)
47
- - [Added](#added-13)
49
+ - [Added](#added-14)
48
50
  - [Changes](#changes-1)
49
51
  - [1.5.0 (2020-04-12)](#150-2020-04-12)
50
- - [Added](#added-14)
51
- - [1.4.0 (2020-04-12)](#140-2020-04-12)
52
52
  - [Added](#added-15)
53
- - [1.3.0 (2020-04-12)](#130-2020-04-12)
53
+ - [1.4.0 (2020-04-12)](#140-2020-04-12)
54
54
  - [Added](#added-16)
55
- - [1.2.0 (2020-04-12)](#120-2020-04-12)
55
+ - [1.3.0 (2020-04-12)](#130-2020-04-12)
56
56
  - [Added](#added-17)
57
- - [1.1.0 (2020-04-09)](#110-2020-04-09)
57
+ - [1.2.0 (2020-04-12)](#120-2020-04-12)
58
58
  - [Added](#added-18)
59
+ - [1.1.0 (2020-04-09)](#110-2020-04-09)
60
+ - [Added](#added-19)
59
61
  - [Fixed](#fixed-2)
60
62
  - [1.0.0 (2020-03-16)](#100-2020-03-16)
61
- - [Added](#added-19)
62
- - [0.6.0 (2020-01-06)](#060-2020-01-06)
63
63
  - [Added](#added-20)
64
- - [0.5.0 (2020-01-04)](#050-2020-01-04)
64
+ - [0.6.0 (2020-01-06)](#060-2020-01-06)
65
65
  - [Added](#added-21)
66
- - [0.4.0 (2020-01-03)](#040-2020-01-03)
66
+ - [0.5.0 (2020-01-04)](#050-2020-01-04)
67
67
  - [Added](#added-22)
68
- - [0.3.0 (2020-01-03)](#030-2020-01-03)
68
+ - [0.4.0 (2020-01-03)](#040-2020-01-03)
69
69
  - [Added](#added-23)
70
+ - [0.3.0 (2020-01-03)](#030-2020-01-03)
71
+ - [Added](#added-24)
70
72
  - [Breaking Changes](#breaking-changes-4)
71
73
  - [0.2.0 (2020-01-02)](#020-2020-01-02)
72
- - [Added](#added-24)
73
- - [0.1.0 (2019-12-26)](#010-2019-12-26)
74
74
  - [Added](#added-25)
75
+ - [0.1.0 (2019-12-26)](#010-2019-12-26)
76
+ - [Added](#added-26)
75
77
 
76
78
  ## Unreleased
77
79
 
@@ -83,6 +85,74 @@ This project follows [semver 2.0.0](http://semver.org/spec/v2.0.0.html) and the
83
85
  ### Fixed
84
86
  -->
85
87
 
88
+ 5.4.0 (2021-03-25)
89
+ ------------------
90
+
91
+ * [#54](https://github.com/serradura/kind/pull/54) - Add `Kind::Functional::Steps` to allow the usage of `Step`, `Map`, `Try`, `Tee`, `Check`, `Success` and `Failure` in any kind of object.
92
+ ```ruby
93
+ # Usage in classes' instances
94
+
95
+ class BaseJob
96
+ def self.perform_now(input); new.perform(input); end
97
+
98
+ def perform(input); raise NotImplementedError; end
99
+ end
100
+
101
+ class CreateUserJob < BaseJob
102
+ include Kind::Functional::Steps
103
+
104
+ def perform(input)
105
+ validate(input) \
106
+ >> Step(:create) \
107
+ >> Step(:welcome_email)
108
+ end
109
+
110
+ private
111
+
112
+ def validate(input)
113
+ # Success() or Failure()
114
+ end
115
+
116
+ def create(input)
117
+ # Success() or Failure()
118
+ end
119
+
120
+ def welcome_email(email)
121
+ # Success() or Failure()
122
+ end
123
+ end
124
+
125
+ # Usage in modules (singleton methods)
126
+
127
+ module CreateUser
128
+ extend self, Kind::Functional::Steps
129
+
130
+ def perform(input)
131
+ Step!(:validate, input) \
132
+ >> Step(:create) \
133
+ >> Step(:welcome_email)
134
+ end
135
+
136
+ private
137
+
138
+ def validate(input)
139
+ # Success() or Failure()
140
+ end
141
+
142
+ def create(input)
143
+ # Success() or Failure()
144
+ end
145
+
146
+ def welcome_email(email)
147
+ # Success() or Failure()
148
+ end
149
+ end
150
+ ```
151
+
152
+ [⬆️ &nbsp;Back to Top](#changelog-)
153
+
154
+ ### Added
155
+
86
156
  5.3.0 (2021-03-23)
87
157
  ------------------
88
158
 
@@ -122,6 +192,8 @@ This project follows [semver 2.0.0](http://semver.org/spec/v2.0.0.html) and the
122
192
  * `Kind::<Type>[1]`
123
193
  * `Kind::NotNil[1]`
124
194
 
195
+ [⬆️ &nbsp;Back to Top](#changelog-)
196
+
125
197
  5.2.0 (2021-03-17)
126
198
  ------------------
127
199
 
@@ -295,6 +367,8 @@ This project follows [semver 2.0.0](http://semver.org/spec/v2.0.0.html) and the
295
367
  p number # 0
296
368
  ```
297
369
 
370
+ [⬆️ &nbsp;Back to Top](#changelog-)
371
+
298
372
  * [#46](https://github.com/serradura/kind/pull/46) - Add `Kind::Either` (either monad). This is basically the same as the `Maybe` monad, but with `Some` called `Right` and `None` called `Left`. But this time, `Left` is also allowed to have an underlying value. This module isn't loaded by default, so you will need to require it.
299
373
  ```ruby
300
374
  require 'kind/either'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
2
  <h1 align="center">🤷 kind</h1>
3
- <p align="center"><i>A simple type system (at runtime) for Ruby - free of dependencies.</i></p>
3
+ <p align="center"><i>A development toolkit for Ruby with several small/cohesive abstractions to empower your development workflow - It's totally free of dependencies.</i></p>
4
4
  </p>
5
5
 
6
6
  <p align="center">
@@ -31,16 +31,18 @@
31
31
 
32
32
  **Motivation:**
33
33
 
34
- As a creator of Ruby gems, I have a common need that I have to handle in many of my projects: type checking of method arguments.
34
+ This project was born to help me with a simple task, create a light and fast type checker (at runtime) for Ruby. The initial idea was to have something to raise an exception when a method or function (procs) received a wrong input.
35
35
 
36
- One of the goals of this project is to do simple type checking like `"some string".is_a?(String)`, but, exposing useful abstractions around this. e.g: [Kind.\<Type\> methods](#verifying-the-kind-of-some-object), [active model validations](#kindvalidator-activemodelvalidations), [maybe monad](#kindmaybe).
36
+ But through time it was natural the addition of more features to improve the development workflow, like monads ([`Kind::Maybe`](#kindmaybe), `Kind::Either` / `Kind::Result`), enums (`Kind::Enum`), immutable objects (`Kind::ImmutableAttributes`), [type validation via ActiveModel::Validation](#kindvalidator-activemodelvalidations), and several abstractions to help the implementation of business logic (`Kind::Functional::Steps`, `Kind::Functional::Action`, `Kind::Action`).
37
+
38
+ So, I invite you to check out these features to see how they could be useful for you. Enjoy!
37
39
 
38
40
  ## Documentation <!-- omit in toc -->
39
41
 
40
42
  Version | Documentation
41
43
  ---------- | -------------
42
44
  unreleased | https://github.com/serradura/kind/blob/main/README.md
43
- 5.3.0 | https://github.com/serradura/kind/blob/v5.x/README.md
45
+ 5.4.0 | https://github.com/serradura/kind/blob/v5.x/README.md
44
46
  4.1.0 | https://github.com/serradura/kind/blob/v4.x/README.md
45
47
  3.1.0 | https://github.com/serradura/kind/blob/v3.x/README.md
46
48
  2.3.0 | https://github.com/serradura/kind/blob/v2.x/README.md
@@ -120,14 +122,14 @@ unreleased | https://github.com/serradura/kind/blob/main/README.md
120
122
 
121
123
  ## Compatibility
122
124
 
123
- | kind | branch | ruby | activemodel |
124
- | -------------- | ------- | -------- | -------------- |
125
- | unreleased | main | >= 2.1.0 | >= 3.2, <= 6.1 |
126
- | 5.3.0 | v5.x | >= 2.1.0 | >= 3.2, <= 6.1 |
127
- | 4.1.0 | v4.x | >= 2.2.0 | >= 3.2, <= 6.1 |
128
- | 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, <= 6.1 |
129
- | 2.3.0 | v2.x | >= 2.2.0 | >= 3.2, <= 6.0 |
130
- | 1.9.0 | v1.x | >= 2.2.0 | >= 3.2, <= 6.0 |
125
+ | kind | branch | ruby | activemodel |
126
+ | -------------- | ------- | ------------------ | -------------- |
127
+ | unreleased | main | >= 2.1.0, <= 3.0.0 | >= 3.2, < 7.0 |
128
+ | 5.4.0 | v5.x | >= 2.1.0, <= 3.0.0 | >= 3.2, < 7.0 |
129
+ | 4.1.0 | v4.x | >= 2.2.0, <= 3.0.0 | >= 3.2, < 7.0 |
130
+ | 3.1.0 | v3.x | >= 2.2.0, <= 2.7 | >= 3.2, < 7.0 |
131
+ | 2.3.0 | v2.x | >= 2.2.0, <= 2.7 | >= 3.2, <= 6.0 |
132
+ | 1.9.0 | v1.x | >= 2.2.0, <= 2.7 | >= 3.2, <= 6.0 |
131
133
 
132
134
  > Note: The activemodel is an optional dependency, it is related with the [Kind::Validator](#kindvalidator-activemodelvalidations).
133
135
 
data/kind.gemspec CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
6
6
  spec.authors = ['Rodrigo Serradura']
7
7
  spec.email = ['rodrigo.serradura@gmail.com']
8
8
 
9
- spec.summary = %q{A simple type system (at runtime) for Ruby.}
10
- spec.description = %q{A simple type system (at runtime) for Ruby - free of dependencies.}
9
+ spec.summary = %q{A development toolkit for Ruby with several small/cohesive abstractions to empower your development workflow.}
10
+ spec.description = %q{A development toolkit for Ruby with several small/cohesive abstractions (monads, enums, business logic, data validation...) to empower your development workflow - It's totally free of dependencies.}
11
11
  spec.homepage = 'https://github.com/serradura/kind'
12
12
  spec.license = 'MIT'
13
13
  spec.required_ruby_version = Gem::Requirement.new('>= 2.1.0')
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'kind/result'
4
3
  require 'kind/functional'
5
- require 'kind/__lib__/action_steps'
4
+ require 'kind/functional/steps'
6
5
 
7
6
  module Kind
8
7
  module Functional::Action
@@ -58,11 +57,9 @@ module Kind
58
57
  )
59
58
 
60
59
  if Kind.of_module?(self)
61
- self.send(:extend, Result::Methods)
62
- self.send(:extend, ACTION_STEPS)
60
+ self.send(:extend, Functional::Steps)
63
61
  else
64
- self.send(:include, Result::Methods)
65
- self.send(:include, ACTION_STEPS)
62
+ self.send(:include, Functional::Steps)
66
63
  self.send(:include, Functional::Behavior)
67
64
 
68
65
  __dependencies__.freeze
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kind/basic'
4
+ require 'kind/empty'
5
+ require 'kind/result'
6
+ require 'kind/__lib__/action_steps'
7
+
8
+ module Kind
9
+ module Functional
10
+ module Steps
11
+ def self.extended(base)
12
+ base.extend(Result::Methods)
13
+ base.extend(ACTION_STEPS)
14
+ end
15
+
16
+ def self.included(base)
17
+ base.send(:include, Result::Methods)
18
+ base.send(:include, ACTION_STEPS)
19
+ end
20
+ end
21
+ end
22
+ 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.3.0'
4
+ VERSION = '5.4.0'
5
5
  end
metadata CHANGED
@@ -1,16 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kind
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.4.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-03-23 00:00:00.000000000 Z
11
+ date: 2021-03-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A simple type system (at runtime) for Ruby - free of dependencies.
13
+ description: A development toolkit for Ruby with several small/cohesive abstractions
14
+ (monads, enums, business logic, data validation...) to empower your development
15
+ workflow - It's totally free of dependencies.
14
16
  email:
15
17
  - rodrigo.serradura@gmail.com
16
18
  executables: []
@@ -57,6 +59,7 @@ files:
57
59
  - lib/kind/function.rb
58
60
  - lib/kind/functional.rb
59
61
  - lib/kind/functional/action.rb
62
+ - lib/kind/functional/steps.rb
60
63
  - lib/kind/immutable_attributes.rb
61
64
  - lib/kind/immutable_attributes/initializer.rb
62
65
  - lib/kind/immutable_attributes/reader.rb
@@ -141,5 +144,6 @@ requirements: []
141
144
  rubygems_version: 3.2.11
142
145
  signing_key:
143
146
  specification_version: 4
144
- summary: A simple type system (at runtime) for Ruby.
147
+ summary: A development toolkit for Ruby with several small/cohesive abstractions to
148
+ empower your development workflow.
145
149
  test_files: []