tenacity 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +3 -0
  2. data/EXTEND.rdoc +11 -1
  3. data/README.rdoc +4 -1
  4. data/Rakefile +20 -9
  5. data/history.txt +21 -0
  6. data/lib/tenacity.rb +12 -4
  7. data/lib/tenacity/associates_proxy.rb +67 -0
  8. data/lib/tenacity/association.rb +19 -6
  9. data/lib/tenacity/associations/has_many.rb +6 -0
  10. data/lib/tenacity/class_methods.rb +52 -1
  11. data/lib/tenacity/instance_methods.rb +7 -3
  12. data/lib/tenacity/orm_ext/activerecord.rb +30 -13
  13. data/lib/tenacity/orm_ext/couchrest.rb +140 -0
  14. data/lib/tenacity/orm_ext/datamapper.rb +139 -0
  15. data/lib/tenacity/orm_ext/mongo_mapper.rb +88 -80
  16. data/lib/tenacity/orm_ext/mongoid.rb +108 -0
  17. data/lib/tenacity/orm_ext/sequel.rb +134 -0
  18. data/lib/tenacity/version.rb +1 -1
  19. data/tenacity.gemspec +14 -3
  20. data/test/association_features/belongs_to_test.rb +42 -0
  21. data/test/association_features/has_many_test.rb +110 -0
  22. data/test/association_features/has_one_test.rb +41 -0
  23. data/test/associations/belongs_to_test.rb +36 -127
  24. data/test/associations/has_many_test.rb +77 -196
  25. data/test/associations/has_one_test.rb +22 -84
  26. data/test/core/classmethods_test.rb +24 -22
  27. data/test/fixtures/active_record_has_many_target.rb +10 -0
  28. data/test/fixtures/active_record_has_one_target.rb +10 -0
  29. data/test/fixtures/{active_record_nuts.rb → active_record_nut.rb} +0 -0
  30. data/test/fixtures/active_record_object.rb +17 -0
  31. data/test/fixtures/couch_rest_door.rb +0 -2
  32. data/test/fixtures/couch_rest_has_many_target.rb +12 -0
  33. data/test/fixtures/couch_rest_has_one_target.rb +12 -0
  34. data/test/fixtures/couch_rest_object.rb +19 -0
  35. data/test/fixtures/couch_rest_windshield.rb +0 -2
  36. data/test/fixtures/data_mapper_has_many_target.rb +19 -0
  37. data/test/fixtures/data_mapper_has_one_target.rb +19 -0
  38. data/test/fixtures/data_mapper_object.rb +20 -0
  39. data/test/fixtures/mongo_mapper_ash_tray.rb +0 -2
  40. data/test/fixtures/mongo_mapper_dashboard.rb +0 -2
  41. data/test/fixtures/mongo_mapper_has_many_target.rb +11 -0
  42. data/test/fixtures/mongo_mapper_has_one_target.rb +11 -0
  43. data/test/fixtures/mongo_mapper_object.rb +18 -0
  44. data/test/fixtures/mongo_mapper_vent.rb +0 -2
  45. data/test/fixtures/mongo_mapper_wheel.rb +0 -2
  46. data/test/fixtures/mongoid_has_many_target.rb +13 -0
  47. data/test/fixtures/mongoid_has_one_target.rb +13 -0
  48. data/test/fixtures/mongoid_object.rb +20 -0
  49. data/test/fixtures/sequel_has_many_target.rb +10 -0
  50. data/test/fixtures/sequel_has_one_target.rb +10 -0
  51. data/test/fixtures/sequel_object.rb +17 -0
  52. data/test/helpers/active_record_test_helper.rb +51 -0
  53. data/test/helpers/data_mapper_test_helper.rb +44 -0
  54. data/test/helpers/mongoid_test_helper.rb +21 -0
  55. data/test/helpers/sequel_test_helper.rb +60 -0
  56. data/test/orm_ext/activerecord_test.rb +55 -35
  57. data/test/orm_ext/couchrest_test.rb +66 -46
  58. data/test/orm_ext/datamapper_test.rb +112 -0
  59. data/test/orm_ext/mongo_mapper_test.rb +64 -44
  60. data/test/orm_ext/mongoid_test.rb +121 -0
  61. data/test/orm_ext/sequel_test.rb +113 -0
  62. data/test/test_helper.rb +87 -11
  63. metadata +159 -59
  64. data/lib/tenacity/orm_ext/couchrest/couchrest_extended_document.rb +0 -42
  65. data/lib/tenacity/orm_ext/couchrest/couchrest_model.rb +0 -44
  66. data/lib/tenacity/orm_ext/couchrest/tenacity_class_methods.rb +0 -43
  67. data/lib/tenacity/orm_ext/couchrest/tenacity_instance_methods.rb +0 -21
  68. data/test/fixtures/couch_rest_radio.rb +0 -10
  69. data/test/fixtures/mongo_mapper_button.rb +0 -6
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Wood
@@ -14,11 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-07 00:00:00 -06:00
17
+ date: 2011-01-24 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ prerelease: false
22
+ name: activesupport
23
+ type: :runtime
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
25
  requirements:
23
26
  - - ">="
24
27
  - !ruby/object:Gem::Version
@@ -26,12 +29,12 @@ dependencies:
26
29
  - 2
27
30
  - 3
28
31
  version: "2.3"
29
- prerelease: false
30
- name: activesupport
31
- type: :runtime
32
- version_requirements: *id001
32
+ requirement: *id001
33
33
  - !ruby/object:Gem::Dependency
34
- requirement: &id002 !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ name: bundler
36
+ type: :development
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
35
38
  requirements:
36
39
  - - ~>
37
40
  - !ruby/object:Gem::Version
@@ -40,12 +43,12 @@ dependencies:
40
43
  - 0
41
44
  - 0
42
45
  version: 1.0.0
46
+ requirement: *id002
47
+ - !ruby/object:Gem::Dependency
43
48
  prerelease: false
44
- name: bundler
49
+ name: rake
45
50
  type: :development
46
- version_requirements: *id002
47
- - !ruby/object:Gem::Dependency
48
- requirement: &id003 !ruby/object:Gem::Requirement
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
49
52
  requirements:
50
53
  - - ~>
51
54
  - !ruby/object:Gem::Version
@@ -54,12 +57,12 @@ dependencies:
54
57
  - 8
55
58
  - 7
56
59
  version: 0.8.7
60
+ requirement: *id003
61
+ - !ruby/object:Gem::Dependency
57
62
  prerelease: false
58
- name: rake
63
+ name: rcov
59
64
  type: :development
60
- version_requirements: *id003
61
- - !ruby/object:Gem::Dependency
62
- requirement: &id004 !ruby/object:Gem::Requirement
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
63
66
  requirements:
64
67
  - - ~>
65
68
  - !ruby/object:Gem::Version
@@ -68,12 +71,12 @@ dependencies:
68
71
  - 9
69
72
  - 9
70
73
  version: 0.9.9
74
+ requirement: *id004
75
+ - !ruby/object:Gem::Dependency
71
76
  prerelease: false
72
- name: rcov
77
+ name: shoulda
73
78
  type: :development
74
- version_requirements: *id004
75
- - !ruby/object:Gem::Dependency
76
- requirement: &id005 !ruby/object:Gem::Requirement
79
+ version_requirements: &id005 !ruby/object:Gem::Requirement
77
80
  requirements:
78
81
  - - ~>
79
82
  - !ruby/object:Gem::Version
@@ -82,40 +85,40 @@ dependencies:
82
85
  - 11
83
86
  - 3
84
87
  version: 2.11.3
88
+ requirement: *id005
89
+ - !ruby/object:Gem::Dependency
85
90
  prerelease: false
86
- name: shoulda
91
+ name: yard
87
92
  type: :development
88
- version_requirements: *id005
89
- - !ruby/object:Gem::Dependency
90
- requirement: &id006 !ruby/object:Gem::Requirement
93
+ version_requirements: &id006 !ruby/object:Gem::Requirement
91
94
  requirements:
92
95
  - - ~>
93
96
  - !ruby/object:Gem::Version
94
97
  segments:
95
98
  - 0
96
- - 8
97
99
  - 6
98
- version: 0.8.6
100
+ - 4
101
+ version: 0.6.4
102
+ requirement: *id006
103
+ - !ruby/object:Gem::Dependency
99
104
  prerelease: false
100
- name: mongo_mapper
105
+ name: sqlite3-ruby
101
106
  type: :development
102
- version_requirements: *id006
103
- - !ruby/object:Gem::Dependency
104
- requirement: &id007 !ruby/object:Gem::Requirement
107
+ version_requirements: &id007 !ruby/object:Gem::Requirement
105
108
  requirements:
106
109
  - - ~>
107
110
  - !ruby/object:Gem::Version
108
111
  segments:
109
112
  - 1
110
- - 1
111
113
  - 3
112
- version: 1.1.3
114
+ - 1
115
+ version: 1.3.1
116
+ requirement: *id007
117
+ - !ruby/object:Gem::Dependency
113
118
  prerelease: false
114
- name: bson_ext
119
+ name: activerecord
115
120
  type: :development
116
- version_requirements: *id007
117
- - !ruby/object:Gem::Dependency
118
- requirement: &id008 !ruby/object:Gem::Requirement
121
+ version_requirements: &id008 !ruby/object:Gem::Requirement
119
122
  requirements:
120
123
  - - ~>
121
124
  - !ruby/object:Gem::Version
@@ -124,50 +127,121 @@ dependencies:
124
127
  - 0
125
128
  - 0
126
129
  version: 3.0.0
130
+ requirement: *id008
131
+ - !ruby/object:Gem::Dependency
127
132
  prerelease: false
128
- name: activerecord
133
+ name: datamapper
129
134
  type: :development
130
- version_requirements: *id008
135
+ version_requirements: &id009 !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ~>
138
+ - !ruby/object:Gem::Version
139
+ segments:
140
+ - 1
141
+ - 0
142
+ - 2
143
+ version: 1.0.2
144
+ requirement: *id009
131
145
  - !ruby/object:Gem::Dependency
132
- requirement: &id009 !ruby/object:Gem::Requirement
146
+ prerelease: false
147
+ name: dm-sqlite-adapter
148
+ type: :development
149
+ version_requirements: &id010 !ruby/object:Gem::Requirement
133
150
  requirements:
134
151
  - - ~>
135
152
  - !ruby/object:Gem::Version
136
153
  segments:
137
154
  - 1
155
+ - 0
156
+ - 2
157
+ version: 1.0.2
158
+ requirement: *id010
159
+ - !ruby/object:Gem::Dependency
160
+ prerelease: false
161
+ name: sequel
162
+ type: :development
163
+ version_requirements: &id011 !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ~>
166
+ - !ruby/object:Gem::Version
167
+ segments:
138
168
  - 3
139
- - 1
140
- version: 1.3.1
169
+ - 19
170
+ - 0
171
+ version: 3.19.0
172
+ requirement: *id011
173
+ - !ruby/object:Gem::Dependency
141
174
  prerelease: false
142
- name: sqlite3-ruby
175
+ name: mongo_mapper
143
176
  type: :development
144
- version_requirements: *id009
177
+ version_requirements: &id012 !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ segments:
182
+ - 0
183
+ - 8
184
+ - 6
185
+ version: 0.8.6
186
+ requirement: *id012
145
187
  - !ruby/object:Gem::Dependency
146
- requirement: &id010 !ruby/object:Gem::Requirement
188
+ prerelease: false
189
+ name: bson_ext
190
+ type: :development
191
+ version_requirements: &id013 !ruby/object:Gem::Requirement
147
192
  requirements:
148
193
  - - ~>
149
194
  - !ruby/object:Gem::Version
150
195
  segments:
151
196
  - 1
197
+ - 1
198
+ - 3
199
+ version: 1.1.3
200
+ requirement: *id013
201
+ - !ruby/object:Gem::Dependency
202
+ prerelease: false
203
+ name: mongoid
204
+ type: :development
205
+ version_requirements: &id014 !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ~>
208
+ - !ruby/object:Gem::Version
209
+ segments:
210
+ - 2
152
211
  - 0
153
212
  - 0
154
- version: 1.0.0
213
+ - beta
214
+ version: 2.0.0.beta
215
+ requirement: *id014
216
+ - !ruby/object:Gem::Dependency
155
217
  prerelease: false
156
218
  name: couchrest
157
219
  type: :development
