rolify 3.0.0 → 3.1.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.
Files changed (31) hide show
  1. data/CHANGELOG.rdoc +13 -1
  2. data/{README.rdoc → README.md} +69 -41
  3. data/lib/generators/rolify/role/role_generator.rb +2 -2
  4. data/lib/generators/rolify/role/templates/initializer.rb +3 -3
  5. data/lib/generators/rolify/role/templates/role-mongoid.rb +9 -0
  6. data/lib/rolify.rb +10 -7
  7. data/lib/rolify/adapters/active_record/resource_adapter.rb +17 -0
  8. data/lib/rolify/adapters/{active_record.rb → active_record/role_adapter.rb} +12 -21
  9. data/lib/rolify/adapters/base.rb +24 -22
  10. data/lib/rolify/adapters/mongoid/resource_adapter.rb +23 -0
  11. data/lib/rolify/adapters/{mongoid.rb → mongoid/role_adapter.rb} +11 -31
  12. data/lib/rolify/configure.rb +5 -4
  13. data/lib/rolify/dynamic.rb +1 -1
  14. data/lib/rolify/role.rb +11 -7
  15. data/lib/rolify/utils.rb +10 -0
  16. data/lib/rolify/version.rb +1 -1
  17. data/rolify.gemspec +1 -1
  18. data/spec/generators/rolify/role/role_generator_spec.rb +41 -19
  19. data/spec/rolify/config_spec.rb +13 -11
  20. data/spec/rolify/resource_spec.rb +28 -29
  21. data/spec/rolify/shared_contexts.rb +17 -17
  22. data/spec/rolify/shared_examples/{shared_examples_for_has_role_setter.rb → shared_examples_for_add_role.rb} +16 -16
  23. data/spec/rolify/shared_examples/shared_examples_for_dynamic.rb +6 -6
  24. data/spec/rolify/shared_examples/shared_examples_for_has_any_role.rb +6 -6
  25. data/spec/rolify/shared_examples/{shared_examples_for_has_role_getter.rb → shared_examples_for_has_role.rb} +0 -0
  26. data/spec/rolify/shared_examples/{shared_examples_for_has_no_role.rb → shared_examples_for_remove_role.rb} +37 -13
  27. data/spec/rolify/shared_examples/shared_examples_for_roles.rb +18 -20
  28. data/spec/spec_helper.rb +0 -4
  29. data/spec/support/adapters/active_record.rb +2 -0
  30. data/spec/support/adapters/mongoid.rb +2 -0
  31. metadata +33 -31
@@ -11,13 +11,13 @@ shared_context "global role", :scope => :global do
11
11
  def load_roles
12
12
  role_class.destroy_all
13
13
  admin.roles = []
14
- admin.has_role "admin"
15
- admin.has_role "staff"
16
- admin.has_role "manager", Group
17
- admin.has_role "player", Forum
18
- admin.has_role "moderator", Forum.last
19
- admin.has_role "moderator", Group.last
20
- admin.has_role "anonymous", Forum.first
14
+ admin.add_role :admin
15
+ admin.add_role :staff
16
+ admin.add_role :manager, Group
17
+ admin.add_role :player, Forum
18
+ admin.add_role :moderator, Forum.last
19
+ admin.add_role :moderator, Group.last
20
+ admin.add_role :anonymous, Forum.first
21
21
  end
22
22
  end
23
23
 
@@ -34,12 +34,12 @@ shared_context "class scoped role", :scope => :class do
34
34
  def load_roles
35
35
  role_class.destroy_all
36
36
  manager.roles = []
37
- manager.has_role "manager", Forum
38
- manager.has_role "player", Forum
39
- manager.has_role "warrior"
40
- manager.has_role "moderator", Forum.last
41
- manager.has_role "moderator", Group.last
42
- manager.has_role "anonymous", Forum.first
37
+ manager.add_role :manager, Forum
38
+ manager.add_role :player, Forum
39
+ manager.add_role :warrior
40
+ manager.add_role :moderator, Forum.last
41
+ manager.add_role :moderator, Group.last
42
+ manager.add_role :anonymous, Forum.first
43
43
  end
44
44
  end
45
45
 
@@ -56,10 +56,10 @@ shared_context "instance scoped role", :scope => :instance do
56
56
  def load_roles
57
57
  role_class.destroy_all
58
58
  moderator.roles = []
59
- moderator.has_role "moderator", Forum.first
60
- moderator.has_role "anonymous", Forum.last
61
- moderator.has_role "visitor", Forum
62
- moderator.has_role "soldier"
59
+ moderator.add_role :moderator, Forum.first
60
+ moderator.add_role :anonymous, Forum.last
61
+ moderator.add_role :visitor, Forum
62
+ moderator.add_role :soldier
63
63
  end
64
64
  end
65
65
 
@@ -1,12 +1,12 @@
1
- shared_examples_for "#has_role_examples" do |param_name, param_method|
1
+ shared_examples_for "#add_role_examples" do |param_name, param_method|
2
2
  context "using #{param_name} as parameter" do
3
3
  context "with a global role", :scope => :global do
4
4
  it "should add the role to the user" do
5
- expect { subject.has_role "root".send(param_method) }.to change{ subject.roles.count }.by(1)
5
+ expect { subject.add_role "root".send(param_method) }.to change { subject.roles.count }.by(1)
6
6
  end
7
7
 
8
8
  it "should create a role to the roles table" do
9
- expect { subject.has_role "moderator".send(param_method) }.to change{ role_class.count }.by(1)
9
+ expect { subject.add_role "moderator".send(param_method) }.to change { role_class.count }.by(1)
10
10
  end
11
11
 
12
12
  context "considering a new global role" do
@@ -19,24 +19,24 @@ shared_examples_for "#has_role_examples" do |param_name, param_method|
19
19
 
20
20
  context "should not create another role" do
21
21
  it "if the role was already assigned to the user" do
22
- subject.has_role "manager".send(param_method)
23
- expect { subject.has_role "manager".send(param_method) }.not_to change{ subject.roles.size }
22
+ subject.add_role "manager".send(param_method)
23
+ expect { subject.add_role "manager".send(param_method) }.not_to change { subject.roles.size }
24
24
  end
25
25
 
26
26
  it "if the role already exists in the db" do
27
27
  role_class.create :name => "god"
28
- expect { subject.has_role "god".send(param_method) }.not_to change{ role_class.count }
28
+ expect { subject.add_role "god".send(param_method) }.not_to change { role_class.count }
29
29
  end
30
30
  end
31
31
  end
32
32
 
33
33
  context "with a class scoped role", :scope => :class do
34
34
  it "should add the role to the user" do
35
- expect { subject.has_role "supervisor".send(param_method), Forum }.to change{ subject.roles.count }.by(1)
35
+ expect { subject.add_role "supervisor".send(param_method), Forum }.to change { subject.roles.count }.by(1)
36
36
  end
37
37
 
38
38
  it "should create a role in the roles table" do
39
- expect { subject.has_role "moderator".send(param_method), Forum }.to change{ role_class.count }.by(1)
39
+ expect { subject.add_role "moderator".send(param_method), Forum }.to change { role_class.count }.by(1)
40
40
  end
41
41
 
42
42
  context "considering a new class scoped role" do
@@ -49,24 +49,24 @@ shared_examples_for "#has_role_examples" do |param_name, param_method|
49
49
 
50
50
  context "should not create another role" do
51
51
  it "if the role was already assigned to the user" do
52
- subject.has_role "warrior".send(param_method), Forum
53
- expect { subject.has_role "warrior".send(param_method), Forum }.not_to change{ subject.roles.size }
52
+ subject.add_role "warrior".send(param_method), Forum
53
+ expect { subject.add_role "warrior".send(param_method), Forum }.not_to change { subject.roles.size }
54
54
  end
55
55
 
56
56
  it "if already existing in the database" do
57
57
  role_class.create :name => "hacker", :resource_type => "Forum"
58
- expect { subject.has_role "hacker".send(param_method), Forum }.not_to change{ role_class.count }
58
+ expect { subject.add_role "hacker".send(param_method), Forum }.not_to change { role_class.count }
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
63
  context "with an instance scoped role", :scope => :instance do
64
64
  it "should add the role to the user" do
65
- expect { subject.has_role "visitor".send(param_method), Forum.last }.to change{ subject.roles.size }.by(1)
65
+ expect { subject.add_role "visitor".send(param_method), Forum.last }.to change { subject.roles.size }.by(1)
66
66
  end
67
67
 
68
68
  it "should create a role in the roles table" do
69
- expect { subject.has_role "member".send(param_method), Forum.last }.to change{ role_class.count }.by(1)
69
+ expect { subject.add_role "member".send(param_method), Forum.last }.to change { role_class.count }.by(1)
70
70
  end
71
71
 
72
72
  context "considering a new class scoped role" do
@@ -78,13 +78,13 @@ shared_examples_for "#has_role_examples" do |param_name, param_method|
78
78
 
79
79
  context "should not create another role" do
80
80
  it "if the role was already assigned to the user" do
81
- subject.has_role "anonymous".send(param_method), Forum.first
82
- expect { subject.has_role "anonymous".send(param_method), Forum.first }.not_to change{ subject.roles.size }
81
+ subject.add_role "anonymous".send(param_method), Forum.first
82
+ expect { subject.add_role "anonymous".send(param_method), Forum.first }.not_to change { subject.roles.size }
83
83
  end
84
84
 
85
85
  it "if already existing in the database" do
86
86
  role_class.create :name => "ghost", :resource_type => "Forum", :resource_id => Forum.first.id
87
- expect { subject.has_role "ghost".send(param_method), Forum.first }.not_to change{ role_class.count }
87
+ expect { subject.add_role "ghost".send(param_method), Forum.first }.not_to change { role_class.count }
88
88
  end
89
89
  end
90
90
  end
@@ -10,8 +10,8 @@ shared_examples_for Rolify::Dynamic do
10
10
  context "using a global role" do
11
11
  subject do
12
12
  admin = user_class.first
13
- admin.has_role "admin"
14
- admin.has_role "moderator", Forum.first
13
+ admin.add_role :admin
14
+ admin.add_role :moderator, Forum.first
15
15
  admin
16
16
  end
17
17
 
@@ -27,7 +27,7 @@ shared_examples_for Rolify::Dynamic do
27
27
  context "using a resource scoped role" do
28
28
  subject do
29
29
  moderator = user_class.where(:login => "moderator").first
30
- moderator.has_role "moderator", Forum.first
30
+ moderator.add_role :moderator, Forum.first
31
31
  moderator
32
32
  end
33
33
 
@@ -49,7 +49,7 @@ shared_examples_for Rolify::Dynamic do
49
49
  context "using a class scoped role" do
50
50
  subject do
51
51
  manager = user_class.where(:login => "god").first
52
- manager.has_role "manager", Forum
52
+ manager.add_role :manager, Forum
53
53
  manager
54
54
  end
55
55
 
@@ -77,7 +77,7 @@ shared_examples_for Rolify::Dynamic do
77
77
  context "using a global role" do
78
78
  before(:all) do
79
79
  other_guy = user_class.last
80
- other_guy.has_role "superman"
80
+ other_guy.add_role :superman
81
81
  end
82
82
 
83
83
  it { should respond_to(:is_superman?).with(0).arguments }
@@ -90,7 +90,7 @@ shared_examples_for Rolify::Dynamic do
90
90
  context "using a resource scope role" do
91
91
  before(:all) do
92
92
  other_guy = user_class.last
93
- other_guy.has_role("batman", Forum.first)
93
+ other_guy.add_role :batman, Forum.first
94
94
  end
95
95
 
96
96
  it { should respond_to(:is_batman?).with(0).arguments }
@@ -2,7 +2,7 @@ shared_examples_for "#has_any_role?_examples" do |param_name, param_method|
2
2
  context "using #{param_name} as parameter" do
3
3
  context "with a global role", :scope => :global do
4
4
  before(:all) do
5
- subject.has_role "staff".send(param_method)
5
+ subject.add_role "staff".send(param_method)
6
6
  end
7
7
 
8
8
  it { subject.has_any_role?("staff".send(param_method)).should be_true }
@@ -21,8 +21,8 @@ shared_examples_for "#has_any_role?_examples" do |param_name, param_method|
21
21
 
22
22
  context "with a class scoped role", :scope => :class do
23
23
  before(:all) do
24
- subject.has_role "player".send(param_method), Forum
25
- subject.has_role "superhero".send(param_method)
24
+ subject.add_role "player".send(param_method), Forum
25
+ subject.add_role "superhero".send(param_method)
26
26
  end
27
27
 
28
28
  it { subject.has_any_role?({ :name => "player".send(param_method), :resource => Forum }).should be_true }
@@ -41,9 +41,9 @@ shared_examples_for "#has_any_role?_examples" do |param_name, param_method|
41
41
 
42
42
  context "with a instance scoped role", :scope => :instance do
43
43
  before(:all) do
44
- subject.has_role "visitor".send(param_method), Forum.last
45
- subject.has_role "leader", Group
46
- subject.has_role "warrior"
44
+ subject.add_role "visitor".send(param_method), Forum.last
45
+ subject.add_role "leader", Group
46
+ subject.add_role "warrior"
47
47
  end
48
48
 
49
49
  it { subject.has_any_role?({ :name => "visitor", :resource => Forum.last }).should be_true }
@@ -1,8 +1,8 @@
1
- shared_examples_for "#has_no_role_examples" do |param_name, param_method|
1
+ shared_examples_for "#remove_role_examples" do |param_name, param_method|
2
2
  context "using #{param_name} as parameter" do
3
3
  context "removing a global role", :scope => :global do
4
4
  context "being a global role of the user" do
5
- it { expect { subject.has_no_role("admin".send(param_method)) }.to change{ subject.roles.size }.by(-1) }
5
+ it { expect { subject.remove_role("admin".send(param_method)) }.to change { subject.roles.size }.by(-1) }
6
6
 
7
7
  it { subject.has_role?("admin".send(param_method)).should be_false }
8
8
  it { subject.has_role?("staff".send(param_method)).should be_true }
@@ -13,7 +13,7 @@ shared_examples_for "#has_no_role_examples" do |param_name, param_method|
13
13
  end
14
14
 
15
15
  context "being a class scoped role to the user" do
16
- it { expect { subject.has_no_role("manager") }.to change{ subject.roles.size }.by(-1) }
16
+ it { expect { subject.remove_role("manager".send(param_method)) }.to change { subject.roles.size }.by(-1) }
17
17
 
18
18
  it { subject.has_role?("admin".send(param_method)).should be_false }
19
19
  it { subject.has_role?("staff".send(param_method)).should be_true }
@@ -24,7 +24,7 @@ shared_examples_for "#has_no_role_examples" do |param_name, param_method|
24
24
  end
25
25
 
26
26
  context "being instance scoped roles to the user" do
27
- it { expect { subject.has_no_role("moderator") }.to change{ subject.roles.size }.by(-2) }
27
+ it { expect { subject.remove_role("moderator".send(param_method)) }.to change { subject.roles.size }.by(-2) }
28
28
 
29
29
  it { subject.has_role?("admin".send(param_method)).should be_false }
30
30
  it { subject.has_role?("staff".send(param_method)).should be_true }
