human_enum 0.1.3 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,176 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ human_enum (1.1.2)
5
+ activerecord (>= 6.1, < 8)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (6.1.7.7)
11
+ activesupport (= 6.1.7.7)
12
+ activerecord (6.1.7.7)
13
+ activemodel (= 6.1.7.7)
14
+ activesupport (= 6.1.7.7)
15
+ activesupport (6.1.7.7)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ zeitwerk (~> 2.3)
21
+ ast (2.4.2)
22
+ base64 (0.1.2)
23
+ coderay (1.1.3)
24
+ concurrent-ruby (1.3.4)
25
+ diff-lcs (1.5.1)
26
+ docile (1.4.1)
27
+ ffi (1.16.3)
28
+ formatador (1.1.0)
29
+ guard (2.19.0)
30
+ formatador (>= 0.2.4)
31
+ listen (>= 2.7, < 4.0)
32
+ lumberjack (>= 1.0.12, < 2.0)
33
+ nenv (~> 0.1)
34
+ notiffany (~> 0.0)
35
+ pry (>= 0.13.0)
36
+ shellany (~> 0.0)
37
+ thor (>= 0.18.1)
38
+ guard-compat (1.2.1)
39
+ guard-rspec (4.7.3)
40
+ guard (~> 2.1)
41
+ guard-compat (~> 1.1)
42
+ rspec (>= 2.99.0, < 4.0)
43
+ guard-rubocop (1.5.0)
44
+ guard (~> 2.0)
45
+ rubocop (< 2.0)
46
+ i18n (1.14.6)
47
+ concurrent-ruby (~> 1.0)
48
+ json (2.7.4)
49
+ language_server-protocol (3.17.0.3)
50
+ listen (3.9.0)
51
+ rb-fsevent (~> 0.10, >= 0.10.3)
52
+ rb-inotify (~> 0.9, >= 0.9.10)
53
+ logger (1.6.1)
54
+ lumberjack (1.2.10)
55
+ method_source (1.1.0)
56
+ minitest (5.25.1)
57
+ nenv (0.3.0)
58
+ notiffany (0.1.3)
59
+ nenv (~> 0.1)
60
+ shellany (~> 0.0)
61
+ parallel (1.26.3)
62
+ parser (3.3.5.0)
63
+ ast (~> 2.4.1)
64
+ racc
65
+ prism (1.2.0)
66
+ pry (0.14.2)
67
+ coderay (~> 1.1)
68
+ method_source (~> 1.0)
69
+ racc (1.8.1)
70
+ rack (3.1.8)
71
+ rainbow (3.1.1)
72
+ rake (13.2.1)
73
+ rb-fsevent (0.11.2)
74
+ rb-inotify (0.11.1)
75
+ ffi (~> 1.0)
76
+ rbs (3.6.1)
77
+ logger
78
+ regexp_parser (2.9.2)
79
+ rexml (3.3.9)
80
+ rspec (3.13.0)
81
+ rspec-core (~> 3.13.0)
82
+ rspec-expectations (~> 3.13.0)
83
+ rspec-mocks (~> 3.13.0)
84
+ rspec-core (3.13.2)
85
+ rspec-support (~> 3.13.0)
86
+ rspec-expectations (3.13.3)
87
+ diff-lcs (>= 1.2.0, < 2.0)
88
+ rspec-support (~> 3.13.0)
89
+ rspec-mocks (3.13.2)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.13.0)
92
+ rspec-support (3.13.1)
93
+ rubocop (1.56.4)
94
+ base64 (~> 0.1.1)
95
+ json (~> 2.3)
96
+ language_server-protocol (>= 3.17.0)
97
+ parallel (~> 1.10)
98
+ parser (>= 3.2.2.3)
99
+ rainbow (>= 2.2.2, < 4.0)
100
+ regexp_parser (>= 1.8, < 3.0)
101
+ rexml (>= 3.2.5, < 4.0)
102
+ rubocop-ast (>= 1.28.1, < 2.0)
103
+ ruby-progressbar (~> 1.7)
104
+ unicode-display_width (>= 2.4.0, < 3.0)
105
+ rubocop-ast (1.32.3)
106
+ parser (>= 3.3.1.0)
107
+ rubocop-performance (1.22.1)
108
+ rubocop (>= 1.48.1, < 2.0)
109
+ rubocop-ast (>= 1.31.1, < 2.0)
110
+ rubocop-rails (2.27.0)
111
+ activesupport (>= 4.2.0)
112
+ rack (>= 1.1)
113
+ rubocop (>= 1.52.0, < 2.0)
114
+ rubocop-ast (>= 1.31.1, < 2.0)
115
+ rubocop-rake (0.6.0)
116
+ rubocop (~> 1.0)
117
+ rubocop-rspec (3.0.0)
118
+ rubocop (~> 1.40)
119
+ ruby-lsp (0.20.1)
120
+ language_server-protocol (~> 3.17.0)
121
+ prism (>= 1.2, < 2.0)
122
+ rbs (>= 3, < 4)
123
+ sorbet-runtime (>= 0.5.10782)
124
+ ruby-lsp-rails (0.3.21)
125
+ ruby-lsp (>= 0.20.0, < 0.21.0)
126
+ ruby-lsp-rspec (0.1.17)
127
+ ruby-lsp (~> 0.20.1)
128
+ ruby-progressbar (1.13.0)
129
+ shellany (0.0.1)
130
+ simplecov (0.22.0)
131
+ docile (~> 1.1)
132
+ simplecov-html (~> 0.11)
133
+ simplecov_json_formatter (~> 0.1)
134
+ simplecov-html (0.13.1)
135
+ simplecov_json_formatter (0.1.4)
136
+ sorbet-runtime (0.5.11620)
137
+ sqlite3 (1.7.3-aarch64-linux)
138
+ sqlite3 (1.7.3-arm-linux)
139
+ sqlite3 (1.7.3-arm64-darwin)
140
+ sqlite3 (1.7.3-x86-linux)
141
+ sqlite3 (1.7.3-x86_64-darwin)
142
+ sqlite3 (1.7.3-x86_64-linux)
143
+ thor (1.3.2)
144
+ tzinfo (2.0.6)
145
+ concurrent-ruby (~> 1.0)
146
+ unicode-display_width (2.6.0)
147
+ zeitwerk (2.6.14)
148
+
149
+ PLATFORMS
150
+ aarch64-linux
151
+ arm-linux
152
+ arm64-darwin
153
+ x86-linux
154
+ x86_64-darwin
155
+ x86_64-linux
156
+
157
+ DEPENDENCIES
158
+ activerecord (~> 6.1.0)
159
+ guard (~> 2.18)
160
+ guard-rspec (~> 4.7)
161
+ guard-rubocop (~> 1.5)
162
+ human_enum!
163
+ rake (~> 13.0)
164
+ rspec (~> 3.12)
165
+ rubocop (~> 1.56.3)
166
+ rubocop-performance
167
+ rubocop-rails
168
+ rubocop-rake
169
+ rubocop-rspec
170
+ ruby-lsp-rails
171
+ ruby-lsp-rspec
172
+ simplecov (~> 0.22.0)
173
+ sqlite3 (~> 1.4)
174
+
175
+ BUNDLED WITH
176
+ 2.5.10
@@ -0,0 +1,174 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ human_enum (1.1.2)
5
+ activerecord (>= 6.1, < 8)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (7.0.8.3)
11
+ activesupport (= 7.0.8.3)
12
+ activerecord (7.0.8.3)
13
+ activemodel (= 7.0.8.3)
14
+ activesupport (= 7.0.8.3)
15
+ activesupport (7.0.8.3)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ ast (2.4.2)
21
+ base64 (0.1.2)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.3.4)
24
+ diff-lcs (1.5.1)
25
+ docile (1.4.1)
26
+ ffi (1.16.3)
27
+ formatador (1.1.0)
28
+ guard (2.19.0)
29
+ formatador (>= 0.2.4)
30
+ listen (>= 2.7, < 4.0)
31
+ lumberjack (>= 1.0.12, < 2.0)
32
+ nenv (~> 0.1)
33
+ notiffany (~> 0.0)
34
+ pry (>= 0.13.0)
35
+ shellany (~> 0.0)
36
+ thor (>= 0.18.1)
37
+ guard-compat (1.2.1)
38
+ guard-rspec (4.7.3)
39
+ guard (~> 2.1)
40
+ guard-compat (~> 1.1)
41
+ rspec (>= 2.99.0, < 4.0)
42
+ guard-rubocop (1.5.0)
43
+ guard (~> 2.0)
44
+ rubocop (< 2.0)
45
+ i18n (1.14.6)
46
+ concurrent-ruby (~> 1.0)
47
+ json (2.7.4)
48
+ language_server-protocol (3.17.0.3)
49
+ listen (3.9.0)
50
+ rb-fsevent (~> 0.10, >= 0.10.3)
51
+ rb-inotify (~> 0.9, >= 0.9.10)
52
+ logger (1.6.1)
53
+ lumberjack (1.2.10)
54
+ method_source (1.1.0)
55
+ minitest (5.25.1)
56
+ nenv (0.3.0)
57
+ notiffany (0.1.3)
58
+ nenv (~> 0.1)
59
+ shellany (~> 0.0)
60
+ parallel (1.26.3)
61
+ parser (3.3.5.0)
62
+ ast (~> 2.4.1)
63
+ racc
64
+ prism (1.2.0)
65
+ pry (0.14.2)
66
+ coderay (~> 1.1)
67
+ method_source (~> 1.0)
68
+ racc (1.8.1)
69
+ rack (3.1.8)
70
+ rainbow (3.1.1)
71
+ rake (13.2.1)
72
+ rb-fsevent (0.11.2)
73
+ rb-inotify (0.11.1)
74
+ ffi (~> 1.0)
75
+ rbs (3.6.1)
76
+ logger
77
+ regexp_parser (2.9.2)
78
+ rexml (3.3.9)
79
+ rspec (3.13.0)
80
+ rspec-core (~> 3.13.0)
81
+ rspec-expectations (~> 3.13.0)
82
+ rspec-mocks (~> 3.13.0)
83
+ rspec-core (3.13.2)
84
+ rspec-support (~> 3.13.0)
85
+ rspec-expectations (3.13.3)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.13.0)
88
+ rspec-mocks (3.13.2)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.13.0)
91
+ rspec-support (3.13.1)
92
+ rubocop (1.56.4)
93
+ base64 (~> 0.1.1)
94
+ json (~> 2.3)
95
+ language_server-protocol (>= 3.17.0)
96
+ parallel (~> 1.10)
97
+ parser (>= 3.2.2.3)
98
+ rainbow (>= 2.2.2, < 4.0)
99
+ regexp_parser (>= 1.8, < 3.0)
100
+ rexml (>= 3.2.5, < 4.0)
101
+ rubocop-ast (>= 1.28.1, < 2.0)
102
+ ruby-progressbar (~> 1.7)
103
+ unicode-display_width (>= 2.4.0, < 3.0)
104
+ rubocop-ast (1.32.3)
105
+ parser (>= 3.3.1.0)
106
+ rubocop-performance (1.22.1)
107
+ rubocop (>= 1.48.1, < 2.0)
108
+ rubocop-ast (>= 1.31.1, < 2.0)
109
+ rubocop-rails (2.27.0)
110
+ activesupport (>= 4.2.0)
111
+ rack (>= 1.1)
112
+ rubocop (>= 1.52.0, < 2.0)
113
+ rubocop-ast (>= 1.31.1, < 2.0)
114
+ rubocop-rake (0.6.0)
115
+ rubocop (~> 1.0)
116
+ rubocop-rspec (3.0.0)
117
+ rubocop (~> 1.40)
118
+ ruby-lsp (0.20.1)
119
+ language_server-protocol (~> 3.17.0)
120
+ prism (>= 1.2, < 2.0)
121
+ rbs (>= 3, < 4)
122
+ sorbet-runtime (>= 0.5.10782)
123
+ ruby-lsp-rails (0.3.21)
124
+ ruby-lsp (>= 0.20.0, < 0.21.0)
125
+ ruby-lsp-rspec (0.1.17)
126
+ ruby-lsp (~> 0.20.1)
127
+ ruby-progressbar (1.13.0)
128
+ shellany (0.0.1)
129
+ simplecov (0.22.0)
130
+ docile (~> 1.1)
131
+ simplecov-html (~> 0.11)
132
+ simplecov_json_formatter (~> 0.1)
133
+ simplecov-html (0.13.1)
134
+ simplecov_json_formatter (0.1.4)
135
+ sorbet-runtime (0.5.11620)
136
+ sqlite3 (1.7.3-aarch64-linux)
137
+ sqlite3 (1.7.3-arm-linux)
138
+ sqlite3 (1.7.3-arm64-darwin)
139
+ sqlite3 (1.7.3-x86-linux)
140
+ sqlite3 (1.7.3-x86_64-darwin)
141
+ sqlite3 (1.7.3-x86_64-linux)
142
+ thor (1.3.2)
143
+ tzinfo (2.0.6)
144
+ concurrent-ruby (~> 1.0)
145
+ unicode-display_width (2.6.0)
146
+
147
+ PLATFORMS
148
+ aarch64-linux
149
+ arm-linux
150
+ arm64-darwin
151
+ x86-linux
152
+ x86_64-darwin
153
+ x86_64-linux
154
+
155
+ DEPENDENCIES
156
+ activerecord (~> 7.0.0)
157
+ guard (~> 2.18)
158
+ guard-rspec (~> 4.7)
159
+ guard-rubocop (~> 1.5)
160
+ human_enum!
161
+ rake (~> 13.0)
162
+ rspec (~> 3.12)
163
+ rubocop (~> 1.56.3)
164
+ rubocop-performance
165
+ rubocop-rails
166
+ rubocop-rake
167
+ rubocop-rspec
168
+ ruby-lsp-rails
169
+ ruby-lsp-rspec
170
+ simplecov (~> 0.22.0)
171
+ sqlite3 (~> 1.4)
172
+
173
+ BUNDLED WITH
174
+ 2.5.10
@@ -0,0 +1,185 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ human_enum (1.1.2)
5
+ activerecord (>= 6.1, < 8)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (7.1.4.2)
11
+ activesupport (= 7.1.4.2)
12
+ activerecord (7.1.4.2)
13
+ activemodel (= 7.1.4.2)
14
+ activesupport (= 7.1.4.2)
15
+ timeout (>= 0.4.0)
16
+ activesupport (7.1.4.2)
17
+ base64
18
+ bigdecimal
19
+ concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ connection_pool (>= 2.2.5)
21
+ drb
22
+ i18n (>= 1.6, < 2)
23
+ minitest (>= 5.1)
24
+ mutex_m
25
+ tzinfo (~> 2.0)
26
+ ast (2.4.2)
27
+ base64 (0.1.2)
28
+ bigdecimal (3.1.8)
29
+ coderay (1.1.3)
30
+ concurrent-ruby (1.3.4)
31
+ connection_pool (2.4.1)
32
+ diff-lcs (1.5.1)
33
+ docile (1.4.1)
34
+ drb (2.2.1)
35
+ ffi (1.16.3)
36
+ formatador (1.1.0)
37
+ guard (2.19.0)
38
+ formatador (>= 0.2.4)
39
+ listen (>= 2.7, < 4.0)
40
+ lumberjack (>= 1.0.12, < 2.0)
41
+ nenv (~> 0.1)
42
+ notiffany (~> 0.0)
43
+ pry (>= 0.13.0)
44
+ shellany (~> 0.0)
45
+ thor (>= 0.18.1)
46
+ guard-compat (1.2.1)
47
+ guard-rspec (4.7.3)
48
+ guard (~> 2.1)
49
+ guard-compat (~> 1.1)
50
+ rspec (>= 2.99.0, < 4.0)
51
+ guard-rubocop (1.5.0)
52
+ guard (~> 2.0)
53
+ rubocop (< 2.0)
54
+ i18n (1.14.6)
55
+ concurrent-ruby (~> 1.0)
56
+ json (2.7.4)
57
+ language_server-protocol (3.17.0.3)
58
+ listen (3.9.0)
59
+ rb-fsevent (~> 0.10, >= 0.10.3)
60
+ rb-inotify (~> 0.9, >= 0.9.10)
61
+ logger (1.6.1)
62
+ lumberjack (1.2.10)
63
+ method_source (1.1.0)
64
+ minitest (5.25.1)
65
+ mutex_m (0.2.0)
66
+ nenv (0.3.0)
67
+ notiffany (0.1.3)
68
+ nenv (~> 0.1)
69
+ shellany (~> 0.0)
70
+ parallel (1.26.3)
71
+ parser (3.3.5.0)
72
+ ast (~> 2.4.1)
73
+ racc
74
+ prism (1.2.0)
75
+ pry (0.14.2)
76
+ coderay (~> 1.1)
77
+ method_source (~> 1.0)
78
+ racc (1.8.1)
79
+ rack (3.1.8)
80
+ rainbow (3.1.1)
81
+ rake (13.2.1)
82
+ rb-fsevent (0.11.2)
83
+ rb-inotify (0.11.1)
84
+ ffi (~> 1.0)
85
+ rbs (3.6.1)
86
+ logger
87
+ regexp_parser (2.9.2)
88
+ rexml (3.3.9)
89
+ rspec (3.13.0)
90
+ rspec-core (~> 3.13.0)
91
+ rspec-expectations (~> 3.13.0)
92
+ rspec-mocks (~> 3.13.0)
93
+ rspec-core (3.13.2)
94
+ rspec-support (~> 3.13.0)
95
+ rspec-expectations (3.13.3)
96
+ diff-lcs (>= 1.2.0, < 2.0)
97
+ rspec-support (~> 3.13.0)
98
+ rspec-mocks (3.13.2)
99
+ diff-lcs (>= 1.2.0, < 2.0)
100
+ rspec-support (~> 3.13.0)
101
+ rspec-support (3.13.1)
102
+ rubocop (1.56.4)
103
+ base64 (~> 0.1.1)
104
+ json (~> 2.3)
105
+ language_server-protocol (>= 3.17.0)
106
+ parallel (~> 1.10)
107
+ parser (>= 3.2.2.3)
108
+ rainbow (>= 2.2.2, < 4.0)
109
+ regexp_parser (>= 1.8, < 3.0)
110
+ rexml (>= 3.2.5, < 4.0)
111
+ rubocop-ast (>= 1.28.1, < 2.0)
112
+ ruby-progressbar (~> 1.7)
113
+ unicode-display_width (>= 2.4.0, < 3.0)
114
+ rubocop-ast (1.32.3)
115
+ parser (>= 3.3.1.0)
116
+ rubocop-performance (1.22.1)
117
+ rubocop (>= 1.48.1, < 2.0)
118
+ rubocop-ast (>= 1.31.1, < 2.0)
119
+ rubocop-rails (2.27.0)
120
+ activesupport (>= 4.2.0)
121
+ rack (>= 1.1)
122
+ rubocop (>= 1.52.0, < 2.0)
123
+ rubocop-ast (>= 1.31.1, < 2.0)
124
+ rubocop-rake (0.6.0)
125
+ rubocop (~> 1.0)
126
+ rubocop-rspec (3.0.0)
127
+ rubocop (~> 1.40)
128
+ ruby-lsp (0.20.1)
129
+ language_server-protocol (~> 3.17.0)
130
+ prism (>= 1.2, < 2.0)
131
+ rbs (>= 3, < 4)
132
+ sorbet-runtime (>= 0.5.10782)
133
+ ruby-lsp-rails (0.3.21)
134
+ ruby-lsp (>= 0.20.0, < 0.21.0)
135
+ ruby-lsp-rspec (0.1.17)
136
+ ruby-lsp (~> 0.20.1)
137
+ ruby-progressbar (1.13.0)
138
+ shellany (0.0.1)
139
+ simplecov (0.22.0)
140
+ docile (~> 1.1)
141
+ simplecov-html (~> 0.11)
142
+ simplecov_json_formatter (~> 0.1)
143
+ simplecov-html (0.13.1)
144
+ simplecov_json_formatter (0.1.4)
145
+ sorbet-runtime (0.5.11620)
146
+ sqlite3 (1.7.3-aarch64-linux)
147
+ sqlite3 (1.7.3-arm-linux)
148
+ sqlite3 (1.7.3-arm64-darwin)
149
+ sqlite3 (1.7.3-x86-linux)
150
+ sqlite3 (1.7.3-x86_64-darwin)
151
+ sqlite3 (1.7.3-x86_64-linux)
152
+ thor (1.3.2)
153
+ timeout (0.4.1)
154
+ tzinfo (2.0.6)
155
+ concurrent-ruby (~> 1.0)
156
+ unicode-display_width (2.6.0)
157
+
158
+ PLATFORMS
159
+ aarch64-linux
160
+ arm-linux
161
+ arm64-darwin
162
+ x86-linux
163
+ x86_64-darwin
164
+ x86_64-linux
165
+
166
+ DEPENDENCIES
167
+ activerecord (~> 7.1.0)
168
+ guard (~> 2.18)
169
+ guard-rspec (~> 4.7)
170
+ guard-rubocop (~> 1.5)
171
+ human_enum!
172
+ rake (~> 13.0)
173
+ rspec (~> 3.12)
174
+ rubocop (~> 1.56.3)
175
+ rubocop-performance
176
+ rubocop-rails
177
+ rubocop-rake
178
+ rubocop-rspec
179
+ ruby-lsp-rails
180
+ ruby-lsp-rspec
181
+ simplecov (~> 0.22.0)
182
+ sqlite3 (~> 1.4)
183
+
184
+ BUNDLED WITH
185
+ 2.5.10
data/Guardfile CHANGED
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- guard :rubocop, all_on_start: false, cli: '-a' do
4
- watch(/.+\.rb$/)
5
- watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
6
- end
3
+ # guard :rubocop, all_on_start: false, cli: '-a' do
4
+ # watch(/.+\.rb$/)
5
+ # watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
6
+ # end
7
7
 
8
8
  guard :rspec, cmd: 'bundle exec rspec' do
9
9
  require 'guard/rspec/dsl'
10
10
  dsl = Guard::RSpec::Dsl.new(self)
11
11
 
12
- # Feel free to open issues for suggestions and improvements
13
-
14
12
  # RSpec files
15
13
  rspec = dsl.rspec
16
14
  watch(rspec.spec_helper) { rspec.spec_dir }
@@ -20,10 +18,4 @@ guard :rspec, cmd: 'bundle exec rspec' do
20
18
  # Ruby files
21
19
  ruby = dsl.ruby
22
20
  dsl.watch_spec_files_for(ruby.lib_files)
23
-
24
- # Turnip features and steps
25
- watch(%r{^spec/acceptance/(.+)\.feature$})
26
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
27
- Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
28
- end
29
21
  end
data/README.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  This gem allows you to specify enum value translations in your I18n locale files like any other ActiveRecord attribute and adds helper methods to get humanized translations of enum values.
4
4
 
5
+ [![Tests](https://github.com/rafasoares/human_enum/actions/workflows/tests.yml/badge.svg)](https://github.com/rafasoares/human_enum/actions/workflows/tests.yml)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/b1caef25c888cde6688e/maintainability)](https://codeclimate.com/github/rafasoares/human_enum/maintainability)
7
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/b1caef25c888cde6688e/test_coverage)](https://codeclimate.com/github/rafasoares/human_enum/test_coverage)
8
+
9
+ ## Requirements
10
+
11
+ This gem only supports actively maintained versions of Ruby and Rails. Currently, that is:
12
+ * Ruby 3.1+
13
+ * Rails 6.1+
14
+
15
+ It may work with older versions, but it is not officially supported.
16
+
5
17
  ## Installation
6
18
 
7
19
  Add this line to your application's Gemfile:
@@ -12,15 +24,19 @@ gem 'human_enum'
12
24
 
13
25
  And then execute:
14
26
 
15
- $ bundle
27
+ ```sh
28
+ bundle
29
+ ```
16
30
 
17
31
  Or install it yourself as:
18
32
 
19
- $ gem install human_enum
33
+ ```sh
34
+ gem install human_enum
35
+ ```
20
36
 
21
37
  ## Usage
22
38
 
23
- First, include the concern in your models:
39
+ First, include the concern in your models.
24
40
 
25
41
  ```ruby
26
42
  class MyModel < ApplicationRecord
@@ -28,7 +44,7 @@ class MyModel < ApplicationRecord
28
44
  end
29
45
  ```
30
46
 
31
- Alternativelly, add it to your `ApplicationRecord` to add the functionality to every model in your application:
47
+ For convenience, you can add it to your `ApplicationRecord` to add the functionality to every model in your application. For models that don't declare `enum` attributes, no extra logic is called.
32
48
 
33
49
  ```ruby
34
50
  class ApplicationRecord < ActiveRecord::Base
@@ -38,15 +54,19 @@ class ApplicationRecord < ActiveRecord::Base
38
54
  end
39
55
  ```
40
56
 
41
- Declare your enums as you normally would:
57
+ Then declare your enums as you normally would:
42
58
 
43
59
  ```ruby
44
60
  class MyModel < ApplicationRecord
45
- enum model_type: [:default, :special]
61
+ # For Rails 7+
62
+ enum :model_type, %i[default special]
63
+
64
+ # For Rails 6
65
+ enum model_type: %i[default special]
46
66
  end
47
67
  ```
48
68
 
49
- And add the enum values to your locale files under the pluralized version of the enum attribute:
69
+ And add the enum values to your locale files under the **pluralized** version of the enum attribute:
50
70
 
51
71
  ```yaml
52
72
  en:
@@ -58,10 +78,12 @@ en:
58
78
  special: I am so special
59
79
  ```
60
80
 
61
- Then, you can use the helper method `human_[enum_attribute_name]` whenever you need the translated / humanized version of the enum value:
81
+ Note: internally, `human_enum` uses the model's [`i18n_scope`](https://api.rubyonrails.org/classes/ActiveModel/Translation.html#method-i-i18n_scope), so any customizations to your model/I18n setup should be automatically picked up.
82
+
83
+ Finally, you can use the helper method `human_[enum_attribute_name]` whenever you need the translated/human version of the enum value:
62
84
 
63
85
  ```ruby
64
- model = MyModel.new model_type: :special
86
+ model = MyModel.new(model_type: :special)
65
87
  puts model.human_model_type # "I am so special"
66
88
  ```
67
89
 
@@ -73,9 +95,9 @@ puts MyModel.human_model_types # "{default: 'Default Type', special: 'I am so sp
73
95
 
74
96
  ## Development
75
97
 
76
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
98
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
77
99
 
78
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
100
+ To install this gem onto your local machine, run `bin/rake install`.
79
101
 
80
102
  ## Contributing
81
103
 
@@ -85,4 +107,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/rafaso
85
107
  ## License
86
108
 
87
109
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
88
-
data/bin/rake ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
12
+
13
+ bundle_binstub = File.expand_path('bundle', __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require 'rubygems'
25
+ require 'bundler/setup'
26
+
27
+ load Gem.bin_path('rake', 'rake')