rich_enums 0.1.4 → 0.2.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 +6 -3
- data/.ruby-version +1 -1
- data/Gemfile +0 -3
- data/Gemfile.lock +50 -33
- data/README.md +2 -0
- data/gemfiles/activerecord_7.0.gemfile +0 -2
- data/gemfiles/activerecord_7.0.gemfile.lock +93 -0
- data/gemfiles/activerecord_7.1.gemfile +0 -2
- data/gemfiles/activerecord_7.1.gemfile.lock +78 -0
- data/gemfiles/{activerecord_6.1.gemfile → activerecord_7.2.gemfile} +1 -3
- data/gemfiles/activerecord_7.2.gemfile.lock +78 -0
- data/gemfiles/activerecord_8.0.gemfile +6 -0
- data/gemfiles/activerecord_8.0.gemfile.lock +95 -0
- data/lib/rich_enums/version.rb +1 -1
- data/lib/rich_enums.rb +24 -7
- data/rich_enums.gemspec +6 -2
- data/test_all_rails.sh +20 -0
- metadata +64 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16505db690aa1a16bd6573da210fd040948b1c1e1ecf2ecd6c400b37d98ca4d6
|
4
|
+
data.tar.gz: e150b4031bafd3a95c2960fca5e2a25978634e158681358e5582948ef3192b4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4355b36ad9dfef90b1e97d5db2c16c237370f0f93a61e65edc54c79f73136f31658d5dd0df8948f8d63b32a2d8ec997e16cb6f7cd6a9e8f6fab22b17457f5fef
|
7
|
+
data.tar.gz: a2ef558581aab6ec3ac2fde660df56d4ec967e56b00a68d15f16348f3b9009f0e65a45cfaf8c8f0249a70bcaef4dc38334659d230d4827144cc3f07e5e930a3b
|
data/.github/workflows/ci.yml
CHANGED
@@ -3,6 +3,7 @@ env:
|
|
3
3
|
|
4
4
|
name: RichEnums CI
|
5
5
|
on:
|
6
|
+
workflow_dispatch:
|
6
7
|
pull_request:
|
7
8
|
paths-ignore:
|
8
9
|
- .gitignore
|
@@ -23,14 +24,16 @@ jobs:
|
|
23
24
|
strategy:
|
24
25
|
matrix:
|
25
26
|
include:
|
27
|
+
- ruby: '3.4'
|
28
|
+
rails: '8.0'
|
29
|
+
- ruby: '3.3'
|
30
|
+
rails: '7.2'
|
26
31
|
- ruby: '3.2'
|
27
32
|
rails: '7.1'
|
28
33
|
- ruby: '3.2'
|
29
34
|
rails: '7.0'
|
30
|
-
- ruby: '3.2'
|
31
|
-
rails: '6.1'
|
32
35
|
- ruby: '3.1'
|
33
|
-
rails: '
|
36
|
+
rails: '7.0'
|
34
37
|
env:
|
35
38
|
BUNDLE_GEMFILE: gemfiles/activerecord_${{ matrix.rails }}.gemfile
|
36
39
|
steps:
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,60 +1,77 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rich_enums (0.
|
5
|
-
activerecord (>=
|
4
|
+
rich_enums (0.2.0)
|
5
|
+
activerecord (>= 7.0, < 9.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (
|
11
|
-
activesupport (=
|
12
|
-
activerecord (
|
13
|
-
activemodel (=
|
14
|
-
activesupport (=
|
15
|
-
|
16
|
-
|
10
|
+
activemodel (8.0.2)
|
11
|
+
activesupport (= 8.0.2)
|
12
|
+
activerecord (8.0.2)
|
13
|
+
activemodel (= 8.0.2)
|
14
|
+
activesupport (= 8.0.2)
|
15
|
+
timeout (>= 0.4.0)
|
16
|
+
activesupport (8.0.2)
|
17
|
+
base64
|
18
|
+
benchmark (>= 0.3)
|
19
|
+
bigdecimal
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
21
|
+
connection_pool (>= 2.2.5)
|
22
|
+
drb
|
17
23
|
i18n (>= 1.6, < 2)
|
24
|
+
logger (>= 1.4.2)
|
18
25
|
minitest (>= 5.1)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
securerandom (>= 0.3)
|
27
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
28
|
+
uri (>= 0.13.1)
|
29
|
+
base64 (0.2.0)
|
30
|
+
benchmark (0.4.0)
|
31
|
+
bigdecimal (3.1.9)
|
32
|
+
concurrent-ruby (1.3.5)
|
33
|
+
connection_pool (2.5.0)
|
34
|
+
diff-lcs (1.6.0)
|
35
|
+
drb (2.2.1)
|
36
|
+
i18n (1.14.7)
|
24
37
|
concurrent-ruby (~> 1.0)
|
25
|
-
|
26
|
-
|
38
|
+
logger (1.6.6)
|
39
|
+
mini_portile2 (2.8.8)
|
40
|
+
minitest (5.25.5)
|
27
41
|
rake (12.3.3)
|
28
|
-
rspec (3.
|
29
|
-
rspec-core (~> 3.
|
30
|
-
rspec-expectations (~> 3.
|
31
|
-
rspec-mocks (~> 3.
|
32
|
-
rspec-core (3.
|
33
|
-
rspec-support (~> 3.
|
34
|
-
rspec-expectations (3.
|
42
|
+
rspec (3.13.0)
|
43
|
+
rspec-core (~> 3.13.0)
|
44
|
+
rspec-expectations (~> 3.13.0)
|
45
|
+
rspec-mocks (~> 3.13.0)
|
46
|
+
rspec-core (3.13.3)
|
47
|
+
rspec-support (~> 3.13.0)
|
48
|
+
rspec-expectations (3.13.3)
|
35
49
|
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
-
rspec-support (~> 3.
|
37
|
-
rspec-mocks (3.
|
50
|
+
rspec-support (~> 3.13.0)
|
51
|
+
rspec-mocks (3.13.2)
|
38
52
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
-
rspec-support (~> 3.
|
40
|
-
rspec-support (3.
|
41
|
-
|
53
|
+
rspec-support (~> 3.13.0)
|
54
|
+
rspec-support (3.13.2)
|
55
|
+
securerandom (0.4.1)
|
56
|
+
sqlite3 (2.6.0)
|
42
57
|
mini_portile2 (~> 2.8.0)
|
43
|
-
temping (4.
|
44
|
-
activerecord (>= 6.0, <
|
45
|
-
activesupport (>= 6.0, <
|
58
|
+
temping (4.3.0)
|
59
|
+
activerecord (>= 6.0, < 8.1)
|
60
|
+
activesupport (>= 6.0, < 8.1)
|
61
|
+
timeout (0.4.3)
|
46
62
|
tzinfo (2.0.6)
|
47
63
|
concurrent-ruby (~> 1.0)
|
48
|
-
|
64
|
+
uri (1.0.3)
|
49
65
|
|
50
66
|
PLATFORMS
|
51
67
|
ruby
|
52
68
|
|
53
69
|
DEPENDENCIES
|
70
|
+
logger (~> 1.6)
|
54
71
|
rake (~> 12.0)
|
55
72
|
rich_enums!
|
56
73
|
rspec (~> 3.0)
|
57
|
-
sqlite3 (
|
74
|
+
sqlite3 (>= 1.4, < 3.0)
|
58
75
|
temping (~> 4.1)
|
59
76
|
|
60
77
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -17,6 +17,7 @@ user.role_code # => 'ROLE001'
|
|
17
17
|
user.role_for_database # => 1
|
18
18
|
User.roles # => {"admin"=>1, "user"=>2}
|
19
19
|
User.role_codes # => {"admin"=>"ROLE001", "user"=>"ROLE101"}
|
20
|
+
User.role_alt_name_to_ids # => {"ROLE001"=>1, "ROLE101"=>2}
|
20
21
|
|
21
22
|
```
|
22
23
|
|
@@ -61,6 +62,7 @@ user.role_alt_name # => 'ROLE001'
|
|
61
62
|
user.role_for_database # => 1
|
62
63
|
User.roles # => {"admin"=>1, "user"=>2}
|
63
64
|
User.role_alt_names # => {"admin"=>"ROLE001", "user"=>"ROLE101"}
|
65
|
+
User.role_alt_name_to_ids # => {"ROLE001"=>1, "ROLE101"=>2}
|
64
66
|
ExternalSystem.sync(user.external_id, role_code: user.role_alt_name)
|
65
67
|
```
|
66
68
|
Any arguments other than 'alt' are forwarded to the default enum definition.
|
@@ -0,0 +1,93 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
rich_enums (0.2.0)
|
5
|
+
activerecord (>= 7.0, < 9.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (7.2.2.1)
|
11
|
+
activesupport (= 7.2.2.1)
|
12
|
+
activerecord (7.2.2.1)
|
13
|
+
activemodel (= 7.2.2.1)
|
14
|
+
activesupport (= 7.2.2.1)
|
15
|
+
timeout (>= 0.4.0)
|
16
|
+
activesupport (7.2.2.1)
|
17
|
+
base64
|
18
|
+
benchmark (>= 0.3)
|
19
|
+
bigdecimal
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
21
|
+
connection_pool (>= 2.2.5)
|
22
|
+
drb
|
23
|
+
i18n (>= 1.6, < 2)
|
24
|
+
logger (>= 1.4.2)
|
25
|
+
minitest (>= 5.1)
|
26
|
+
securerandom (>= 0.3)
|
27
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
28
|
+
base64 (0.2.0)
|
29
|
+
benchmark (0.4.0)
|
30
|
+
bigdecimal (3.1.9)
|
31
|
+
concurrent-ruby (1.3.5)
|
32
|
+
connection_pool (2.5.0)
|
33
|
+
diff-lcs (1.6.0)
|
34
|
+
drb (2.2.1)
|
35
|
+
i18n (1.14.7)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
logger (1.6.6)
|
38
|
+
minitest (5.25.5)
|
39
|
+
rake (12.3.3)
|
40
|
+
rspec (3.13.0)
|
41
|
+
rspec-core (~> 3.13.0)
|
42
|
+
rspec-expectations (~> 3.13.0)
|
43
|
+
rspec-mocks (~> 3.13.0)
|
44
|
+
rspec-core (3.13.3)
|
45
|
+
rspec-support (~> 3.13.0)
|
46
|
+
rspec-expectations (3.13.3)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.13.0)
|
49
|
+
rspec-mocks (3.13.2)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.13.0)
|
52
|
+
rspec-support (3.13.2)
|
53
|
+
securerandom (0.4.1)
|
54
|
+
sqlite3 (2.6.0-aarch64-linux-gnu)
|
55
|
+
sqlite3 (2.6.0-aarch64-linux-musl)
|
56
|
+
sqlite3 (2.6.0-arm-linux-gnu)
|
57
|
+
sqlite3 (2.6.0-arm-linux-musl)
|
58
|
+
sqlite3 (2.6.0-arm64-darwin)
|
59
|
+
sqlite3 (2.6.0-x86-linux-gnu)
|
60
|
+
sqlite3 (2.6.0-x86-linux-musl)
|
61
|
+
sqlite3 (2.6.0-x86_64-darwin)
|
62
|
+
sqlite3 (2.6.0-x86_64-linux-gnu)
|
63
|
+
sqlite3 (2.6.0-x86_64-linux-musl)
|
64
|
+
temping (4.3.0)
|
65
|
+
activerecord (>= 6.0, < 8.1)
|
66
|
+
activesupport (>= 6.0, < 8.1)
|
67
|
+
timeout (0.4.3)
|
68
|
+
tzinfo (2.0.6)
|
69
|
+
concurrent-ruby (~> 1.0)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
aarch64-linux-gnu
|
73
|
+
aarch64-linux-musl
|
74
|
+
arm-linux-gnu
|
75
|
+
arm-linux-musl
|
76
|
+
arm64-darwin
|
77
|
+
x86-linux-gnu
|
78
|
+
x86-linux-musl
|
79
|
+
x86_64-darwin
|
80
|
+
x86_64-linux-gnu
|
81
|
+
x86_64-linux-musl
|
82
|
+
|
83
|
+
DEPENDENCIES
|
84
|
+
activerecord (~> 7.0)
|
85
|
+
logger (~> 1.6)
|
86
|
+
rake (~> 12.0)
|
87
|
+
rich_enums!
|
88
|
+
rspec (~> 3.0)
|
89
|
+
sqlite3 (>= 1.4, < 3.0)
|
90
|
+
temping (~> 4.1)
|
91
|
+
|
92
|
+
BUNDLED WITH
|
93
|
+
2.6.5
|
@@ -0,0 +1,78 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
rich_enums (0.2.0)
|
5
|
+
activerecord (>= 7.0, < 9.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (7.2.2.1)
|
11
|
+
activesupport (= 7.2.2.1)
|
12
|
+
activerecord (7.2.2.1)
|
13
|
+
activemodel (= 7.2.2.1)
|
14
|
+
activesupport (= 7.2.2.1)
|
15
|
+
timeout (>= 0.4.0)
|
16
|
+
activesupport (7.2.2.1)
|
17
|
+
base64
|
18
|
+
benchmark (>= 0.3)
|
19
|
+
bigdecimal
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
21
|
+
connection_pool (>= 2.2.5)
|
22
|
+
drb
|
23
|
+
i18n (>= 1.6, < 2)
|
24
|
+
logger (>= 1.4.2)
|
25
|
+
minitest (>= 5.1)
|
26
|
+
securerandom (>= 0.3)
|
27
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
28
|
+
base64 (0.2.0)
|
29
|
+
benchmark (0.4.0)
|
30
|
+
bigdecimal (3.1.9)
|
31
|
+
concurrent-ruby (1.3.5)
|
32
|
+
connection_pool (2.5.0)
|
33
|
+
diff-lcs (1.6.0)
|
34
|
+
drb (2.2.1)
|
35
|
+
i18n (1.14.7)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
logger (1.6.6)
|
38
|
+
minitest (5.25.5)
|
39
|
+
rake (12.3.3)
|
40
|
+
rspec (3.13.0)
|
41
|
+
rspec-core (~> 3.13.0)
|
42
|
+
rspec-expectations (~> 3.13.0)
|
43
|
+
rspec-mocks (~> 3.13.0)
|
44
|
+
rspec-core (3.13.3)
|
45
|
+
rspec-support (~> 3.13.0)
|
46
|
+
rspec-expectations (3.13.3)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.13.0)
|
49
|
+
rspec-mocks (3.13.2)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.13.0)
|
52
|
+
rspec-support (3.13.2)
|
53
|
+
securerandom (0.4.1)
|
54
|
+
sqlite3 (2.6.0-arm64-darwin)
|
55
|
+
sqlite3 (2.6.0-x86_64-darwin)
|
56
|
+
temping (4.3.0)
|
57
|
+
activerecord (>= 6.0, < 8.1)
|
58
|
+
activesupport (>= 6.0, < 8.1)
|
59
|
+
timeout (0.4.3)
|
60
|
+
tzinfo (2.0.6)
|
61
|
+
concurrent-ruby (~> 1.0)
|
62
|
+
|
63
|
+
PLATFORMS
|
64
|
+
arm64-darwin-23
|
65
|
+
arm64-darwin-24
|
66
|
+
x86_64-darwin-21
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
activerecord (~> 7.1)
|
70
|
+
logger (~> 1.6)
|
71
|
+
rake (~> 12.0)
|
72
|
+
rich_enums!
|
73
|
+
rspec (~> 3.0)
|
74
|
+
sqlite3 (>= 1.4, < 3.0)
|
75
|
+
temping (~> 4.1)
|
76
|
+
|
77
|
+
BUNDLED WITH
|
78
|
+
2.5.16
|
@@ -0,0 +1,78 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
rich_enums (0.2.0)
|
5
|
+
activerecord (>= 7.0, < 9.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (7.2.2.1)
|
11
|
+
activesupport (= 7.2.2.1)
|
12
|
+
activerecord (7.2.2.1)
|
13
|
+
activemodel (= 7.2.2.1)
|
14
|
+
activesupport (= 7.2.2.1)
|
15
|
+
timeout (>= 0.4.0)
|
16
|
+
activesupport (7.2.2.1)
|
17
|
+
base64
|
18
|
+
benchmark (>= 0.3)
|
19
|
+
bigdecimal
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
21
|
+
connection_pool (>= 2.2.5)
|
22
|
+
drb
|
23
|
+
i18n (>= 1.6, < 2)
|
24
|
+
logger (>= 1.4.2)
|
25
|
+
minitest (>= 5.1)
|
26
|
+
securerandom (>= 0.3)
|
27
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
28
|
+
base64 (0.2.0)
|
29
|
+
benchmark (0.4.0)
|
30
|
+
bigdecimal (3.1.9)
|
31
|
+
concurrent-ruby (1.3.5)
|
32
|
+
connection_pool (2.5.0)
|
33
|
+
diff-lcs (1.6.0)
|
34
|
+
drb (2.2.1)
|
35
|
+
i18n (1.14.7)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
logger (1.6.6)
|
38
|
+
minitest (5.25.5)
|
39
|
+
rake (12.3.3)
|
40
|
+
rspec (3.13.0)
|
41
|
+
rspec-core (~> 3.13.0)
|
42
|
+
rspec-expectations (~> 3.13.0)
|
43
|
+
rspec-mocks (~> 3.13.0)
|
44
|
+
rspec-core (3.13.3)
|
45
|
+
rspec-support (~> 3.13.0)
|
46
|
+
rspec-expectations (3.13.3)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.13.0)
|
49
|
+
rspec-mocks (3.13.2)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.13.0)
|
52
|
+
rspec-support (3.13.2)
|
53
|
+
securerandom (0.4.1)
|
54
|
+
sqlite3 (2.6.0-arm64-darwin)
|
55
|
+
sqlite3 (2.6.0-x86_64-darwin)
|
56
|
+
temping (4.3.0)
|
57
|
+
activerecord (>= 6.0, < 8.1)
|
58
|
+
activesupport (>= 6.0, < 8.1)
|
59
|
+
timeout (0.4.3)
|
60
|
+
tzinfo (2.0.6)
|
61
|
+
concurrent-ruby (~> 1.0)
|
62
|
+
|
63
|
+
PLATFORMS
|
64
|
+
arm64-darwin-23
|
65
|
+
arm64-darwin-24
|
66
|
+
x86_64-darwin-21
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
activerecord (~> 7.2)
|
70
|
+
logger (~> 1.6)
|
71
|
+
rake (~> 12.0)
|
72
|
+
rich_enums!
|
73
|
+
rspec (~> 3.0)
|
74
|
+
sqlite3 (>= 1.4, < 3.0)
|
75
|
+
temping (~> 4.1)
|
76
|
+
|
77
|
+
BUNDLED WITH
|
78
|
+
2.5.16
|
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
rich_enums (0.2.0)
|
5
|
+
activerecord (>= 7.0, < 9.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (8.0.2)
|
11
|
+
activesupport (= 8.0.2)
|
12
|
+
activerecord (8.0.2)
|
13
|
+
activemodel (= 8.0.2)
|
14
|
+
activesupport (= 8.0.2)
|
15
|
+
timeout (>= 0.4.0)
|
16
|
+
activesupport (8.0.2)
|
17
|
+
base64
|
18
|
+
benchmark (>= 0.3)
|
19
|
+
bigdecimal
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
21
|
+
connection_pool (>= 2.2.5)
|
22
|
+
drb
|
23
|
+
i18n (>= 1.6, < 2)
|
24
|
+
logger (>= 1.4.2)
|
25
|
+
minitest (>= 5.1)
|
26
|
+
securerandom (>= 0.3)
|
27
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
28
|
+
uri (>= 0.13.1)
|
29
|
+
base64 (0.2.0)
|
30
|
+
benchmark (0.4.0)
|
31
|
+
bigdecimal (3.1.9)
|
32
|
+
concurrent-ruby (1.3.5)
|
33
|
+
connection_pool (2.5.0)
|
34
|
+
diff-lcs (1.6.0)
|
35
|
+
drb (2.2.1)
|
36
|
+
i18n (1.14.7)
|
37
|
+
concurrent-ruby (~> 1.0)
|
38
|
+
logger (1.6.6)
|
39
|
+
minitest (5.25.5)
|
40
|
+
rake (12.3.3)
|
41
|
+
rspec (3.13.0)
|
42
|
+
rspec-core (~> 3.13.0)
|
43
|
+
rspec-expectations (~> 3.13.0)
|
44
|
+
rspec-mocks (~> 3.13.0)
|
45
|
+
rspec-core (3.13.3)
|
46
|
+
rspec-support (~> 3.13.0)
|
47
|
+
rspec-expectations (3.13.3)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.13.0)
|
50
|
+
rspec-mocks (3.13.2)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.13.0)
|
53
|
+
rspec-support (3.13.2)
|
54
|
+
securerandom (0.4.1)
|
55
|
+
sqlite3 (2.6.0-aarch64-linux-gnu)
|
56
|
+
sqlite3 (2.6.0-aarch64-linux-musl)
|
57
|
+
sqlite3 (2.6.0-arm-linux-gnu)
|
58
|
+
sqlite3 (2.6.0-arm-linux-musl)
|
59
|
+
sqlite3 (2.6.0-arm64-darwin)
|
60
|
+
sqlite3 (2.6.0-x86-linux-gnu)
|
61
|
+
sqlite3 (2.6.0-x86-linux-musl)
|
62
|
+
sqlite3 (2.6.0-x86_64-darwin)
|
63
|
+
sqlite3 (2.6.0-x86_64-linux-gnu)
|
64
|
+
sqlite3 (2.6.0-x86_64-linux-musl)
|
65
|
+
temping (4.3.0)
|
66
|
+
activerecord (>= 6.0, < 8.1)
|
67
|
+
activesupport (>= 6.0, < 8.1)
|
68
|
+
timeout (0.4.3)
|
69
|
+
tzinfo (2.0.6)
|
70
|
+
concurrent-ruby (~> 1.0)
|
71
|
+
uri (1.0.3)
|
72
|
+
|
73
|
+
PLATFORMS
|
74
|
+
aarch64-linux-gnu
|
75
|
+
aarch64-linux-musl
|
76
|
+
arm-linux-gnu
|
77
|
+
arm-linux-musl
|
78
|
+
arm64-darwin
|
79
|
+
x86-linux-gnu
|
80
|
+
x86-linux-musl
|
81
|
+
x86_64-darwin
|
82
|
+
x86_64-linux-gnu
|
83
|
+
x86_64-linux-musl
|
84
|
+
|
85
|
+
DEPENDENCIES
|
86
|
+
activerecord (~> 8.0)
|
87
|
+
logger (~> 1.6)
|
88
|
+
rake (~> 12.0)
|
89
|
+
rich_enums!
|
90
|
+
rspec (~> 3.0)
|
91
|
+
sqlite3 (>= 1.4, < 3.0)
|
92
|
+
temping (~> 4.1)
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
2.6.5
|
data/lib/rich_enums/version.rb
CHANGED
data/lib/rich_enums.rb
CHANGED
@@ -15,6 +15,8 @@ module RichEnums
|
|
15
15
|
# and
|
16
16
|
# 2. Class method "column1_names" that will map the enum values to the full String description
|
17
17
|
# and can be accessed by ClassName.<column>_names which will return a hash like { symbol1: string1, symbol2: string2 ...}
|
18
|
+
# 3. Class method "column1_alt_name_to_ids" will map the enum values the string values and can
|
19
|
+
# be accessed by ClassName.<column>_alt_name_to_ids which will return a hash like { string1: value1, string2: value2 ...}
|
18
20
|
# e.g.
|
19
21
|
# class Enrollment
|
20
22
|
# include RichEnums
|
@@ -31,6 +33,9 @@ module RichEnums
|
|
31
33
|
# Calling learner_payment_path_names returns
|
32
34
|
# {"greenfig_online"=>"GreenFig Online", "partner"=>"Partner", "partner_online"=>"Partner Online",
|
33
35
|
# "po_check"=>"P.O. / Check", "other"=>"Other"}
|
36
|
+
# iii. a class method called learner_payment_path_alt_name_to_ids
|
37
|
+
# Calling learner_payment_path_alt_name_to_ids returns
|
38
|
+
# {"GreenFig Online"=>10, "Partner"=>20, "Partner Online"=>30, "P.O. / Check"=>40, "Other"=>100}
|
34
39
|
# 3. Instance method "column1_name" will return the String associated with the enum value
|
35
40
|
# e = Enrollment.new
|
36
41
|
# e.learner_payment_path_po_check! -> normal enum method to update the object with enum value
|
@@ -57,21 +62,33 @@ module RichEnums
|
|
57
62
|
options = column_symbol_value_string_options
|
58
63
|
# we allow for an option called alt: to allow the users to tag the alternate mapping. Defaults to 'alt_name'
|
59
64
|
alt = options.delete(:alt).to_s || 'alt_name'
|
65
|
+
alt_map_method = 'alt_name_to_ids'
|
60
66
|
|
61
67
|
# create two hashes from the provided input - 1 to be used to define the enum and the other for the name map
|
62
|
-
split_hash = symbol_value_string.each_with_object({ for_enum: {}, for_display: {} }) do |(symbol, value_string), obj|
|
63
|
-
|
64
|
-
|
68
|
+
split_hash = symbol_value_string.each_with_object({ for_enum: {}, for_display: {}, for_filter: {} }) do |(symbol, value_string), obj|
|
69
|
+
value = value_string.is_a?(Array) ? value_string.first : value_string
|
70
|
+
display_string = value_string.is_a?(Array) ? value_string.second : symbol.to_s
|
71
|
+
|
72
|
+
obj[:for_enum][symbol] = value
|
73
|
+
obj[:for_display][symbol.to_s] = display_string
|
74
|
+
obj[:for_filter][display_string] = value
|
65
75
|
end
|
66
76
|
|
67
77
|
# 1. Define the Enum
|
68
|
-
|
78
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.2')
|
79
|
+
enum column, split_hash[:for_enum], **options
|
80
|
+
else
|
81
|
+
enum "#{column}": split_hash[:for_enum], **options
|
82
|
+
end
|
69
83
|
|
70
|
-
# 2. Define our custom class
|
71
|
-
# - the data to be returned by our custom
|
84
|
+
# 2. Define our custom class methods
|
85
|
+
# - the data to be returned by our custom methods is available as a class instance variable
|
72
86
|
instance_variable_set("@#{column}_#{alt.pluralize}", split_hash[:for_display])
|
73
|
-
#
|
87
|
+
instance_variable_set("@#{column}_#{alt_map_method}", split_hash[:for_filter])
|
88
|
+
|
89
|
+
# - the custom methods are just a getter for the class instance variables
|
74
90
|
define_singleton_method("#{column}_#{alt.pluralize}") { instance_variable_get("@#{column}_#{alt.pluralize}") }
|
91
|
+
define_singleton_method("#{column}_#{alt_map_method}") { instance_variable_get("@#{column}_#{alt_map_method}") }
|
75
92
|
|
76
93
|
# 3. Define our custom instance method to show the String associated with the enum value
|
77
94
|
define_method("#{column}_#{alt}") { self.class.send("#{column}_#{alt.pluralize}")[send(column.to_s)] }
|
data/rich_enums.gemspec
CHANGED
@@ -22,9 +22,13 @@ DESC
|
|
22
22
|
spec.metadata['source_code_uri'] = 'https://github.com/betacraft/rich_enums'
|
23
23
|
spec.metadata['changelog_uri'] = 'https://github.com/betacraft/rich_enums/README.md'
|
24
24
|
|
25
|
-
spec.add_development_dependency 'sqlite3', '
|
25
|
+
spec.add_development_dependency 'sqlite3', '>= 1.4', '< 3.0'
|
26
26
|
spec.add_development_dependency 'temping', '~> 4.1'
|
27
|
-
spec.
|
27
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'logger', '~> 1.6'
|
30
|
+
spec.add_runtime_dependency 'activerecord', '>= 7.0', '< 9.0'
|
31
|
+
|
28
32
|
# Specify which files should be added to the gem when it is released.
|
29
33
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
34
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
data/test_all_rails.sh
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Array of Rails versions to test
|
4
|
+
RAILS_VERSIONS=("7.0" "7.1" "7.2" "8.0")
|
5
|
+
|
6
|
+
# Function to run tests for a specific Rails version
|
7
|
+
run_tests() {
|
8
|
+
local rails_version="$1"
|
9
|
+
echo "\n=== Testing with Rails $rails_version ==="
|
10
|
+
export BUNDLE_GEMFILE="gemfiles/activerecord_${rails_version}.gemfile"
|
11
|
+
bundle install --quiet
|
12
|
+
bundle exec rspec
|
13
|
+
echo "\n=== Done with Rails $rails_version ==="
|
14
|
+
echo "===================================\n"
|
15
|
+
}
|
16
|
+
|
17
|
+
# Run tests for each Rails version
|
18
|
+
for rails_version in "${RAILS_VERSIONS[@]}"; do
|
19
|
+
run_tests "$rails_version"
|
20
|
+
done
|
metadata
CHANGED
@@ -1,30 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rich_enums
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- harunkumars
|
8
8
|
- rtdp
|
9
|
-
autorequire:
|
10
9
|
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2025-03-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: sqlite3
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
|
-
- - "
|
17
|
+
- - ">="
|
19
18
|
- !ruby/object:Gem::Version
|
20
19
|
version: '1.4'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
21
23
|
type: :development
|
22
24
|
prerelease: false
|
23
25
|
version_requirements: !ruby/object:Gem::Requirement
|
24
26
|
requirements:
|
25
|
-
- - "
|
27
|
+
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
27
29
|
version: '1.4'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
28
33
|
- !ruby/object:Gem::Dependency
|
29
34
|
name: temping
|
30
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,26 +44,68 @@ dependencies:
|
|
39
44
|
- - "~>"
|
40
45
|
- !ruby/object:Gem::Version
|
41
46
|
version: '4.1'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '12.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '12.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: logger
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.6'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.6'
|
42
89
|
- !ruby/object:Gem::Dependency
|
43
90
|
name: activerecord
|
44
91
|
requirement: !ruby/object:Gem::Requirement
|
45
92
|
requirements:
|
46
93
|
- - ">="
|
47
94
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
95
|
+
version: '7.0'
|
49
96
|
- - "<"
|
50
97
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
98
|
+
version: '9.0'
|
52
99
|
type: :runtime
|
53
100
|
prerelease: false
|
54
101
|
version_requirements: !ruby/object:Gem::Requirement
|
55
102
|
requirements:
|
56
103
|
- - ">="
|
57
104
|
- !ruby/object:Gem::Version
|
58
|
-
version: '
|
105
|
+
version: '7.0'
|
59
106
|
- - "<"
|
60
107
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
108
|
+
version: '9.0'
|
62
109
|
description: "With Enums we are able to map a label to a value on the database. \nUse
|
63
110
|
Rich Enum if you need to maintain an additional mapping at the point of enum definition,
|
64
111
|
\nfor e.g. for presentation purposes or for mapping to a different value on a different
|
@@ -83,12 +130,18 @@ files:
|
|
83
130
|
- Rakefile
|
84
131
|
- bin/console
|
85
132
|
- bin/setup
|
86
|
-
- gemfiles/activerecord_6.1.gemfile
|
87
133
|
- gemfiles/activerecord_7.0.gemfile
|
134
|
+
- gemfiles/activerecord_7.0.gemfile.lock
|
88
135
|
- gemfiles/activerecord_7.1.gemfile
|
136
|
+
- gemfiles/activerecord_7.1.gemfile.lock
|
137
|
+
- gemfiles/activerecord_7.2.gemfile
|
138
|
+
- gemfiles/activerecord_7.2.gemfile.lock
|
139
|
+
- gemfiles/activerecord_8.0.gemfile
|
140
|
+
- gemfiles/activerecord_8.0.gemfile.lock
|
89
141
|
- lib/rich_enums.rb
|
90
142
|
- lib/rich_enums/version.rb
|
91
143
|
- rich_enums.gemspec
|
144
|
+
- test_all_rails.sh
|
92
145
|
homepage: https://github.com/betacraft/rich_enums
|
93
146
|
licenses:
|
94
147
|
- MIT
|
@@ -97,7 +150,6 @@ metadata:
|
|
97
150
|
homepage_uri: https://github.com/betacraft/rich_enums
|
98
151
|
source_code_uri: https://github.com/betacraft/rich_enums
|
99
152
|
changelog_uri: https://github.com/betacraft/rich_enums/README.md
|
100
|
-
post_install_message:
|
101
153
|
rdoc_options: []
|
102
154
|
require_paths:
|
103
155
|
- lib
|
@@ -112,8 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
164
|
- !ruby/object:Gem::Version
|
113
165
|
version: '0'
|
114
166
|
requirements: []
|
115
|
-
rubygems_version: 3.5
|
116
|
-
signing_key:
|
167
|
+
rubygems_version: 3.6.5
|
117
168
|
specification_version: 4
|
118
169
|
summary: When a simple name to value mapping is not enough
|
119
170
|
test_files: []
|