@@ -35,17 +35,41 @@ shared_examples_for "#has_no_role_examples" do |param_name, param_method|
35
35
  end
36
36
 
37
37
  context "not being a role of the user" do
38
- it { expect { subject.has_no_role("superhero") }.not_to change{ subject.roles.size } }
38
+ it { expect { subject.remove_role("superhero".send(param_method)) }.not_to change { subject.roles.size } }
39
+ end
40
+
41
+ context "used by another user" do
42
+ before do
43
+ user = user_class.last
44
+ user.add_role "staff".send(param_method)
45
+ end
46
+
47
+ it { expect { subject.remove_role("staff".send(param_method)) }.not_to change { role_class.count } }
48
+
49
+ it { subject.has_role?("admin".send(param_method)).should be_false }
50
+ it { subject.has_role?("staff".send(param_method)).should be_false }
51
+ it { subject.has_role?("manager".send(param_method), Group).should be_false }
52
+ it { subject.has_role?("moderator".send(param_method), Forum.last).should be_false }
53
+ it { subject.has_role?("moderator".send(param_method), Group.last).should be_false }
54
+ it { subject.has_role?("anonymous".send(param_method), Forum.first).should be_true }
55
+ end
56
+
57
+ context "not used by anyone else" do
58
+ before do
59
+ subject.add_role "nobody".send(param_method)
60
+ end
61
+
62
+ it { expect { subject.remove_role("nobody".send(param_method)) }.to change { role_class.count }.by(-1) }
39
63
  end
40
64
  end
41
65
 
42
66
  context "removing a class scoped role", :scope => :class do
43
67
  context "being a global role of the user" do
44
- it { expect { subject.has_no_role("warrior", Forum) }.not_to change{ subject.roles.size } }
68
+ it { expect { subject.remove_role("warrior".send(param_method), Forum) }.not_to change{ subject.roles.size } }
45
69
  end
46
70
 
47
71
  context "being a class scoped role to the user" do
48
- it { expect { subject.has_no_role("manager", Forum) }.to change{ subject.roles.size }.by(-1) }
72
+ it { expect { subject.remove_role("manager".send(param_method), Forum) }.to change{ subject.roles.size }.by(-1) }
49
73
 
50
74
  it { subject.has_role?("warrior").should be_true }
51
75
  it { subject.has_role?("manager", Forum).should be_false }
@@ -56,7 +80,7 @@ shared_examples_for "#has_no_role_examples" do |param_name, param_method|
56
80
  end
57
81
 
58
82
  context "being instance scoped role to the user" do
59
- it { expect { subject.has_no_role("moderator", Forum) }.to change{ subject.roles.size }.by(-1) }
83
+ it { expect { subject.remove_role("moderator".send(param_method), Forum) }.to change { subject.roles.size }.by(-1) }
60
84
 
61
85
  it { subject.has_role?("warrior").should be_true }
62
86
  it { subject.has_role?("manager", Forum).should be_false }
@@ -67,21 +91,21 @@ shared_examples_for "#has_no_role_examples" do |param_name, param_method|
67
91
  end
68
92
 
69
93
  context "not being a role of the user" do
70
- it { expect { subject.has_no_role("manager", Group) }.not_to change{ subject.roles.size } }
94
+ it { expect { subject.remove_role("manager".send(param_method), Group) }.not_to change { subject.roles.size } }
71
95
  end
72
96
  end
73
97
 
74
98
  context "removing a instance scoped role", :scope => :instance do
75
99
  context "being a global role of the user" do
76
- it { expect { subject.has_no_role("soldier", Group.first) }.not_to change{ subject.roles.size } }
100
+ it { expect { subject.remove_role("soldier".send(param_method), Group.first) }.not_to change { subject.roles.size } }
77
101
  end
78
102
 
79
103
  context "being a class scoped role to the user" do
