ruolo 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a59aa52708f49c8096c1c0623d7098120fa34e73cdd4bc72d8380f165bd67ac
4
- data.tar.gz: d6463de5e3dceceecbac1fe0b0ed873748e508246497bc460ed2dc73ed55ddb6
3
+ metadata.gz: 73d74a22524e1a1538360b9ef7434bf89cae8bae9d2cdb6d2c23f8641ee742f5
4
+ data.tar.gz: 1171a2731d591334e1bea3f2f188c9900506a71b3a89c25d307dc3af6e528afa
5
5
  SHA512:
6
- metadata.gz: 7f8944b7a657b4c7681558fd32f617a5df71d6639e869e3cf1b606e706a98379a48262384d041c252fb70d15111adceac3f75da92e5e97a2ed6e3d68209a12ff
7
- data.tar.gz: bc75347e0ffce4b4c1d13d0fc2e265d21cac5e5c716be49df994a3b08948ba831f71d5c0ab4653ad78ee163f12bab81c961a2f92a46ae705264d0cd92334d766
6
+ metadata.gz: c06710f4fe37f7ea58ba1a65517b42da510f3bc03314fcda954ac7a2c343d7561f330fa22be86dbaf09e38a7717493484328f544aa56dbefe83c0d46247d249c
7
+ data.tar.gz: 703bd51408cfd80263cc7e35efd468a35a5ca2cd80c2dc36e9ea365083a99e440043447cbea3c0deedcb0b1d6c8cd7ea066b7ff6154c8f168913a1ddced53355
data/.rubocop.yml CHANGED
@@ -7,3 +7,13 @@ AllCops:
7
7
 
8
8
  Layout/ExtraSpacing:
9
9
  AllowForAlignment: false
10
+
11
+ # TODO: remove on next major rubocop
12
+ Style/HashEachMethods:
13
+ Enabled: true
14
+
15
+ Style/HashTransformKeys:
16
+ Enabled: true
17
+
18
+ Style/HashTransformValues:
19
+ Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-09-11 16:19:35 -0400 using RuboCop version 0.74.0.
3
+ # on 2020-03-27 23:01:52 -0400 using RuboCop version 0.80.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
9
+ # Offense count: 2
10
10
  Metrics/AbcSize:
11
11
  Max: 22
12
12
 
@@ -16,11 +16,16 @@ Metrics/AbcSize:
16
16
  Metrics/BlockLength:
17
17
  Max: 87
18
18
 
19
- # Offense count: 1
19
+ # Offense count: 2
20
20
  # Configuration parameters: CountComments, ExcludedMethods.
21
21
  Metrics/MethodLength:
22
22
  Max: 12
23
23
 
24
+ # Offense count: 1
25
+ Naming/AccessorMethodName:
26
+ Exclude:
27
+ - 'lib/ruolo/models/user.rb'
28
+
24
29
  # Offense count: 6
25
30
  RSpec/BeforeAfterAll:
26
31
  Exclude:
@@ -45,9 +50,9 @@ Style/Documentation:
45
50
  - 'test/**/*'
46
51
  - 'bin/console'
47
52
 
48
- # Offense count: 21
53
+ # Offense count: 23
49
54
  # Cop supports --auto-correct.
50
55
  # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
51
56
  # URISchemes: http, https
52
- Metrics/LineLength:
57
+ Layout/LineLength:
53
58
  Max: 146
data/.travis.yml CHANGED
@@ -5,6 +5,7 @@ language: ruby
5
5
  rvm:
6
6
  - 2.5
7
7
  - 2.6
8
+ - 2.7
8
9
 
9
10
  services:
10
11
  - postgresql
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.4.0 2020-03-27
7
+
8
+ Add `set_roles` method to the user mixin to synchronize desired roles for an
9
+ individual user.
10
+
6
11
  ## v0.3.0 2019-10-08
7
12
 
8
13
  Add a `role?` method to the user mixin to check for given roles instead of
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 Mario Finelli
3
+ # Copyright 2019-2020 Mario Finelli
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -36,6 +36,28 @@ module Ruolo
36
36
  def role?(role)
37
37
  !(roles.map(&:name) & Array(role)).empty?
38
38
  end
39
+
40
+ # Given a set of all roles that the user should have add/remove roles as
41
+ # necessary.
42
+ #
43
+ # @param wanted_roles [Array<String>] list of role names
44
+ # @return [void]
45
+ def set_roles(wanted_roles)
46
+ current_roles = roles.map(&:name)
47
+
48
+ remove = current_roles.reject { |r| wanted_roles.include?(r) }
49
+ add = wanted_roles.reject { |r| current_roles.include?(r) }
50
+
51
+ Ruolo.configuration.connection.transaction do
52
+ remove.each do |role|
53
+ remove_role(Ruolo::Models::Role.where(name: role).first)
54
+ end
55
+
56
+ add.each do |role|
57
+ add_role(Ruolo::Models::Role.where(name: role).first)
58
+ end
59
+ end
60
+ end
39
61
  end
40
62
  end
41
63
  end
data/lib/ruolo/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2019 Mario Finelli
3
+ # Copyright 2019-2020 Mario Finelli
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module Ruolo
18
- VERSION = '0.3.0'
18
+ VERSION = '0.4.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.3.0
4
+ version: 0.4.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-10-08 00:00:00.000000000 Z
11
+ date: 2020-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  requirements: []
242
- rubygems_version: 3.0.3
242
+ rubygems_version: 3.1.2
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: A library to keep your static role-based access control policies in sync