mongoid_roles_zhd 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +17 -0
- data/LICENSE +20 -0
- data/README.textile +99 -0
- data/Rakefile +26 -0
- data/VERSION +1 -0
- data/lib/generators/mongoid/roles/core_ext.rb +11 -0
- data/lib/generators/mongoid/roles/roles_generator.rb +173 -0
- data/lib/generators/mongoid/roles/templates/role.rb +8 -0
- data/lib/mongoid_roles.rb +10 -0
- data/lib/mongoid_roles/base.rb +91 -0
- data/lib/mongoid_roles/base_role.rb +27 -0
- data/lib/mongoid_roles/embedded_role.rb +24 -0
- data/lib/mongoid_roles/namespaces.rb +12 -0
- data/lib/mongoid_roles/role.rb +10 -0
- data/lib/mongoid_roles/strategy.rb +15 -0
- data/lib/mongoid_roles/strategy/multi.rb +59 -0
- data/lib/mongoid_roles/strategy/multi/embed_many_roles.rb +124 -0
- data/lib/mongoid_roles/strategy/multi/many_roles.rb +83 -0
- data/lib/mongoid_roles/strategy/multi/role_strings.rb +54 -0
- data/lib/mongoid_roles/strategy/multi/roles_mask.rb +130 -0
- data/lib/mongoid_roles/strategy/shared.rb +29 -0
- data/lib/mongoid_roles/strategy/single.rb +34 -0
- data/lib/mongoid_roles/strategy/single/admin_flag.rb +55 -0
- data/lib/mongoid_roles/strategy/single/embed_one_role.rb +83 -0
- data/lib/mongoid_roles/strategy/single/one_role.rb +66 -0
- data/lib/mongoid_roles/strategy/single/role_string.rb +61 -0
- data/mongoid_roles.gemspec +125 -0
- data/sandbox/roles_assign.rb +54 -0
- data/sandbox/single_role.rb +82 -0
- data/sandbox/test.rb +47 -0
- data/sandbox/test_query.rb +49 -0
- data/spec/generator_spec_helper.rb +12 -0
- data/spec/mongoid_roles/generators/roles_generator_spec.rb +67 -0
- data/spec/mongoid_roles/strategy/api_examples.rb +200 -0
- data/spec/mongoid_roles/strategy/multi/embed_many_roles_spec.rb +15 -0
- data/spec/mongoid_roles/strategy/multi/many_roles_old_spec.rb +22 -0
- data/spec/mongoid_roles/strategy/multi/many_roles_spec.rb +19 -0
- data/spec/mongoid_roles/strategy/multi/role_strings_spec.rb +16 -0
- data/spec/mongoid_roles/strategy/multi/roles_mask_spec.rb +20 -0
- data/spec/mongoid_roles/strategy/single/admin_flag_spec.rb +18 -0
- data/spec/mongoid_roles/strategy/single/embed_one_role_spec.rb +18 -0
- data/spec/mongoid_roles/strategy/single/one_role_spec.rb +18 -0
- data/spec/mongoid_roles/strategy/single/role_string_spec.rb +18 -0
- data/spec/mongoid_roles/strategy/user_setup.rb +13 -0
- data/spec/spec_helper.rb +15 -0
- data/tmp/rails/app/models/user.rb +8 -0
- data/tmp/rails/config/routes.rb +2 -0
- metadata +256 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class User
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Roles
|
6
|
+
|
7
|
+
strategy :embed_many_roles, :role_class => :role #, :config => :default
|
8
|
+
valid_roles_are :admin, :guest, :user
|
9
|
+
end
|
10
|
+
|
11
|
+
def api_name
|
12
|
+
:embed_many_roles
|
13
|
+
end
|
14
|
+
|
15
|
+
load 'mongoid_roles/strategy/api_examples.rb'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# IMPORTANT
|
4
|
+
# This is only to support Mongoid 2 before rc.5
|
5
|
+
|
6
|
+
class Role
|
7
|
+
end
|
8
|
+
|
9
|
+
class User
|
10
|
+
include Mongoid::Document
|
11
|
+
include Mongoid::Roles
|
12
|
+
|
13
|
+
strategy :many_roles_old
|
14
|
+
valid_roles_are :admin, :guest, :user
|
15
|
+
end
|
16
|
+
|
17
|
+
def api_name
|
18
|
+
:many_roles_old
|
19
|
+
end
|
20
|
+
|
21
|
+
load 'roles_mongoid/strategy/api_examples.rb'
|
22
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Role
|
4
|
+
end
|
5
|
+
|
6
|
+
class User
|
7
|
+
include Mongoid::Document
|
8
|
+
include Mongoid::Roles
|
9
|
+
|
10
|
+
strategy :many_roles
|
11
|
+
valid_roles_are :admin, :guest, :user
|
12
|
+
end
|
13
|
+
|
14
|
+
def api_name
|
15
|
+
:many_roles
|
16
|
+
end
|
17
|
+
|
18
|
+
load 'roles_mongoid/strategy/api_examples.rb'
|
19
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class User
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Roles
|
6
|
+
|
7
|
+
strategy :role_strings
|
8
|
+
valid_roles_are :admin, :guest, :user
|
9
|
+
end
|
10
|
+
|
11
|
+
def api_name
|
12
|
+
:role_strings
|
13
|
+
end
|
14
|
+
|
15
|
+
load 'roles_mongoid/strategy/api_examples.rb'
|
16
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
use_roles_strategy :roles_mask
|
4
|
+
|
5
|
+
class User
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Roles
|
8
|
+
|
9
|
+
strategy :roles_mask
|
10
|
+
valid_roles_are :admin, :guest, :user
|
11
|
+
end
|
12
|
+
|
13
|
+
def api_name
|
14
|
+
:roles_mask
|
15
|
+
end
|
16
|
+
|
17
|
+
load 'roles_mongoid/strategy/api_examples.rb'
|
18
|
+
|
19
|
+
|
20
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
use_roles_strategy :admin_flag
|
3
|
+
|
4
|
+
class User
|
5
|
+
include Mongoid::Document
|
6
|
+
include Mongoid::Roles
|
7
|
+
|
8
|
+
strategy :admin_flag
|
9
|
+
valid_roles_are :admin, :guest
|
10
|
+
|
11
|
+
field :name, :type => String
|
12
|
+
end
|
13
|
+
|
14
|
+
def api_name
|
15
|
+
:admin_flag
|
16
|
+
end
|
17
|
+
|
18
|
+
load 'mongoid_roles/strategy/api_examples.rb'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
use_roles_strategy :embed_one_role
|
4
|
+
|
5
|
+
class User
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Roles
|
8
|
+
|
9
|
+
strategy :embed_one_role, :role_class => :role #, :config => :default
|
10
|
+
valid_roles_are :admin, :guest, :user
|
11
|
+
end
|
12
|
+
|
13
|
+
def api_name
|
14
|
+
:embed_one_role
|
15
|
+
end
|
16
|
+
|
17
|
+
load 'mongoid_roles/strategy/api_examples.rb'
|
18
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Role
|
4
|
+
end
|
5
|
+
|
6
|
+
class User
|
7
|
+
include Mongoid::Document
|
8
|
+
include Mongoid::Roles
|
9
|
+
|
10
|
+
strategy :one_role
|
11
|
+
valid_roles_are :admin, :guest, :user
|
12
|
+
end
|
13
|
+
|
14
|
+
def api_name
|
15
|
+
:one_role
|
16
|
+
end
|
17
|
+
|
18
|
+
load 'mongoid_roles/strategy/api_examples.rb'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
use_roles_strategy :role_string
|
4
|
+
|
5
|
+
class User
|
6
|
+
include Mongoid::Document
|
7
|
+
include Mongoid::Roles
|
8
|
+
|
9
|
+
strategy :role_string
|
10
|
+
valid_roles_are :admin, :guest, :user
|
11
|
+
end
|
12
|
+
|
13
|
+
def api_name
|
14
|
+
:role_string
|
15
|
+
end
|
16
|
+
|
17
|
+
load 'mongoid_roles/strategy/api_examples.rb'
|
18
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
def default_user_setup
|
2
|
+
@guest_user = User.create(:name => 'Guest user')
|
3
|
+
@guest_user.add_roles :guest
|
4
|
+
@guest_user.save
|
5
|
+
|
6
|
+
@normal_user = User.create(:name => 'Normal user')
|
7
|
+
@normal_user.add_roles :guest, :user
|
8
|
+
@normal_user.save
|
9
|
+
|
10
|
+
@admin_user = User.create(:name => 'Admin user')
|
11
|
+
@admin_user.add_roles :admin
|
12
|
+
@admin_user.save
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'mongoid'
|
3
|
+
require 'mongoid_roles'
|
4
|
+
|
5
|
+
Mongoid.configure.master = Mongo::Connection.new.db('mongoid_roles')
|
6
|
+
|
7
|
+
Mongoid.database.collections.each do |coll|
|
8
|
+
coll.remove
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.mock_with :mocha
|
13
|
+
end
|
14
|
+
|
15
|
+
|
metadata
ADDED
@@ -0,0 +1,256 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongoid_roles_zhd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- ZhangHanDong
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-16 00:00:00 +08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 29
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 4
|
32
|
+
- 1
|
33
|
+
version: 2.4.1
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: generator-spec
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 5
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 7
|
48
|
+
- 3
|
49
|
+
version: 0.7.3
|
50
|
+
type: :development
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: mongoid
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 11
|
61
|
+
segments:
|
62
|
+
- 2
|
63
|
+
- 0
|
64
|
+
- 2
|
65
|
+
version: 2.0.2
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: bson
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 25
|
77
|
+
segments:
|
78
|
+
- 1
|
79
|
+
- 3
|
80
|
+
- 1
|
81
|
+
version: 1.3.1
|
82
|
+
type: :runtime
|
83
|
+
version_requirements: *id004
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: sugar-high
|
86
|
+
prerelease: false
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 15
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
- 4
|
96
|
+
- 0
|
97
|
+
version: 0.4.0
|
98
|
+
type: :runtime
|
99
|
+
version_requirements: *id005
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: require_all
|
102
|
+
prerelease: false
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ~>
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 31
|
109
|
+
segments:
|
110
|
+
- 1
|
111
|
+
- 2
|
112
|
+
- 0
|
113
|
+
version: 1.2.0
|
114
|
+
type: :runtime
|
115
|
+
version_requirements: *id006
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: roles_generic
|
118
|
+
prerelease: false
|
119
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
hash: 1
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
- 3
|
128
|
+
- 9
|
129
|
+
version: 0.3.9
|
130
|
+
type: :runtime
|
131
|
+
version_requirements: *id007
|
132
|
+
- !ruby/object:Gem::Dependency
|
133
|
+
name: rails_artifactor
|
134
|
+
prerelease: false
|
135
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 21
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
- 3
|
144
|
+
- 3
|
145
|
+
version: 0.3.3
|
146
|
+
type: :runtime
|
147
|
+
version_requirements: *id008
|
148
|
+
description: Makes it easy to set a role strategy on your User model in Mongoid
|
149
|
+
email: blackanger.z@gmail.com
|
150
|
+
executables: []
|
151
|
+
|
152
|
+
extensions: []
|
153
|
+
|
154
|
+
extra_rdoc_files:
|
155
|
+
- LICENSE
|
156
|
+
- README.textile
|
157
|
+
files:
|
158
|
+
- .bundle/config
|
159
|
+
- .document
|
160
|
+
- .rspec
|
161
|
+
- Gemfile
|
162
|
+
- LICENSE
|
163
|
+
- README.textile
|
164
|
+
- Rakefile
|
165
|
+
- VERSION
|
166
|
+
- lib/generators/mongoid/roles/core_ext.rb
|
167
|
+
- lib/generators/mongoid/roles/roles_generator.rb
|
168
|
+
- lib/generators/mongoid/roles/templates/role.rb
|
169
|
+
- lib/mongoid_roles.rb
|
170
|
+
- lib/mongoid_roles/base.rb
|
171
|
+
- lib/mongoid_roles/base_role.rb
|
172
|
+
- lib/mongoid_roles/embedded_role.rb
|
173
|
+
- lib/mongoid_roles/namespaces.rb
|
174
|
+
- lib/mongoid_roles/role.rb
|
175
|
+
- lib/mongoid_roles/strategy.rb
|
176
|
+
- lib/mongoid_roles/strategy/multi.rb
|
177
|
+
- lib/mongoid_roles/strategy/multi/embed_many_roles.rb
|
178
|
+
- lib/mongoid_roles/strategy/multi/many_roles.rb
|
179
|
+
- lib/mongoid_roles/strategy/multi/role_strings.rb
|
180
|
+
- lib/mongoid_roles/strategy/multi/roles_mask.rb
|
181
|
+
- lib/mongoid_roles/strategy/shared.rb
|
182
|
+
- lib/mongoid_roles/strategy/single.rb
|
183
|
+
- lib/mongoid_roles/strategy/single/admin_flag.rb
|
184
|
+
- lib/mongoid_roles/strategy/single/embed_one_role.rb
|
185
|
+
- lib/mongoid_roles/strategy/single/one_role.rb
|
186
|
+
- lib/mongoid_roles/strategy/single/role_string.rb
|
187
|
+
- mongoid_roles.gemspec
|
188
|
+
- sandbox/roles_assign.rb
|
189
|
+
- sandbox/single_role.rb
|
190
|
+
- sandbox/test.rb
|
191
|
+
- sandbox/test_query.rb
|
192
|
+
- spec/generator_spec_helper.rb
|
193
|
+
- spec/mongoid_roles/generators/roles_generator_spec.rb
|
194
|
+
- spec/mongoid_roles/strategy/api_examples.rb
|
195
|
+
- spec/mongoid_roles/strategy/multi/embed_many_roles_spec.rb
|
196
|
+
- spec/mongoid_roles/strategy/multi/many_roles_old_spec.rb
|
197
|
+
- spec/mongoid_roles/strategy/multi/many_roles_spec.rb
|
198
|
+
- spec/mongoid_roles/strategy/multi/role_strings_spec.rb
|
199
|
+
- spec/mongoid_roles/strategy/multi/roles_mask_spec.rb
|
200
|
+
- spec/mongoid_roles/strategy/single/admin_flag_spec.rb
|
201
|
+
- spec/mongoid_roles/strategy/single/embed_one_role_spec.rb
|
202
|
+
- spec/mongoid_roles/strategy/single/one_role_spec.rb
|
203
|
+
- spec/mongoid_roles/strategy/single/role_string_spec.rb
|
204
|
+
- spec/mongoid_roles/strategy/user_setup.rb
|
205
|
+
- spec/spec_helper.rb
|
206
|
+
- tmp/rails/app/models/user.rb
|
207
|
+
- tmp/rails/config/routes.rb
|
208
|
+
has_rdoc: true
|
209
|
+
homepage: https://github.com/ZhangHanDong/roles_mongoid
|
210
|
+
licenses: []
|
211
|
+
|
212
|
+
post_install_message:
|
213
|
+
rdoc_options: []
|
214
|
+
|
215
|
+
require_paths:
|
216
|
+
- lib
|
217
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
218
|
+
none: false
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
hash: 3
|
223
|
+
segments:
|
224
|
+
- 0
|
225
|
+
version: "0"
|
226
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
|
+
none: false
|
228
|
+
requirements:
|
229
|
+
- - ">="
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
hash: 3
|
232
|
+
segments:
|
233
|
+
- 0
|
234
|
+
version: "0"
|
235
|
+
requirements: []
|
236
|
+
|
237
|
+
rubyforge_project:
|
238
|
+
rubygems_version: 1.6.2
|
239
|
+
signing_key:
|
240
|
+
specification_version: 3
|
241
|
+
summary: Implementation of Roles generic API for Mongoid
|
242
|
+
test_files:
|
243
|
+
- spec/generator_spec_helper.rb
|
244
|
+
- spec/mongoid_roles/generators/roles_generator_spec.rb
|
245
|
+
- spec/mongoid_roles/strategy/api_examples.rb
|
246
|
+
- spec/mongoid_roles/strategy/multi/embed_many_roles_spec.rb
|
247
|
+
- spec/mongoid_roles/strategy/multi/many_roles_old_spec.rb
|
248
|
+
- spec/mongoid_roles/strategy/multi/many_roles_spec.rb
|
249
|
+
- spec/mongoid_roles/strategy/multi/role_strings_spec.rb
|
250
|
+
- spec/mongoid_roles/strategy/multi/roles_mask_spec.rb
|
251
|
+
- spec/mongoid_roles/strategy/single/admin_flag_spec.rb
|
252
|
+
- spec/mongoid_roles/strategy/single/embed_one_role_spec.rb
|
253
|
+
- spec/mongoid_roles/strategy/single/one_role_spec.rb
|
254
|
+
- spec/mongoid_roles/strategy/single/role_string_spec.rb
|
255
|
+
- spec/mongoid_roles/strategy/user_setup.rb
|
256
|
+
- spec/spec_helper.rb
|