role_fu 0.3.1 → 0.3.3
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/CHANGELOG.md +6 -0
- data/gemfiles/rails_7.2.gemfile.lock +2 -2
- data/gemfiles/rails_8.0.gemfile.lock +2 -2
- data/gemfiles/rails_8.1.gemfile.lock +2 -2
- data/lib/generators/role_fu/abilities_generator.rb +14 -1
- data/lib/generators/role_fu/audit_generator.rb +14 -1
- data/lib/generators/role_fu/role_fu_generator.rb +13 -1
- data/lib/generators/role_fu/templates/abilities_migration.rb.erb +2 -2
- data/lib/generators/role_fu/templates/audit_migration.rb.erb +4 -4
- data/lib/generators/role_fu/templates/migration.rb.erb +5 -5
- data/lib/role_fu/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b631da54e6c8f434750a6246d69bb8b7add820b2fc5f4749175572ef1c63154
|
|
4
|
+
data.tar.gz: 570b07c252c379dad3196093527e3b30c9baba27083bc33ff4f034aa187974d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8d5e5db755e6e38b447daa753141e01bb67b157292fceb3b363bf489ccba6662c260eabef549e535a182e8add734d683acb0a5ae05979ff2a1343d5907aead0
|
|
7
|
+
data.tar.gz: 524e26d7e7e308cbcde01bf8e067c01a853a69a4c94a61f22c7ce31500d0eb7ed963094cdcb3cfd26ec6f88d5f9e84a1ea757ba5e706aca6e138c2655abe1b99
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.3.3] - 2026-02-07
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **UUID Support**: Generators now automatically detect and use UUIDs for primary and foreign keys if enabled in the application or model configuration.
|
|
8
|
+
|
|
3
9
|
## [0.3.1] - 2026-02-06
|
|
4
10
|
|
|
5
11
|
### Improved
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ..
|
|
3
3
|
specs:
|
|
4
|
-
role_fu (0.3.
|
|
4
|
+
role_fu (0.3.3)
|
|
5
5
|
activerecord (>= 7.2)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -389,7 +389,7 @@ CHECKSUMS
|
|
|
389
389
|
rdoc (7.1.0) sha256=494899df0706c178596ca6e1d50f1b7eb285a9b2aae715be5abd742734f17363
|
|
390
390
|
regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
|
|
391
391
|
reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
|
|
392
|
-
role_fu (0.3.
|
|
392
|
+
role_fu (0.3.3)
|
|
393
393
|
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
394
394
|
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
395
395
|
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ..
|
|
3
3
|
specs:
|
|
4
|
-
role_fu (0.3.
|
|
4
|
+
role_fu (0.3.3)
|
|
5
5
|
activerecord (>= 7.2)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -385,7 +385,7 @@ CHECKSUMS
|
|
|
385
385
|
rdoc (7.1.0) sha256=494899df0706c178596ca6e1d50f1b7eb285a9b2aae715be5abd742734f17363
|
|
386
386
|
regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
|
|
387
387
|
reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
|
|
388
|
-
role_fu (0.3.
|
|
388
|
+
role_fu (0.3.3)
|
|
389
389
|
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
390
390
|
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
391
391
|
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ..
|
|
3
3
|
specs:
|
|
4
|
-
role_fu (0.3.
|
|
4
|
+
role_fu (0.3.3)
|
|
5
5
|
activerecord (>= 7.2)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -387,7 +387,7 @@ CHECKSUMS
|
|
|
387
387
|
rdoc (7.1.0) sha256=494899df0706c178596ca6e1d50f1b7eb285a9b2aae715be5abd742734f17363
|
|
388
388
|
regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
|
|
389
389
|
reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
|
|
390
|
-
role_fu (0.3.
|
|
390
|
+
role_fu (0.3.3)
|
|
391
391
|
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
392
392
|
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
393
393
|
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
@@ -22,7 +22,7 @@ module RoleFu
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def create_abilities_migration
|
|
25
|
-
migration_template "abilities_migration.rb.erb", "db/migrate/role_fu_create_permissions.rb"
|
|
25
|
+
migration_template "abilities_migration.rb.erb", "db/migrate/role_fu_create_permissions.rb"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def inject_into_role_model
|
|
@@ -56,6 +56,19 @@ module RoleFu
|
|
|
56
56
|
def migration_version
|
|
57
57
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if Rails::VERSION::MAJOR >= 5
|
|
58
58
|
end
|
|
59
|
+
|
|
60
|
+
def uuid_enabled?
|
|
61
|
+
options[:primary_key_type] == "uuid" ||
|
|
62
|
+
Rails.configuration.generators.options.dig(:active_record, :primary_key_type) == :uuid ||
|
|
63
|
+
role_has_uuid_pk?
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def role_has_uuid_pk?
|
|
67
|
+
role_cname = RoleFu.configuration.role_class_name
|
|
68
|
+
klass = role_cname.safe_constantize
|
|
69
|
+
return false unless klass&.table_exists?
|
|
70
|
+
klass.columns_hash[klass.primary_key]&.type == :uuid
|
|
71
|
+
end
|
|
59
72
|
end
|
|
60
73
|
end
|
|
61
74
|
end
|
|
@@ -18,7 +18,7 @@ module RoleFu
|
|
|
18
18
|
desc "" # Empty desc to avoid duplication at the bottom
|
|
19
19
|
|
|
20
20
|
def create_audit_migration
|
|
21
|
-
migration_template "audit_migration.rb.erb", "db/migrate/role_fu_create_audits.rb"
|
|
21
|
+
migration_template "audit_migration.rb.erb", "db/migrate/role_fu_create_audits.rb"
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def create_model
|
|
@@ -30,6 +30,19 @@ module RoleFu
|
|
|
30
30
|
def migration_version
|
|
31
31
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if Rails::VERSION::MAJOR >= 5
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
def uuid_enabled?
|
|
35
|
+
options[:primary_key_type] == "uuid" ||
|
|
36
|
+
Rails.configuration.generators.options.dig(:active_record, :primary_key_type) == :uuid ||
|
|
37
|
+
user_has_uuid_pk?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def user_has_uuid_pk?
|
|
41
|
+
user_cname = RoleFu.configuration.user_class_name || "User"
|
|
42
|
+
klass = user_cname.safe_constantize
|
|
43
|
+
return false unless klass&.table_exists?
|
|
44
|
+
klass.columns_hash[klass.primary_key]&.type == :uuid
|
|
45
|
+
end
|
|
33
46
|
end
|
|
34
47
|
end
|
|
35
48
|
end
|
|
@@ -33,7 +33,7 @@ module RoleFu
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def copy_role_fu_migration
|
|
36
|
-
migration_template "migration.rb.erb", "db/migrate/role_fu_create_#{table_name}.rb"
|
|
36
|
+
migration_template "migration.rb.erb", "db/migrate/role_fu_create_#{table_name}.rb"
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def inject_role_fu_into_user_model
|
|
@@ -52,6 +52,18 @@ module RoleFu
|
|
|
52
52
|
def migration_version
|
|
53
53
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if Rails::VERSION::MAJOR >= 5
|
|
54
54
|
end
|
|
55
|
+
|
|
56
|
+
def uuid_enabled?
|
|
57
|
+
options[:primary_key_type] == "uuid" ||
|
|
58
|
+
Rails.configuration.generators.options.dig(:active_record, :primary_key_type) == :uuid ||
|
|
59
|
+
user_has_uuid_pk?
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def user_has_uuid_pk?
|
|
63
|
+
klass = user_cname.safe_constantize
|
|
64
|
+
return false unless klass&.table_exists?
|
|
65
|
+
klass.columns_hash[klass.primary_key]&.type == :uuid
|
|
66
|
+
end
|
|
55
67
|
end
|
|
56
68
|
end
|
|
57
69
|
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
class RoleFuCreatePermissions < ActiveRecord::Migration<%= migration_version %>
|
|
4
4
|
def change
|
|
5
|
-
create_table :permissions do |t|
|
|
6
|
-
t.references :role, null: false, index: true
|
|
5
|
+
create_table :permissions<%= ", id: :uuid" if uuid_enabled? %> do |t|
|
|
6
|
+
t.references :role, null: false, index: true<%= ", type: :uuid" if uuid_enabled? %>
|
|
7
7
|
t.string :action, null: false
|
|
8
8
|
t.jsonb :conditions, default: {}
|
|
9
9
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
class RoleFuCreateAudits < ActiveRecord::Migration<%= migration_version %>
|
|
4
4
|
def change
|
|
5
|
-
create_table :role_assignment_audits do |t|
|
|
6
|
-
t.references :user, index: true
|
|
7
|
-
t.references :role, index: true
|
|
8
|
-
t.references :role_assignment, index: true
|
|
5
|
+
create_table :role_assignment_audits<%= ", id: :uuid" if uuid_enabled? %> do |t|
|
|
6
|
+
t.references :user, index: true<%= ", type: :uuid" if uuid_enabled? %>
|
|
7
|
+
t.references :role, index: true<%= ", type: :uuid" if uuid_enabled? %>
|
|
8
|
+
t.references :role_assignment, index: true<%= ", type: :uuid" if uuid_enabled? %>
|
|
9
9
|
t.string :operation, null: false # INSERT, UPDATE, DELETE
|
|
10
10
|
t.string :whodunnit
|
|
11
11
|
t.jsonb :meta_snapshot
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
class RoleFuCreate<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
|
|
4
4
|
def change
|
|
5
|
-
create_table :<%= table_name %> do |t|
|
|
5
|
+
create_table :<%= table_name %><%= ", id: :uuid" if uuid_enabled? %> do |t|
|
|
6
6
|
t.string :name
|
|
7
|
-
t.references :resource, polymorphic: true, index: true
|
|
7
|
+
t.references :resource, polymorphic: true, index: true<%= ", type: :uuid" if uuid_enabled? %>
|
|
8
8
|
|
|
9
9
|
t.timestamps
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
create_table :<%= table_name.singularize %>_assignments do |t|
|
|
13
|
-
t.references :<%= user_cname.underscore %>, index: true
|
|
14
|
-
t.references :<%= table_name.singularize %>, index: true
|
|
12
|
+
create_table :<%= table_name.singularize %>_assignments<%= ", id: :uuid" if uuid_enabled? %> do |t|
|
|
13
|
+
t.references :<%= user_cname.underscore %>, index: true<%= ", type: :uuid" if uuid_enabled? %>
|
|
14
|
+
t.references :<%= table_name.singularize %>, index: true<%= ", type: :uuid" if uuid_enabled? %>
|
|
15
15
|
t.datetime :expires_at, index: true
|
|
16
16
|
t.jsonb :meta, default: {}
|
|
17
17
|
|
data/lib/role_fu/version.rb
CHANGED