troles 0.5.1 → 0.5.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.
- data/Design.textile +68 -0
- data/Gemfile +9 -7
- data/Gemfile.lock +81 -76
- data/README.textile +63 -170
- data/VERSION +1 -1
- data/lib/trole.rb +2 -2
- data/lib/trole_groups/storage/base_many.rb +16 -5
- data/lib/troles/adapters/active_record/config.rb +19 -5
- data/lib/troles/api/config.rb +1 -1
- data/lib/troles/api/core.rb +4 -4
- data/lib/troles/common/api/core.rb +13 -14
- data/lib/troles/common/api/read.rb +6 -0
- data/lib/troles/common/api.rb +3 -2
- data/lib/troles/common/config/schema/helpers.rb +30 -11
- data/lib/troles/common/config/schema/role_helpers.rb +5 -5
- data/lib/troles/common/config/valid_roles.rb +4 -3
- data/lib/troles/common/dependencies.rb +1 -1
- data/lib/troles/common/storage.rb +16 -4
- data/lib/troles/common.rb +2 -2
- data/lib/troles/config.rb +4 -4
- data/lib/troles/storage/join_ref_many.rb +13 -0
- data/lib/troles/storage.rb +6 -5
- data/lib/troles.rb +3 -8
- data/spec/active_record/migrations/many/custom_join.rb +31 -0
- data/spec/active_record/migrations/many/join_ref_many.rb +31 -0
- data/spec/active_record/migrations/many/ref_many.rb +0 -8
- data/spec/active_record/models/custom_join.rb +13 -0
- data/spec/active_record/models/join_ref_many.rb +13 -0
- data/spec/active_record/models/ref_many.rb +0 -2
- data/spec/active_record/strategies/many/custom_join_spec.rb +46 -0
- data/spec/active_record/strategies/many/join_ref_many_spec.rb +46 -0
- data/spec/active_record/strategies/many/ref_many_spec.rb +2 -2
- data/spec/generic/models/base_user.rb +2 -1
- data/spec/trole/strategies/embed_one_spec.rb +1 -1
- data/spec/trole/strategies/ref_one_spec.rb +1 -1
- data/spec/trole/strategies/string_one_spec.rb +1 -1
- data/spec/troles/common/multi_roles_spec.rb +7 -13
- data/spec/troles/strategies/bit_many_spec.rb +1 -1
- data/spec/troles/strategies/embed_many_spec.rb +1 -1
- data/spec/troles/strategies/ref_many_spec.rb +1 -1
- data/spec/troles/strategies/string_many_spec.rb +1 -1
- data/spec/troles/strategy_helper.rb +1 -1
- data/troles.gemspec +38 -24
- metadata +72 -42
data/Design.textile
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
h2. Status June 7, 2011
|
2
|
+
|
3
|
+
I'm now in the process of implementing TroleGroups! Finally a fully integrated role groups solution for Ruby and Rails ;)
|
4
|
+
Due to the flexible design ot troles and trole, I can reuse the same infrastructure/design/architecture to implement trole_groups!
|
5
|
+
*Yiii...haaa!*
|
6
|
+
|
7
|
+
"A RoleGroup is simply another role_subject and can thus be configured with a given role strategy!"
|
8
|
+
|
9
|
+
Simple and Sweet :)
|
10
|
+
|
11
|
+
h2. The Ruby Class Decorator (RCD) pattern is born!!!
|
12
|
+
|
13
|
+
I realized a while ago that I had come upon a very cool kind of "class decorator" design pattern that can be generalized to any gem that "decorates" a class (or perhaps multiple classes) with certain behavior. Gems such as _act_as_xxx_ come to mind fx.
|
14
|
+
|
15
|
+
I will soon try to generalize this pattern into a separate project and then have trole, troles and trole_groups all use this to leverage their functionality. Also, I will make use of an idea that I just had while taking a cold shower (try it sometime if you have a mind block!).
|
16
|
+
The idea is to have an internal default API, and an exposed API that by default is a reflection of the internal API. However the user is free to block parts of the API from being loaded or define his own external API that utilizes the inner API.
|
17
|
+
|
18
|
+
Since this is a general purpose decorator pattern, there should also be a kind of Index where you can see which decorators have been applied to an object and what API each such decorator exposes! Cool stuff!!!!
|
19
|
+
|
20
|
+
Some example usage:
|
21
|
+
<pre>
|
22
|
+
return if !User.has_decorator?(:troles_group)
|
23
|
+
# do some trole group stuff!!!
|
24
|
+
|
25
|
+
# later ...
|
26
|
+
|
27
|
+
# list all decorators currently applied to the User class
|
28
|
+
puts User.decorators
|
29
|
+
|
30
|
+
# print the methods of the public Write API for the :troles_group decorator :)
|
31
|
+
puts User.decorator(:troles_group).public_api(:write).methods.sort
|
32
|
+
|
33
|
+
# print the methods of the internal Write API for the :troles_group decorator :)
|
34
|
+
puts User.decorator(:troles_group).internal_api(:write).methods.sort
|
35
|
+
</pre>
|
36
|
+
|
37
|
+
I will use the new Decorator API very soon... sth like this:
|
38
|
+
|
39
|
+
<pre>
|
40
|
+
User.decorator(:trole_groups).configure(:strategy) :ref_one do |strategy|
|
41
|
+
strategy.orm = :mongoid
|
42
|
+
strategy.auto_load = true
|
43
|
+
end.configure!
|
44
|
+
</pre>
|
45
|
+
|
46
|
+
Awesome!
|
47
|
+
|
48
|
+
h3. Yard documentation
|
49
|
+
|
50
|
+
I'm using "Yard":http://rubydoc.info/docs/yard/file/docs/GettingStarted.md for documentation.
|
51
|
+
|
52
|
+
<pre>$ yard server
|
53
|
+
|
54
|
+
From browser, go to: http://0.0.0.0:8808/ # then you can enjoy! the nice documentation :)
|
55
|
+
</pre>
|
56
|
+
|
57
|
+
There is now support for Caching and invalidation of the _role_list_ when the roles change.
|
58
|
+
The specs now validate that caching works as it should.
|
59
|
+
|
60
|
+
Please help out to finalize this project! :)
|
61
|
+
|
62
|
+
h2. Bug hunting by running specs
|
63
|
+
|
64
|
+
Run specs for at most one strategy at the time for now...
|
65
|
+
|
66
|
+
@$ rspec spec/troles/strategies/bit_many_spec.rb@
|
67
|
+
|
68
|
+
Please see the document _spec/Guide to running specs.textile_ where I advise on how best to do "bug hunting" to help get this project off the ground!
|
data/Gemfile
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
source
|
1
|
+
source :rubygems
|
2
2
|
|
3
|
-
gem 'sugar-high', '
|
3
|
+
gem 'sugar-high', '>= 0.4.4'
|
4
|
+
gem 'sweetloader', '>= 0.1.0'
|
4
5
|
gem 'require_all', '~> 1.2.0'
|
5
|
-
gem 'yard', '> 0.6.1'
|
6
6
|
|
7
7
|
group :development, :test do
|
8
|
-
gem '
|
9
|
-
gem '
|
8
|
+
gem 'yard', '> 0.6.1'
|
9
|
+
gem 'rails', '>= 3.0.1'
|
10
|
+
gem 'rspec-rails', '>= 2.4.0'
|
10
11
|
gem 'sqlite3'
|
11
12
|
gem 'capybara', '> 0.4.0'
|
12
13
|
gem 'shoulda'
|
@@ -16,11 +17,12 @@ group :development, :test do
|
|
16
17
|
|
17
18
|
gem 'rake', '~> 0.9.0'
|
18
19
|
gem 'bundler', '>= 1'
|
19
|
-
gem 'jeweler', '>= 1.
|
20
|
+
gem 'jeweler', '>= 1.6'
|
20
21
|
gem 'rdoc', '>= 3.6'
|
21
22
|
gem 'rcov'
|
23
|
+
gem 'yard', '> 0.6.1'
|
22
24
|
|
23
25
|
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
24
26
|
# gem 'ruby-debug'
|
25
27
|
# gem 'ruby-debug19'
|
26
|
-
end
|
28
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,108 +1,107 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/kristianmandrup/database_cleaner.git
|
3
|
-
revision:
|
3
|
+
revision: 1215a0631ca1fd17087e8609eff40cabea960eb8
|
4
4
|
specs:
|
5
5
|
database_cleaner (0.6.8)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionmailer (3.1.0
|
11
|
-
actionpack (= 3.1.0
|
10
|
+
actionmailer (3.1.0)
|
11
|
+
actionpack (= 3.1.0)
|
12
12
|
mail (~> 2.3.0)
|
13
|
-
actionpack (3.1.0
|
14
|
-
activemodel (= 3.1.0
|
15
|
-
activesupport (= 3.1.0
|
13
|
+
actionpack (3.1.0)
|
14
|
+
activemodel (= 3.1.0)
|
15
|
+
activesupport (= 3.1.0)
|
16
16
|
builder (~> 3.0.0)
|
17
17
|
erubis (~> 2.7.0)
|
18
|
-
i18n (~> 0.6
|
19
|
-
rack (~> 1.3.
|
20
|
-
rack-cache (~> 1.0.
|
21
|
-
rack-mount (~> 0.8.
|
22
|
-
rack-test (~> 0.6.
|
23
|
-
sprockets (~> 2.0.0
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
bcrypt-ruby (~> 2.1.4)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
rack (~> 1.3.2)
|
20
|
+
rack-cache (~> 1.0.3)
|
21
|
+
rack-mount (~> 0.8.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.0.0)
|
24
|
+
activemodel (3.1.0)
|
25
|
+
activesupport (= 3.1.0)
|
26
|
+
bcrypt-ruby (~> 3.0.0)
|
28
27
|
builder (~> 3.0.0)
|
29
|
-
i18n (~> 0.6
|
30
|
-
activerecord (3.1.0
|
31
|
-
activemodel (= 3.1.0
|
32
|
-
activesupport (= 3.1.0
|
33
|
-
arel (~> 2.
|
34
|
-
tzinfo (~> 0.3.
|
35
|
-
activeresource (3.1.0
|
36
|
-
activemodel (= 3.1.0
|
37
|
-
activesupport (= 3.1.0
|
38
|
-
activesupport (3.1.0
|
28
|
+
i18n (~> 0.6)
|
29
|
+
activerecord (3.1.0)
|
30
|
+
activemodel (= 3.1.0)
|
31
|
+
activesupport (= 3.1.0)
|
32
|
+
arel (~> 2.2.1)
|
33
|
+
tzinfo (~> 0.3.29)
|
34
|
+
activeresource (3.1.0)
|
35
|
+
activemodel (= 3.1.0)
|
36
|
+
activesupport (= 3.1.0)
|
37
|
+
activesupport (3.1.0)
|
39
38
|
multi_json (~> 1.0)
|
40
|
-
arel (2.
|
41
|
-
bcrypt-ruby (
|
39
|
+
arel (2.2.1)
|
40
|
+
bcrypt-ruby (3.0.1)
|
42
41
|
builder (3.0.0)
|
43
|
-
capybara (
|
44
|
-
celerity (>= 0.7.9)
|
45
|
-
culerity (>= 0.2.4)
|
42
|
+
capybara (1.1.1)
|
46
43
|
mime-types (>= 1.16)
|
47
44
|
nokogiri (>= 1.3.3)
|
48
45
|
rack (>= 1.0.0)
|
49
46
|
rack-test (>= 0.5.4)
|
50
|
-
selenium-webdriver (
|
51
|
-
xpath (~> 0.1.
|
52
|
-
|
53
|
-
childprocess (0.1.9)
|
47
|
+
selenium-webdriver (~> 2.0)
|
48
|
+
xpath (~> 0.1.4)
|
49
|
+
childprocess (0.2.2)
|
54
50
|
ffi (~> 1.0.6)
|
55
|
-
|
56
|
-
diff-lcs (1.1.2)
|
51
|
+
diff-lcs (1.1.3)
|
57
52
|
erubis (2.7.0)
|
58
|
-
factory_girl (1.
|
59
|
-
|
60
|
-
|
53
|
+
factory_girl (2.1.2)
|
54
|
+
activesupport
|
55
|
+
factory_girl_rails (1.2.0)
|
56
|
+
factory_girl (~> 2.1.0)
|
61
57
|
railties (>= 3.0.0)
|
62
58
|
ffi (1.0.9)
|
63
59
|
git (1.2.5)
|
64
|
-
hike (1.
|
60
|
+
hike (1.2.1)
|
65
61
|
i18n (0.6.0)
|
66
|
-
jeweler (1.6.
|
62
|
+
jeweler (1.6.4)
|
67
63
|
bundler (~> 1.0)
|
68
64
|
git (>= 1.2.5)
|
69
65
|
rake
|
70
|
-
json_pure (1.
|
66
|
+
json_pure (1.6.1)
|
71
67
|
mail (2.3.0)
|
72
68
|
i18n (>= 0.4.0)
|
73
69
|
mime-types (~> 1.16)
|
74
70
|
treetop (~> 1.4.8)
|
71
|
+
metaclass (0.0.1)
|
75
72
|
mime-types (1.16)
|
76
|
-
mocha (0.
|
73
|
+
mocha (0.10.0)
|
74
|
+
metaclass (~> 0.0.1)
|
77
75
|
multi_json (1.0.3)
|
78
|
-
nokogiri (1.
|
79
|
-
polyglot (0.3.
|
80
|
-
rack (1.3.
|
81
|
-
rack-cache (1.0.
|
76
|
+
nokogiri (1.5.0)
|
77
|
+
polyglot (0.3.2)
|
78
|
+
rack (1.3.3)
|
79
|
+
rack-cache (1.0.3)
|
82
80
|
rack (>= 0.4)
|
83
|
-
rack-mount (0.8.
|
81
|
+
rack-mount (0.8.3)
|
84
82
|
rack (>= 1.0.0)
|
85
83
|
rack-ssl (1.3.2)
|
86
84
|
rack
|
87
|
-
rack-test (0.6.
|
85
|
+
rack-test (0.6.1)
|
88
86
|
rack (>= 1.0)
|
89
|
-
rails (3.1.0
|
90
|
-
actionmailer (= 3.1.0
|
91
|
-
actionpack (= 3.1.0
|
92
|
-
activerecord (= 3.1.0
|
93
|
-
activeresource (= 3.1.0
|
94
|
-
activesupport (= 3.1.0
|
87
|
+
rails (3.1.0)
|
88
|
+
actionmailer (= 3.1.0)
|
89
|
+
actionpack (= 3.1.0)
|
90
|
+
activerecord (= 3.1.0)
|
91
|
+
activeresource (= 3.1.0)
|
92
|
+
activesupport (= 3.1.0)
|
95
93
|
bundler (~> 1.0)
|
96
|
-
railties (= 3.1.0
|
97
|
-
railties (3.1.0
|
98
|
-
actionpack (= 3.1.0
|
99
|
-
activesupport (= 3.1.0
|
94
|
+
railties (= 3.1.0)
|
95
|
+
railties (3.1.0)
|
96
|
+
actionpack (= 3.1.0)
|
97
|
+
activesupport (= 3.1.0)
|
100
98
|
rack-ssl (~> 1.3.2)
|
101
99
|
rake (>= 0.8.7)
|
100
|
+
rdoc (~> 3.4)
|
102
101
|
thor (~> 0.14.6)
|
103
102
|
rake (0.9.2)
|
104
|
-
rcov (0.9.
|
105
|
-
rdoc (3.
|
103
|
+
rcov (0.9.10)
|
104
|
+
rdoc (3.9.4)
|
106
105
|
require_all (1.2.0)
|
107
106
|
rspec (2.6.0)
|
108
107
|
rspec-core (~> 2.6.0)
|
@@ -118,26 +117,31 @@ GEM
|
|
118
117
|
railties (~> 3.0)
|
119
118
|
rspec (~> 2.6.0)
|
120
119
|
rubyzip (0.9.4)
|
121
|
-
selenium-webdriver (
|
122
|
-
childprocess (>= 0.1
|
120
|
+
selenium-webdriver (2.7.0)
|
121
|
+
childprocess (>= 0.2.1)
|
123
122
|
ffi (>= 1.0.7)
|
124
123
|
json_pure
|
125
124
|
rubyzip
|
126
125
|
shoulda (2.11.3)
|
127
|
-
sprockets (2.0.
|
128
|
-
hike (~> 1.
|
126
|
+
sprockets (2.0.1)
|
127
|
+
hike (~> 1.2)
|
129
128
|
rack (~> 1.0)
|
130
129
|
tilt (!= 1.3.0, ~> 1.1)
|
131
|
-
sqlite3 (1.3.
|
132
|
-
sugar-high (0.
|
130
|
+
sqlite3 (1.3.4)
|
131
|
+
sugar-high (0.6.0)
|
132
|
+
activesupport (>= 3.0.1)
|
133
|
+
sweetloader (0.1.0)
|
134
|
+
activesupport (>= 3.0.1)
|
135
|
+
i18n
|
133
136
|
thor (0.14.6)
|
134
|
-
tilt (1.3.
|
135
|
-
treetop (1.4.
|
137
|
+
tilt (1.3.3)
|
138
|
+
treetop (1.4.10)
|
139
|
+
polyglot
|
136
140
|
polyglot (>= 0.3.1)
|
137
|
-
tzinfo (0.3.
|
141
|
+
tzinfo (0.3.30)
|
138
142
|
xpath (0.1.4)
|
139
143
|
nokogiri (~> 1.3)
|
140
|
-
yard (0.7.
|
144
|
+
yard (0.7.2)
|
141
145
|
|
142
146
|
PLATFORMS
|
143
147
|
ruby
|
@@ -147,15 +151,16 @@ DEPENDENCIES
|
|
147
151
|
capybara (> 0.4.0)
|
148
152
|
database_cleaner (~> 0.6.8)!
|
149
153
|
factory_girl_rails
|
150
|
-
jeweler (>= 1.
|
154
|
+
jeweler (>= 1.6)
|
151
155
|
mocha
|
152
|
-
rails (
|
156
|
+
rails (>= 3.0.1)
|
153
157
|
rake (~> 0.9.0)
|
154
158
|
rcov
|
155
159
|
rdoc (>= 3.6)
|
156
160
|
require_all (~> 1.2.0)
|
157
|
-
rspec-rails (
|
161
|
+
rspec-rails (>= 2.4.0)
|
158
162
|
shoulda
|
159
163
|
sqlite3
|
160
|
-
sugar-high (
|
164
|
+
sugar-high (>= 0.4.4)
|
165
|
+
sweetloader (>= 0.1.0)
|
161
166
|
yard (> 0.6.1)
|