80
- it { expect { subject.has_no_role("visitor", Forum.first) }.not_to change{ subject.roles.size } }
104
+ it { expect { subject.remove_role("visitor".send(param_method), Forum.first) }.not_to change { subject.roles.size } }
81
105
  end
82
106
 
83
107
  context "being instance scoped role to the user" do
84
- it { expect { subject.has_no_role("moderator", Forum.first) }.to change{ subject.roles.size }.by(-1) }
108
+ it { expect { subject.remove_role("moderator".send(param_method), Forum.first) }.to change { subject.roles.size }.by(-1) }
85
109
 
86
110
  it { subject.has_role?("soldier").should be_true }
87
111
  it { subject.has_role?("visitor", Forum).should be_true }
@@ -90,7 +114,7 @@ shared_examples_for "#has_no_role_examples" do |param_name, param_method|
90
114
  end
91
115
 
92
116
  context "not being a role of the user" do
93
- it { expect { subject.has_no_role("anonymous", Forum.first) }.not_to change{ subject.roles.size } }
117
+ it { expect { subject.remove_role("anonymous".send(param_method), Forum.first) }.not_to change { subject.roles.size } }
94
118
  end
95
119
  end
96
120
  end
@@ -1,9 +1,9 @@
1
1
  require "rolify/shared_contexts"
2
- require "rolify/shared_examples/shared_examples_for_has_role_setter"
3
- require "rolify/shared_examples/shared_examples_for_has_role_getter"
2
+ require "rolify/shared_examples/shared_examples_for_add_role"
3
+ require "rolify/shared_examples/shared_examples_for_has_role"
4
4
  require "rolify/shared_examples/shared_examples_for_has_all_roles"
5
5
  require "rolify/shared_examples/shared_examples_for_has_any_role"
6
- require "rolify/shared_examples/shared_examples_for_has_no_role"
6
+ require "rolify/shared_examples/shared_examples_for_remove_role"
7
7
 
8
8
 
9
9
  shared_examples_for Rolify::Role do
@@ -19,8 +19,8 @@ shared_examples_for Rolify::Role do
19
19
  context "in a Instance level" do
20
20
  before(:all) do
21
21
  admin = user_class.first
22
- admin.has_role "admin"
23
- admin.has_role "moderator", Forum.first
22
+ admin.add_role :admin
23
+ admin.add_role :moderator, Forum.first
24
24
  admin
25
25
  end
26
26
 
@@ -28,12 +28,11 @@ shared_examples_for Rolify::Role do
28
28
  user_class.first
29
29
  end
30
30
 
31
- it { should respond_to(:has_role).with(1).arguments }
32
- it { should respond_to(:has_role).with(2).arguments }
33
-
34
- it { should respond_to(:grant).with(1).arguments }
35
- it { should respond_to(:grant).with(2).arguments }
36
-
31
+ [ :has_role, :grant, :add_role ].each do |method_alias|
32
+ it { should respond_to(method_alias.to_sym).with(1).arguments }
33
+ it { should respond_to(method_alias.to_sym).with(2).arguments }
34
+ end
35
+
37
36
  it { should respond_to(:has_role?).with(1).arguments }
38
37
  it { should respond_to(:has_role?).with(2).arguments }
39
38
 
@@ -43,19 +42,18 @@ shared_examples_for Rolify::Role do
43
42
  it { should respond_to(:has_any_role?) }
44
43
  it { should respond_to(:has_any_role?) }
45
44
 
46
- it { should respond_to(:has_no_role).with(1).arguments }
47
- it { should respond_to(:has_no_role).with(2).arguments }
48
-
49
- it { should respond_to(:revoke).with(1).arguments }
50
- it { should respond_to(:revoke).with(2).arguments }
45
+ [ :has_no_role, :revoke, :remove_role ].each do |method_alias|
46
+ it { should respond_to(method_alias.to_sym).with(1).arguments }
47
+ it { should respond_to(method_alias.to_sym).with(2).arguments }
48
+ end
51
49
 
52
50
  it { should_not respond_to(:is_admin?) }
53
51
  it { should_not respond_to(:is_moderator_of?) }
54
52
  end
55
53
 
56
54
  describe "#has_role" do
57
- it_should_behave_like "#has_role_examples", "String", :to_s
58
- it_should_behave_like "#has_role_examples", "Symbol", :to_sym
55
+ it_should_behave_like "#add_role_examples", "String", :to_s
56
+ it_should_behave_like "#add_role_examples", "Symbol", :to_sym
59
57
  end
60
58
 
61
59
  describe "#has_role?" do
@@ -74,7 +72,7 @@ shared_examples_for Rolify::Role do
74
72
  end
75
73
 
76
74
  describe "#has_no_role" do
77
- it_should_behave_like "#has_no_role_examples", "String", :to_s
78
- it_should_behave_like "#has_no_role_examples", "Symbol", :to_sym
75
+ it_should_behave_like "#remove_role_examples", "String", :to_s
76
+ it_should_behave_like "#remove_role_examples", "Symbol", :to_sym
79
77
  end
80
78
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,4 @@
1
1
  require 'rubygems'
2
- require 'bundler/setup'
3
-
4
- require 'mongoid'
5
- Bundler.require(:default, :development, :test)
6
2
  require 'rolify'
7
3
  require 'ammeter/init'
8
4
 
@@ -1,3 +1,5 @@
1
+ require 'active_record'
2
+
1
3
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
2
4
  ActiveRecord::Base.extend Rolify
3
5
 
@@ -1,3 +1,5 @@
1
+ require 'mongoid'
2
+
1
3
  Mongoid.configure do |config|
2
4
  config.master = Mongo::Connection.new.db("godfather")
3
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rolify
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-02 00:00:00.000000000 Z
12
+ date: 2012-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
16
- requirement: &70312381195700 !ruby/object:Gem::Requirement
16
+ requirement: &70359244800420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70312381195700
24
+ version_requirements: *70359244800420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &70312381193740 !ruby/object:Gem::Requirement
27
+ requirement: &70359244799000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70312381193740
35
+ version_requirements: *70359244799000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mongoid
38
- requirement: &70312381191900 !ruby/object:Gem::Requirement
38
+ requirement: &70359244797140 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70312381191900
46
+ version_requirements: *70359244797140
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bson_ext
49
- requirement: &70312381191220 !ruby/object:Gem::Requirement
49
+ requirement: &70359244794900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70312381191220
57
+ version_requirements: *70359244794900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: ammeter
60
- requirement: &70312381190320 !ruby/object:Gem::Requirement
60
+ requirement: &70359244792460 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70312381190320
68
+ version_requirements: *70359244792460
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
- requirement: &70312381189180 !ruby/object:Gem::Requirement
71
+ requirement: &70359244791380 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70312381189180
79
+ version_requirements: *70359244791380
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &70312381188380 !ruby/object:Gem::Requirement
82
+ requirement: &70359244788860 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70312381188380
90
+ version_requirements: *70359244788860
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: bundler
93
- requirement: &70312381187520 !ruby/object:Gem::Requirement
93
+ requirement: &70359244786160 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,9 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70312381187520
102
- description: ! 'Very simple Roles library without any authorization enforcement (built
103
- to use with cancan) supporting scope on resource: user.is_moderator?(Forum.first)
104
- => # return false if user is moderator of another Forum '
101
+ version_requirements: *70359244786160
102
+ description: Very simple Roles library without any authorization enforcement supporting
103
+ scope on resource objects (instance or class)
105
104
  email:
106
105
  - f.monbillard@gmail.com
107
106
  executables: []
@@ -113,7 +112,7 @@ files:
113
112
  - CHANGELOG.rdoc
114
113
  - Gemfile
115
114
  - LICENSE
116
- - README.rdoc
115
+ - README.md
117
116
  - Rakefile
118
117
  - UPGRADE.rdoc