158
- version_requirements: *id010
159
- - !ruby/object:Gem::Dependency
160
- requirement: &id011 !ruby/object:Gem::Requirement
220
+ version_requirements: &id015 !ruby/object:Gem::Requirement
161
221
  requirements:
162
- - - ">="
222
+ - - ~>
163
223
  - !ruby/object:Gem::Version
164
224
  segments:
225
+ - 1
226
+ - 0
165
227
  - 0
166
- version: "0"
228
+ version: 1.0.0
229
+ requirement: *id015
230
+ - !ruby/object:Gem::Dependency
167
231
  prerelease: false
168
232
  name: couchrest_model
169
233
  type: :development
170
- version_requirements: *id011
234
+ version_requirements: &id016 !ruby/object:Gem::Requirement
235
+ requirements:
236
+ - - ~>
237
+ - !ruby/object:Gem::Version
238
+ segments:
239
+ - 1
240
+ - 0
241
+ - 0
242
+ - beta
243
+ version: 1.0.0.beta
244
+ requirement: *id016
171
245
  description: Tenacity provides a database client independent way of specifying simple relationships between models backed by different databases.
172
246
  email:
173
247
  - john@johnpwood.net
@@ -186,6 +260,7 @@ files:
186
260
  - Rakefile
187
261
  - history.txt
188
262
  - lib/tenacity.rb
263
+ - lib/tenacity/associates_proxy.rb
189
264
  - lib/tenacity/association.rb
190
265
  - lib/tenacity/associations/belongs_to.rb
191
266
  - lib/tenacity/associations/has_many.rb
@@ -193,13 +268,16 @@ files:
193
268
  - lib/tenacity/class_methods.rb
194
269
  - lib/tenacity/instance_methods.rb
195
270
  - lib/tenacity/orm_ext/activerecord.rb
196
- - lib/tenacity/orm_ext/couchrest/couchrest_extended_document.rb
197
- - lib/tenacity/orm_ext/couchrest/couchrest_model.rb
198
- - lib/tenacity/orm_ext/couchrest/tenacity_class_methods.rb
199
- - lib/tenacity/orm_ext/couchrest/tenacity_instance_methods.rb
271
+ - lib/tenacity/orm_ext/couchrest.rb
272
+ - lib/tenacity/orm_ext/datamapper.rb
200
273
  - lib/tenacity/orm_ext/mongo_mapper.rb
274
+ - lib/tenacity/orm_ext/mongoid.rb
275
+ - lib/tenacity/orm_ext/sequel.rb
201
276
  - lib/tenacity/version.rb
202
277
  - tenacity.gemspec
278
+ - test/association_features/belongs_to_test.rb
279
+ - test/association_features/has_many_test.rb
280
+ - test/association_features/has_one_test.rb
203
281
  - test/associations/belongs_to_test.rb
204
282
  - test/associations/has_many_test.rb
205
283
  - test/associations/has_one_test.rb
@@ -207,21 +285,43 @@ files:
207
285
  - test/fixtures/active_record_car.rb
208
286
  - test/fixtures/active_record_climate_control_unit.rb
209
287
  - test/fixtures/active_record_engine.rb
210
- - test/fixtures/active_record_nuts.rb
288
+ - test/fixtures/active_record_has_many_target.rb
289
+ - test/fixtures/active_record_has_one_target.rb
290
+ - test/fixtures/active_record_nut.rb
291
+ - test/fixtures/active_record_object.rb
211
292
  - test/fixtures/couch_rest_door.rb
212
- - test/fixtures/couch_rest_radio.rb
293
+ - test/fixtures/couch_rest_has_many_target.rb
294
+ - test/fixtures/couch_rest_has_one_target.rb
295
+ - test/fixtures/couch_rest_object.rb
213
296
  - test/fixtures/couch_rest_windshield.rb
297
+ - test/fixtures/data_mapper_has_many_target.rb
298
+ - test/fixtures/data_mapper_has_one_target.rb
299
+ - test/fixtures/data_mapper_object.rb
214
300
  - test/fixtures/mongo_mapper_ash_tray.rb
215
- - test/fixtures/mongo_mapper_button.rb
216
301
  - test/fixtures/mongo_mapper_dashboard.rb
