monarchy 2.0.5 → 2.0.6
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_changelog_generator +1 -1
- data/.rubocop.yml +2 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +9 -2
- data/Gemfile.lock +1 -1
- data/README.md +15 -2
- data/lib/monarchy/acts_as_user.rb +8 -3
- data/lib/monarchy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: addca284a9a12f9d545fbf43ebf3de15908a6618
|
4
|
+
data.tar.gz: ba69a2d1eb4a11dff1a6ad294c9d2469b653d5f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0b5d0651fc8ea7b1bcf4e77bb532304fac7a3d695093510fcf11e2115bcc98ea2cc4a22b05bf1df6796a204bccaa63b74b21b6365f3804762f87fd6d15d0102
|
7
|
+
data.tar.gz: 7184060eb920b6323dfbe85ffac7e2f8725907c458be8f9691c6b305bf5443c4e74ec686bb101b7accd1bcfd4eb1a715fdc28402eeee2c6fed13175897bde2a8
|
data/.github_changelog_generator
CHANGED
@@ -1 +1 @@
|
|
1
|
-
future-release=2.0.
|
1
|
+
future-release=2.0.6
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [2.0.
|
4
|
-
[Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.0.
|
3
|
+
## [2.0.6](https://github.com/Exelord/Monarchy/tree/2.0.6) (2016-11-29)
|
4
|
+
[Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.0.5...2.0.6)
|
5
|
+
|
6
|
+
**Fixed bugs:**
|
7
|
+
|
8
|
+
- Fix roles order [\#63](https://github.com/Exelord/Monarchy/pull/63) ([Exelord](https://github.com/Exelord))
|
9
|
+
|
10
|
+
## [v2.0.5](https://github.com/Exelord/Monarchy/tree/v2.0.5) (2016-11-10)
|
11
|
+
[Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.0.4...v2.0.5)
|
5
12
|
|
6
13
|
**Merged pull requests:**
|
7
14
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,9 @@
|
|
12
12
|
<a href="https://codeclimate.com/github/Exelord/Monarchy">
|
13
13
|
<img src="https://codeclimate.com/github/Exelord/Monarchy/badges/gpa.svg">
|
14
14
|
</a>
|
15
|
+
<a href="https://codeclimate.com/github/Exelord/Monarchy/coverage">
|
16
|
+
<img src="https://codeclimate.com/github/Exelord/Monarchy/badges/coverage.svg" />
|
17
|
+
</a>
|
15
18
|
</p>
|
16
19
|
|
17
20
|
Monarchy is a ruby gem offering a complete solution to manage an access in your web application.
|
@@ -33,19 +36,29 @@ manager_role = Monarchy.role_class.create(name: :manager, level: 4, inherited_ro
|
|
33
36
|
project1 = Project.create()
|
34
37
|
project2 = Project.create(parent: project1)
|
35
38
|
project3 = Project.create(parent: project2)
|
36
|
-
project4 = Project.create()
|
39
|
+
project4 = Project.create(parent: project1)
|
37
40
|
|
38
41
|
# Grant user
|
39
42
|
user.grant(:manager, project2)
|
40
43
|
|
41
44
|
# Accessible projects
|
42
|
-
Project.accessible_for(user) # returns [
|
45
|
+
Project.accessible_for(user) # returns [project1, project2, project3]
|
43
46
|
|
44
47
|
# User inherited roles
|
45
48
|
user.roles_for(project1) # returns a default role eg. [guest_role]
|
46
49
|
user.roles_for(project2) # returns [manager_role]
|
47
50
|
user.roles_for(project3) # returns [admin_role]
|
48
51
|
user.roles_for(project4) # returns empty array []
|
52
|
+
|
53
|
+
# Graphical visualization
|
54
|
+
|
55
|
+
# project1 (default role, eg. guest)
|
56
|
+
# |
|
57
|
+
# |
|
58
|
+
# (granted as manager) project2 project4 (no access)
|
59
|
+
# |
|
60
|
+
# |
|
61
|
+
# project3 (admin | inherited role from manager_role)
|
49
62
|
```
|
50
63
|
|
51
64
|
## Requirements
|
@@ -55,10 +55,10 @@ module Monarchy
|
|
55
55
|
accessible_roles = if inheritnce
|
56
56
|
resource_and_inheritance_roles(resource)
|
57
57
|
else
|
58
|
-
resource_roles(resource)
|
58
|
+
resource_roles(resource)
|
59
59
|
end
|
60
60
|
|
61
|
-
return accessible_roles if accessible_roles.present?
|
61
|
+
return accessible_roles.order(level: :desc, name: :asc) if accessible_roles.present?
|
62
62
|
inheritnce ? descendant_role(resource) : Monarchy.role_class.none
|
63
63
|
end
|
64
64
|
|
@@ -87,7 +87,12 @@ module Monarchy
|
|
87
87
|
def descendant_role(resource)
|
88
88
|
descendants = resource.hierarchy.descendants
|
89
89
|
children_access = members_for(descendants).present?
|
90
|
-
|
90
|
+
|
91
|
+
if children_access
|
92
|
+
Monarchy.role_class.where(id: inherited_default_role).order(level: :desc, name: :asc)
|
93
|
+
else
|
94
|
+
Monarchy.role_class.none
|
95
|
+
end
|
91
96
|
end
|
92
97
|
|
93
98
|
def revoking_role(role_name, resource, strategy = nil)
|
data/lib/monarchy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monarchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Exelord
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|