119
118
  - lib/generators/rolify/role/role_generator.rb
@@ -125,14 +124,17 @@ files:
125
124
  - lib/generators/rolify/role/templates/role-active_record.rb
126
125
  - lib/generators/rolify/role/templates/role-mongoid.rb
127
126
  - lib/rolify.rb
128
- - lib/rolify/adapters/active_record.rb
127
+ - lib/rolify/adapters/active_record/resource_adapter.rb
128
+ - lib/rolify/adapters/active_record/role_adapter.rb
129
129
  - lib/rolify/adapters/base.rb
130
- - lib/rolify/adapters/mongoid.rb
130
+ - lib/rolify/adapters/mongoid/resource_adapter.rb
131
+ - lib/rolify/adapters/mongoid/role_adapter.rb
131
132
  - lib/rolify/configure.rb
132
133
  - lib/rolify/dynamic.rb
133
134
  - lib/rolify/railtie.rb
134
135
  - lib/rolify/resource.rb
135
136
  - lib/rolify/role.rb
137
+ - lib/rolify/utils.rb
136
138
  - lib/rolify/version.rb
137
139
  - rolify.gemspec
138
140
  - spec/generators/rolify/role/role_generator_spec.rb
@@ -141,12 +143,12 @@ files:
141
143
  - spec/rolify/resource_spec.rb
142
144
  - spec/rolify/role_spec.rb
143
145
  - spec/rolify/shared_contexts.rb
146
+ - spec/rolify/shared_examples/shared_examples_for_add_role.rb
144
147
  - spec/rolify/shared_examples/shared_examples_for_dynamic.rb
145
148
  - spec/rolify/shared_examples/shared_examples_for_has_all_roles.rb
146
149
  - spec/rolify/shared_examples/shared_examples_for_has_any_role.rb
147
- - spec/rolify/shared_examples/shared_examples_for_has_no_role.rb
148
- - spec/rolify/shared_examples/shared_examples_for_has_role_getter.rb
149
- - spec/rolify/shared_examples/shared_examples_for_has_role_setter.rb
150
+ - spec/rolify/shared_examples/shared_examples_for_has_role.rb
151
+ - spec/rolify/shared_examples/shared_examples_for_remove_role.rb
150
152
  - spec/rolify/shared_examples/shared_examples_for_roles.rb
151
153
  - spec/spec_helper.rb
152
154
  - spec/support/adapters/active_record.rb
@@ -173,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
175
  version: '0'
174
176
  requirements: []
175
177
  rubyforge_project: rolify
176
- rubygems_version: 1.8.16
178
+ rubygems_version: 1.8.17
177
179
  signing_key:
178
180
  specification_version: 3
179
181
  summary: Roles library with resource scoping
@@ -184,12 +186,12 @@ test_files:
184
186
  - spec/rolify/resource_spec.rb
185
187
  - spec/rolify/role_spec.rb
186
188
  - spec/rolify/shared_contexts.rb
189
+ - spec/rolify/shared_examples/shared_examples_for_add_role.rb
187
190
  - spec/rolify/shared_examples/shared_examples_for_dynamic.rb
188
191
  - spec/rolify/shared_examples/shared_examples_for_has_all_roles.rb
189
192
  - spec/rolify/shared_examples/shared_examples_for_has_any_role.rb
190
- - spec/rolify/shared_examples/shared_examples_for_has_no_role.rb
191
- - spec/rolify/shared_examples/shared_examples_for_has_role_getter.rb
192
- - spec/rolify/shared_examples/shared_examples_for_has_role_setter.rb
193
+ - spec/rolify/shared_examples/shared_examples_for_has_role.rb
194
+ - spec/rolify/shared_examples/shared_examples_for_remove_role.rb
193
195
  - spec/rolify/shared_examples/shared_examples_for_roles.rb
194
196
  - spec/spec_helper.rb
195
197
  - spec/support/adapters/active_record.rb