guachiman 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -10
- data/guachiman.gemspec +2 -2
- data/lib/guachiman.rb +1 -1
- data/lib/guachiman/version.rb +1 -1
- data/test/guachiman_test.rb +10 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a18c344b744428ee649a57ba3f4268d4aabc793e
|
4
|
+
data.tar.gz: d5ce9e297a202f2baa78966042610216aa39a862
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdb2fc2a9913e3bbdcadb0904004f471f2a4893f1a684b9ef1051d26a5287c4e8910bfcef6109ae772a72c83ed18b412c8be4e9a158238bb261f47e30b996214
|
7
|
+
data.tar.gz: 40234abb8475dcc0d0f98e54388b3b21ce42047f4433472ef201102cd8abf76ed549e61683e3cec7de12d511fc1b7c0dff0f0e1ac41fa1da4a4dbf839266c39e
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
Guachiman
|
2
2
|
=========
|
3
3
|
|
4
|
-
|
5
4
|
Minimal authorization library inspired by [RailsCast #385 Authorization from Scratch][1] by Ryan Bates.
|
6
5
|
|
7
6
|
Guachiman allows you to store authorization rules as a tree of permissions nested within groups.
|
@@ -15,12 +14,11 @@ be the result of the block evaluation.
|
|
15
14
|
[3]: https://www.codeship.io/projects/28071
|
16
15
|
|
17
16
|
|
18
|
-
Upgrading to
|
19
|
-
|
17
|
+
Upgrading to ~> 1.0.0
|
18
|
+
---------------------
|
20
19
|
|
21
20
|
**Starting with version 1.0.0 all Rails-specific code and support has been removed.**
|
22
|
-
A new gem called guachiman-rails will be the recommended way to use Guachiman with Rails.
|
23
|
-
More info [in the repo][4].
|
21
|
+
A new gem called [guachiman-rails][4] will be the recommended way to use Guachiman with Rails.
|
24
22
|
|
25
23
|
[4]: https://github.com/goddamnhippie/guachiman-rails
|
26
24
|
|
@@ -56,9 +54,9 @@ Describe your authorization objects in this way:
|
|
56
54
|
class Authorization
|
57
55
|
include Guachiman
|
58
56
|
|
59
|
-
def initialize(user)
|
57
|
+
def initialize(user = nil)
|
60
58
|
if @current_user = user
|
61
|
-
|
59
|
+
user_authorization
|
62
60
|
else
|
63
61
|
guest_authorization
|
64
62
|
end
|
@@ -70,7 +68,7 @@ private
|
|
70
68
|
allow :sessions, [:new]
|
71
69
|
end
|
72
70
|
|
73
|
-
def
|
71
|
+
def user_authorization
|
74
72
|
guest_authorization
|
75
73
|
|
76
74
|
allow :users, [:show, :edit, :update] do |user_id|
|
@@ -100,8 +98,7 @@ user_authorization.allow?(:users, :show, user.id)
|
|
100
98
|
|
101
99
|
### `#allow`
|
102
100
|
|
103
|
-
This is what you use to set permissions. It takes two parameters, `group` and `permissions`, and
|
104
|
-
All are optional and depend on how specific you want to be.
|
101
|
+
This is what you use to set permissions. It takes two parameters, `group` and `permissions`, and an optional block.
|
105
102
|
|
106
103
|
### `#allow?`
|
107
104
|
|
data/guachiman.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Guachiman::VERSION
|
9
9
|
spec.authors = ['Francesco Rodriguez', 'Gustavo Beathyate']
|
10
10
|
spec.email = ['lrodriguezsanc@gmail.com', 'gustavo.bt@me.com']
|
11
|
-
spec.summary = 'Minimal authorization
|
12
|
-
spec.description = "#{ spec.summary }
|
11
|
+
spec.summary = 'Minimal authorization'
|
12
|
+
spec.description = "#{ spec.summary } library"
|
13
13
|
spec.homepage = 'https://github.com/goddamnhippie/guachiman'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
data/lib/guachiman.rb
CHANGED
data/lib/guachiman/version.rb
CHANGED
data/test/guachiman_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "bundler/setup"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "guachiman"
|
4
4
|
|
5
5
|
class GuachimanTest < MiniTest::Test
|
6
6
|
def setup
|
@@ -23,11 +23,17 @@ class GuachimanTest < MiniTest::Test
|
|
23
23
|
assert @authorization.allow?(:group, :permission2)
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def test_block_rules_without_object
|
27
27
|
refute @authorization.allow?(:group, :permission3)
|
28
28
|
refute @authorization.allow?(:group, :permission4)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_block_rules_with_bad_object
|
29
32
|
refute @authorization.allow?(:group, :permission3, 0)
|
30
33
|
refute @authorization.allow?(:group, :permission4, 0)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_block_rules_with_good_object
|
31
37
|
assert @authorization.allow?(:group, :permission3, 1)
|
32
38
|
assert @authorization.allow?(:group, :permission4, 1)
|
33
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guachiman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodriguez
|
@@ -71,8 +71,7 @@ dependencies:
|
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: 1.6.0
|
74
|
-
description:
|
75
|
-
and #386'
|
74
|
+
description: Minimal authorization library
|
76
75
|
email:
|
77
76
|
- lrodriguezsanc@gmail.com
|
78
77
|
- gustavo.bt@me.com
|
@@ -112,6 +111,6 @@ rubyforge_project:
|
|
112
111
|
rubygems_version: 2.4.1
|
113
112
|
signing_key:
|
114
113
|
specification_version: 4
|
115
|
-
summary: Minimal authorization
|
114
|
+
summary: Minimal authorization
|
116
115
|
test_files:
|
117
116
|
- test/guachiman_test.rb
|