kind 5.10.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db0a2008eeb0137d93f74239fc4731ee7cc217a5714a30b9e57305e0d2a5b10a
4
- data.tar.gz: 3b5efef522cc08fdd856ea4a9e3197eaef10c887a335479cac3a70cc67012ec6
3
+ metadata.gz: 694de1c1a1e505d1ad4146c29f086a193331dc8d94339731ef8fbaf788be88ba
4
+ data.tar.gz: 2136a2da3f10f7b43b83bd193fc2558585c4c8c84a34b45285bb24a0ae6a2ef6
5
5
  SHA512:
6
- metadata.gz: 2ded2725b6df3fee68cb30df6aa3172d2b16493f7071314a8be8dc0345dd450461ba899defad6af62073569e83348108f6ac6bbd7699ddc3c47c9e4ea9107069
7
- data.tar.gz: d724177aa2643868ef4ff5700c51d228209aa1f40ca756a3670f8ddb5f769af61a8a14f7433a04a9d7f9451deda73b60b91739c0e7a153a03d4eabde20ba24b3
6
+ metadata.gz: 69440d7516d26553d67e5736070ba07340df3ea30762382cb32c5c40fbbba594fe8f18af909ab5cda4c8b6adf45db39ddc85ea05266ffc842b4ea5e605ad5ff5
7
+ data.tar.gz: 5fb8a35a9d887e4790eef6481a6ab3dd95bc569b3ef18fec06ce52a6ab14f9601627880d3472cefe4a731d7335db552214d474e362fddffc1c3e26f84a469f14
@@ -1,27 +1,68 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ pull_request:
1
9
 
2
- name: build
3
- on: [pull_request]
4
10
  jobs:
5
11
  test:
6
12
  runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ permissions:
15
+ contents: read
7
16
  strategy:
17
+ fail-fast: false
8
18
  matrix:
9
- ruby: [2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 3.0]
19
+ ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "4.0", head]
10
20
  steps:
11
- - uses: actions/checkout@v2
12
- - uses: ruby/setup-ruby@v1
21
+ - uses: actions/checkout@v4
22
+ with:
23
+ persist-credentials: false
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
13
26
  with:
14
27
  ruby-version: ${{ matrix.ruby }}
15
- bundler-cache: true
16
- - name: Test and generate coverage
17
- run: bin/test
18
- - name: Format coverage
19
- if: ${{ matrix.ruby >= 3 }}
20
- run: bin/prepare_coverage
21
- - uses: paambaati/codeclimate-action@v2.7.5
22
- if: ${{ matrix.ruby >= 3 }}
23
- env:
24
- CC_TEST_REPORTER_ID: 9561ceed21b6724aea8063e82e5700bc8266e962978089594bf2d8f8ca5ffc94
28
+ - name: Install bundler
29
+ run: gem install bundler -v 2.4.22
30
+ if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' }}
31
+ - name: Bundle install
32
+ run: bundle install
33
+ - name: Setup project
34
+ run: bundle exec appraisal install
35
+ - name: Run baseline tests (no activemodel)
36
+ run: bundle exec rake test
37
+ - name: Run per-module isolation tests (KIND_BASIC=t)
38
+ run: bundle exec rake test_basic_modules
39
+ - name: Run tests for Rails 6.0
40
+ run: bundle exec appraisal rails-6-0 rake test
41
+ if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' }}
42
+ - name: Run tests for Rails 6.1
43
+ run: bundle exec appraisal rails-6-1 rake test
44
+ if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' }}
45
+ - name: Run tests for Rails 7.0
46
+ run: bundle exec appraisal rails-7-0 rake test
47
+ if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' || matrix.ruby == '3.1' || matrix.ruby == '3.2' || matrix.ruby == '3.3' }}
48
+ - name: Run tests for Rails 7.1
49
+ run: bundle exec appraisal rails-7-1 rake test
50
+ if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' || matrix.ruby == '3.1' || matrix.ruby == '3.2' || matrix.ruby == '3.3' }}
51
+ - name: Run tests for Rails 7.2
52
+ run: bundle exec appraisal rails-7-2 rake test
53
+ if: ${{ matrix.ruby == '3.1' || matrix.ruby == '3.2' || matrix.ruby == '3.3' || matrix.ruby == '3.4' }}
54
+ - name: Run tests for Rails 8.0
55
+ run: bundle exec appraisal rails-8-0 rake test
56
+ if: ${{ matrix.ruby == '3.2' || matrix.ruby == '3.3' || matrix.ruby == '3.4' }}
57
+ - name: Run tests for Rails 8.1
58
+ run: bundle exec appraisal rails-8-1 rake test
59
+ if: ${{ matrix.ruby == '3.3' || matrix.ruby == '3.4' || matrix.ruby == '4.0' }}
60
+ - name: Run tests for Rails edge
61
+ run: bundle exec appraisal rails-edge rake test
62
+ if: ${{ matrix.ruby == '4.0' || matrix.ruby == 'head' }}
63
+ - name: Upload coverage to Qlty
64
+ uses: qltysh/qlty-action/coverage@v2
65
+ if: ${{ matrix.ruby == '3.4' && !github.base_ref }}
25
66
  with:
26
- debug: true
27
- coverageLocations: coverage/.resultset.json:simplecov
67
+ token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
68
+ files: coverage/.resultset.json
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ .DS_Store
2
+
1
3
  /.bundle/
2
4
  /.yardoc
3
5
  /_yardoc/
@@ -8,5 +10,10 @@
8
10
  /tmp/
9
11
 
10
12
  Gemfile.lock
13
+
14
+ gemfiles/*.lock
15
+ gemfiles/.bundle/
16
+
11
17
  .foo
12
- .tool-versions
18
+ .tool-versions
19
+ tags
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.0.0
1
+ ruby 4.0.1
data/Appraisals ADDED
@@ -0,0 +1,84 @@
1
+ if RUBY_VERSION < "3.1"
2
+ appraise "rails-6-0" do
3
+ group :test do
4
+ gem "logger", "~> 1.6", ">= 1.6.6"
5
+ gem "stringio", "~> 3.2"
6
+
7
+ gem "minitest", "5.26.1"
8
+ gem "activemodel", "~> 6.0.0"
9
+ end
10
+ end
11
+
12
+ appraise "rails-6-1" do
13
+ group :test do
14
+ gem "logger", "~> 1.6", ">= 1.6.6"
15
+ gem "stringio", "~> 3.2"
16
+
17
+ gem "minitest", "5.26.1"
18
+ gem "activemodel", "~> 6.1.0"
19
+ end
20
+ end
21
+ end
22
+
23
+ if RUBY_VERSION >= "2.7" && RUBY_VERSION < "3.4"
24
+ appraise "rails-7-0" do
25
+ group :test do
26
+ gem "logger", "~> 1.6", ">= 1.6.6"
27
+ gem "stringio", "~> 3.2"
28
+ gem "securerandom", "~> 0.3.2"
29
+
30
+ gem "minitest", "5.26.1"
31
+ gem "activemodel", "~> 7.0.0"
32
+ end
33
+ end
34
+
35
+ appraise "rails-7-1" do
36
+ group :test do
37
+ gem "logger", "~> 1.6", ">= 1.6.6"
38
+ gem "stringio", "~> 3.2"
39
+ gem "securerandom", "~> 0.3.2"
40
+
41
+ gem "minitest", "5.26.1"
42
+ gem "activemodel", "~> 7.1.0"
43
+ end
44
+ end
45
+ end
46
+
47
+ if RUBY_VERSION >= "3.1" && RUBY_VERSION < "4.0"
48
+ appraise "rails-7-2" do
49
+ group :test do
50
+ gem "minitest", "~> 5.27"
51
+ gem "activemodel", "~> 7.2.0"
52
+ end
53
+ end
54
+ end
55
+
56
+ if RUBY_VERSION >= "3.2" && RUBY_VERSION < "4.0"
57
+ appraise "rails-8-0" do
58
+ group :test do
59
+ gem "ostruct", "~> 0.6.3"
60
+ gem "minitest", "~> 5.27"
61
+ gem "activemodel", "~> 8.0.0"
62
+ end
63
+ end
64
+ end
65
+
66
+ if RUBY_VERSION >= "3.3.0"
67
+ minitest_version = (RUBY_VERSION >= "4.0.0") ? "~> 6.0" : "~> 5.27"
68
+
69
+ appraise "rails-8-1" do
70
+ group :test do
71
+ gem "ostruct", "~> 0.6.3"
72
+ gem "minitest", minitest_version
73
+ gem "activemodel", "~> 8.1.0"
74
+ end
75
+ end
76
+
77
+ appraise "rails-edge" do
78
+ group :test do
79
+ gem "ostruct", "~> 0.6.3"
80
+ gem "minitest", minitest_version
81
+ gem "activemodel", github: "rails/rails", branch: "main"
82
+ end
83
+ end
84
+ end
data/CHANGELOG.md CHANGED
@@ -3,98 +3,106 @@
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.10.0 (2021-09-23)](#5100-2021-09-23)
7
6
  - [Added](#added)
8
- - [5.9.0 (2021-09-22)](#590-2021-09-22)
7
+ - [5.10.0 (2021-09-23)](#5100-2021-09-23)
9
8
  - [Added](#added-1)
9
+ - [5.9.0 (2021-09-22)](#590-2021-09-22)
10
+ - [Added](#added-2)
10
11
  - [5.8.1 (2021-09-22)](#581-2021-09-22)
11
12
  - [Fixed](#fixed)
12
13
  - [5.8.0 (2021-09-22)](#580-2021-09-22)
13
- - [Added](#added-2)
14
- - [5.7.0 (2021-06-22)](#570-2021-06-22)
15
14
  - [Added](#added-3)
16
- - [5.6.0 (2021-05-14)](#560-2021-05-14)
15
+ - [5.7.0 (2021-06-22)](#570-2021-06-22)
17
16
  - [Added](#added-4)
18
- - [5.5.0 (2021-04-05)](#550-2021-04-05)
17
+ - [5.6.0 (2021-05-14)](#560-2021-05-14)
19
18
  - [Added](#added-5)
19
+ - [5.5.0 (2021-04-05)](#550-2021-04-05)
20
+ - [Added](#added-6)
20
21
  - [5.4.1 (2021-03-26)](#541-2021-03-26)
21
22
  - [Fixed](#fixed-1)
22
23
  - [5.4.0 (2021-03-25)](#540-2021-03-25)
23
- - [Added](#added-6)
24
- - [5.3.0 (2021-03-23)](#530-2021-03-23)
25
24
  - [Added](#added-7)
26
- - [5.2.0 (2021-03-17)](#520-2021-03-17)
25
+ - [5.3.0 (2021-03-23)](#530-2021-03-23)
27
26
  - [Added](#added-8)
27
+ - [5.2.0 (2021-03-17)](#520-2021-03-17)
28
+ - [Added](#added-9)
28
29
  - [Deprecated](#deprecated)
29
30
  - [Changes](#changes)
30
31
  - [5.1.0 (2021-02-23)](#510-2021-02-23)
31
- - [Added](#added-9)
32
+ - [Added](#added-10)
32
33
  - [Deprecated](#deprecated-1)
33
34
  - [5.0.0 (2021-02-22)](#500-2021-02-22)
34
35
  - [Breaking Changes](#breaking-changes)
35
36
  - [Removed](#removed)
36
37
  - [4.1.0 (2021-02-22)](#410-2021-02-22)
37
- - [Added](#added-10)
38
- - [4.0.0 (2021-02-22)](#400-2021-02-22)
39
38
  - [Added](#added-11)
39
+ - [4.0.0 (2021-02-22)](#400-2021-02-22)
40
+ - [Added](#added-12)
40
41
  - [Deprecated](#deprecated-2)
41
42
  - [Fixed](#fixed-2)
42
43
  - [3.1.0 (2020-07-08)](#310-2020-07-08)
43
- - [Added](#added-12)
44
+ - [Added](#added-13)
44
45
  - [3.0.0 (2020-06-25)](#300-2020-06-25)
45
46
  - [Breaking Changes](#breaking-changes-1)
46
- - [Added](#added-13)
47
- - [2.3.0 (2020-06-24)](#230-2020-06-24)
48
47
  - [Added](#added-14)
49
- - [2.2.0 (2020-06-23)](#220-2020-06-23)
48
+ - [2.3.0 (2020-06-24)](#230-2020-06-24)
50
49
  - [Added](#added-15)
51
- - [2.1.0 (2020-05-12)](#210-2020-05-12)
50
+ - [2.2.0 (2020-06-23)](#220-2020-06-23)
52
51
  - [Added](#added-16)
52
+ - [2.1.0 (2020-05-12)](#210-2020-05-12)
53
+ - [Added](#added-17)
53
54
  - [Breaking Changes](#breaking-changes-2)
54
55
  - [2.0.0 (2020-05-07)](#200-2020-05-07)
55
- - [Added](#added-17)
56
+ - [Added](#added-18)
56
57
  - [Breaking Changes](#breaking-changes-3)
57
58
  - [Removed](#removed-1)
58
59
  - [1.9.0 (2020-05-06)](#190-2020-05-06)
59
- - [Added](#added-18)
60
- - [1.8.0 (2020-05-03)](#180-2020-05-03)
61
60
  - [Added](#added-19)
61
+ - [1.8.0 (2020-05-03)](#180-2020-05-03)
62
+ - [Added](#added-20)
62
63
  - [1.7.0 (2020-05-03)](#170-2020-05-03)
63
64
  - [Fixed](#fixed-3)
64
65
  - [1.6.0 (2020-04-17)](#160-2020-04-17)
65
- - [Added](#added-20)
66
+ - [Added](#added-21)
66
67
  - [Changes](#changes-1)
67
68
  - [1.5.0 (2020-04-12)](#150-2020-04-12)
68
- - [Added](#added-21)
69
- - [1.4.0 (2020-04-12)](#140-2020-04-12)
70
69
  - [Added](#added-22)
71
- - [1.3.0 (2020-04-12)](#130-2020-04-12)
70
+ - [1.4.0 (2020-04-12)](#140-2020-04-12)
72
71
  - [Added](#added-23)
73
- - [1.2.0 (2020-04-12)](#120-2020-04-12)
72
+ - [1.3.0 (2020-04-12)](#130-2020-04-12)
74
73
  - [Added](#added-24)
75
- - [1.1.0 (2020-04-09)](#110-2020-04-09)
74
+ - [1.2.0 (2020-04-12)](#120-2020-04-12)
76
75
  - [Added](#added-25)
76
+ - [1.1.0 (2020-04-09)](#110-2020-04-09)
77
+ - [Added](#added-26)
77
78
  - [Fixed](#fixed-4)
78
79
  - [1.0.0 (2020-03-16)](#100-2020-03-16)
79
- - [Added](#added-26)
80
- - [0.6.0 (2020-01-06)](#060-2020-01-06)
81
80
  - [Added](#added-27)
82
- - [0.5.0 (2020-01-04)](#050-2020-01-04)
81
+ - [0.6.0 (2020-01-06)](#060-2020-01-06)
83
82
  - [Added](#added-28)
84
- - [0.4.0 (2020-01-03)](#040-2020-01-03)
83
+ - [0.5.0 (2020-01-04)](#050-2020-01-04)
85
84
  - [Added](#added-29)
86
- - [0.3.0 (2020-01-03)](#030-2020-01-03)
85
+ - [0.4.0 (2020-01-03)](#040-2020-01-03)
87
86
  - [Added](#added-30)
87
+ - [0.3.0 (2020-01-03)](#030-2020-01-03)
88
+ - [Added](#added-31)
88
89
  - [Breaking Changes](#breaking-changes-4)
89
90
  - [0.2.0 (2020-01-02)](#020-2020-01-02)
90
- - [Added](#added-31)
91
- - [0.1.0 (2019-12-26)](#010-2019-12-26)
92
91
  - [Added](#added-32)
92
+ - [0.1.0 (2019-12-26)](#010-2019-12-26)
93
+ - [Added](#added-33)
93
94
 
94
95
  ## Unreleased
95
96
 
96
- <!--
97
97
  ### Added
98
+
99
+ * [#71](https://github.com/serradura/kind/pull/71) - Add `Kind::Maybe#to_proc`.
100
+ ```ruby
101
+ result = operation_that_can_return_nil().then(&Kind::Maybe)
102
+ # => #<Kind::Some value=:result>
103
+ ```
104
+
105
+ <!--
98
106
  ### Breaking Changes
99
107
  ### Deprecated
100
108
  ### Removed
data/Gemfile CHANGED
@@ -1,48 +1,14 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- activemodel_version = ENV['ACTIVEMODEL_VERSION']
6
-
7
- activemodel = case activemodel_version
8
- when '3.2' then '3.2.22'
9
- when '4.0' then '4.0.13'
10
- when '4.1' then '4.1.16'
11
- when '4.2' then '4.2.11'
12
- when '5.0' then '5.0.7'
13
- when '5.1' then '5.1.7'
14
- when '5.2' then '5.2.4'
15
- when '6.0' then '6.0.3.4'
16
- when '6.1' then '6.1.2'
17
- end
18
-
19
- simplecov_version =
20
- case RUBY_VERSION
21
- when /\A2.[123]/ then '0.17.1'
22
- when /\A2.4/ then '~> 0.18.5'
23
- else '~> 0.21.2'
24
- end
25
-
26
- is_ruby_2_1 = RUBY_VERSION <= '2.2.0'
5
+ # Specify your gem's dependencies in kind.gemspec
6
+ gemspec
27
7
 
28
- minitest_version =
29
- if activemodel_version
30
- activemodel_version < '4.1' ? '~> 4.2' : '~> 5.0'
31
- else
32
- is_ruby_2_1 ? '~> 4.2' : '~> 5.0'
33
- end
8
+ gem "rake", "~> 13.0"
34
9
 
35
10
  group :test do
36
- if activemodel_version
37
- gem 'activesupport', activemodel, require: false
38
- gem 'activemodel' , activemodel, require: false
39
- end
40
-
41
- gem 'minitest' , minitest_version
42
- gem 'simplecov', simplecov_version, require: false
11
+ gem "minitest", "~> 5.0"
12
+ gem "ostruct", "~> 0.6.3" if RUBY_VERSION >= "3.5"
13
+ gem "simplecov", "~> 0.22.0", require: false
43
14
  end
44
-
45
- gem 'rake', is_ruby_2_1 ? '~> 12.3' : '~> 13.0'
46
-
47
- # Specify your gem's dependencies in type_validator.gemspec
48
- gemspec
data/README.md CHANGED
@@ -1,32 +1,16 @@
1
1
  <p align="center">
2
- <h1 align="center">🤷 kind</h1>
2
+ <h1 align="center" id="-kind">🤷 kind</h1>
3
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
- </p>
5
-
6
- <p align="center">
7
- <a href="https://rubygems.org/gems/kind">
8
- <img alt="Gem" src="https://img.shields.io/gem/v/kind.svg?style=flat-square">
9
- </a>
10
-
11
- <a href="https://github.com/serradura/kind/actions/workflows/ci.yml">
12
- <img alt="Build Status" src="https://github.com/serradura/kind/actions/workflows/ci.yml/badge.svg">
13
- </a>
14
-
15
- <br />
16
-
17
- <img src="https://img.shields.io/badge/ruby%20%3E=%202.1,%20%3C%203.1-ruby.svg?colorA=99004d&colorB=cc0066" alt="Ruby">
18
-
19
- <img src="https://img.shields.io/badge/rails%20%3E=%203.2.0,%20%3C%207.0-rails.svg?colorA=8B0000&colorB=FF0000" alt="Rails">
20
-
21
- <br />
22
-
23
- <a href="https://codeclimate.com/github/serradura/kind/maintainability">
24
- <img alt="Maintainability" src="https://api.codeclimate.com/v1/badges/711329decb2806ccac95/maintainability">
25
- </a>
26
-
27
- <a href="https://codeclimate.com/github/serradura/kind/test_coverage">
28
- <img alt="Test Coverage" src="https://api.codeclimate.com/v1/badges/711329decb2806ccac95/test_coverage">
29
- </a>
4
+ <p align="center">
5
+ <a href="https://badge.fury.io/rb/kind"><img src="https://badge.fury.io/rb/kind.svg" alt="Gem Version" height="18"></a>
6
+ <a href="https://github.com/serradura/kind/actions/workflows/ci.yml"><img alt="Build Status" src="https://github.com/serradura/kind/actions/workflows/ci.yml/badge.svg"></a>
7
+ <br/>
8
+ <a href="https://qlty.sh/gh/serradura/projects/kind"><img src="https://qlty.sh/gh/serradura/projects/kind/maintainability.svg" alt="Maintainability" /></a>
9
+ <a href="https://qlty.sh/gh/serradura/projects/kind"><img src="https://qlty.sh/gh/serradura/projects/kind/coverage.svg" alt="Code Coverage" /></a>
10
+ <br/>
11
+ <img src="https://img.shields.io/badge/Ruby%20%3E%3D%202.7%2C%20%3C%3D%20Head-ruby.svg?colorA=444&colorB=333" alt="Ruby">
12
+ <img src="https://img.shields.io/badge/Rails%20%3E%3D%206.0%2C%20%3C%3D%20Edge-rails.svg?colorA=444&colorB=333" alt="Rails">
13
+ </p>
30
14
  </p>
31
15
 
32
16
  **Motivation:**
@@ -42,11 +26,8 @@ So, I invite you to check out these features to see how they could be useful for
42
26
  Version | Documentation
43
27
  ---------- | -------------
44
28
  unreleased | https://github.com/serradura/kind/blob/main/README.md
29
+ 6.0.0 | https://github.com/serradura/kind/blob/v6.x/README.md
45
30
  5.10.0 | https://github.com/serradura/kind/blob/v5.x/README.md
46
- 4.1.0 | https://github.com/serradura/kind/blob/v4.x/README.md
47
- 3.1.0 | https://github.com/serradura/kind/blob/v3.x/README.md
48
- 2.3.0 | https://github.com/serradura/kind/blob/v2.x/README.md
49
- 1.9.0 | https://github.com/serradura/kind/blob/v1.x/README.md
50
31
 
51
32
  ## Table of Contents <!-- omit in toc -->
52
33
  - [Compatibility](#compatibility)
@@ -92,7 +73,7 @@ unreleased | https://github.com/serradura/kind/blob/main/README.md
92
73
  - [Kind::None() and Kind::Some()](#kindnone-and-kindsome)
93
74
  - [Kind::Optional](#kindoptional)
94
75
  - [Replacing blocks by lambdas](#replacing-blocks-by-lambdas-2)
95
- - [Kind::Maybe(<Type>)](#kindmaybetype)
76
+ - [Kind::Maybe(<Type>)](#kindtypemaybe)
96
77
  - [Real world examples](#real-world-examples)
97
78
  - [Error handling](#error-handling)
98
79
  - [Kind::Maybe.wrap {}](#kindmaybewrap-)
@@ -122,14 +103,24 @@ unreleased | https://github.com/serradura/kind/blob/main/README.md
122
103
 
123
104
  ## Compatibility
124
105
 
125
- | kind | branch | ruby | activemodel |
126
- | -------------- | ------- | ------------------ | -------------- |
127
- | unreleased | main | >= 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
- | 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 |
106
+ | kind | branch | ruby | activemodel |
107
+ | ---------------- | ------ | -------- | -------------- |
108
+ | unreleased | main | >= 2.7 | >= 6.0 |
109
+ | 6.0.0 | v6.x | >= 2.7 | >= 6.0 |
110
+ | 5.10.0 | v5.x | >= 2.1.0, <= 3.0.0 | >= 3.2, < 7.0 |
111
+
112
+ This library is tested (CI matrix) against:
113
+
114
+ | Ruby / Rails | 6.0 | 6.1 | 7.0 | 7.1 | 7.2 | 8.0 | 8.1 | Edge |
115
+ |--------------|-----|-----|-----|-----|-----|-----|-----|------|
116
+ | 2.7 | ✅ | ✅ | ✅ | ✅ | | | | |
117
+ | 3.0 | ✅ | ✅ | ✅ | ✅ | | | | |
118
+ | 3.1 | | | ✅ | ✅ | ✅ | | | |
119
+ | 3.2 | | | ✅ | ✅ | ✅ | ✅ | | |
120
+ | 3.3 | | | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
121
+ | 3.4 | | | | | ✅ | ✅ | ✅ | ✅ |
122
+ | 4.x | | | | | | | ✅ | ✅ |
123
+ | Head | | | | | | | ✅ | ✅ |
133
124
 
134
125
  > Note: The activemodel is an optional dependency, it is related with the [Kind::Validator](#kindvalidator-activemodelvalidations).
135
126
 
@@ -138,7 +129,7 @@ unreleased | https://github.com/serradura/kind/blob/main/README.md
138
129
  Add this line to your application's Gemfile:
139
130
 
140
131
  ```ruby
141
- gem 'kind'
132
+ gem 'kind', '~> 6.0'
142
133
  ```
143
134
 
144
135
  And then execute:
@@ -277,7 +268,7 @@ Kind::String.value('1', default: 1) # Kind::Error (1 expected to be a kind of S
277
268
 
278
269
  ### Kind::\<Type\>.maybe
279
270
 
280
- This method exposes a [typed `Kind::Maybe`](#kindmaybetype) and using it will be possible to apply a sequence of operations in the case of the wrapped value has the expected kind.
271
+ This method exposes a [typed `Kind::Maybe`](#kindtypemaybe) and using it will be possible to apply a sequence of operations in the case of the wrapped value has the expected kind.
281
272
 
282
273
  ```ruby
283
274
  Double = ->(value) do
@@ -865,9 +856,9 @@ This module also has the method `to_proc`, because of this you can make use of t
865
856
 
866
857
  ## Kind::Undefined
867
858
 
868
- The [`Kind::Undefined`](https://github.com/serradura/kind/blob/1674bab/lib/kind/undefined.rb) constant can be used to distinguish the usage of `nil`.
859
+ The [`Kind::Undefined`](https://github.com/serradura/kind/blob/main/lib/kind/basic/undefined.rb) constant can be used to distinguish the usage of `nil`.
869
860
 
870
- If you are interested, check out [the tests](https://github.com/serradura/kind/blob/main/test/kind/undefined_test.rb) to understand its methods.
861
+ If you are interested, check out [the tests](https://github.com/serradura/kind/blob/main/test/kind/basic/undefined_test.rb) to understand its methods.
871
862
 
872
863
  [⬆️ &nbsp;Back to Top](#table-of-contents-)
873
864
 
data/Rakefile CHANGED
@@ -7,4 +7,70 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList["test/**/*_test.rb"]
8
8
  end
9
9
 
10
- task :default => :test
10
+ require "appraisal/task"
11
+
12
+ Appraisal::Task.new
13
+
14
+ KIND_BASIC_MODULE_GLOBS = [
15
+ "test/kind/{basic/*_test,basic_test}.rb",
16
+ "test/kind/enum_test.rb",
17
+ "test/kind/presence_test.rb",
18
+ "test/kind/dig_test.rb",
19
+ "test/kind/try_test.rb",
20
+ "test/kind/maybe_test.rb",
21
+ "test/kind/immutable_attributes_test.rb",
22
+ "test/kind/function_test.rb",
23
+ "test/kind/action_test.rb",
24
+ "test/kind/{functional/*_test,functional_test}.rb",
25
+ "test/kind/either/*_test.rb",
26
+ "test/kind/result/*_test.rb"
27
+ ].freeze
28
+
29
+ def run_isolated_module(files, env: {})
30
+ return if files.empty?
31
+
32
+ loader = Gem.bin_path('rake', 'rake_test_loader.rb') rescue nil
33
+ loader ||= File.join(Gem.loaded_specs['rake'].full_gem_path, 'lib/rake/rake_test_loader.rb')
34
+
35
+ sh(env, FileUtils::RUBY, '-Ilib', '-Itest', loader, *files)
36
+ end
37
+
38
+ desc "Run each kind module in isolation (KIND_BASIC=t)"
39
+ task :test_basic_modules do
40
+ KIND_BASIC_MODULE_GLOBS.each do |glob|
41
+ run_isolated_module(Dir.glob(glob), env: { 'KIND_BASIC' => 't' })
42
+ end
43
+
44
+ run_isolated_module(Dir.glob('test/kind/strict_disabled_test.rb'), env: { 'KIND_STRICT' => 't' })
45
+ end
46
+
47
+ desc "Run the full test suite against every supported Rails version"
48
+ task :matrix do
49
+ appraisals =
50
+ if RUBY_VERSION < "3.1"
51
+ %w[rails-6-0 rails-6-1 rails-7-0 rails-7-1]
52
+ elsif RUBY_VERSION < "3.2"
53
+ %w[rails-7-0 rails-7-1 rails-7-2]
54
+ elsif RUBY_VERSION < "3.3"
55
+ %w[rails-7-0 rails-7-1 rails-7-2 rails-8-0]
56
+ elsif RUBY_VERSION < "3.4"
57
+ %w[rails-7-0 rails-7-1 rails-7-2 rails-8-0 rails-8-1 rails-edge]
58
+ elsif RUBY_VERSION < "4.0"
59
+ %w[rails-7-2 rails-8-0 rails-8-1 rails-edge]
60
+ else
61
+ %w[rails-8-1 rails-edge]
62
+ end
63
+
64
+ # Default (no activemodel)
65
+ sh "bundle exec rake test"
66
+
67
+ # Per-module isolation runs
68
+ Rake::Task[:test_basic_modules].invoke
69
+
70
+ # Each activemodel appraisal
71
+ appraisals.each do |appraisal|
72
+ sh "bundle exec appraisal #{appraisal} rake test"
73
+ end
74
+ end
75
+
76
+ task default: :test
data/bin/matrix ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ ruby -v
7
+
8
+ rm -f Gemfile.lock
9
+
10
+ bundle install
11
+
12
+ bundle exec appraisal update
13
+
14
+ bundle exec rake matrix
15
+
16
+ ruby -v
data/bin/setup CHANGED
@@ -3,6 +3,10 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
+ rm -f Gemfile.lock
7
+
6
8
  bundle install
7
9
 
10
+ bundle exec appraisal install
11
+
8
12
  # Do any other automated setup that you need to do here
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+
7
+ group :test do
8
+ gem "minitest", "~> 6.0"
9
+ gem "ostruct", "~> 0.6.3"
10
+ gem "simplecov", "~> 0.22.0", require: false
11
+ gem "activemodel", "~> 8.1.0"
12
+ end
13
+
14
+ gemspec path: "../"
@@ -0,0 +1,14 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+
7
+ group :test do
8
+ gem "minitest", "~> 6.0"
9
+ gem "ostruct", "~> 0.6.3"
10
+ gem "simplecov", "~> 0.22.0", require: false
11
+ gem "activemodel", branch: "main", git: "https://github.com/rails/rails"
12
+ end
13
+
14
+ gemspec path: "../"
data/kind.gemspec CHANGED
@@ -10,11 +10,11 @@ Gem::Specification.new do |spec|
10
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
- spec.required_ruby_version = Gem::Requirement.new('>= 2.1.0')
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
14
14
 
15
15
  spec.metadata['homepage_uri'] = spec.homepage
16
16
  spec.metadata['source_code_uri'] = 'https://github.com/serradura/kind'
17
- # spec.metadata['changelog_uri'] = 'TODO: Put your gem's CHANGELOG.md URL here.'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/serradura/kind/blob/main/CHANGELOG.md'
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -24,4 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.bindir = 'exe'
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
+
28
+ spec.add_development_dependency 'appraisal', '~> 2.5'
29
+ spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'rake', '~> 13.0'
27
31
  end
