enum-i18n 0.1.1 → 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 +5 -5
- data/CHANGELOG.md +17 -0
- data/DEPRECATION.md +77 -0
- data/README.md +41 -0
- data/enum-i18n.gemspec +19 -16
- data/lib/enum-i18n/version.rb +1 -1
- data/lib/enum-i18n.rb +7 -2
- metadata +15 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b4b1aacc546f0315164eb3ad00e80ff3af4050eba67ea5e2316131dfab5c0214
|
4
|
+
data.tar.gz: 31730cf41c51a85184f1878d8820295e03e5957feeb14da7c7fc82f03a433655
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42a08489c794314793a29e490d83e440a371e7e55477d3bc83ce18a6497939c5fc3fcdc953ea6e8c76b18e69865f044cf6fbda7d8af7b6d410ddabc36936bf5a
|
7
|
+
data.tar.gz: e441ef9c936e7b2bce508c53846a7cab9702126e0099424d170381f8e75465fe62dc19f2b1e18ae01794dc77d84ee83cc532a07f48fc6bcd5c3f15993d3a51e4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [DEPRECATED]
|
4
|
+
|
5
|
+
⚠️ **This gem is deprecated and will be archived on or after August 31, 2025.** ⚠️
|
6
|
+
|
7
|
+
### Why Deprecated?
|
8
|
+
- Rails 7.1+ provides better built-in alternatives using `human_attribute_name`
|
9
|
+
- Alternative gems like `enum_help` and `enumerize` are more actively maintained
|
10
|
+
- Consider migrating to Rails built-in solutions or alternative gems
|
11
|
+
|
12
|
+
### Migration Path
|
13
|
+
- **Rails 7.1+**: Use `User.human_attribute_name("status.#{@user.status}")`
|
14
|
+
- **Alternative gems**: Consider `enum_help` or `enumerize`
|
15
|
+
|
16
|
+
---
|
17
|
+
|
1
18
|
# CHANGELOG
|
2
19
|
|
3
20
|
# v0.1.1
|
data/DEPRECATION.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Deprecation Notice
|
2
|
+
|
3
|
+
## ⚠️ This gem is deprecated and will be archived on or after August 31, 2025 ⚠️
|
4
|
+
|
5
|
+
## Why is this gem deprecated?
|
6
|
+
|
7
|
+
The `enum-i18n` gem was created to provide I18n support for ActiveRecord enums when Rails didn't have built-in alternatives. However, the Rails ecosystem has evolved, and there are now better solutions available.
|
8
|
+
|
9
|
+
## What are the alternatives?
|
10
|
+
|
11
|
+
### 1. Rails Built-in (Recommended for Rails 7.1+)
|
12
|
+
|
13
|
+
Rails 7.1+ provides the `human_attribute_name` method which can handle enum values:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
class User < ApplicationRecord
|
17
|
+
enum :status, [:active, :inactive, :pending]
|
18
|
+
end
|
19
|
+
|
20
|
+
# In your locale files (config/locales/en.yml)
|
21
|
+
en:
|
22
|
+
activerecord:
|
23
|
+
attributes:
|
24
|
+
user:
|
25
|
+
statuses:
|
26
|
+
active: "Active"
|
27
|
+
inactive: "Inactive"
|
28
|
+
pending: "Pending"
|
29
|
+
|
30
|
+
# Usage
|
31
|
+
User.human_attribute_name("statuses.#{@user.status}")
|
32
|
+
# => "Active" (if @user.status is :active)
|
33
|
+
```
|
34
|
+
|
35
|
+
### 2. Alternative Gems
|
36
|
+
|
37
|
+
#### enum_help
|
38
|
+
```ruby
|
39
|
+
gem 'enum_help'
|
40
|
+
|
41
|
+
# Provides similar functionality with more features
|
42
|
+
@user.status_text # => "Active"
|
43
|
+
```
|
44
|
+
|
45
|
+
#### enumerize
|
46
|
+
```ruby
|
47
|
+
gem 'enumerize'
|
48
|
+
|
49
|
+
# More feature-rich enum management
|
50
|
+
enumerize :status, in: [:active, :inactive, :pending]
|
51
|
+
@user.status.text # => "Active"
|
52
|
+
```
|
53
|
+
|
54
|
+
## Migration Timeline
|
55
|
+
|
56
|
+
- **August 31, 2025 or later**: Gem will be archived and removed from RubyGems
|
57
|
+
|
58
|
+
## How to migrate
|
59
|
+
|
60
|
+
1. **Remove the gem** from your Gemfile
|
61
|
+
2. **Choose an alternative** from the options above
|
62
|
+
3. **Update your code** to use the new method
|
63
|
+
4. **Update your locale files** if necessary
|
64
|
+
|
65
|
+
## Need help?
|
66
|
+
|
67
|
+
If you need assistance with migration, please:
|
68
|
+
1. Check the README.md for detailed examples
|
69
|
+
2. Consider opening an issue for migration support
|
70
|
+
3. Review the alternative gem documentation
|
71
|
+
|
72
|
+
## Thank you
|
73
|
+
|
74
|
+
Thank you for using `enum-i18n`. We hope this gem served you well, and we encourage you to migrate to the more modern alternatives available today.
|
75
|
+
|
76
|
+
## Archive Date
|
77
|
+
**This gem will be archived on or after August 31, 2025.**
|
data/README.md
CHANGED
@@ -1,5 +1,46 @@
|
|
1
1
|
# EnumI18n
|
2
2
|
|
3
|
+
⚠️ **DEPRECATED: This gem is deprecated and will be archived soon.** ⚠️
|
4
|
+
|
5
|
+
## Why Deprecated?
|
6
|
+
|
7
|
+
This gem was created to provide I18n support for ActiveRecord enums, but Rails now has better built-in alternatives:
|
8
|
+
|
9
|
+
- **Rails 7.1+**: Use `human_attribute_name` with enum values
|
10
|
+
- **Alternative gems**: Consider using `enum_help` or `enumerize` which are more actively maintained
|
11
|
+
|
12
|
+
## Migration Guide
|
13
|
+
|
14
|
+
### Before (with enum-i18n):
|
15
|
+
```ruby
|
16
|
+
class User < ApplicationRecord
|
17
|
+
include EnumI18n
|
18
|
+
enum :status, [:active, :inactive]
|
19
|
+
end
|
20
|
+
|
21
|
+
# Usage
|
22
|
+
@user.status_text # => "Active"
|
23
|
+
```
|
24
|
+
|
25
|
+
### After (Rails 7.1+):
|
26
|
+
```ruby
|
27
|
+
class User < ApplicationRecord
|
28
|
+
enum :status, [:active, :inactive]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Usage
|
32
|
+
User.human_attribute_name("status.#{@user.status}") # => "Active"
|
33
|
+
```
|
34
|
+
|
35
|
+
### Alternative gems:
|
36
|
+
- **enum_help**: `gem 'enum_help'` - More actively maintained
|
37
|
+
- **enumerize**: `gem 'enumerize'` - Feature-rich enum management
|
38
|
+
|
39
|
+
## Archive Date
|
40
|
+
**This gem will be archived on or after August 31, 2025.**
|
41
|
+
|
42
|
+
---
|
43
|
+
|
3
44
|
Enum attributes with I18n and ActiveRecord support
|
4
45
|
|
5
46
|
## Installation
|
data/enum-i18n.gemspec
CHANGED
@@ -1,29 +1,32 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require 'enum-i18n/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'enum-i18n'
|
8
7
|
spec.version = EnumI18n::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['amyroi']
|
9
|
+
spec.email = ['atsuko.mori.200@gmail.com']
|
11
10
|
|
12
|
-
spec.summary = 'Enum attributes with I18n and ActiveRecord support'
|
13
|
-
spec.description = 'Enum attributes with I18n and ActiveRecord support'
|
11
|
+
spec.summary = 'Enum attributes with I18n and ActiveRecord support (DEPRECATED)'
|
12
|
+
spec.description = 'Enum attributes with I18n and ActiveRecord support. DEPRECATED: This gem is deprecated and will be archived soon. Consider using Rails built-in human_attribute_name or alternative gems like enum_help.'
|
14
13
|
spec.homepage = 'https://github.com/amyroi/enum-i18n'
|
15
|
-
spec.license =
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.metadata = {
|
16
|
+
'deprecation_warning' => 'This gem is deprecated and will be archived on or after August 31, 2025. Consider migrating to Rails built-in alternatives or alternative gems.',
|
17
|
+
'github_repo' => 'https://github.com/amyroi/enum-i18n'
|
18
|
+
}
|
16
19
|
|
17
|
-
spec.files
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
21
|
f.match(%r{^(test|spec|features)/})
|
19
22
|
end
|
20
|
-
spec.bindir =
|
23
|
+
spec.bindir = 'exe'
|
21
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
25
|
+
spec.require_paths = ['lib']
|
23
26
|
|
24
|
-
spec.add_runtime_dependency
|
27
|
+
spec.add_runtime_dependency 'activerecord', '>= 4.1'
|
25
28
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
32
|
end
|
data/lib/enum-i18n/version.rb
CHANGED
data/lib/enum-i18n.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'enum-i18n/version'
|
2
|
+
|
3
|
+
# DEPRECATED: This gem is deprecated and will be archived on or after August 31, 2025.
|
4
|
+
# Consider using Rails built-in human_attribute_name or alternative gems like enum_help.
|
5
|
+
# See README.md for migration guide.
|
6
|
+
warn 'DEPRECATION WARNING: The enum-i18n gem is deprecated and will be archived on or after August 31, 2025. Consider migrating to Rails built-in alternatives or alternative gems.'
|
2
7
|
|
3
8
|
module EnumI18n
|
4
9
|
extend ActiveSupport::Concern
|
@@ -10,7 +15,7 @@ module EnumI18n
|
|
10
15
|
name = model_name.try(:i18n_key).to_s
|
11
16
|
defined_enums.each do |enum|
|
12
17
|
enum_column = enum.first
|
13
|
-
class_eval <<-METHOD
|
18
|
+
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
14
19
|
def #{enum_column}_text(scope=nil)
|
15
20
|
scope ||= 'activerecord.enum.#{name}.#{enum_column}'
|
16
21
|
I18n.t(#{enum_column}, scope: scope)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enum-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- amyroi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -66,7 +66,9 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
-
description: Enum attributes with I18n and ActiveRecord support
|
69
|
+
description: 'Enum attributes with I18n and ActiveRecord support. DEPRECATED: This
|
70
|
+
gem is deprecated and will be archived soon. Consider using Rails built-in human_attribute_name
|
71
|
+
or alternative gems like enum_help.'
|
70
72
|
email:
|
71
73
|
- atsuko.mori.200@gmail.com
|
72
74
|
executables: []
|
@@ -78,6 +80,7 @@ files:
|
|
78
80
|
- ".travis.yml"
|
79
81
|
- CHANGELOG.md
|
80
82
|
- CODE_OF_CONDUCT.md
|
83
|
+
- DEPRECATION.md
|
81
84
|
- Gemfile
|
82
85
|
- LICENSE.txt
|
83
86
|
- README.md
|
@@ -90,8 +93,11 @@ files:
|
|
90
93
|
homepage: https://github.com/amyroi/enum-i18n
|
91
94
|
licenses:
|
92
95
|
- MIT
|
93
|
-
metadata:
|
94
|
-
|
96
|
+
metadata:
|
97
|
+
deprecation_warning: This gem is deprecated and will be archived on or after August
|
98
|
+
31, 2025. Consider migrating to Rails built-in alternatives or alternative gems.
|
99
|
+
github_repo: https://github.com/amyroi/enum-i18n
|
100
|
+
post_install_message:
|
95
101
|
rdoc_options: []
|
96
102
|
require_paths:
|
97
103
|
- lib
|
@@ -106,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
112
|
- !ruby/object:Gem::Version
|
107
113
|
version: '0'
|
108
114
|
requirements: []
|
109
|
-
|
110
|
-
|
111
|
-
signing_key:
|
115
|
+
rubygems_version: 3.5.23
|
116
|
+
signing_key:
|
112
117
|
specification_version: 4
|
113
|
-
summary: Enum attributes with I18n and ActiveRecord support
|
118
|
+
summary: Enum attributes with I18n and ActiveRecord support (DEPRECATED)
|
114
119
|
test_files: []
|