troles 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Design.textile +68 -0
  2. data/Gemfile +9 -7
  3. data/Gemfile.lock +81 -76
  4. data/README.textile +63 -170
  5. data/VERSION +1 -1
  6. data/lib/trole.rb +2 -2
  7. data/lib/trole_groups/storage/base_many.rb +16 -5
  8. data/lib/troles/adapters/active_record/config.rb +19 -5
  9. data/lib/troles/api/config.rb +1 -1
  10. data/lib/troles/api/core.rb +4 -4
  11. data/lib/troles/common/api/core.rb +13 -14
  12. data/lib/troles/common/api/read.rb +6 -0
  13. data/lib/troles/common/api.rb +3 -2
  14. data/lib/troles/common/config/schema/helpers.rb +30 -11
  15. data/lib/troles/common/config/schema/role_helpers.rb +5 -5
  16. data/lib/troles/common/config/valid_roles.rb +4 -3
  17. data/lib/troles/common/dependencies.rb +1 -1
  18. data/lib/troles/common/storage.rb +16 -4
  19. data/lib/troles/common.rb +2 -2
  20. data/lib/troles/config.rb +4 -4
  21. data/lib/troles/storage/join_ref_many.rb +13 -0
  22. data/lib/troles/storage.rb +6 -5
  23. data/lib/troles.rb +3 -8
  24. data/spec/active_record/migrations/many/custom_join.rb +31 -0
  25. data/spec/active_record/migrations/many/join_ref_many.rb +31 -0
  26. data/spec/active_record/migrations/many/ref_many.rb +0 -8
  27. data/spec/active_record/models/custom_join.rb +13 -0
  28. data/spec/active_record/models/join_ref_many.rb +13 -0
  29. data/spec/active_record/models/ref_many.rb +0 -2
  30. data/spec/active_record/strategies/many/custom_join_spec.rb +46 -0
  31. data/spec/active_record/strategies/many/join_ref_many_spec.rb +46 -0
  32. data/spec/active_record/strategies/many/ref_many_spec.rb +2 -2
  33. data/spec/generic/models/base_user.rb +2 -1
  34. data/spec/trole/strategies/embed_one_spec.rb +1 -1
  35. data/spec/trole/strategies/ref_one_spec.rb +1 -1
  36. data/spec/trole/strategies/string_one_spec.rb +1 -1
  37. data/spec/troles/common/multi_roles_spec.rb +7 -13
  38. data/spec/troles/strategies/bit_many_spec.rb +1 -1
  39. data/spec/troles/strategies/embed_many_spec.rb +1 -1
  40. data/spec/troles/strategies/ref_many_spec.rb +1 -1
  41. data/spec/troles/strategies/string_many_spec.rb +1 -1
  42. data/spec/troles/strategy_helper.rb +1 -1
  43. data/troles.gemspec +38 -24
  44. 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 "http://rubygems.org"
1
+ source :rubygems
2
2
 
3
- gem 'sugar-high', '~> 0.4.4'
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 'rails', '~> 3.1.0.rc1'
9
- gem 'rspec-rails', '> 2.4.0'
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.5'
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: f1947e0a2c4e9086490d7c975b21ed1a3d70b3a8
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.rc1)
11
- actionpack (= 3.1.0.rc1)
10
+ actionmailer (3.1.0)
11
+ actionpack (= 3.1.0)
12
12
  mail (~> 2.3.0)
13
- actionpack (3.1.0.rc1)
14
- activemodel (= 3.1.0.rc1)
15
- activesupport (= 3.1.0.rc1)
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.0beta1)
19
- rack (~> 1.3.0.beta2)
20
- rack-cache (~> 1.0.1)
21
- rack-mount (~> 0.8.1)
22
- rack-test (~> 0.6.0)
23
- sprockets (~> 2.0.0.beta.5)
24
- tzinfo (~> 0.3.27)
25
- activemodel (3.1.0.rc1)
26
- activesupport (= 3.1.0.rc1)
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.0beta1)
30
- activerecord (3.1.0.rc1)
31
- activemodel (= 3.1.0.rc1)
32
- activesupport (= 3.1.0.rc1)
33
- arel (~> 2.1.1)
34
- tzinfo (~> 0.3.27)
35
- activeresource (3.1.0.rc1)
36
- activemodel (= 3.1.0.rc1)
37
- activesupport (= 3.1.0.rc1)
38
- activesupport (3.1.0.rc1)
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.1.1)
41
- bcrypt-ruby (2.1.4)
39
+ arel (2.2.1)
40
+ bcrypt-ruby (3.0.1)
42
41
  builder (3.0.0)
43
- capybara (0.4.1.2)
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 (>= 0.0.27)
51
- xpath (~> 0.1.3)
52
- celerity (0.8.9)
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
- culerity (0.2.15)
56
- diff-lcs (1.1.2)
51
+ diff-lcs (1.1.3)
57
52
  erubis (2.7.0)
58
- factory_girl (1.3.3)
59
- factory_girl_rails (1.0.1)
60
- factory_girl (~> 1.3)
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.0.0)
60
+ hike (1.2.1)
65
61
  i18n (0.6.0)
66
- jeweler (1.6.2)
62
+ jeweler (1.6.4)
67
63
  bundler (~> 1.0)
68
64
  git (>= 1.2.5)
69
65
  rake
70
- json_pure (1.5.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.9.12)
73
+ mocha (0.10.0)
74
+ metaclass (~> 0.0.1)
77
75
  multi_json (1.0.3)
78
- nokogiri (1.4.4)
79
- polyglot (0.3.1)
80
- rack (1.3.0)
81
- rack-cache (1.0.2)
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.1)
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.0)
85
+ rack-test (0.6.1)
88
86
  rack (>= 1.0)
89
- rails (3.1.0.rc1)
90
- actionmailer (= 3.1.0.rc1)
91
- actionpack (= 3.1.0.rc1)
92
- activerecord (= 3.1.0.rc1)
93
- activeresource (= 3.1.0.rc1)
94
- activesupport (= 3.1.0.rc1)
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.rc1)
97
- railties (3.1.0.rc1)
98
- actionpack (= 3.1.0.rc1)
99
- activesupport (= 3.1.0.rc1)
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.9)
105
- rdoc (3.6.1)
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 (0.2.1)
122
- childprocess (>= 0.1.7)
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.0.beta.10)
128
- hike (~> 1.0)
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.3)
132
- sugar-high (0.4.4.2)
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.2)
135
- treetop (1.4.9)
137
+ tilt (1.3.3)
138
+ treetop (1.4.10)
139
+ polyglot
136
140
  polyglot (>= 0.3.1)
137
- tzinfo (0.3.27)
141
+ tzinfo (0.3.30)
138
142
  xpath (0.1.4)
139
143
  nokogiri (~> 1.3)
140
- yard (0.7.1)
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.5)
154
+ jeweler (>= 1.6)
151
155
  mocha
152
- rails (~> 3.1.0.rc1)
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 (> 2.4.0)
161
+ rspec-rails (>= 2.4.0)
158
162
  shoulda
159
163
  sqlite3
160
- sugar-high (~> 0.4.4)
164
+ sugar-high (>= 0.4.4)
165
+ sweetloader (>= 0.1.0)
161
166
  yard (> 0.6.1)