302
+ - test/fixtures/mongo_mapper_has_many_target.rb
303
+ - test/fixtures/mongo_mapper_has_one_target.rb
304
+ - test/fixtures/mongo_mapper_object.rb
217
305
  - test/fixtures/mongo_mapper_vent.rb
218
306
  - test/fixtures/mongo_mapper_wheel.rb
307
+ - test/fixtures/mongoid_has_many_target.rb
308
+ - test/fixtures/mongoid_has_one_target.rb
309
+ - test/fixtures/mongoid_object.rb
310
+ - test/fixtures/sequel_has_many_target.rb
311
+ - test/fixtures/sequel_has_one_target.rb
312
+ - test/fixtures/sequel_object.rb
219
313
  - test/helpers/active_record_test_helper.rb
220
314
  - test/helpers/couch_rest_test_helper.rb
315
+ - test/helpers/data_mapper_test_helper.rb
221
316
  - test/helpers/mongo_mapper_test_helper.rb
317
+ - test/helpers/mongoid_test_helper.rb
318
+ - test/helpers/sequel_test_helper.rb
222
319
  - test/orm_ext/activerecord_test.rb
223
320
  - test/orm_ext/couchrest_test.rb
321
+ - test/orm_ext/datamapper_test.rb
224
322
  - test/orm_ext/mongo_mapper_test.rb
323
+ - test/orm_ext/mongoid_test.rb
324
+ - test/orm_ext/sequel_test.rb
225
325
  - test/test_helper.rb
226
326
  has_rdoc: true
227
327
  homepage: http://github.com/jwood/tenacity
@@ -1,42 +0,0 @@
1
- begin
2
- require 'couchrest'
3
-
4
- module CouchRest #:nodoc:
5
-
6
- # Tenacity relationships on CouchRest objects require no special keys
7
- # defined on the object. Tenacity will define the keys that it needs
8
- # to support the relationships. Take the following class for example:
9
- #
10
- # class Car < CouchRest::ExtendedDocument
11
- # include Tenacity
12
- #
13
- # t_has_many :wheels
14
- # t_has_one :dashboard
15
- # t_belongs_to :driver
16
- # end
17
- #
18
- # == t_belongs_to
19
- #
20
- # The +t_belongs_to+ association will define a property named after the association.
21
- # The example above will create a property named <tt>:driver_id</tt>
22
- #
23
- #
24
- # == t_has_one
25
- #
26
- # The +t_has_one+ association will not define any new properties on the object, since
27
- # the associated object holds the foreign key.
28
- #
29
- #
30
- # == t_has_many
31
- #
32
- # The +t_has_many+ association will define a property named after the association.
33
- # The example above will create a property named <tt>:wheels_ids</tt>
34
- #
35
- class ExtendedDocument
36
- include CouchRest::TenacityInstanceMethods
37
- extend CouchRest::TenacityClassMethods
38
- end
39
- end
40
- rescue LoadError
41
- # CouchRest::ExtendedDocument not available
42
- end
@@ -1,44 +0,0 @@
1
- begin
2
- require 'couchrest'
3
-
4
- module CouchRest #:nodoc:
5
- module Model #:nodoc:
6
-
7
- # Tenacity relationships on CouchRest objects require no special keys
8
- # defined on the object. Tenacity will define the keys that it needs
9
- # to support the relationships. Take the following class for example:
10
- #
11
- # class Car < CouchRest::Model::Base
12
- # include Tenacity
13
- #
14
- # t_has_many :wheels
15
- # t_has_one :dashboard
16
- # t_belongs_to :driver
17
- # end
18
- #
19
- # == t_belongs_to
20
- #
21
- # The +t_belongs_to+ association will define a property named after the association.
22
- # The example above will create a property named <tt>:driver_id</tt>
23
- #
24
- #
25
- # == t_has_one
26
- #
27
- # The +t_has_one+ association will not define any new properties on the object, since
28
- # the associated object holds the foreign key.
29
- #
30
- #
31
- # == t_has_many
32
- #
33
- # The +t_has_many+ association will define a property named after the association.
34
- # The example above will create a property named <tt>:wheels_ids</tt>
35
- #
36
- class Base
37
- include CouchRest::TenacityInstanceMethods
38
- extend CouchRest::TenacityClassMethods
39
- end
40
- end
41
- end
42
- rescue LoadError
43
- # CouchRest::Model not available
44
- end