ingress 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6fadfe0fa815422092e415f66fd83dc1915ce0cec8852544d877b1adb763f0
4
- data.tar.gz: 731ff12c70dcbfbe16e1b6abb1c2162cd86aee4c4c4e643077280e1b8f90cab3
3
+ metadata.gz: a8f17e43cf5bacf92bc38048ec7e9eb8588e46567d2ac14a86b64664c369c57e
4
+ data.tar.gz: ffebe86e57b6539ccee3bf4265e4d9dc103a88260e16354f4e4e1a8280600f00
5
5
  SHA512:
6
- metadata.gz: fb49bb4e9cae990a081babb2be38d814c443a6e7d60b2abf0c1eeb2d508e02f5a136e6ec4201f70555938adfe5a31f93216fd1aafba903f0f4d6016bdc263948
7
- data.tar.gz: a92d7ae6f9246b5c0457744d1644fd0fc338c83b333cef0993f064fff8ee609098b7d9c841c6b71cbbdb97e5e7aff83bd131445ef22a901e86e13d1f6d440d63
6
+ metadata.gz: 22e432bad1f93dad170bb773cb259558ed95bebbd5bfd4cb885498609e3b9912136fbb159dd5dfb3af9c6c99350a5ccf9a3582937a9b7443f66aa9a3dfd1668c
7
+ data.tar.gz: 9e27effdf8b6f8a222c50c8f7d05fed65447fa22dd8a9e8cffb3bfa25cd67437917377bf57ce57fca0c547ff623545a447af758f451158b475af4439d717baf3
data/ingress.gemspec CHANGED
@@ -12,6 +12,10 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Simple role based authorization for Ruby applications}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
+ spec.metadata = {
16
+ "bug_tracker_uri" => "https://github.com/skorks/ingress/issues",
17
+ "source_code_uri" => "https://github.com/skorks/ingress",
18
+ }
15
19
 
16
20
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
21
  spec.bindir = "bin"
@@ -13,11 +13,11 @@ module Ingress
13
13
  @allows
14
14
  end
15
15
 
16
- def match?(given_action, given_subject, user)
16
+ def match?(given_action, given_subject, user, options = {})
17
17
  return false unless action_matches?(given_action)
18
18
  return false unless subject_matches?(given_subject)
19
19
 
20
- conditions_match?(user, given_subject)
20
+ conditions_match?(user, given_subject, options)
21
21
  end
22
22
 
23
23
  private
@@ -35,9 +35,13 @@ module Ingress
35
35
  "*" == subject
36
36
  end
37
37
 
38
- def conditions_match?(user, given_subject)
38
+ def conditions_match?(user, given_subject, options)
39
39
  conditions.all? do |condition|
40
- condition.call(user, given_subject)
40
+ if condition.arity == 2
41
+ condition.call(user, given_subject)
42
+ else
43
+ condition.call(user, given_subject, options)
44
+ end
41
45
  end
42
46
  rescue => e
43
47
  log_error(e)
@@ -42,17 +42,17 @@ module Ingress
42
42
  @user = user
43
43
  end
44
44
 
45
- def can?(action, subject)
45
+ def can?(action, subject, options = {})
46
46
  user_role_identifiers.any? do |role_identifier|
47
47
  rules = self.class.permissions_repository.rules_for(role_identifier, action, subject)
48
48
 
49
49
  cannot_match = rules.reject(&:allows?).any? do |rule|
50
- rule.match?(action, subject, user)
50
+ rule.match?(action, subject, user, options)
51
51
  end
52
52
  break false if cannot_match
53
53
 
54
54
  rules.select(&:allows?).any? do |rule|
55
- rule.match?(action, subject, user)
55
+ rule.match?(action, subject, user, options)
56
56
  end
57
57
  end
58
58
  end
@@ -1,3 +1,3 @@
1
1
  module Ingress
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ingress
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
  - Alan Skorkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-02 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,7 +87,9 @@ files:
87
87
  homepage: ''
88
88
  licenses:
89
89
  - MIT
90
- metadata: {}
90
+ metadata:
91
+ bug_tracker_uri: https://github.com/skorks/ingress/issues
92
+ source_code_uri: https://github.com/skorks/ingress
91
93
  post_install_message:
92
94
  rdoc_options: []
93
95
  require_paths: