ruolo 0.2.0 → 0.3.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/CHANGELOG.md +5 -0
- data/README.md +13 -0
- data/lib/ruolo/models/user.rb +10 -1
- data/lib/ruolo/version.rb +1 -1
- 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: 0a59aa52708f49c8096c1c0623d7098120fa34e73cdd4bc72d8380f165bd67ac
|
4
|
+
data.tar.gz: d6463de5e3dceceecbac1fe0b0ed873748e508246497bc460ed2dc73ed55ddb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f8944b7a657b4c7681558fd32f617a5df71d6639e869e3cf1b606e706a98379a48262384d041c252fb70d15111adceac3f75da92e5e97a2ed6e3d68209a12ff
|
7
|
+
data.tar.gz: bc75347e0ffce4b4c1d13d0fc2e265d21cac5e5c716be49df994a3b08948ba831f71d5c0ab4653ad78ee163f12bab81c961a2f92a46ae705264d0cd92334d766
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
This file keeps track of changes between releases for the ruolo project
|
4
4
|
which adheres to [semantic versioning](https://semver.org).
|
5
5
|
|
6
|
+
## v0.3.0 2019-10-08
|
7
|
+
|
8
|
+
Add a `role?` method to the user mixin to check for given roles instead of
|
9
|
+
permissions.
|
10
|
+
|
6
11
|
## v0.2.0 2019-09-11
|
7
12
|
|
8
13
|
Initial cleanup of original code: add tests and documentation.
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Ruolo
|
2
2
|
|
3
|
+
[](https://rubygems.org/gems/ruolo)
|
3
4
|
[](https://travis-ci.org/mfinelli/ruolo)
|
4
5
|
[](https://coveralls.io/github/mfinelli/ruolo?branch=master)
|
5
6
|
[](http://inch-ci.org/github/mfinelli/ruolo)
|
@@ -17,6 +18,18 @@ and authorization of users after that, `ruolo` is completely unopinionated.
|
|
17
18
|
|
18
19
|
## Usage
|
19
20
|
|
21
|
+
### Require
|
22
|
+
|
23
|
+
Include the gem in your gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'ruolo', require: false
|
27
|
+
```
|
28
|
+
|
29
|
+
Notice the `require: false` which is necessary so it doesn't automatically get
|
30
|
+
included if you do something like `Bundler.require`. Make sure that you have a
|
31
|
+
database connection and _then_ require the gem and configure it.
|
32
|
+
|
20
33
|
### Migrations
|
21
34
|
|
22
35
|
You'll need to run the following database migration to setup your schema, fill
|
data/lib/ruolo/models/user.rb
CHANGED
@@ -19,7 +19,7 @@ module Ruolo
|
|
19
19
|
# A mixin to include in downstream user classes that adds useful helper
|
20
20
|
# methods for dealing with roles and permissions.
|
21
21
|
module User
|
22
|
-
# Given the name of a permission
|
22
|
+
# Given the name of a permission determine whether the user's role
|
23
23
|
# membership includes it.
|
24
24
|
#
|
25
25
|
# @param permission [String] the name of the permission
|
@@ -27,6 +27,15 @@ module Ruolo
|
|
27
27
|
def permission?(permission)
|
28
28
|
roles.map { |role| role.permissions.map(&:name) }.flatten.uniq.include?(permission)
|
29
29
|
end
|
30
|
+
|
31
|
+
# Given a role name or array of role names determine if the user has
|
32
|
+
# that/those roles.
|
33
|
+
#
|
34
|
+
# @param role [String|Array<String>] role(s) to check
|
35
|
+
# @return [Boolean] if the user has the given role(s)
|
36
|
+
def role?(role)
|
37
|
+
!(roles.map(&:name) & Array(role)).empty?
|
38
|
+
end
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
data/lib/ruolo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruolo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Finelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|