rails-acu 2.1.0 → 2.2.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
  SHA1:
3
- metadata.gz: 7a7d60b156e3659b6855ebf7aaf31408b27d7cca
4
- data.tar.gz: 3348325c341c48d2a4a24019882caca888f44d49
3
+ metadata.gz: 1b2563936934989850c0e722493a76812b1fd6b6
4
+ data.tar.gz: 1614f918ac20a0428122766f4d87009ef1ebffe5
5
5
  SHA512:
6
- metadata.gz: ab06cba37ec9e9ee51a7f8c7d339e1d98906f4abb6521d616132411322c3de435017a51faeb816ac22a2a6af64d6473a9d3362e51c2d500d4e3ddd7bd4ebc261
7
- data.tar.gz: 54381599563969a2a81af8f4d8a92e853f0667b4b30fe34aed5f7fb3e8cea53da2b517cbf6eb62750007ebd736824eda5419c81acefece4a5266fefbd6aba511
6
+ metadata.gz: f13538958c6e64044bb04110c14bcfe6059bd844b82e7e0d80f84a7ca259015f0530c9e5b303347bd7224c236ad56adf4bcfd914d25c1e6839a3d17346d78ee2
7
+ data.tar.gz: 176d26a870e35eb5ab33485811ccebf63d9ebc211c9a4913995efe0e734b15dea86cec662600a4262ff6834f7fb7cadff6c933e1bce197723881eab430bd8b7c
data/Gemfile.lock CHANGED
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- rails-acu (2.1.0)
10
+ rails-acu (2.2.0)
11
11
  rails (~> 5.0.0, >= 5.0.0)
12
12
 
13
13
  GEM
@@ -63,8 +63,8 @@ GEM
63
63
  warden (~> 1.2.3)
64
64
  diff-lcs (1.3)
65
65
  erubis (2.7.0)
66
- globalid (0.3.7)
67
- activesupport (>= 4.1.0)
66
+ globalid (0.4.0)
67
+ activesupport (>= 4.2.0)
68
68
  i18n (0.8.1)
69
69
  jquery-rails (4.3.1)
70
70
  rails-dom-testing (>= 1, < 3)
data/README.md CHANGED
@@ -112,7 +112,7 @@ The method `Acu::Monitor.gaurd` accepts a hashed list of agruments named `by`, p
112
112
 
113
113
  ### Some handy helpers
114
114
  Although you can define a binary allow/deny access rule in the `acu_rules.rb` file but there will be some gray area that neither you can allow _full access_ to the resource nor _no access_.<br />
115
- for those situations you allow the entities to get access but limits their operations in the action/view/layout with the `acu_is?` and `acu_as` helpers, here is some usage example of them:
115
+ For those situations you allow the entities to get access but limits their operations in the action/view/layout with the `acu_is?`, `acu_as` and `acu_except` helpers, here is some usage example of them:
116
116
 
117
117
  ```ruby
118
118
  # return true if the entity `:admin`'s block in `whois :admin` return true, otherwise false
@@ -128,6 +128,11 @@ end
128
128
  acu_as [:admin, :client] do
129
129
  puts 'You are either `admin` or `client`'
130
130
  end
131
+
132
+ # DO NOT executes the block if current user identified as either `:guest`
133
+ acu_except [:guest] do
134
+ puts 'Except `:guest`s anyone else can execute this code'
135
+ end
131
136
  ```
132
137
 
133
138
  ### Configurations
@@ -214,6 +219,26 @@ class Acu::Errors::MissingController < MissingData
214
219
  class Acu::Errors::MissingNamespace < MissingData
215
220
  ```
216
221
 
222
+ ## Known contributions subjects to work on
223
+
224
+ ### Implementing to overriding the rules in inner loops:
225
+ Consider we have to give the everyone to access the default namespace except `:profile` controller which will only allow by signed in users, although there are tools provided
226
+ for this purpose, such as `except` and `only` tags on `controller` and `namespace` but it would be nice if there are such a command like `override` which its skeleton has been
227
+ defined in the `Acu::Rules.override` which enables the previously defined rule to be overrided, the following pseudo-example removes the `allow :everyone` rule from the controller
228
+ `profile`:
229
+
230
+ ```ruby
231
+ # config/initializers/acu_rules.rb
232
+ [...]
233
+ namespace do
234
+ allow :everyone
235
+ controller :profiles do
236
+ override :everyone
237
+ allow :signed_in
238
+ end
239
+ end
240
+ [...]
241
+ ```
217
242
 
218
243
 
219
244
  ## Contributing
@@ -6,4 +6,8 @@ end
6
6
 
7
7
  def acu_as symbol
8
8
  yield if acu_is? symbol
9
+ end
10
+
11
+ def acu_except symbol
12
+ yield if not acu_is? symbol
9
13
  end
data/lib/acu/rules.rb CHANGED
@@ -97,6 +97,10 @@ module Acu
97
97
  op *symbol, @DENY_SYMBOL, on
98
98
  end
99
99
 
100
+ def override *symbol, with:, on: []
101
+ raise Exception.new('not implemented!');
102
+ end
103
+
100
104
  ################### end of ops ####################
101
105
 
102
106
  protected
data/lib/acu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Acu
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -526,7 +526,7 @@ RSpec.describe HomeController, type: :controller do
526
526
  expect(acu_is? :everyone).to be true
527
527
  expect(acu_is? :client).to be false
528
528
  end
529
- it "acu_do" do
529
+ it "acu_as" do
530
530
  Acu::Rules.define do
531
531
  whois :everyone { true }
532
532
  whois :client { false }
@@ -544,6 +544,24 @@ RSpec.describe HomeController, type: :controller do
544
544
  expect(acu_is? :everyone).to be true
545
545
  end
546
546
  end
547
+ it "acu_except" do
548
+ Acu::Rules.define do
549
+ whois :everyone { true }
550
+ whois :client { false }
551
+ end
552
+ acu_except :everyone do
553
+ # an invalid syntax, this should never run
554
+ expect(true).not_to be true
555
+ end
556
+ acu_except :client do
557
+ # a valid syntax
558
+ expect(true).to be true
559
+ end
560
+ # no-one gets through
561
+ acu_except [:client, :everyone] do
562
+ expect(true).not_to be true
563
+ end
564
+ end
547
565
  end
548
566
  context 'caching' do
549
567
  it '[Rails.cache]' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-acu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dariush Hasanpour
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-02 00:00:00.000000000 Z
11
+ date: 2017-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails