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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3366759c1da52afa0c58dfc5c4778868b4fba8ff7b1f3a29cbd0a7580306e3af
4
- data.tar.gz: 8bb57e581742d56a7259880eb33998eb042a6ef5a1df4b230072c7e923dbe991
3
+ metadata.gz: 0a59aa52708f49c8096c1c0623d7098120fa34e73cdd4bc72d8380f165bd67ac
4
+ data.tar.gz: d6463de5e3dceceecbac1fe0b0ed873748e508246497bc460ed2dc73ed55ddb6
5
5
  SHA512:
6
- metadata.gz: 6bc881521a3481e12b107b14e611140cf47abcb508438b296167030aad9bf411983f7ad7765ce2f58eb754a07df8e9570f6bc14baf98e95cde2e0a713d5b095c
7
- data.tar.gz: 2aad3aed99d638fe0e46544a462342533d8e70392b552310fa7f209047905307715819f028d9a89650f949ad625e867c45e959d8b7c7c32231bc85aa25e91067
6
+ metadata.gz: 7f8944b7a657b4c7681558fd32f617a5df71d6639e869e3cf1b606e706a98379a48262384d041c252fb70d15111adceac3f75da92e5e97a2ed6e3d68209a12ff
7
+ data.tar.gz: bc75347e0ffce4b4c1d13d0fc2e265d21cac5e5c716be49df994a3b08948ba831f71d5c0ab4653ad78ee163f12bab81c961a2f92a46ae705264d0cd92334d766
@@ -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
+ [![RubyGems](https://img.shields.io/gem/v/ruolo.svg)](https://rubygems.org/gems/ruolo)
3
4
  [![Build Status](https://travis-ci.org/mfinelli/ruolo.svg?branch=master)](https://travis-ci.org/mfinelli/ruolo)
4
5
  [![Coverage Status](https://coveralls.io/repos/github/mfinelli/ruolo/badge.svg?branch=master)](https://coveralls.io/github/mfinelli/ruolo?branch=master)
5
6
  [![Inline docs](http://inch-ci.org/github/mfinelli/ruolo.svg?branch=master)](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
@@ -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 determin whether the user's role
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
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module Ruolo
18
- VERSION = '0.2.0'
18
+ VERSION = '0.3.0'
19
19
  end
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.2.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-09-11 00:00:00.000000000 Z
11
+ date: 2019-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel