human_enum 1.1.2 → 1.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/dependabot.yml +2 -2
- data/.github/workflows/tests.yml +15 -6
- data/.qlty/qlty.toml +109 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +14 -3
- data/Gemfile.lock +59 -51
- data/Gemfile.rails-6.1.lock +42 -34
- data/Gemfile.rails-7.0.lock +41 -33
- data/Gemfile.rails-7.1.lock +55 -42
- data/Gemfile.rails-7.2.lock +196 -0
- data/Gemfile.rails-8.0.lock +198 -0
- data/README.md +12 -7
- data/human_enum.gemspec +1 -1
- data/lib/human_enum/version.rb +1 -1
- data/lib/human_enum.rb +2 -2
- metadata +8 -9
- data/.codeclimate.yml +0 -4
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
human_enum (1.2.0)
|
|
5
|
+
activerecord (>= 6.1, < 9)
|
|
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
|
+
ast (2.4.2)
|
|
30
|
+
base64 (0.1.2)
|
|
31
|
+
benchmark (0.4.0)
|
|
32
|
+
bigdecimal (3.1.8)
|
|
33
|
+
coderay (1.1.3)
|
|
34
|
+
concurrent-ruby (1.3.4)
|
|
35
|
+
connection_pool (2.4.1)
|
|
36
|
+
diff-lcs (1.6.0)
|
|
37
|
+
docile (1.4.1)
|
|
38
|
+
drb (2.2.1)
|
|
39
|
+
ffi (1.17.1-aarch64-linux-gnu)
|
|
40
|
+
ffi (1.17.1-arm-linux-gnu)
|
|
41
|
+
ffi (1.17.1-arm64-darwin)
|
|
42
|
+
ffi (1.17.1-x86-linux-gnu)
|
|
43
|
+
ffi (1.17.1-x86_64-darwin)
|
|
44
|
+
ffi (1.17.1-x86_64-linux-gnu)
|
|
45
|
+
formatador (1.1.0)
|
|
46
|
+
guard (2.19.1)
|
|
47
|
+
formatador (>= 0.2.4)
|
|
48
|
+
listen (>= 2.7, < 4.0)
|
|
49
|
+
logger (~> 1.6)
|
|
50
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
51
|
+
nenv (~> 0.1)
|
|
52
|
+
notiffany (~> 0.0)
|
|
53
|
+
ostruct (~> 0.6)
|
|
54
|
+
pry (>= 0.13.0)
|
|
55
|
+
shellany (~> 0.0)
|
|
56
|
+
thor (>= 0.18.1)
|
|
57
|
+
guard-compat (1.2.1)
|
|
58
|
+
guard-rspec (4.7.3)
|
|
59
|
+
guard (~> 2.1)
|
|
60
|
+
guard-compat (~> 1.1)
|
|
61
|
+
rspec (>= 2.99.0, < 4.0)
|
|
62
|
+
guard-rubocop (1.5.0)
|
|
63
|
+
guard (~> 2.0)
|
|
64
|
+
rubocop (< 2.0)
|
|
65
|
+
i18n (1.14.6)
|
|
66
|
+
concurrent-ruby (~> 1.0)
|
|
67
|
+
json (2.10.2)
|
|
68
|
+
language_server-protocol (3.17.0.4)
|
|
69
|
+
listen (3.9.0)
|
|
70
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
71
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
72
|
+
logger (1.6.3)
|
|
73
|
+
lumberjack (1.2.10)
|
|
74
|
+
method_source (1.1.0)
|
|
75
|
+
minitest (5.25.4)
|
|
76
|
+
nenv (0.3.0)
|
|
77
|
+
notiffany (0.1.3)
|
|
78
|
+
nenv (~> 0.1)
|
|
79
|
+
shellany (~> 0.0)
|
|
80
|
+
ostruct (0.6.1)
|
|
81
|
+
parallel (1.26.3)
|
|
82
|
+
parser (3.3.7.1)
|
|
83
|
+
ast (~> 2.4.1)
|
|
84
|
+
racc
|
|
85
|
+
prism (1.3.0)
|
|
86
|
+
pry (0.15.2)
|
|
87
|
+
coderay (~> 1.1)
|
|
88
|
+
method_source (~> 1.0)
|
|
89
|
+
racc (1.8.1)
|
|
90
|
+
rack (3.1.12)
|
|
91
|
+
rainbow (3.1.1)
|
|
92
|
+
rake (13.2.1)
|
|
93
|
+
rb-fsevent (0.11.2)
|
|
94
|
+
rb-inotify (0.11.1)
|
|
95
|
+
ffi (~> 1.0)
|
|
96
|
+
rbs (3.8.1)
|
|
97
|
+
logger
|
|
98
|
+
regexp_parser (2.10.0)
|
|
99
|
+
rexml (3.4.1)
|
|
100
|
+
rspec (3.13.0)
|
|
101
|
+
rspec-core (~> 3.13.0)
|
|
102
|
+
rspec-expectations (~> 3.13.0)
|
|
103
|
+
rspec-mocks (~> 3.13.0)
|
|
104
|
+
rspec-core (3.13.3)
|
|
105
|
+
rspec-support (~> 3.13.0)
|
|
106
|
+
rspec-expectations (3.13.3)
|
|
107
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
108
|
+
rspec-support (~> 3.13.0)
|
|
109
|
+
rspec-mocks (3.13.2)
|
|
110
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
111
|
+
rspec-support (~> 3.13.0)
|
|
112
|
+
rspec-support (3.13.2)
|
|
113
|
+
rubocop (1.56.4)
|
|
114
|
+
base64 (~> 0.1.1)
|
|
115
|
+
json (~> 2.3)
|
|
116
|
+
language_server-protocol (>= 3.17.0)
|
|
117
|
+
parallel (~> 1.10)
|
|
118
|
+
parser (>= 3.2.2.3)
|
|
119
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
120
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
121
|
+
rexml (>= 3.2.5, < 4.0)
|
|
122
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
|
123
|
+
ruby-progressbar (~> 1.7)
|
|
124
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
125
|
+
rubocop-ast (1.38.1)
|
|
126
|
+
parser (>= 3.3.1.0)
|
|
127
|
+
rubocop-performance (1.23.1)
|
|
128
|
+
rubocop (>= 1.48.1, < 2.0)
|
|
129
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
130
|
+
rubocop-rails (2.29.1)
|
|
131
|
+
activesupport (>= 4.2.0)
|
|
132
|
+
rack (>= 1.1)
|
|
133
|
+
rubocop (>= 1.52.0, < 2.0)
|
|
134
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
135
|
+
rubocop-rake (0.6.0)
|
|
136
|
+
rubocop (~> 1.0)
|
|
137
|
+
rubocop-rspec (3.0.0)
|
|
138
|
+
rubocop (~> 1.40)
|
|
139
|
+
ruby-lsp (0.23.11)
|
|
140
|
+
language_server-protocol (~> 3.17.0)
|
|
141
|
+
prism (>= 1.2, < 2.0)
|
|
142
|
+
rbs (>= 3, < 4)
|
|
143
|
+
sorbet-runtime (>= 0.5.10782)
|
|
144
|
+
ruby-lsp-rails (0.4.0)
|
|
145
|
+
ruby-lsp (>= 0.23.0, < 0.24.0)
|
|
146
|
+
ruby-lsp-rspec (0.1.22)
|
|
147
|
+
ruby-lsp (~> 0.23.0)
|
|
148
|
+
ruby-progressbar (1.13.0)
|
|
149
|
+
securerandom (0.4.0)
|
|
150
|
+
shellany (0.0.1)
|
|
151
|
+
simplecov (0.22.0)
|
|
152
|
+
docile (~> 1.1)
|
|
153
|
+
simplecov-html (~> 0.11)
|
|
154
|
+
simplecov_json_formatter (~> 0.1)
|
|
155
|
+
simplecov-html (0.13.1)
|
|
156
|
+
simplecov_json_formatter (0.1.4)
|
|
157
|
+
sorbet-runtime (0.5.11919)
|
|
158
|
+
sqlite3 (2.6.0-aarch64-linux-gnu)
|
|
159
|
+
sqlite3 (2.6.0-arm-linux-gnu)
|
|
160
|
+
sqlite3 (2.6.0-arm64-darwin)
|
|
161
|
+
sqlite3 (2.6.0-x86-linux-gnu)
|
|
162
|
+
sqlite3 (2.6.0-x86_64-darwin)
|
|
163
|
+
sqlite3 (2.6.0-x86_64-linux-gnu)
|
|
164
|
+
thor (1.3.2)
|
|
165
|
+
timeout (0.4.3)
|
|
166
|
+
tzinfo (2.0.6)
|
|
167
|
+
concurrent-ruby (~> 1.0)
|
|
168
|
+
unicode-display_width (2.6.0)
|
|
169
|
+
uri (1.0.3)
|
|
170
|
+
|
|
171
|
+
PLATFORMS
|
|
172
|
+
aarch64-linux
|
|
173
|
+
arm-linux
|
|
174
|
+
arm64-darwin
|
|
175
|
+
x86-linux
|
|
176
|
+
x86_64-darwin
|
|
177
|
+
x86_64-linux
|
|
178
|
+
|
|
179
|
+
DEPENDENCIES
|
|
180
|
+
activerecord (~> 8.0.0)
|
|
181
|
+
guard (~> 2.18)
|
|
182
|
+
guard-rspec (~> 4.7)
|
|
183
|
+
guard-rubocop (~> 1.5)
|
|
184
|
+
human_enum!
|
|
185
|
+
rake (~> 13.0)
|
|
186
|
+
rspec (~> 3.12)
|
|
187
|
+
rubocop (~> 1.56.3)
|
|
188
|
+
rubocop-performance
|
|
189
|
+
rubocop-rails
|
|
190
|
+
rubocop-rake
|
|
191
|
+
rubocop-rspec
|
|
192
|
+
ruby-lsp-rails
|
|
193
|
+
ruby-lsp-rspec
|
|
194
|
+
simplecov (~> 0.22.0)
|
|
195
|
+
sqlite3 (~> 2.0)
|
|
196
|
+
|
|
197
|
+
BUNDLED WITH
|
|
198
|
+
2.5.10
|
data/README.md
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# HumanEnum
|
|
2
2
|
|
|
3
|
-
This gem allows you to specify enum value translations in your I18n locale files
|
|
3
|
+
This gem allows you to specify enum value translations in your I18n locale files
|
|
4
|
+
like any other ActiveRecord attribute and adds helper methods to get humanized
|
|
5
|
+
translations of enum values.
|
|
4
6
|
|
|
5
7
|
[](https://github.com/rafasoares/human_enum/actions/workflows/tests.yml)
|
|
6
|
-
[](https://qlty.sh/gh/rafasoares/projects/human_enum)
|
|
9
|
+
[](https://qlty.sh/gh/rafasoares/projects/human_enum)
|
|
8
10
|
|
|
9
11
|
## Requirements
|
|
10
12
|
|
|
11
13
|
This gem only supports actively maintained versions of Ruby and Rails. Currently, that is:
|
|
14
|
+
|
|
12
15
|
* Ruby 3.1+
|
|
13
16
|
* Rails 6.1+
|
|
14
17
|
|
|
@@ -44,7 +47,9 @@ class MyModel < ApplicationRecord
|
|
|
44
47
|
end
|
|
45
48
|
```
|
|
46
49
|
|
|
47
|
-
For convenience, you can add it to your `ApplicationRecord` to add the
|
|
50
|
+
For convenience, you can add it to your `ApplicationRecord` to add the
|
|
51
|
+
functionality to every model in your application. For models that don't declare
|
|
52
|
+
`enum` attributes, no extra logic is called.
|
|
48
53
|
|
|
49
54
|
```ruby
|
|
50
55
|
class ApplicationRecord < ActiveRecord::Base
|
|
@@ -66,7 +71,8 @@ class MyModel < ApplicationRecord
|
|
|
66
71
|
end
|
|
67
72
|
```
|
|
68
73
|
|
|
69
|
-
And add the enum values to your locale files under the **pluralized** version of
|
|
74
|
+
And add the enum values to your locale files under the **pluralized** version of
|
|
75
|
+
the enum attribute:
|
|
70
76
|
|
|
71
77
|
```yaml
|
|
72
78
|
en:
|
|
@@ -101,8 +107,7 @@ To install this gem onto your local machine, run `bin/rake install`.
|
|
|
101
107
|
|
|
102
108
|
## Contributing
|
|
103
109
|
|
|
104
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/rafasoares/human_enum
|
|
105
|
-
|
|
110
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/rafasoares/human_enum>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
106
111
|
|
|
107
112
|
## License
|
|
108
113
|
|
data/human_enum.gemspec
CHANGED
data/lib/human_enum/version.rb
CHANGED
data/lib/human_enum.rb
CHANGED
|
@@ -49,7 +49,7 @@ module HumanEnum
|
|
|
49
49
|
|
|
50
50
|
class_methods do # rubocop:disable Metrics/BlockLength
|
|
51
51
|
def enum(...)
|
|
52
|
-
super
|
|
52
|
+
super.tap { humanize_enums }
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# DEPRECATED: This method is deprecated and will be removed in future versions.
|
|
@@ -104,7 +104,7 @@ module HumanEnum
|
|
|
104
104
|
collection_name = enum_name.to_s.pluralize
|
|
105
105
|
return if respond_to?(:"human_#{collection_name}")
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
define_singleton_method :"human_#{collection_name}" do
|
|
108
108
|
values.to_h { |key, _| [key.to_sym, _translate_enum(enum_name, key)] }
|
|
109
109
|
end
|
|
110
110
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: human_enum
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rafael Soares
|
|
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:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -19,7 +18,7 @@ dependencies:
|
|
|
19
18
|
version: '6.1'
|
|
20
19
|
- - "<"
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
21
|
+
version: '9'
|
|
23
22
|
type: :runtime
|
|
24
23
|
prerelease: false
|
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +28,7 @@ dependencies:
|
|
|
29
28
|
version: '6.1'
|
|
30
29
|
- - "<"
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
31
|
+
version: '9'
|
|
33
32
|
description: |-
|
|
34
33
|
This gem allows you to specify enum value translations
|
|
35
34
|
like any other ActiveRecord attribute and adds helper methods to get
|
|
@@ -40,7 +39,6 @@ executables: []
|
|
|
40
39
|
extensions: []
|
|
41
40
|
extra_rdoc_files: []
|
|
42
41
|
files:
|
|
43
|
-
- ".codeclimate.yml"
|
|
44
42
|
- ".devcontainer/devcontainer.json"
|
|
45
43
|
- ".github/dependabot.yml"
|
|
46
44
|
- ".github/workflows/publish.yml"
|
|
@@ -48,6 +46,7 @@ files:
|
|
|
48
46
|
- ".github/workflows/tests.yml"
|
|
49
47
|
- ".gitignore"
|
|
50
48
|
- ".hound.yml"
|
|
49
|
+
- ".qlty/qlty.toml"
|
|
51
50
|
- ".rspec"
|
|
52
51
|
- ".rubocop.yml"
|
|
53
52
|
- ".ruby-gemset"
|
|
@@ -62,6 +61,8 @@ files:
|
|
|
62
61
|
- Gemfile.rails-6.1.lock
|
|
63
62
|
- Gemfile.rails-7.0.lock
|
|
64
63
|
- Gemfile.rails-7.1.lock
|
|
64
|
+
- Gemfile.rails-7.2.lock
|
|
65
|
+
- Gemfile.rails-8.0.lock
|
|
65
66
|
- Guardfile
|
|
66
67
|
- LICENSE.txt
|
|
67
68
|
- README.md
|
|
@@ -81,7 +82,6 @@ metadata:
|
|
|
81
82
|
source_code_uri: https://github.com/rafasoares/human_enum
|
|
82
83
|
changelog_uri: https://github.com/rafasoares/human_enum/blob/main/CHANGELOG.md
|
|
83
84
|
rubygems_mfa_required: 'true'
|
|
84
|
-
post_install_message:
|
|
85
85
|
rdoc_options: []
|
|
86
86
|
require_paths:
|
|
87
87
|
- lib
|
|
@@ -96,8 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
97
|
version: '0'
|
|
98
98
|
requirements: []
|
|
99
|
-
rubygems_version: 3.
|
|
100
|
-
signing_key:
|
|
99
|
+
rubygems_version: 3.6.8
|
|
101
100
|
specification_version: 4
|
|
102
101
|
summary: Adds simple and easy I18n support for Rails enums
|
|
103
102
|
test_files: []
|
data/.codeclimate.yml
DELETED