guachiman 1.0.1 → 1.0.2

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: 97d7c5faf252acffc4cd784ae04bd48dc95bbfcc
4
- data.tar.gz: 1e87686d64536b2672e1554bb67e32007e8c2494
3
+ metadata.gz: a18c344b744428ee649a57ba3f4268d4aabc793e
4
+ data.tar.gz: d5ce9e297a202f2baa78966042610216aa39a862
5
5
  SHA512:
6
- metadata.gz: ac3f9f4298eb754ad5c743546304c0f258b10869fdb19e48c7f4fc342fed8544fe2f71132bc3ac6fe3810df457db54d1d32e3d6986a1ccbfb4305bf1dad564b2
7
- data.tar.gz: 81f6dc65dacdb2250978b11914a49fe5b0a72ec423ccd0fbff188d64743ca224383c70c1e53318fa0ed06fee6ebe585dc1afd05aad5f3993372d27fcf01bb532
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 v1.0.0
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
- member_authorization
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 member_authorization
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 a block.
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
 
@@ -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 library'
12
- spec.description = "#{ spec.summary } inspired by Ryan Bates' Railscasts #385 and #386"
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
 
@@ -1,4 +1,4 @@
1
- require 'guachiman/version'
1
+ require "guachiman/version"
2
2
 
3
3
  module Guachiman
4
4
  def rules
@@ -1,3 +1,3 @@
1
1
  module Guachiman
2
- VERSION = '1.0.1'
2
+ VERSION = "1.0.2"
3
3
  end
@@ -1,6 +1,6 @@
1
- require 'bundler/setup'
2
- require 'minitest/autorun'
3
- require 'guachiman'
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 test_block_rules
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.1
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: 'Minimal authorization library inspired by Ryan Bates'' Railscasts #385
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 library
114
+ summary: Minimal authorization
116
115
  test_files:
117
116
  - test/guachiman_test.rb