u-struct 1.1.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 +8 -0
- data/.tool-versions +1 -1
- data/Appraisals +84 -0
- data/CHANGELOG.md +34 -68
- data/CLAUDE.md +144 -0
- data/Gemfile +14 -8
- data/README.md +23 -12
- data/Rakefile +30 -0
- data/bin/matrix +16 -0
- data/bin/setup +4 -0
- data/lib/micro/struct/version.rb +1 -1
- data/u-struct.gemspec +6 -6
- metadata +26 -14
- data/.vscode/settings.json +0 -8
- data/bin/prepare_coverage +0 -25
- data/bin/run_ci +0 -17
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
CHANGED
|
@@ -18,6 +18,14 @@ require:
|
|
|
18
18
|
AllCops:
|
|
19
19
|
NewCops: enable
|
|
20
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
|
|
21
29
|
|
|
22
30
|
# == Gemspec ==
|
|
23
31
|
|
data/.tool-versions
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby 3.
|
|
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,57 +2,32 @@
|
|
|
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
|
-
- [[1.1.0] - 2021-03-23](#110---2021-03-23)
|
|
10
|
-
- [Added](#added)
|
|
11
|
-
- [[1.0.0] - 2021-01-19](#100---2021-01-19)
|
|
12
|
-
- [[0.12.0] - 2021-12-22](#0120---2021-12-22)
|
|
13
|
-
- [Added](#added-1)
|
|
14
|
-
- [[0.11.0] - 2021-12-19](#0110---2021-12-19)
|
|
15
|
-
- [Added](#added-2)
|
|
16
|
-
- [[0.10.0] - 2021-12-15](#0100---2021-12-15)
|
|
17
|
-
- [Changed](#changed)
|
|
18
|
-
- [[0.9.0] - 2021-12-14](#090---2021-12-14)
|
|
19
|
-
- [Added](#added-3)
|
|
20
|
-
- [Changed](#changed-1)
|
|
21
|
-
- [[0.8.0] - 2021-12-05](#080---2021-12-05)
|
|
22
|
-
- [Added](#added-4)
|
|
23
|
-
- [[0.7.0] - 2021-12-04](#070---2021-12-04)
|
|
24
|
-
- [Added](#added-5)
|
|
25
|
-
- [Changed](#changed-2)
|
|
26
|
-
- [[0.6.0] - 2021-12-03](#060---2021-12-03)
|
|
27
|
-
- [Added](#added-6)
|
|
28
|
-
- [[0.5.0] - 2021-12-02](#050---2021-12-02)
|
|
29
|
-
- [Added](#added-7)
|
|
30
|
-
- [[0.4.0] - 2021-12-02](#040---2021-12-02)
|
|
31
|
-
- [Added](#added-8)
|
|
32
|
-
- [[0.3.1] - 2021-12-02](#031---2021-12-02)
|
|
33
|
-
- [Fixed](#fixed)
|
|
34
|
-
- [[0.3.0] - 2021-12-02](#030---2021-12-02)
|
|
35
|
-
- [Added](#added-9)
|
|
36
|
-
- [[0.2.0] - 2021-12-02](#020---2021-12-02)
|
|
37
|
-
- [Added](#added-10)
|
|
38
|
-
- [[0.1.0] - 2021-12-02](#010---2021-12-02)
|
|
39
|
-
- [Added](#added-11)
|
|
40
8
|
## [Unreleased]
|
|
41
9
|
|
|
42
|
-
[
|
|
10
|
+
## [2.0.0] - 2026-06-01
|
|
43
11
|
|
|
44
|
-
|
|
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
|
|
45
19
|
|
|
46
|
-
[Diff](https://github.com/serradura/u-struct/compare/v1.0.0...v1.1.0) | [Tag](https://github.com/serradura/u-struct/tree/v1.1.0)
|
|
47
20
|
### Added
|
|
48
21
|
|
|
49
22
|
- Add `Micro::Struct[]` as an alias of `Micro::Struct.with`.
|
|
23
|
+
|
|
50
24
|
```ruby
|
|
51
25
|
Micro::Struct[:readonly] # is the same as Micro::Struct.with(:readonly)
|
|
52
26
|
```
|
|
53
27
|
|
|
54
28
|
- Add `Micro::Struct.immutable` method as a shortcut to `Micro::Struct.with(:readonly, :instance_copy)`.
|
|
55
29
|
It also accepts the `with:` option, which can be used to define additional features.
|
|
30
|
+
|
|
56
31
|
```ruby
|
|
57
32
|
Micro::Struct.immutable.new(:name)
|
|
58
33
|
|
|
@@ -73,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
73
48
|
|
|
74
49
|
- Add `Micro::Struct.readonly` method as a shortcut to `Micro::Struct.with(:readonly)`.
|
|
75
50
|
It has the same properties of `Micro::Struct.immutable`.
|
|
51
|
+
|
|
76
52
|
```ruby
|
|
77
53
|
Micro::Struct.readonly.new(:name)
|
|
78
54
|
|
|
@@ -90,18 +66,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
90
66
|
|
|
91
67
|
Micro::Struct.readonly(with: [:to_hash]).instance(name: 'Serradura')
|
|
92
68
|
```
|
|
93
|
-
|
|
69
|
+
|
|
70
|
+
**Development stuff**
|
|
94
71
|
|
|
95
72
|
- Set up Rubocop.
|
|
96
73
|
- Add `.rbi` files, and set up sorbet to be used in development.
|
|
97
74
|
|
|
98
75
|
<p align="right">(<a href="#changelog-">⬆️ back to top</a>)</p>
|
|
99
76
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
## [1.0.0] - 2021-01-19
|
|
103
|
-
|
|
104
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.12.0...v1.0.0) | [Tag](https://github.com/serradura/u-struct/tree/v1.0.0)
|
|
77
|
+
## [1.0.0] - 2022-01-20
|
|
105
78
|
|
|
106
79
|
- Review and update docs and examples. ;)
|
|
107
80
|
|
|
@@ -109,8 +82,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
109
82
|
|
|
110
83
|
## [0.12.0] - 2021-12-22
|
|
111
84
|
|
|
112
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.11.0...v0.12.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.12.0)
|
|
113
|
-
|
|
114
85
|
### Added
|
|
115
86
|
|
|
116
87
|
- Add `Micro::Struct.instance` to create a struct instance from a given hash.
|
|
@@ -134,6 +105,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
134
105
|
person2.first_name = 'John'
|
|
135
106
|
# NoMethodError (private method `first_name=' called for #<struct first_name="Rodrigo", last_name="Serradura">)
|
|
136
107
|
```
|
|
108
|
+
|
|
137
109
|
You can use pass a block to define some custom behavior to the struct instance.
|
|
138
110
|
|
|
139
111
|
```ruby
|
|
@@ -183,8 +155,6 @@ Person.features.options?(:to_ary, :readonly) # => false
|
|
|
183
155
|
|
|
184
156
|
## [0.11.0] - 2021-12-19
|
|
185
157
|
|
|
186
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.10.0...v0.11.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.11.0)
|
|
187
|
-
|
|
188
158
|
### Added
|
|
189
159
|
|
|
190
160
|
- Reduce the required Ruby version to `>= 2.2.0`.
|
|
@@ -195,8 +165,6 @@ Person.features.options?(:to_ary, :readonly) # => false
|
|
|
195
165
|
|
|
196
166
|
## [0.10.0] - 2021-12-15
|
|
197
167
|
|
|
198
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.9.0...v0.10.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.10.0)
|
|
199
|
-
|
|
200
168
|
### Changed
|
|
201
169
|
|
|
202
170
|
- Make `Micro::Struct.new` return a Ruby struct instead of a module.
|
|
@@ -231,8 +199,6 @@ rgb_color.to_hex
|
|
|
231
199
|
|
|
232
200
|
## [0.9.0] - 2021-12-14
|
|
233
201
|
|
|
234
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.8.0...v0.9.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.9.0)
|
|
235
|
-
|
|
236
202
|
### Added
|
|
237
203
|
|
|
238
204
|
- Add `__new__` method and make `.new` its alias. You can use `__new__` when overwriting the module's `new`.
|
|
@@ -322,8 +288,6 @@ rgb_color.to_hash # => {:r=>1, :g=>5, :b=>255}
|
|
|
322
288
|
|
|
323
289
|
## [0.8.0] - 2021-12-05
|
|
324
290
|
|
|
325
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.7.0...v0.8.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.8.0)
|
|
326
|
-
|
|
327
291
|
### Added
|
|
328
292
|
|
|
329
293
|
- Add `.===` to the module, it delegates the calling to its struct.
|
|
@@ -342,8 +306,6 @@ Person === person
|
|
|
342
306
|
|
|
343
307
|
## [0.7.0] - 2021-12-04
|
|
344
308
|
|
|
345
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.6.0...v0.7.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.7.0)
|
|
346
|
-
|
|
347
309
|
### Added
|
|
348
310
|
|
|
349
311
|
- Add `required:` option to define required struct members.
|
|
@@ -373,8 +335,6 @@ Person = Micro::Struct.new(
|
|
|
373
335
|
|
|
374
336
|
## [0.6.0] - 2021-12-03
|
|
375
337
|
|
|
376
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.5.0...v0.6.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.6.0)
|
|
377
|
-
|
|
378
338
|
### Added
|
|
379
339
|
|
|
380
340
|
- Add the capability to create a struct with optional members.
|
|
@@ -400,8 +360,6 @@ Persona.new
|
|
|
400
360
|
|
|
401
361
|
## [0.5.0] - 2021-12-02
|
|
402
362
|
|
|
403
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.4.0...v0.5.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.5.0)
|
|
404
|
-
|
|
405
363
|
### Added
|
|
406
364
|
|
|
407
365
|
- Add new feature `:instance_copy`. It instantiates a struct of the same kind from its current state.
|
|
@@ -453,8 +411,6 @@ new_person.name # => "John Doe"
|
|
|
453
411
|
|
|
454
412
|
## [0.4.0] - 2021-12-02
|
|
455
413
|
|
|
456
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.3.1...v0.4.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.4.0)
|
|
457
|
-
|
|
458
414
|
### Added
|
|
459
415
|
|
|
460
416
|
- Add `.members` to the module, it delegates the calling to its struct.
|
|
@@ -484,8 +440,6 @@ Person.respond_to?(:to_proc) # => false
|
|
|
484
440
|
|
|
485
441
|
## [0.3.1] - 2021-12-02
|
|
486
442
|
|
|
487
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.3.0...v0.3.1) | [Tag](https://github.com/serradura/u-struct/tree/v0.3.1)
|
|
488
|
-
|
|
489
443
|
### Fixed
|
|
490
444
|
|
|
491
445
|
- Fix the spec.files config of `u-struct.gemspec`.
|
|
@@ -494,8 +448,6 @@ Person.respond_to?(:to_proc) # => false
|
|
|
494
448
|
|
|
495
449
|
## [0.3.0] - 2021-12-02
|
|
496
450
|
|
|
497
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.2.0...v0.3.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.3.0)
|
|
498
|
-
|
|
499
451
|
### Added
|
|
500
452
|
|
|
501
453
|
- Add `lib/u-struct.rb` to allow the bundler to require the gem in an automatic way.
|
|
@@ -504,8 +456,6 @@ Person.respond_to?(:to_proc) # => false
|
|
|
504
456
|
|
|
505
457
|
## [0.2.0] - 2021-12-02
|
|
506
458
|
|
|
507
|
-
[Diff](https://github.com/serradura/u-struct/compare/v0.1.0...v0.2.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.2.0)
|
|
508
|
-
|
|
509
459
|
### Added
|
|
510
460
|
|
|
511
461
|
- Add `to_hash` as an alias of Struct's `to_h`.
|
|
@@ -526,8 +476,6 @@ print_first_and_last_name(**person) # Rodrigo Serradura
|
|
|
526
476
|
|
|
527
477
|
## [0.1.0] - 2021-12-02
|
|
528
478
|
|
|
529
|
-
[Diff](https://github.com/serradura/u-struct/compare/19beceb97a9bc22f2a485b82e4002b6a2e20a73c...v0.1.0) | [Tag](https://github.com/serradura/u-struct/tree/v0.1.0)
|
|
530
|
-
|
|
531
479
|
### Added
|
|
532
480
|
|
|
533
481
|
- Create a module containing a Ruby struct with some custom features.
|
|
@@ -588,3 +536,21 @@ Person::Struct.new
|
|
|
588
536
|
```
|
|
589
537
|
|
|
590
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
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
Notes for AI assistants working in `u-struct`.
|
|
4
|
+
|
|
5
|
+
## Golden rule: maintenance mode — no new features, no breaking changes
|
|
6
|
+
|
|
7
|
+
`u-struct` was created as an alternative to Ruby's native `Data`, which now
|
|
8
|
+
ships with Ruby (3.2+). The gem is therefore considered unnecessary going
|
|
9
|
+
forward and is kept **only to support existing applications**. There are **no
|
|
10
|
+
plans to add new features** — new code should prefer native `Data`.
|
|
11
|
+
|
|
12
|
+
The public API is **frozen**: every change must keep existing code working.
|
|
13
|
+
Major version bumps are reserved for dependency-floor changes (dropping a Ruby
|
|
14
|
+
or Rails version from the supported matrix) per SemVer — they do **not** signal
|
|
15
|
+
a behavior break.
|
|
16
|
+
|
|
17
|
+
So scope work to bug/compatibility fixes and supported-matrix upkeep. If a task
|
|
18
|
+
as stated would add a feature or require a breaking change, stop and surface
|
|
19
|
+
that — suggest native `Data` for new capabilities, or propose a backward-
|
|
20
|
+
compatible path. Don't ship the break or the feature creep.
|
|
21
|
+
|
|
22
|
+
## How to work in this repo
|
|
23
|
+
|
|
24
|
+
### 1. Think before coding
|
|
25
|
+
|
|
26
|
+
**Don't assume. Don't hide confusion. Surface tradeoffs.**
|
|
27
|
+
|
|
28
|
+
- State assumptions explicitly. If uncertain, ask.
|
|
29
|
+
- If multiple interpretations exist, present them — don't pick silently.
|
|
30
|
+
- If a simpler approach exists, say so. Push back when warranted.
|
|
31
|
+
- If something is unclear, stop. Name what's confusing. Ask.
|
|
32
|
+
|
|
33
|
+
### 2. Simplicity first
|
|
34
|
+
|
|
35
|
+
**Minimum code that solves the problem. Nothing speculative.**
|
|
36
|
+
|
|
37
|
+
- No features beyond what was asked.
|
|
38
|
+
- No abstractions for single-use code.
|
|
39
|
+
- No "flexibility" or "configurability" that wasn't requested.
|
|
40
|
+
- No error handling for impossible scenarios.
|
|
41
|
+
- If you write 200 lines and it could be 50, rewrite it.
|
|
42
|
+
|
|
43
|
+
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes,
|
|
44
|
+
simplify.
|
|
45
|
+
|
|
46
|
+
### 3. Surgical changes
|
|
47
|
+
|
|
48
|
+
**Touch only what you must. Clean up only your own mess.**
|
|
49
|
+
|
|
50
|
+
- Don't "improve" adjacent code, comments, or formatting.
|
|
51
|
+
- Don't refactor things that aren't broken.
|
|
52
|
+
- Match existing style, even if you'd do it differently.
|
|
53
|
+
- If you notice unrelated dead code, mention it — don't delete it.
|
|
54
|
+
- Remove imports/variables/functions that _your_ changes orphaned. Don't
|
|
55
|
+
remove pre-existing dead code unless asked.
|
|
56
|
+
|
|
57
|
+
The test: every changed line should trace directly to the user's request.
|
|
58
|
+
|
|
59
|
+
### 4. Goal-driven execution
|
|
60
|
+
|
|
61
|
+
**Define success criteria. Loop until verified.**
|
|
62
|
+
|
|
63
|
+
Turn vague tasks into verifiable goals:
|
|
64
|
+
|
|
65
|
+
- "Add validation" → "Write tests for invalid inputs, then make them pass"
|
|
66
|
+
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
|
|
67
|
+
- "Refactor X" → "Ensure tests pass before and after"
|
|
68
|
+
|
|
69
|
+
For multi-step work, state a brief plan with a verification check per step.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## What this is
|
|
74
|
+
|
|
75
|
+
`u-struct` is a zero-runtime-dependency Ruby gem for building "powered" Structs.
|
|
76
|
+
The public surface lives under `lib/micro/struct/` and is exposed through
|
|
77
|
+
`Micro::Struct`:
|
|
78
|
+
|
|
79
|
+
- `Micro::Struct.new(...)` — like `Struct`, but members are **required** by
|
|
80
|
+
default; `optional:` / `required:` tune that, and a block adds custom methods.
|
|
81
|
+
- `Micro::Struct.with(*features)` — opt into behaviors before `.new`:
|
|
82
|
+
`:to_ary`, `:to_hash`, `:to_proc`, `:readonly`, `:instance_copy`,
|
|
83
|
+
`:exposed_features`.
|
|
84
|
+
- `Micro::Struct[...]` and `Micro::Struct.instance` — shorthand builders.
|
|
85
|
+
|
|
86
|
+
Internals: `factory/` (`create_struct`, `members`) assembles the Struct,
|
|
87
|
+
`features.rb` implements the opt-in behaviors, `normalize_names.rb` handles
|
|
88
|
+
member-name coercion. The umbrella `require 'u-struct'` loads everything;
|
|
89
|
+
`Micro::Struct::VERSION` lives in `lib/micro/struct/version.rb`.
|
|
90
|
+
|
|
91
|
+
The gem has **no ActiveModel/ActiveRecord dependency** and touches no Rails
|
|
92
|
+
code. The ActiveModel appraisals (see below) exist only to guarantee `u-struct`
|
|
93
|
+
loads and behaves correctly inside Rails apps across the supported range — they
|
|
94
|
+
are a compatibility smoke test, not coverage of Rails-specific behavior.
|
|
95
|
+
|
|
96
|
+
## Running tests
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
bundle exec rake test # default suite, current bundle (no activemodel)
|
|
100
|
+
bundle exec appraisal <name> rake test # one ActiveModel appraisal (see Appraisals)
|
|
101
|
+
bundle exec rake matrix # baseline + every ActiveModel appraisal for the active Ruby
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`bin/setup` reinstalls and refreshes appraisals; `bin/matrix` reinstalls then
|
|
105
|
+
runs `rake matrix`. CI runs the matrix across the full Ruby × ActiveModel grid
|
|
106
|
+
(Ruby 2.7 → head, ActiveModel 6.0 → 8.1 + edge), and additionally runs
|
|
107
|
+
**RuboCop** and **Sorbet** (`srb tc`) on Ruby 3.1 — keep both green:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
bundle exec rubocop # Ruby 3.1 toolchain (pinned in the Gemfile)
|
|
111
|
+
bundle exec srb tc # type-check; sources are `# typed:`-annotated
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Tests are the success criterion for any behavior change — write or update a
|
|
115
|
+
test first, then make it pass (rule 4).
|
|
116
|
+
|
|
117
|
+
## CHANGELOG and README are part of every change
|
|
118
|
+
|
|
119
|
+
Both files are user-facing — keep them in sync with the code:
|
|
120
|
+
|
|
121
|
+
- **`CHANGELOG.md`**: follows [Keep a Changelog](https://keepachangelog.com/).
|
|
122
|
+
Every user-visible change (new API, behavior change, breaking change, dep
|
|
123
|
+
bump that shifts the supported matrix, security fix) gets a bullet under the
|
|
124
|
+
appropriate section (`Added` / `Changed` / `Deprecated` / `Removed` /
|
|
125
|
+
`Fixed` / `Security`) of the `[Unreleased]` block. Pure README/CI/internal-
|
|
126
|
+
refactor changes generally don't need an entry.
|
|
127
|
+
- **`README.md`**: the Ruby/Rails badges at the top encode the supported
|
|
128
|
+
matrix, and the **Usage** section documents the public API. Update the badges
|
|
129
|
+
when the supported bounds move, and update the relevant Usage subsection in
|
|
130
|
+
the same commit when you change a documented API.
|
|
131
|
+
|
|
132
|
+
## Bumping the version
|
|
133
|
+
|
|
134
|
+
1. Edit `lib/micro/struct/version.rb` — change `Micro::Struct::VERSION`. Follow
|
|
135
|
+
[SemVer](https://semver.org/): patch for fixes, minor for additive
|
|
136
|
+
user-visible changes, major for breaking changes.
|
|
137
|
+
2. Add a new entry at the top of `CHANGELOG.md` (`## [X.Y.Z] - YYYY-MM-DD`)
|
|
138
|
+
with a matching `[Diff]`/compare link, and move the `[Unreleased]` items
|
|
139
|
+
into it.
|
|
140
|
+
3. If the supported matrix moved, double-check that the README Ruby/Rails
|
|
141
|
+
badges, the Ruby × Rails CI matrix (`.github/workflows/ci.yml`), and the
|
|
142
|
+
`Appraisals` file all reflect the new bounds.
|
|
143
|
+
|
|
144
|
+
Don't tag, push, or `gem release` — humans do that.
|
data/Gemfile
CHANGED
|
@@ -2,21 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
source 'https://rubygems.org'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
|
+
|
|
7
|
+
# Specify your gem's dependencies in u-struct.gemspec
|
|
6
8
|
gemspec
|
|
7
9
|
|
|
8
|
-
gem 'rake', '13.0
|
|
10
|
+
gem 'rake', '~> 13.0'
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
group :test do
|
|
13
|
+
gem 'minitest', '~> 5.0'
|
|
14
|
+
gem 'ostruct', '~> 0.6.3' if RUBY_VERSION >= '3.5'
|
|
15
|
+
gem 'simplecov', '~> 0.22.0', require: false
|
|
16
|
+
end
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
# Linting and type-checking run only on Ruby 3.1 (pinned toolchain); see
|
|
19
|
+
# .github/workflows/ci.yml. The pins are gated to that series so they never
|
|
20
|
+
# break `bundle install` on the rest of the Ruby matrix.
|
|
21
|
+
if RUBY_VERSION >= '3.1.0' && RUBY_VERSION < '3.2.0'
|
|
13
22
|
gem 'rubocop', '1.26'
|
|
14
23
|
gem 'rubocop-minitest', '0.18.0'
|
|
15
24
|
gem 'rubocop-rake', '0.6.0'
|
|
16
|
-
gem 'simplecov', '0.21.2'
|
|
17
|
-
end
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
gem 'sorbet', '0.5.9775'
|
|
26
|
+
gem 'sorbet', '0.5.9775'
|
|
21
27
|
gem 'tapioca', '0.7.0'
|
|
22
28
|
end
|
data/README.md
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<h1 align="center">🧱 μ-struct</h1>
|
|
3
3
|
<p align="center"><i>Create powered Ruby structs.</i></p>
|
|
4
|
-
<br>
|
|
5
4
|
</p>
|
|
6
5
|
|
|
7
6
|
<p align="center">
|
|
8
|
-
<img src="https://img.shields.io/badge/ruby%20%3E=%202.2,%20%3C%203.2-ruby.svg?colorA=99004d&colorB=cc0066" alt="Ruby">
|
|
9
7
|
<a href="https://rubygems.org/gems/u-struct">
|
|
10
8
|
<img alt="Gem" src="https://img.shields.io/gem/v/u-struct.svg?style=flat-square">
|
|
11
9
|
</a>
|
|
12
|
-
<a href="https://github.com/
|
|
13
|
-
<img alt="Build Status" src="https://github.com/
|
|
14
|
-
</a>
|
|
15
|
-
<a href="https://codeclimate.com/github/serradura/u-struct/maintainability">
|
|
16
|
-
<img alt="Maintainability" src="https://api.codeclimate.com/v1/badges/2cc0204411cc2b392b7a/maintainability">
|
|
17
|
-
</a>
|
|
18
|
-
<a href="https://codeclimate.com/github/serradura/u-struct/test_coverage">
|
|
19
|
-
<img alt="Test Coverage" src="https://api.codeclimate.com/v1/badges/2cc0204411cc2b392b7a/test_coverage">
|
|
10
|
+
<a href="https://github.com/u-gems/u-struct/actions/workflows/ci.yml">
|
|
11
|
+
<img alt="Build Status" src="https://github.com/u-gems/u-struct/actions/workflows/ci.yml/badge.svg">
|
|
20
12
|
</a>
|
|
13
|
+
<br/>
|
|
14
|
+
<a href="https://qlty.sh/gh/u-gems/projects/u-struct"><img src="https://qlty.sh/gh/u-gems/projects/u-struct/maintainability.svg" alt="Maintainability" /></a>
|
|
15
|
+
<a href="https://qlty.sh/gh/u-gems/projects/u-struct"><img src="https://qlty.sh/gh/u-gems/projects/u-struct/coverage.svg" alt="Code Coverage" /></a>
|
|
16
|
+
<br/>
|
|
17
|
+
<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">
|
|
18
|
+
<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">
|
|
21
19
|
</p>
|
|
22
20
|
|
|
21
|
+
> [!IMPORTANT]
|
|
22
|
+
> **No breaking API changes — ever.** `u-struct`'s public API is frozen: every release stays backward-compatible, so code that builds on it keeps working.
|
|
23
|
+
>
|
|
24
|
+
> Major version bumps signal only that a Ruby or Rails version was dropped from the supported matrix — per SemVer, a dependency-floor change. Your code keeps working.
|
|
25
|
+
>
|
|
26
|
+
> **Maintenance mode.** Ruby 3.2+ ships a native [`Data`](https://docs.ruby-lang.org/en/3.2/Data.html) type that covers this gem's use case; `u-struct` is kept only to support existing apps and gets no new features. New code should prefer `Data`.
|
|
27
|
+
|
|
23
28
|
# Table of contents: <!-- omit in toc -->
|
|
29
|
+
|
|
24
30
|
- [Introduction](#introduction)
|
|
25
31
|
- [Motivation](#motivation)
|
|
26
32
|
- [Installation](#installation)
|
|
@@ -289,6 +295,7 @@ person.name # "Rodrigo Serradura"
|
|
|
289
295
|
This method can do two things: first, it can create `Struct` factories; second, it sets some special behavior to their structs.
|
|
290
296
|
|
|
291
297
|
These are all of the available features which you can use (pick one, many, or all of them):
|
|
298
|
+
|
|
292
299
|
- [`:to_ary`](#to_ary)
|
|
293
300
|
- [`:to_hash`](#to_hash)
|
|
294
301
|
- [`:to_proc`](#to_proc)
|
|
@@ -334,6 +341,7 @@ new_person.class == person.class
|
|
|
334
341
|
### `Micro::Struct[]`
|
|
335
342
|
|
|
336
343
|
The `[]` brackets method is as an alias of `Micro::Struct.with`. e.g.
|
|
344
|
+
|
|
337
345
|
```ruby
|
|
338
346
|
Micro::Struct[:readonly, :to_hash] # is the same as Micro::Struct.with(:readonly, :to_hash)
|
|
339
347
|
```
|
|
@@ -531,6 +539,7 @@ This method is as a shortcut to `Micro::Struct.with(:readonly, :instance_copy)`.
|
|
|
531
539
|
As it is quite common to see the usage of these two features, I decided to create this method to improve the DX.
|
|
532
540
|
|
|
533
541
|
Additional info:
|
|
542
|
+
|
|
534
543
|
1. It accepts the `with:` option, which can be used to define additional features.
|
|
535
544
|
2. The `.instance` method can be called after its usage.
|
|
536
545
|
|
|
@@ -561,6 +570,7 @@ Micro::Struct.immutable(with: [:to_hash]).instance(name: 'Serradura')
|
|
|
561
570
|
This method is as a shortcut to `Micro::Struct.with(:readonly)`.
|
|
562
571
|
|
|
563
572
|
Additional info:
|
|
573
|
+
|
|
564
574
|
1. It accepts the `with:` option, which can be used to define additional features.
|
|
565
575
|
2. The `.instance` method can be called after its usage.
|
|
566
576
|
|
|
@@ -743,6 +753,7 @@ RGBColor.new(red: 1, green: -1, blue: 255)
|
|
|
743
753
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
744
754
|
|
|
745
755
|
Additional tools:
|
|
756
|
+
|
|
746
757
|
- Sorbet (type checker): `bundle exec srb tc` (requires `Ruby >= 2.7`).
|
|
747
758
|
- Rubocop (linter and code formatter): `bundle rubocop` (requires `Ruby >= 2.5`).
|
|
748
759
|
|
|
@@ -752,7 +763,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
752
763
|
|
|
753
764
|
## Contributing
|
|
754
765
|
|
|
755
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
766
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/u-gems/u-struct. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/u-gems/u-struct/blob/main/CODE_OF_CONDUCT.md).
|
|
756
767
|
|
|
757
768
|
<p align="right">(<a href="#table-of-contents-">⬆️ back to top</a>)</p>
|
|
758
769
|
|
|
@@ -764,7 +775,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
764
775
|
|
|
765
776
|
## Code of Conduct
|
|
766
777
|
|
|
767
|
-
Everyone interacting in the `Micro::Struct` project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
|
778
|
+
Everyone interacting in the `Micro::Struct` project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/u-gems/u-struct/blob/main/CODE_OF_CONDUCT.md).
|
|
768
779
|
|
|
769
780
|
<p align="right">(<a href="#table-of-contents-">⬆️ back to top</a>)</p>
|
|
770
781
|
|
data/Rakefile
CHANGED
|
@@ -9,4 +9,34 @@ Rake::TestTask.new(:test) do |t|
|
|
|
9
9
|
t.test_files = FileList['test/**/*_test.rb']
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
require 'appraisal/task'
|
|
13
|
+
|
|
14
|
+
Appraisal::Task.new
|
|
15
|
+
|
|
16
|
+
desc 'Run the full test suite against every supported Rails version'
|
|
17
|
+
task :matrix do
|
|
18
|
+
appraisals =
|
|
19
|
+
if RUBY_VERSION < '3.1'
|
|
20
|
+
%w[rails-6-0 rails-6-1 rails-7-0 rails-7-1]
|
|
21
|
+
elsif RUBY_VERSION < '3.2'
|
|
22
|
+
%w[rails-7-0 rails-7-1 rails-7-2]
|
|
23
|
+
elsif RUBY_VERSION < '3.3'
|
|
24
|
+
%w[rails-7-0 rails-7-1 rails-7-2 rails-8-0]
|
|
25
|
+
elsif RUBY_VERSION < '3.4'
|
|
26
|
+
%w[rails-7-0 rails-7-1 rails-7-2 rails-8-0 rails-8-1 rails-edge]
|
|
27
|
+
elsif RUBY_VERSION < '4.0'
|
|
28
|
+
%w[rails-7-2 rails-8-0 rails-8-1 rails-edge]
|
|
29
|
+
else
|
|
30
|
+
%w[rails-8-1 rails-edge]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Baseline (no activemodel)
|
|
34
|
+
sh 'bundle exec rake test'
|
|
35
|
+
|
|
36
|
+
# Each activemodel appraisal
|
|
37
|
+
appraisals.each do |appraisal|
|
|
38
|
+
sh "bundle exec appraisal #{appraisal} rake test"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
12
42
|
task default: :test
|
data/bin/matrix
ADDED
data/bin/setup
CHANGED
data/lib/micro/struct/version.rb
CHANGED
data/u-struct.gemspec
CHANGED
|
@@ -10,13 +10,14 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
|
|
11
11
|
spec.summary = 'Create powered Ruby structs.'
|
|
12
12
|
spec.description = 'Create powered Ruby structs.'
|
|
13
|
-
spec.homepage = 'https://github.com/
|
|
13
|
+
spec.homepage = 'https://github.com/u-gems/u-struct'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
|
-
spec.required_ruby_version = '>= 2.
|
|
15
|
+
spec.required_ruby_version = '>= 2.7.0'
|
|
16
16
|
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
-
spec.metadata['source_code_uri'] = 'https://github.com/
|
|
19
|
-
spec.metadata['changelog_uri'] = 'https://github.com/
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/u-gems/u-struct'
|
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/u-gems/u-struct/blob/main/CHANGELOG.md'
|
|
20
|
+
spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
|
|
20
21
|
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
@@ -27,10 +28,9 @@ Gem::Specification.new do |spec|
|
|
|
27
28
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
28
29
|
spec.require_paths = ['lib']
|
|
29
30
|
|
|
30
|
-
# Uncomment to register a new dependency of your gem
|
|
31
|
-
|
|
32
31
|
# For more information and examples about making a new gem, checkout our
|
|
33
32
|
# guide at: https://bundler.io/guides/creating_gem.html
|
|
33
|
+
spec.add_development_dependency 'appraisal', '~> 2.5'
|
|
34
34
|
spec.add_development_dependency 'bundler'
|
|
35
35
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
36
36
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: u-struct
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.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:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
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'
|
|
13
26
|
- !ruby/object:Gem::Dependency
|
|
14
27
|
name: bundler
|
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -50,16 +63,16 @@ files:
|
|
|
50
63
|
- ".rubocop.yml"
|
|
51
64
|
- ".rubocop_todo.yml"
|
|
52
65
|
- ".tool-versions"
|
|
53
|
-
-
|
|
66
|
+
- Appraisals
|
|
54
67
|
- CHANGELOG.md
|
|
68
|
+
- CLAUDE.md
|
|
55
69
|
- CODE_OF_CONDUCT.md
|
|
56
70
|
- Gemfile
|
|
57
71
|
- LICENSE.txt
|
|
58
72
|
- README.md
|
|
59
73
|
- Rakefile
|
|
60
74
|
- bin/console
|
|
61
|
-
- bin/
|
|
62
|
-
- bin/run_ci
|
|
75
|
+
- bin/matrix
|
|
63
76
|
- bin/setup
|
|
64
77
|
- bin/tapioca
|
|
65
78
|
- examples/person_1.rb
|
|
@@ -108,14 +121,14 @@ files:
|
|
|
108
121
|
- sorbet/tapioca/config.yml
|
|
109
122
|
- sorbet/tapioca/require.rb
|
|
110
123
|
- u-struct.gemspec
|
|
111
|
-
homepage: https://github.com/
|
|
124
|
+
homepage: https://github.com/u-gems/u-struct
|
|
112
125
|
licenses:
|
|
113
126
|
- MIT
|
|
114
127
|
metadata:
|
|
115
|
-
homepage_uri: https://github.com/
|
|
116
|
-
source_code_uri: https://github.com/
|
|
117
|
-
changelog_uri: https://github.com/
|
|
118
|
-
|
|
128
|
+
homepage_uri: https://github.com/u-gems/u-struct
|
|
129
|
+
source_code_uri: https://github.com/u-gems/u-struct
|
|
130
|
+
changelog_uri: https://github.com/u-gems/u-struct/blob/main/CHANGELOG.md
|
|
131
|
+
bug_tracker_uri: https://github.com/u-gems/u-struct/issues
|
|
119
132
|
rdoc_options: []
|
|
120
133
|
require_paths:
|
|
121
134
|
- lib
|
|
@@ -123,15 +136,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
123
136
|
requirements:
|
|
124
137
|
- - ">="
|
|
125
138
|
- !ruby/object:Gem::Version
|
|
126
|
-
version: 2.
|
|
139
|
+
version: 2.7.0
|
|
127
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
141
|
requirements:
|
|
129
142
|
- - ">="
|
|
130
143
|
- !ruby/object:Gem::Version
|
|
131
144
|
version: '0'
|
|
132
145
|
requirements: []
|
|
133
|
-
rubygems_version:
|
|
134
|
-
signing_key:
|
|
146
|
+
rubygems_version: 4.0.12
|
|
135
147
|
specification_version: 4
|
|
136
148
|
summary: Create powered Ruby structs.
|
|
137
149
|
test_files: []
|
data/.vscode/settings.json
DELETED
data/bin/prepare_coverage
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
# Borrowed from https://gist.github.com/qortex/7e7c49f3731391a91ee898336183acef
|
|
5
|
-
|
|
6
|
-
# Temporary hack to get CodeClimate to work with SimpleCov 0.18 JSON format until issue is fixed
|
|
7
|
-
# upstream: https://github.com/codeclimate/test-reporter/issues/413
|
|
8
|
-
|
|
9
|
-
require 'json'
|
|
10
|
-
|
|
11
|
-
filename = 'coverage/.resultset.json'
|
|
12
|
-
contents = JSON.parse(File.read(filename))
|
|
13
|
-
|
|
14
|
-
def remove_lines_key(obj)
|
|
15
|
-
return obj unless obj.is_a?(Hash)
|
|
16
|
-
|
|
17
|
-
obj.transform_values do |val|
|
|
18
|
-
val.is_a?(Hash) && val.key?('lines') ? val['lines'] : remove_lines_key(val)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# overwrite
|
|
23
|
-
File.write(filename, JSON.generate(remove_lines_key(contents)))
|
|
24
|
-
|
|
25
|
-
puts Dir['coverage/.*.json']
|
data/bin/run_ci
DELETED