action_sentinel 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/action_sentinel/version.rb +1 -1
- data/lib/generators/action_sentinel/access_permission_generator.rb +25 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e32f9fe1d318938091c07167a07ff9b4e8584f0ed712df14b29cbec36819a6e
|
4
|
+
data.tar.gz: a91742b5c786cd20650583bb9eb6dc1fab4ba3b12067958e930b519851917cda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb4ff67b1fc12d024c50d80758109c09158d60a22f3d2d1435bf0daa6b47faacd5cb41cf837c7a48fbdc7e088b69ffb80459f4e73e7611b90f3131e853ec0667
|
7
|
+
data.tar.gz: 82533ced4780a2b942fae90aca15203b730638af6301155dcbc9fb52777cf9d149b917c41ae6b95184fd5f4cd7d86f2bf0785a61fa234db4646d87f5442987f1
|
data/CHANGELOG.md
CHANGED
@@ -8,3 +8,8 @@
|
|
8
8
|
|
9
9
|
- Changed `controller_name` attribute to `controller_path` in `AccessPermission` model
|
10
10
|
- Allow to create actions permissions to scoped controllers
|
11
|
+
|
12
|
+
## [0.3.0] - 2024-01-05
|
13
|
+
|
14
|
+
- Fixed errors when revoking `AccessPermissionGenerator` methods
|
15
|
+
- Added logger to `AccessPermissionGenerator`
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "rails/generators"
|
4
4
|
require "rails/generators/active_record"
|
5
|
+
require "logger"
|
5
6
|
|
6
7
|
module ActionSentinel
|
7
8
|
class AccessPermissionGenerator < Rails::Generators::Base
|
@@ -18,13 +19,27 @@ module ActionSentinel
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def create_access_pemission_and_migration
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
model_file = File.join("app", "models", "#{singular_model_name}.rb")
|
23
|
+
|
24
|
+
if File.exist?(model_file) || revoke_process?
|
25
|
+
inject_action_permissible_into_model(model_file)
|
26
|
+
generate_access_permission
|
27
|
+
generate_migration
|
28
|
+
else
|
29
|
+
logger.info("The file #{model_file} does not appear to exist")
|
30
|
+
end
|
24
31
|
end
|
25
32
|
|
26
33
|
private
|
27
34
|
|
35
|
+
def logger
|
36
|
+
Logger.new($stdout)
|
37
|
+
end
|
38
|
+
|
39
|
+
def revoke_process?
|
40
|
+
behavior == :revoke
|
41
|
+
end
|
42
|
+
|
28
43
|
def generate_access_permission
|
29
44
|
template "access_permission.rb", File.join("app", "models", "access_permission.rb")
|
30
45
|
end
|
@@ -53,10 +68,13 @@ module ActionSentinel
|
|
53
68
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
54
69
|
end
|
55
70
|
|
56
|
-
def inject_action_permissible_into_model
|
57
|
-
|
58
|
-
|
59
|
-
|
71
|
+
def inject_action_permissible_into_model(model_file)
|
72
|
+
if File.exist?(model_file)
|
73
|
+
inject_into_class(model_file, model_class) do
|
74
|
+
"\taction_permissible\n"
|
75
|
+
end
|
76
|
+
else
|
77
|
+
logger.info("The file #{model_file} does not appear to exist")
|
60
78
|
end
|
61
79
|
end
|
62
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_sentinel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Stael
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|