u-struct 1.0.0 → 2.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 +4 -4
- data/.github/workflows/ci.yml +62 -17
- data/.gitignore +3 -0
- data/.rubocop.yml +137 -0
- data/.rubocop_todo.yml +10 -0
- data/.tool-versions +1 -0
- data/Appraisals +84 -0
- data/CHANGELOG.md +101 -47
- data/CLAUDE.md +144 -0
- data/Gemfile +20 -3
- data/README.md +187 -72
- data/Rakefile +35 -5
- data/bin/console +3 -3
- data/bin/matrix +16 -0
- data/bin/setup +4 -0
- data/bin/tapioca +28 -0
- data/examples/rgb/number.rb +1 -1
- data/examples/rgb_1.rb +3 -3
- data/examples/rgb_2.rb +2 -2
- data/examples/rgb_3.rb +1 -1
- data/lib/micro/struct/factory/create_struct.rb +12 -5
- data/lib/micro/struct/factory/members.rb +1 -0
- data/lib/micro/struct/factory.rb +10 -5
- data/lib/micro/struct/features.rb +18 -23
- data/lib/micro/struct/normalize_names.rb +4 -3
- data/lib/micro/struct/version.rb +2 -1
- data/lib/micro/struct.rb +32 -5
- data/lib/u-struct.rb +2 -0
- data/rbi/micro/struct/factory/create_struct.rbi +60 -0
- data/rbi/micro/struct/factory/members.rbi +67 -0
- data/rbi/micro/struct/factory.rbi +41 -0
- data/rbi/micro/struct/features.rbi +41 -0
- data/rbi/micro/struct/normalize_names.rbi +20 -0
- data/rbi/micro/struct/version.rbi +3 -0
- data/rbi/micro/struct.rbi +68 -0
- data/sorbet/config +8 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +54 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +11 -0
- data/sorbet/rbi/gems/docile@1.4.0.rbi +54 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
- data/sorbet/rbi/gems/minitest@5.15.0.rbi +345 -0
- data/sorbet/rbi/gems/parser@3.1.0.0.rbi +1196 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +806 -0
- data/sorbet/rbi/gems/rbi@0.0.9.rbi +1602 -0
- data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +89 -0
- data/sorbet/rbi/gems/simplecov@0.21.2.rbi +577 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.3.rbi +8 -0
- data/sorbet/rbi/gems/spoom@1.1.8.rbi +1252 -0
- data/sorbet/rbi/gems/tapioca@0.6.2.rbi +1232 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +844 -0
- data/sorbet/rbi/gems/unparser@0.6.3.rbi +8 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +601 -0
- data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +199 -0
- data/sorbet/rbi/gems/yard@0.9.27.rbi +4112 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- data/u-struct.gemspec +9 -9
- metadata +60 -14
- data/.vscode/settings.json +0 -8
- data/bin/prepare_coverage +0 -27
- data/bin/test +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8253f1eefa995a1bb88ffd06463a7868bd9891191d287e4146afc2017c0152a0
|
|
4
|
+
data.tar.gz: bcda03d7c0d4d6e3fb8a523be53ee297afac42e9d2c76cff6ecda4cf5857bbe4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72c2639605ff42489c6914e8f3b6d7add9931327e3a7f78acad7f865e3c29dd711e5fc23201e724e0d1d85c014a438e846e9681547fb505acb8756986eb176e6
|
|
7
|
+
data.tar.gz: f98014a72acc88d90ca4e48f53a977b3bc9762faa4435a34fa30a6422a6f78d6365d795a3a182c96ca915fab537a681e5555f852acc1efaa5eee4c6eba1d59c8
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -1,27 +1,72 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
pull_request:
|
|
1
9
|
|
|
2
|
-
name: build
|
|
3
|
-
on: [push]
|
|
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.
|
|
19
|
+
ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "4.0", head]
|
|
10
20
|
steps:
|
|
11
|
-
- uses: actions/checkout@
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- name:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 RuboCop
|
|
36
|
+
run: bundle exec rubocop
|
|
37
|
+
if: ${{ matrix.ruby == '3.1' }}
|
|
38
|
+
- name: Run Sorbet typecheck
|
|
39
|
+
run: bundle exec srb tc
|
|
40
|
+
if: ${{ matrix.ruby == '3.1' }}
|
|
41
|
+
- name: Run baseline tests (no activemodel)
|
|
42
|
+
run: bundle exec rake test
|
|
43
|
+
- name: Run tests for Rails 6.0
|
|
44
|
+
run: bundle exec appraisal rails-6-0 rake test
|
|
45
|
+
if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' }}
|
|
46
|
+
- name: Run tests for Rails 6.1
|
|
47
|
+
run: bundle exec appraisal rails-6-1 rake test
|
|
48
|
+
if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' }}
|
|
49
|
+
- name: Run tests for Rails 7.0
|
|
50
|
+
run: bundle exec appraisal rails-7-0 rake test
|
|
51
|
+
if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' || matrix.ruby == '3.1' || matrix.ruby == '3.2' || matrix.ruby == '3.3' }}
|
|
52
|
+
- name: Run tests for Rails 7.1
|
|
53
|
+
run: bundle exec appraisal rails-7-1 rake test
|
|
54
|
+
if: ${{ matrix.ruby == '2.7' || matrix.ruby == '3.0' || matrix.ruby == '3.1' || matrix.ruby == '3.2' || matrix.ruby == '3.3' }}
|
|
55
|
+
- name: Run tests for Rails 7.2
|
|
56
|
+
run: bundle exec appraisal rails-7-2 rake test
|
|
57
|
+
if: ${{ matrix.ruby == '3.1' || matrix.ruby == '3.2' || matrix.ruby == '3.3' || matrix.ruby == '3.4' }}
|
|
58
|
+
- name: Run tests for Rails 8.0
|
|
59
|
+
run: bundle exec appraisal rails-8-0 rake test
|
|
60
|
+
if: ${{ matrix.ruby == '3.2' || matrix.ruby == '3.3' || matrix.ruby == '3.4' }}
|
|
61
|
+
- name: Run tests for Rails 8.1
|
|
62
|
+
run: bundle exec appraisal rails-8-1 rake test
|
|
63
|
+
if: ${{ matrix.ruby == '3.3' || matrix.ruby == '3.4' || matrix.ruby == '4.0' }}
|
|
64
|
+
- name: Run tests for Rails edge
|
|
65
|
+
run: bundle exec appraisal rails-edge rake test
|
|
66
|
+
if: ${{ matrix.ruby == '4.0' || matrix.ruby == 'head' }}
|
|
67
|
+
- name: Upload coverage to Qlty
|
|
68
|
+
uses: qltysh/qlty-action/coverage@v2
|
|
69
|
+
if: ${{ matrix.ruby == '3.4' && !github.base_ref }}
|
|
25
70
|
with:
|
|
26
|
-
|
|
27
|
-
|
|
71
|
+
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
|
|
72
|
+
files: coverage/.resultset.json
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
|
4
|
+
# configuration file. It makes it possible to enable/disable
|
|
5
|
+
# certain cops (checks) and to alter their behavior if they accept
|
|
6
|
+
# any parameters. The file can be placed either in your home
|
|
7
|
+
# directory or in some project directory.
|
|
8
|
+
#
|
|
9
|
+
# RuboCop will start looking for the configuration file in the directory
|
|
10
|
+
# where the inspected file is and continue its way up to the root directory.
|
|
11
|
+
#
|
|
12
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
|
13
|
+
|
|
14
|
+
require:
|
|
15
|
+
- rubocop-rake
|
|
16
|
+
- rubocop-minitest
|
|
17
|
+
|
|
18
|
+
AllCops:
|
|
19
|
+
NewCops: enable
|
|
20
|
+
TargetRubyVersion: 2.5
|
|
21
|
+
# Appraisal config + the gemfiles it generates; these mirror the canonical
|
|
22
|
+
# kind layout (double-quoted) and aren't linted as project source.
|
|
23
|
+
Exclude:
|
|
24
|
+
- 'Appraisals'
|
|
25
|
+
- 'gemfiles/**/*'
|
|
26
|
+
inherit_mode:
|
|
27
|
+
merge:
|
|
28
|
+
- Exclude
|
|
29
|
+
|
|
30
|
+
# == Gemspec ==
|
|
31
|
+
|
|
32
|
+
Gemspec/RequiredRubyVersion:
|
|
33
|
+
Enabled: false
|
|
34
|
+
|
|
35
|
+
# == Style ==
|
|
36
|
+
|
|
37
|
+
Style/Alias:
|
|
38
|
+
Enabled: false
|
|
39
|
+
|
|
40
|
+
Style/CaseEquality:
|
|
41
|
+
Enabled: false
|
|
42
|
+
|
|
43
|
+
Style/ClassAndModuleChildren:
|
|
44
|
+
Enabled: false
|
|
45
|
+
|
|
46
|
+
Style/CombinableLoops:
|
|
47
|
+
Exclude:
|
|
48
|
+
- test/**/*.rb
|
|
49
|
+
|
|
50
|
+
Style/Documentation:
|
|
51
|
+
Enabled: false
|
|
52
|
+
|
|
53
|
+
Style/FormatStringToken:
|
|
54
|
+
EnforcedStyle: annotated
|
|
55
|
+
|
|
56
|
+
Style/Lambda:
|
|
57
|
+
Enabled: false
|
|
58
|
+
|
|
59
|
+
Style/LambdaCall:
|
|
60
|
+
Enabled: false
|
|
61
|
+
|
|
62
|
+
Style/ModuleFunction:
|
|
63
|
+
EnforcedStyle: extend_self
|
|
64
|
+
|
|
65
|
+
Style/RaiseArgs:
|
|
66
|
+
EnforcedStyle: compact
|
|
67
|
+
|
|
68
|
+
Style/SymbolArray:
|
|
69
|
+
EnforcedStyle: brackets
|
|
70
|
+
|
|
71
|
+
# == Layout ==
|
|
72
|
+
|
|
73
|
+
Layout/ArrayAlignment:
|
|
74
|
+
Enabled: false
|
|
75
|
+
|
|
76
|
+
Layout/ExtraSpacing:
|
|
77
|
+
Enabled: false
|
|
78
|
+
|
|
79
|
+
Layout/HashAlignment:
|
|
80
|
+
Enabled: false
|
|
81
|
+
|
|
82
|
+
Layout/SpaceAroundOperators:
|
|
83
|
+
Enabled: false
|
|
84
|
+
|
|
85
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
|
86
|
+
EnforcedStyle: no_space
|
|
87
|
+
EnforcedStyleForEmptyBrackets: no_space
|
|
88
|
+
|
|
89
|
+
Layout/SpaceInsideHashLiteralBraces:
|
|
90
|
+
EnforcedStyle: no_space
|
|
91
|
+
|
|
92
|
+
# == Lint ==
|
|
93
|
+
|
|
94
|
+
Lint/ConstantDefinitionInBlock:
|
|
95
|
+
Enabled: false
|
|
96
|
+
|
|
97
|
+
Lint/NestedMethodDefinition:
|
|
98
|
+
Exclude:
|
|
99
|
+
- test/micro/struct/instance_method_test.rb
|
|
100
|
+
|
|
101
|
+
# == Naming ==
|
|
102
|
+
|
|
103
|
+
Naming/ClassAndModuleCamelCase:
|
|
104
|
+
Enabled: false
|
|
105
|
+
|
|
106
|
+
Naming/FileName:
|
|
107
|
+
Exclude:
|
|
108
|
+
- lib/u-struct.rb
|
|
109
|
+
|
|
110
|
+
Naming/MethodParameterName:
|
|
111
|
+
Exclude:
|
|
112
|
+
- examples/**/*.rb
|
|
113
|
+
|
|
114
|
+
Naming/RescuedExceptionsVariableName:
|
|
115
|
+
PreferredName: exception
|
|
116
|
+
|
|
117
|
+
# == Metrics ==
|
|
118
|
+
|
|
119
|
+
Metrics/AbcSize:
|
|
120
|
+
Exclude:
|
|
121
|
+
- test/**/*.rb
|
|
122
|
+
|
|
123
|
+
Metrics/MethodLength:
|
|
124
|
+
Exclude:
|
|
125
|
+
- test/**/*.rb
|
|
126
|
+
|
|
127
|
+
Metrics/ClassLength:
|
|
128
|
+
Exclude:
|
|
129
|
+
- test/**/*.rb
|
|
130
|
+
|
|
131
|
+
# == Minitest ==
|
|
132
|
+
|
|
133
|
+
Minitest/AssertWithExpectedArgument:
|
|
134
|
+
Enabled: false
|
|
135
|
+
|
|
136
|
+
Minitest/MultipleAssertions:
|
|
137
|
+
Max: 21
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2022-01-27 11:53:52 UTC using RuboCop version 1.25.0.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
Gemspec/RequireMFA:
|
|
10
|
+
Enabled: false
|
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.2.11
|
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
|
@@ -2,48 +2,83 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
- [[Unreleased]](#unreleased)
|
|
9
|
-
- [[0.12.0] - 2021-12-22](#0120---2021-12-22)
|
|
10
|
-
- [Added](#added)
|
|
11
|
-
- [[0.11.0] - 2021-12-19](#0110---2021-12-19)
|
|
12
|
-
- [Added](#added-1)
|
|
13
|
-
- [[0.10.0] - 2021-12-15](#0100---2021-12-15)
|
|
14
|
-
- [Changed](#changed)
|
|
15
|
-
- [[0.9.0] - 2021-12-14](#090---2021-12-14)
|
|
16
|
-
- [Added](#added-2)
|
|
17
|
-
- [Changed](#changed-1)
|
|
18
|
-
- [[0.8.0] - 2021-12-05](#080---2021-12-05)
|
|
19
|
-
- [Added](#added-3)
|
|
20
|
-
- [[0.7.0] - 2021-12-04](#070---2021-12-04)
|
|
21
|
-
- [Added](#added-4)
|
|
22
|
-
- [Changed](#changed-2)
|
|
23
|
-
- [[0.6.0] - 2021-12-03](#060---2021-12-03)
|
|
24
|
-
- [Added](#added-5)
|
|
25
|
-
- [[0.5.0] - 2021-12-02](#050---2021-12-02)
|
|
26
|
-
- [Added](#added-6)
|
|
27
|
-
- [[0.4.0] - 2021-12-02](#040---2021-12-02)
|
|
28
|
-
- [Added](#added-7)
|
|
29
|
-
- [[0.3.1] - 2021-12-02](#031---2021-12-02)
|
|
30
|
-
- [Fixed](#fixed)
|
|
31
|
-
- [[0.3.0] - 2021-12-02](#030---2021-12-02)
|
|
32
|
-
- [Added](#added-8)
|
|
33
|
-
- [[0.2.0] - 2021-12-02](#020---2021-12-02)
|
|
34
|
-
- [Added](#added-9)
|
|
35
|
-
- [[0.1.0] - 2021-12-02](#010---2021-12-02)
|
|
36
|
-
- [Added](#added-10)
|
|
37
|
-
|
|
38
8
|
## [Unreleased]
|
|
39
9
|
|
|
40
|
-
[
|
|
10
|
+
## [2.0.0] - 2026-06-01
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bump the minimum supported Ruby to `>= 2.7.0` (was `>= 2.2.0`).
|
|
15
|
+
- Modernize the CI: test against Ruby 2.7 → 4.0 + head and, via Appraisal,
|
|
16
|
+
against ActiveModel 6.0 → 8.1 + edge (Rails `>= 6.0`).
|
|
17
|
+
|
|
18
|
+
## [1.1.0] - 2022-03-23
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- Add `Micro::Struct[]` as an alias of `Micro::Struct.with`.
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
Micro::Struct[:readonly] # is the same as Micro::Struct.with(:readonly)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Add `Micro::Struct.immutable` method as a shortcut to `Micro::Struct.with(:readonly, :instance_copy)`.
|
|
29
|
+
It also accepts the `with:` option, which can be used to define additional features.
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
Micro::Struct.immutable.new(:name)
|
|
33
|
+
|
|
34
|
+
Micro::Struct.immutable.new(:name) do
|
|
35
|
+
def hi(other_name)
|
|
36
|
+
"Hi, #{other_name}! My name is #{name}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Micro::Struct.immutable(with: :to_hash).new(:name)
|
|
41
|
+
|
|
42
|
+
Micro::Struct.immutable(with: [:to_hash, :to_proc]).new(:name)
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
Micro::Struct.immutable.instance(name: 'Rodrigo')
|
|
45
|
+
|
|
46
|
+
Micro::Struct.immutable(with: [:to_hash]).instance(name: 'Serradura')
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- Add `Micro::Struct.readonly` method as a shortcut to `Micro::Struct.with(:readonly)`.
|
|
50
|
+
It has the same properties of `Micro::Struct.immutable`.
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
Micro::Struct.readonly.new(:name)
|
|
54
|
+
|
|
55
|
+
Micro::Struct.readonly.new(:name) do
|
|
56
|
+
def hi(other_name)
|
|
57
|
+
"Hi, #{other_name}! My name is #{name}"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Micro::Struct.readonly(with: :to_hash).new(:name)
|
|
62
|
+
|
|
63
|
+
Micro::Struct.readonly(with: [:to_hash, :to_proc]).new(:name)
|
|
64
|
+
|
|
65
|
+
Micro::Struct.readonly.instance(name: 'Rodrigo')
|
|
66
|
+
|
|
67
|
+
Micro::Struct.readonly(with: [:to_hash]).instance(name: 'Serradura')
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Development stuff**
|
|
71
|
+
|
|
72
|
+
- Set up Rubocop.
|
|
73
|
+
- Add `.rbi` files, and set up sorbet to be used in development.
|
|
74
|
+
|
|
75
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
76
|
+
|
|
77
|
+
## [1.0.0] - 2022-01-20
|
|
43
78
|
|
|
44
79
|
- Review and update docs and examples. ;)
|
|
45
80
|
|
|
46
|
-
|
|
81
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
47
82
|
|
|
48
83
|
## [0.12.0] - 2021-12-22
|
|
49
84
|
|
|
@@ -70,6 +105,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
70
105
|
person2.first_name = 'John'
|
|
71
106
|
# NoMethodError (private method `first_name=' called for #<struct first_name="Rodrigo", last_name="Serradura">)
|
|
72
107
|
```
|
|
108
|
+
|
|
73
109
|
You can use pass a block to define some custom behavior to the struct instance.
|
|
74
110
|
|
|
75
111
|
```ruby
|
|
@@ -115,7 +151,7 @@ Person.features.options?(:to_proc, :readonly) # => true
|
|
|
115
151
|
Person.features.options?(:to_ary, :readonly) # => false
|
|
116
152
|
```
|
|
117
153
|
|
|
118
|
-
|
|
154
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
119
155
|
|
|
120
156
|
## [0.11.0] - 2021-12-19
|
|
121
157
|
|
|
@@ -125,7 +161,7 @@ Person.features.options?(:to_ary, :readonly) # => false
|
|
|
125
161
|
- Set up a CI with Github actions.
|
|
126
162
|
- Test the codebase against the Ruby versions: `2.2`, `2.3`, `2.4`, `2.5`, `2.6`, `2.7`, `3.0` and `3.1.0-preview1`.
|
|
127
163
|
|
|
128
|
-
|
|
164
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
129
165
|
|
|
130
166
|
## [0.10.0] - 2021-12-15
|
|
131
167
|
|
|
@@ -159,7 +195,7 @@ rgb_color.to_hex
|
|
|
159
195
|
# => "#0105ff"
|
|
160
196
|
```
|
|
161
197
|
|
|
162
|
-
|
|
198
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
163
199
|
|
|
164
200
|
## [0.9.0] - 2021-12-14
|
|
165
201
|
|
|
@@ -248,7 +284,7 @@ rgb_color.to_ary # => [1, 5, 255]
|
|
|
248
284
|
rgb_color.to_hash # => {:r=>1, :g=>5, :b=>255}
|
|
249
285
|
```
|
|
250
286
|
|
|
251
|
-
|
|
287
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
252
288
|
|
|
253
289
|
## [0.8.0] - 2021-12-05
|
|
254
290
|
|
|
@@ -266,7 +302,7 @@ Person === person
|
|
|
266
302
|
# => true
|
|
267
303
|
```
|
|
268
304
|
|
|
269
|
-
|
|
305
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
270
306
|
|
|
271
307
|
## [0.7.0] - 2021-12-04
|
|
272
308
|
|
|
@@ -295,7 +331,7 @@ Person = Micro::Struct.new(
|
|
|
295
331
|
)
|
|
296
332
|
```
|
|
297
333
|
|
|
298
|
-
|
|
334
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
299
335
|
|
|
300
336
|
## [0.6.0] - 2021-12-03
|
|
301
337
|
|
|
@@ -320,7 +356,7 @@ Persona.new
|
|
|
320
356
|
# => #<struct Persona::Struct first_name=nil, last_name=nil>
|
|
321
357
|
```
|
|
322
358
|
|
|
323
|
-
|
|
359
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
324
360
|
|
|
325
361
|
## [0.5.0] - 2021-12-02
|
|
326
362
|
|
|
@@ -371,7 +407,7 @@ person.name # => "Rodrigo Serradura"
|
|
|
371
407
|
new_person.name # => "John Doe"
|
|
372
408
|
```
|
|
373
409
|
|
|
374
|
-
|
|
410
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
375
411
|
|
|
376
412
|
## [0.4.0] - 2021-12-02
|
|
377
413
|
|
|
@@ -400,7 +436,7 @@ person.respond_to?(:to_hash) # => false
|
|
|
400
436
|
Person.respond_to?(:to_proc) # => false
|
|
401
437
|
```
|
|
402
438
|
|
|
403
|
-
|
|
439
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
404
440
|
|
|
405
441
|
## [0.3.1] - 2021-12-02
|
|
406
442
|
|
|
@@ -408,7 +444,7 @@ Person.respond_to?(:to_proc) # => false
|
|
|
408
444
|
|
|
409
445
|
- Fix the spec.files config of `u-struct.gemspec`.
|
|
410
446
|
|
|
411
|
-
|
|
447
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
412
448
|
|
|
413
449
|
## [0.3.0] - 2021-12-02
|
|
414
450
|
|
|
@@ -416,7 +452,7 @@ Person.respond_to?(:to_proc) # => false
|
|
|
416
452
|
|
|
417
453
|
- Add `lib/u-struct.rb` to allow the bundler to require the gem in an automatic way.
|
|
418
454
|
|
|
419
|
-
|
|
455
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
420
456
|
|
|
421
457
|
## [0.2.0] - 2021-12-02
|
|
422
458
|
|
|
@@ -436,7 +472,7 @@ person = Person.new(first_name: 'Rodrigo', last_name: 'Serradura')
|
|
|
436
472
|
print_first_and_last_name(**person) # Rodrigo Serradura
|
|
437
473
|
```
|
|
438
474
|
|
|
439
|
-
|
|
475
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
440
476
|
|
|
441
477
|
## [0.1.0] - 2021-12-02
|
|
442
478
|
|
|
@@ -499,4 +535,22 @@ Person::Struct.new
|
|
|
499
535
|
# => NoMethodError (private method `new' called for Person::Struct:Class)
|
|
500
536
|
```
|
|
501
537
|
|
|
502
|
-
|
|
538
|
+
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
539
|
+
|
|
540
|
+
[Unreleased]: https://github.com/u-gems/u-struct/compare/v2.0.0...HEAD
|
|
541
|
+
[2.0.0]: https://github.com/u-gems/u-struct/compare/v1.1.0...v2.0.0
|
|
542
|
+
[1.1.0]: https://github.com/u-gems/u-struct/compare/v1.0.0...v1.1.0
|
|
543
|
+
[1.0.0]: https://github.com/u-gems/u-struct/compare/v0.12.0...v1.0.0
|
|
544
|
+
[0.12.0]: https://github.com/u-gems/u-struct/compare/v0.11.0...v0.12.0
|
|
545
|
+
[0.11.0]: https://github.com/u-gems/u-struct/compare/v0.10.0...v0.11.0
|
|
546
|
+
[0.10.0]: https://github.com/u-gems/u-struct/compare/v0.9.0...v0.10.0
|
|
547
|
+
[0.9.0]: https://github.com/u-gems/u-struct/compare/v0.8.0...v0.9.0
|
|
548
|
+
[0.8.0]: https://github.com/u-gems/u-struct/compare/v0.7.0...v0.8.0
|
|
549
|
+
[0.7.0]: https://github.com/u-gems/u-struct/compare/v0.6.0...v0.7.0
|
|
550
|
+
[0.6.0]: https://github.com/u-gems/u-struct/compare/v0.5.0...v0.6.0
|
|
551
|
+
[0.5.0]: https://github.com/u-gems/u-struct/compare/v0.4.0...v0.5.0
|
|
552
|
+
[0.4.0]: https://github.com/u-gems/u-struct/compare/v0.3.1...v0.4.0
|
|
553
|
+
[0.3.1]: https://github.com/u-gems/u-struct/compare/v0.3.0...v0.3.1
|
|
554
|
+
[0.3.0]: https://github.com/u-gems/u-struct/compare/v0.2.0...v0.3.0
|
|
555
|
+
[0.2.0]: https://github.com/u-gems/u-struct/compare/v0.1.0...v0.2.0
|
|
556
|
+
[0.1.0]: https://github.com/u-gems/u-struct/releases/tag/v0.1.0
|