data/lib/kind/any.rb CHANGED
@@ -27,12 +27,12 @@ module Kind
27
27
  end
28
28
 
29
29
  def name
30
- str = @values.inspect
31
-
32
- if @values.is_a?(::Set)
33
- str.sub!(/\A#<Set: /, '')
34
- str.chomp!('>')
35
- end
30
+ str =
31
+ if @values.is_a?(::Set)
32
+ "{#{@values.to_a.map(&:inspect).join(', ')}}"
33
+ else
34
+ @values.inspect
35
+ end
36
36
 
37
37
  "Kind::Any#{str}"
38
38
  end
data/lib/kind/maybe.rb CHANGED
@@ -18,6 +18,10 @@ module Kind
18
18
  .new(value)
19
19
  end
20
20
 
21
+ def to_proc
22
+ ->(value) { new(value) }
23
+ end
24
+
21
25
  alias_method :[], :new
22
26
 
23
27
  module Buildable
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.10.0'
4
+ VERSION = '6.0.0'
5
5
  end
metadata CHANGED
@@ -1,15 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kind
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.10.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2021-09-23 00:00:00.000000000 Z
12
- dependencies: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: appraisal
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.5'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.5'
26
+ - !ruby/object:Gem::Dependency
27
+ name: bundler
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rake
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '13.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '13.0'
13
54
  description: A development toolkit for Ruby with several small/cohesive abstractions
14
55
  (monads, enums, business logic, data validation...) to empower your development
15
56
  workflow - It's totally free of dependencies.
@@ -23,6 +64,7 @@ files:
23
64
  - ".gitignore"
24
65
  - ".tool-versions"
25
66
  - ".vscode/settings.json"
67
+ - Appraisals
26
68
  - CHANGELOG.md
27
69
  - CODE_OF_CONDUCT.md
28
70
  - Gemfile
@@ -30,9 +72,10 @@ files:
30
72
  - README.md
31
73
  - Rakefile
32
74
  - bin/console
33
- - bin/prepare_coverage
75
+ - bin/matrix
34
76
  - bin/setup
35
- - bin/test
77
+ - gemfiles/rails_8_1.gemfile
78
+ - gemfiles/rails_edge.gemfile
36
79
  - kind.gemspec
37
80
  - lib/kind.rb
38
81
  - lib/kind/__lib__/action_steps.rb
@@ -129,7 +172,7 @@ licenses:
129
172
  metadata:
130
173
  homepage_uri: https://github.com/serradura/kind
131
174
  source_code_uri: https://github.com/serradura/kind
132
- post_install_message:
175
+ changelog_uri: https://github.com/serradura/kind/blob/main/CHANGELOG.md
133
176
  rdoc_options: []
134
177
  require_paths:
135
178
  - lib
@@ -137,15 +180,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
180
  requirements:
138
181
  - - ">="
139
182
  - !ruby/object:Gem::Version
140
- version: 2.1.0
183
+ version: 2.7.0
141
184
  required_rubygems_version: !ruby/object:Gem::Requirement
142
185
  requirements:
143
186
  - - ">="
144
187
  - !ruby/object:Gem::Version
145
188
  version: '0'
146
189
  requirements: []
147
- rubygems_version: 3.2.11
148
- signing_key:
190
+ rubygems_version: 4.0.7
149
191
  specification_version: 4
150
192
  summary: A development toolkit for Ruby with several small/cohesive abstractions to
151
193
  empower your development workflow.
data/bin/prepare_coverage DELETED
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
- # Borrowed from https://gist.github.com/qortex/7e7c49f3731391a91ee898336183acef
4
-
5
- # Temporary hack to get CodeClimate to work with SimpleCov 0.18 JSON format until issue is fixed
6
- # upstream: https://github.com/codeclimate/test-reporter/issues/413
7
-
8
- require "json"
9
-
10
- filename = "coverage/.resultset.json"
11
- contents = JSON.parse(File.read(filename))
12
-
13
- def remove_lines_key(obj)
14
- case obj
15
- when Hash
16
- obj.transform_values do |val|
17
- val.is_a?(Hash) && val.key?("lines") ? val["lines"] : remove_lines_key(val)
18
- end
19
- else
20
- obj
21
- end
22
- end
23
-
24
- # overwrite
25
- File.write(filename, JSON.generate(remove_lines_key(contents)))
26
-
27
- puts Dir['coverage/.*.json']
data/bin/test DELETED
@@ -1,76 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- RUBY_V=$(ruby -v)
6
-
7
- function reset_gemfile_and_test {
8
- rm Gemfile.lock
9
-
10
- eval "$1 bundle update"
11
- eval "$1 bundle exec rake test"
12
- }
13
-
14
- function test_with_activemodel {
15
- reset_gemfile_and_test "ACTIVEMODEL_VERSION=$1"
16
- }
17
-
18
- function run_tests_by_modules {
19
- rm Gemfile.lock
20
-
21
- bundle update
22
-
23
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/{basic/*_test,basic_test}.rb'"
24
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/enum_test.rb'"
25
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/presence_test.rb'"
26
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/dig_test.rb'"
27
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/try_test.rb'"
28
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/maybe_test.rb'"
29
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/immutable_attributes_test.rb'"
30
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/function_test.rb'"
31
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/action_test.rb'"
32
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/{functional/*_test,functional_test}.rb'"
33
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/either/*_test.rb'"
34
- eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/result/*_test.rb'"
35
-
36
- eval "KIND_STRICT=t bundle exec rake test TEST='test/kind/strict_disabled_test.rb'"
37
- }
38
-
39
- RUBY_2_12345="ruby 2.[12345]."
40
- RUBY_2_2345="ruby 2.[2345]."
41
- RUBY_2_1234="ruby 2.[1234]."
42
- RUBY_2_567="ruby 2.[567]."
43
- RUBY_2_12="ruby 2.[12]."
44
- RUBY_3_X="ruby 3.0."
45
-
46
- if [[ $RUBY_V =~ $RUBY_2_12345 ]]; then
47
- if [[ $RUBY_V =~ $RUBY_2_12 ]]; then
48
- test_with_activemodel "3.2"
49
- fi
50
-
51
- if [[ $RUBY_V =~ $RUBY_2_2345 ]]; then
52
- test_with_activemodel "4.0"
53
- test_with_activemodel "4.1"
54
- test_with_activemodel "4.2"
55
- test_with_activemodel "5.0"
56
- test_with_activemodel "5.1"
57
- test_with_activemodel "5.2"
58
- fi
59
-
60
- if [[ $RUBY_V =~ $RUBY_2_1234 ]]; then
61
- run_tests_by_modules
62
-
63
- reset_gemfile_and_test
64
- fi
65
- fi
66
-
67
- if [[ $RUBY_V =~ $RUBY_2_567 ]] || [[ $RUBY_V =~ $RUBY_3_X ]]; then
68
- gem install bundler -v ">= 2" --no-doc
69
-
70
- test_with_activemodel "6.0"
71
- test_with_activemodel "6.1"
72
-
73
- run_tests_by_modules
74
-
75
- reset_gemfile_and_test
76
- fi