power_enum 4.0.0 → 4.1.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/README.markdown +7 -7
- data/VERSION +1 -1
- data/lib/active_record/virtual_enumerations.rb +2 -0
- data/lib/generators/enum/enum_generator.rb +2 -0
- data/lib/generators/enum/enum_generator_helpers/migration_number.rb +2 -0
- data/lib/generators/virtual_enumerations_initializer/virtual_enumerations_initializer_generator.rb +3 -1
- data/lib/power_enum/enumerated.rb +2 -0
- data/lib/power_enum/has_enumerated.rb +2 -0
- data/lib/power_enum/migration/command_recorder.rb +3 -1
- data/lib/power_enum/reflection.rb +2 -0
- data/lib/power_enum/schema/schema_statements.rb +5 -1
- data/lib/power_enum.rb +2 -0
- data/lib/testing/rspec.rb +4 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a9bac7b30dfaa281e8f62c7bd6aae94b70f285bf1127fa3bda48fab02a8c061
|
4
|
+
data.tar.gz: 9ec32944da6a0c71f5e4738d8125ddb69b0013865559a5749b68cd26dae15bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb5dd72c479a1bda79dad034a50ed42bfbec695e70c642d33fd530b9348fbd5e277392b7a60f54dd0a0b08151f168e1500e1d5709479e98e50cd6c61ffad737
|
7
|
+
data.tar.gz: b833be13cb9ede042f3595c06a113cbe67436dc84198667b001ed8ef26471c4f42c3c1e417c19e58b5bae83794323ee475ab2501353cf470b1cb3ea43c5af1c3
|
data/README.markdown
CHANGED
@@ -10,7 +10,7 @@ Enumerations for Rails Done Right.
|
|
10
10
|
|
11
11
|
## Versions
|
12
12
|
|
13
|
-
* PowerEnum 4.X (this version) supports Rails 6.X, and Rails 7.0
|
13
|
+
* PowerEnum 4.0.X (this version) supports Rails 6.X, and Rails 7.0 (Experimental)
|
14
14
|
* PowerEnum 3.X supports Rails 4.2, Rails 5.X and Rails 6.0
|
15
15
|
* PowerEnum 2.X supports Rails 4.X and Rails 5.0
|
16
16
|
* PowerEnum 1.X supports Rails 3.1/3.2, available here: https://github.com/albertosaurus/power_enum
|
@@ -53,7 +53,7 @@ See "How to use it" below for more information.
|
|
53
53
|
|
54
54
|
## Requirements
|
55
55
|
|
56
|
-
### PowerEnum 4.X
|
56
|
+
### PowerEnum 4.0.X
|
57
57
|
|
58
58
|
* Ruby 2.7 or later (JRuby should work but isn't extensively tested).
|
59
59
|
* Rails 6.0, 6.1, 6.2, 7.0
|
@@ -84,10 +84,6 @@ then run
|
|
84
84
|
|
85
85
|
gem install power_enum
|
86
86
|
|
87
|
-
If you want to verify the gem signature, use the `HighSecurity` installation option.
|
88
|
-
|
89
|
-
gem install power_enum -P HighSecurity
|
90
|
-
|
91
87
|
## Gem Contents
|
92
88
|
|
93
89
|
This package adds:
|
@@ -158,6 +154,8 @@ create_enum :booking_status, :name_limit => 50
|
|
158
154
|
# end
|
159
155
|
```
|
160
156
|
|
157
|
+
**WARNING - This conflicts with PostgreSQL enum support in Rails 7+ and will be renamed in future versions.**
|
158
|
+
|
161
159
|
Now, when you create your Booking model, your migration should create a reference column for status id's and a foreign
|
162
160
|
key relationship to the booking\_statuses table.
|
163
161
|
|
@@ -169,7 +167,7 @@ create_table :bookings do |t|
|
|
169
167
|
end
|
170
168
|
|
171
169
|
# It's highly recommended to add a foreign key constraint here.
|
172
|
-
# Ideally, you would use a gem of some sort to handle this.
|
170
|
+
# Ideally, you would use a gem of some sort to handle this for Rails < 6.
|
173
171
|
# I have been using PgPower https://rubygems.org/gems/pg_power with much
|
174
172
|
# success. It's fork, PgSaurus https://rubygems.org/gems/pg_saurus should
|
175
173
|
# work just as well.
|
@@ -191,6 +189,8 @@ There are two methods added to Rails migrations:
|
|
191
189
|
|
192
190
|
##### create\_enum(enum\_name, options = {}, &block)
|
193
191
|
|
192
|
+
**WARNING - This conflicts with PostgreSQL enum support in Rails 7+ and will be renamed in future versions.**
|
193
|
+
|
194
194
|
Creates a new enum table. `enum_name` will be automatically pluralized. The following options are supported:
|
195
195
|
|
196
196
|
- [:name\_column] Specify the column name for name of the enum. By default it's :name. This can be a String or a Symbol
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.1.0
|
data/lib/generators/virtual_enumerations_initializer/virtual_enumerations_initializer_generator.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (c) 2011 Arthur Shagall
|
2
4
|
# Released under the MIT license. See LICENSE for details.
|
3
5
|
|
@@ -12,4 +14,4 @@ class VirtualEnumerationsInitializerGenerator < Rails::Generators::Base
|
|
12
14
|
template 'virtual_enumerations.rb.erb', "config/initializers/#{initializer_name}.rb"
|
13
15
|
end
|
14
16
|
|
15
|
-
end
|
17
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (c) 2011 Arthur Shagall
|
2
4
|
# Released under the MIT license. See LICENSE for details.
|
3
5
|
|
@@ -8,7 +10,9 @@ module PowerEnum::Schema
|
|
8
10
|
|
9
11
|
def self.included(base) # :nodoc:
|
10
12
|
base::AbstractAdapter.class_eval do
|
11
|
-
|
13
|
+
# This squashes the "#create_enum" in the PostgreSQL adapter in Rails 7+.
|
14
|
+
# .../activerecord-7.0.X.Y/lib/active_record/connection_adapters/postgresql_adapter.rb
|
15
|
+
prepend PowerEnum::Schema::AbstractAdapter
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
data/lib/power_enum.rb
CHANGED
data/lib/testing/rspec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if defined? RSpec
|
2
4
|
require 'rspec/expectations'
|
3
5
|
|
@@ -90,7 +92,7 @@ if defined? RSpec
|
|
90
92
|
failure_message do
|
91
93
|
message = "should act as enumerated"
|
92
94
|
if @items
|
93
|
-
message
|
95
|
+
message = "#{message} and have members #{@items.inspect}"
|
94
96
|
end
|
95
97
|
message
|
96
98
|
end
|
@@ -98,7 +100,7 @@ if defined? RSpec
|
|
98
100
|
failure_message_when_negated do
|
99
101
|
message = "should not act as enumerated"
|
100
102
|
if @items
|
101
|
-
message
|
103
|
+
message = "#{message} with members #{@items.inspect}"
|
102
104
|
end
|
103
105
|
message
|
104
106
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: power_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trevor Squires
|
8
8
|
- Pivotal Labs
|
9
9
|
- Arthur Shagall
|
10
10
|
- Sergey Potapov
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2025-06-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -151,7 +151,7 @@ homepage: http://github.com/albertosaurus/power_enum_2
|
|
151
151
|
licenses:
|
152
152
|
- MIT
|
153
153
|
metadata: {}
|
154
|
-
post_install_message:
|
154
|
+
post_install_message:
|
155
155
|
rdoc_options: []
|
156
156
|
require_paths:
|
157
157
|
- lib
|
@@ -166,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
|
-
rubygems_version: 3.2.
|
170
|
-
signing_key:
|
169
|
+
rubygems_version: 3.2.33
|
170
|
+
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Allows you to treat instances of your ActiveRecord models as though they
|
173
173
|
were an enumeration of values
|