tenacity 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 (47) hide show
  1. data/EXTEND.rdoc +10 -3
  2. data/Gemfile +1 -2
  3. data/README.rdoc +3 -2
  4. data/Rakefile +6 -0
  5. data/history.txt +11 -0
  6. data/lib/tenacity/associate_proxy.rb +1 -1
  7. data/lib/tenacity/associates_proxy.rb +4 -4
  8. data/lib/tenacity/associations/has_many.rb +7 -8
  9. data/lib/tenacity/associations/has_one.rb +4 -4
  10. data/lib/tenacity/class_methods.rb +1 -1
  11. data/lib/tenacity/errors.rb +4 -8
  12. data/lib/tenacity/instance_methods.rb +2 -2
  13. data/lib/tenacity/orm_ext/activerecord.rb +5 -1
  14. data/lib/tenacity/orm_ext/couchrest.rb +4 -0
  15. data/lib/tenacity/orm_ext/datamapper.rb +5 -1
  16. data/lib/tenacity/orm_ext/helpers.rb +3 -3
  17. data/lib/tenacity/orm_ext/mongo_mapper.rb +4 -0
  18. data/lib/tenacity/orm_ext/mongoid.rb +4 -0
  19. data/lib/tenacity/orm_ext/ripple.rb +4 -0
  20. data/lib/tenacity/orm_ext/sequel.rb +5 -1
  21. data/lib/tenacity/orm_ext/toystore.rb +4 -0
  22. data/lib/tenacity/version.rb +1 -1
  23. data/test/associations/belongs_to_test.rb +3 -3
  24. data/test/associations/has_many_test.rb +6 -6
  25. data/test/associations/has_one_test.rb +4 -4
  26. data/test/core/classmethods_test.rb +14 -0
  27. data/test/fixtures/active_record_object_with_string_id.rb +5 -0
  28. data/test/fixtures/couch_rest_object.rb +2 -0
  29. data/test/fixtures/data_mapper_object.rb +1 -0
  30. data/test/fixtures/data_mapper_object_with_string_id.rb +6 -0
  31. data/test/fixtures/mongo_mapper_object.rb +4 -0
  32. data/test/fixtures/mongoid_object.rb +2 -0
  33. data/test/fixtures/ripple_object.rb +2 -0
  34. data/test/fixtures/sequel_object_with_string_id.rb +3 -0
  35. data/test/fixtures/toystore_object.rb +2 -0
  36. data/test/helpers/active_record_test_helper.rb +4 -0
  37. data/test/helpers/data_mapper_test_helper.rb +1 -0
  38. data/test/helpers/sequel_test_helper.rb +5 -0
  39. data/test/orm_ext/activerecord_test.rb +16 -0
  40. data/test/orm_ext/datamapper_test.rb +16 -0
  41. data/test/orm_ext/mongo_mapper_test.rb +11 -0
  42. data/test/orm_ext/mongoid_test.rb +11 -0
  43. data/test/orm_ext/ripple_test.rb +147 -134
  44. data/test/orm_ext/sequel_test.rb +16 -0
  45. data/test/orm_ext/toystore_test.rb +11 -0
  46. data/test/test_helper.rb +8 -8
  47. metadata +46 -152
@@ -92,6 +92,22 @@ class SequelTest < Test::Unit::TestCase
92
92
  SequelObject._t_delete([object_1.id, object_2.id, object_3.id], false)
93
93
  assert_equal old_count - 3, SequelObject.count
94
94
  end
95
+
96
+ should "save the object if it is dirty" do
97
+ object = SequelObject.create
98
+ object.prop = "something"
99
+ assert object._t_save_if_dirty
100
+ end
101
+
102
+ should "not save the object if it is not dirty" do
103
+ object = SequelObject.create
104
+ assert !object._t_save_if_dirty
105
+ end
106
+
107
+ should "be able to successfully determine the id type" do
108
+ assert_equal Integer, SequelObject._t_id_type
109
+ assert_equal String, SequelObjectWithStringId._t_id_type
110
+ end
95
111
  end
96
112
 
97
113
  private
@@ -94,6 +94,17 @@ require_toystore do
94
94
  ToystoreHasManyTarget._t_delete([object_1.id, object_2.id, object_3.id], false)
95
95
  assert_equal 0, ToystoreHasManyTarget.get_multi(object_1.id, object_2.id, object_3.id).compact.size
96
96
  end
97
+
98
+ should "save the object if it is dirty" do
99
+ object = ToystoreObject.create
100
+ object.prop = "something"
101
+ assert object._t_save_if_dirty
102
+ end
103
+
104
+ should "not save the object if it is not dirty" do
105
+ object = ToystoreObject.create
106
+ assert !object._t_save_if_dirty
107
+ end
97
108
  end
98
109
 
99
110
  def association
data/test/test_helper.rb CHANGED
@@ -101,30 +101,30 @@ end
101
101
  def class_for_extension(extension, type=nil)
102
102
  if type.nil?
103
103
  class_name = extension.to_s.camelcase + "Object"
104
- elsif type == :belongs_to || type == :has_one
104
+ elsif type == :t_belongs_to || type == :t_has_one
105
105
  class_name = extension.to_s.camelcase + "HasOneTarget"
106
- elsif type == :has_many
106
+ elsif type == :t_has_many
107
107
  class_name = extension.to_s.camelcase + "HasManyTarget"
108
108
  end
109
109
  Kernel.const_get(class_name)
110
110
  end
111
111
 
112
112
  def foreign_key_for(extension, type)
113
- if type == :belongs_to
113
+ if type == :t_belongs_to
114
114
  "#{extension}_object"
115
- elsif type == :has_one
115
+ elsif type == :t_has_one
116
116
  "#{extension}_has_one_target"
117
- elsif type == :has_many
117
+ elsif type == :t_has_many
118
118
  "#{extension}_has_many_targets"
119
119
  end
120
120
  end
121
121
 
122
122
  def foreign_key_id_for(extension, type)
123
- if type == :belongs_to
123
+ if type == :t_belongs_to
124
124
  "#{extension}_object_id"
125
- elsif type == :has_one
125
+ elsif type == :t_has_one
126
126
  "#{extension}_has_one_target_id"
127
- elsif type == :has_many
127
+ elsif type == :t_has_many
128
128
  "#{extension}_has_many_target_ids"
129
129
  end
130
130
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tenacity
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 1
10
- version: 0.5.1
5
+ version: 0.5.2
11
6
  platform: ruby
12
7
  authors:
13
8
  - John Wood
@@ -15,327 +10,228 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-07-05 00:00:00 -05:00
13
+ date: 2011-07-15 00:00:00 -05:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
22
17
  name: activesupport
23
- prerelease: false
24
- type: :runtime
25
18
  requirement: &id001 !ruby/object:Gem::Requirement
26
19
  none: false
27
20
  requirements:
28
21
  - - ">="
29
22
  - !ruby/object:Gem::Version
30
- hash: 5
31
- segments:
32
- - 2
33
- - 3
34
23
  version: "2.3"
24
+ type: :runtime
25
+ prerelease: false
35
26
  version_requirements: *id001
36
27
  - !ruby/object:Gem::Dependency
37
28
  name: bundler
38
- prerelease: false
39
- type: :development
40
29
  requirement: &id002 !ruby/object:Gem::Requirement
41
30
  none: false
42
31
  requirements:
43
32
  - - ~>
44
33
  - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 1
48
- - 0
49
- - 0
50
34
  version: 1.0.0
35
+ type: :development
36
+ prerelease: false
51
37
  version_requirements: *id002
52
38
  - !ruby/object:Gem::Dependency
53
39
  name: rake
54
- prerelease: false
55
- type: :development
56
40
  requirement: &id003 !ruby/object:Gem::Requirement
57
41
  none: false
58
42
  requirements:
59
43
  - - ~>
60
44
  - !ruby/object:Gem::Version
61
- hash: 49
62
- segments:
63
- - 0
64
- - 8
65
- - 7
66
45
  version: 0.8.7
46
+ type: :development
47
+ prerelease: false
67
48
  version_requirements: *id003
68
49
  - !ruby/object:Gem::Dependency
69
50
  name: rcov
70
- prerelease: false
71
- type: :development
72
51
  requirement: &id004 !ruby/object:Gem::Requirement
73
52
  none: false
74
53
  requirements:
75
54
  - - ~>
76
55
  - !ruby/object:Gem::Version
77
- hash: 41
78
- segments:
79
- - 0
80
- - 9
81
- - 9
82
56
  version: 0.9.9
57
+ type: :development
58
+ prerelease: false
83
59
  version_requirements: *id004
84
60
  - !ruby/object:Gem::Dependency
85
61
  name: shoulda
86
- prerelease: false
87
- type: :development
88
62
  requirement: &id005 !ruby/object:Gem::Requirement
89
63
  none: false
90
64
  requirements:
91
65
  - - ~>
92
66
  - !ruby/object:Gem::Version
93
- hash: 37
94
- segments:
95
- - 2
96
- - 11
97
- - 3
98
67
  version: 2.11.3
68
+ type: :development
69
+ prerelease: false
99
70
  version_requirements: *id005
100
71
  - !ruby/object:Gem::Dependency
101
72
  name: mocha
102
- prerelease: false
103
- type: :development
104
73
  requirement: &id006 !ruby/object:Gem::Requirement
105
74
  none: false
106
75
  requirements:
107
76
  - - ~>
108
77
  - !ruby/object:Gem::Version
109
- hash: 47
110
- segments:
111
- - 0
112
- - 9
113
- - 10
114
78
  version: 0.9.10
79
+ type: :development
80
+ prerelease: false
115
81
  version_requirements: *id006
116
82
  - !ruby/object:Gem::Dependency
117
83
  name: yard
118
- prerelease: false
119
- type: :development
120
84
  requirement: &id007 !ruby/object:Gem::Requirement
121
85
  none: false
122
86
  requirements:
123
87
  - - ~>
124
88
  - !ruby/object:Gem::Version
125
- hash: 15
126
- segments:
127
- - 0
128
- - 6
129
- - 4
130
89
  version: 0.6.4
90
+ type: :development
91
+ prerelease: false
131
92
  version_requirements: *id007
132
93
  - !ruby/object:Gem::Dependency
133
94
  name: sqlite3-ruby
134
- prerelease: false
135
- type: :development
136
95
  requirement: &id008 !ruby/object:Gem::Requirement
137
96
  none: false
138
97
  requirements:
139
98
  - - ~>
140
99
  - !ruby/object:Gem::Version
141
- hash: 25
142
- segments:
143
- - 1
144
- - 3
145
- - 1
146
100
  version: 1.3.1
101
+ type: :development
102
+ prerelease: false
147
103
  version_requirements: *id008
148
104
  - !ruby/object:Gem::Dependency
149
105
  name: activerecord
150
- prerelease: false
151
- type: :development
152
106
  requirement: &id009 !ruby/object:Gem::Requirement
153
107
  none: false
154
108
  requirements:
155
109
  - - ~>
156
110
  - !ruby/object:Gem::Version
157
- hash: 7
158
- segments:
159
- - 3
160
- - 0
161
- - 0
162
111
  version: 3.0.0
112
+ type: :development
113
+ prerelease: false
163
114
  version_requirements: *id009
164
115
  - !ruby/object:Gem::Dependency
165
116
  name: datamapper
166
- prerelease: false
167
- type: :development
168
117
  requirement: &id010 !ruby/object:Gem::Requirement
169
118
  none: false
170
119
  requirements:
171
120
  - - ~>
172
121
  - !ruby/object:Gem::Version
173
- hash: 19
174
- segments:
175
- - 1
176
- - 0
177
- - 2
178
122
  version: 1.0.2
123
+ type: :development
124
+ prerelease: false
179
125
  version_requirements: *id010
180
126
  - !ruby/object:Gem::Dependency
181
127
  name: dm-sqlite-adapter
182
- prerelease: false
183
- type: :development
184
128
  requirement: &id011 !ruby/object:Gem::Requirement
185
129
  none: false
186
130
  requirements:
187
131
  - - ~>
188
132
  - !ruby/object:Gem::Version
189
- hash: 19
190
- segments:
191
- - 1
192
- - 0
193
- - 2
194
133
  version: 1.0.2
134
+ type: :development
135
+ prerelease: false
195
136
  version_requirements: *id011
196
137
  - !ruby/object:Gem::Dependency
197
138
  name: sequel
198
- prerelease: false
199
- type: :development
200
139
  requirement: &id012 !ruby/object:Gem::Requirement
201
140
  none: false
202
141
  requirements:
203
142
  - - ~>
204
143
  - !ruby/object:Gem::Version
205
- hash: 75
206
- segments:
207
- - 3
208
- - 19
209
- - 0
210
144
  version: 3.19.0
145
+ type: :development
146
+ prerelease: false
211
147
  version_requirements: *id012
212
148
  - !ruby/object:Gem::Dependency
213
149
  name: mongo_mapper
214
- prerelease: false
215
- type: :development
216
150
  requirement: &id013 !ruby/object:Gem::Requirement
217
151
  none: false
218
152
  requirements:
219
153
  - - ~>
220
154
  - !ruby/object:Gem::Version
221
- hash: 59
222
- segments:
223
- - 0
224
- - 9
225
- - 0
226
155
  version: 0.9.0
156
+ type: :development
157
+ prerelease: false
227
158
  version_requirements: *id013
228
159
  - !ruby/object:Gem::Dependency
229
160
  name: bson_ext
230
- prerelease: false
231
- type: :development
232
161
  requirement: &id014 !ruby/object:Gem::Requirement
233
162
  none: false
234
163
  requirements:
235
164
  - - ~>
236
165
  - !ruby/object:Gem::Version
237
- hash: 27
238
- segments:
239
- - 1
240
- - 3
241
- - 0
242
166
  version: 1.3.0
167
+ type: :development
168
+ prerelease: false
243
169
  version_requirements: *id014
244
170
  - !ruby/object:Gem::Dependency
245
171
  name: mongoid
246
- prerelease: false
247
- type: :development
248
172
  requirement: &id015 !ruby/object:Gem::Requirement
249
173
  none: false
250
174
  requirements:
251
175
  - - ~>
252
176
  - !ruby/object:Gem::Version
253
- hash: 15
254
- segments:
255
- - 2
256
- - 0
257
- - 0
258
177
  version: 2.0.0
178
+ type: :development
179
+ prerelease: false
259
180
  version_requirements: *id015
260
181
  - !ruby/object:Gem::Dependency
261
182
  name: couchrest
262
- prerelease: false
263
- type: :development
264
183
  requirement: &id016 !ruby/object:Gem::Requirement
265
184
  none: false
266
185
  requirements:
267
186
  - - ~>
268
187
  - !ruby/object:Gem::Version
269
- hash: 23
270
- segments:
271
- - 1
272
- - 0
273
- - 0
274
188
  version: 1.0.0
189
+ type: :development
190
+ prerelease: false
275
191
  version_requirements: *id016
276
192
  - !ruby/object:Gem::Dependency
277
193
  name: couchrest_model
278
- prerelease: false
279
- type: :development
280
194
  requirement: &id017 !ruby/object:Gem::Requirement
281
195
  none: false
282
196
  requirements:
283
197
  - - ~>
284
198
  - !ruby/object:Gem::Version
285
- hash: 23
286
- segments:
287
- - 1
288
- - 0
289
- - 0
290
199
  version: 1.0.0
200
+ type: :development
201
+ prerelease: false
291
202
  version_requirements: *id017
292
203
  - !ruby/object:Gem::Dependency
293
204
  name: ripple
294
- prerelease: false
295
- type: :development
296
205
  requirement: &id018 !ruby/object:Gem::Requirement
297
206
  none: false
298
207
  requirements:
299
208
  - - ~>
300
209
  - !ruby/object:Gem::Version
301
- hash: 63
302
- segments:
303
- - 0
304
- - 9
305
- - 2
306
210
  version: 0.9.2
211
+ type: :development
212
+ prerelease: false
307
213
  version_requirements: *id018
308
214
  - !ruby/object:Gem::Dependency
309
215
  name: toystore
310
- prerelease: false
311
- type: :development
312
216
  requirement: &id019 !ruby/object:Gem::Requirement
313
217
  none: false
314
218
  requirements:
315
219
  - - ~>
316
220
  - !ruby/object:Gem::Version
317
- hash: 63
318
- segments:
319
- - 0
320
- - 8
321
- - 0
322
221
  version: 0.8.0
222
+ type: :development
223
+ prerelease: false
323
224
  version_requirements: *id019
324
225
  - !ruby/object:Gem::Dependency
325
226
  name: adapter-mongo
326
- prerelease: false
327
- type: :development
328
227
  requirement: &id020 !ruby/object:Gem::Requirement
329
228
  none: false
330
229
  requirements:
331
230
  - - ~>
332
231
  - !ruby/object:Gem::Version
333
- hash: 15
334
- segments:
335
- - 0
336
- - 5
337
- - 2
338
232
  version: 0.5.2
233
+ type: :development
234
+ prerelease: false
339
235
  version_requirements: *id020
340
236
  description: Tenacity provides a database client independent way of specifying simple relationships between models backed by different databases.
341
237
  email:
@@ -389,6 +285,7 @@ files:
389
285
  - test/fixtures/active_record_has_one_target.rb
390
286
  - test/fixtures/active_record_nut.rb
391
287
  - test/fixtures/active_record_object.rb
288
+ - test/fixtures/active_record_object_with_string_id.rb
392
289
  - test/fixtures/couch_rest_door.rb
393
290
  - test/fixtures/couch_rest_has_many_target.rb
394
291
  - test/fixtures/couch_rest_has_one_target.rb
@@ -397,6 +294,7 @@ files:
397
294
  - test/fixtures/data_mapper_has_many_target.rb
398
295
  - test/fixtures/data_mapper_has_one_target.rb
399
296
  - test/fixtures/data_mapper_object.rb
297
+ - test/fixtures/data_mapper_object_with_string_id.rb
400
298
  - test/fixtures/mongo_mapper_air_filter.rb
401
299
  - test/fixtures/mongo_mapper_alternator.rb
402
300
  - test/fixtures/mongo_mapper_ash_tray.rb
@@ -422,6 +320,7 @@ files:
422
320
  - test/fixtures/sequel_has_many_target.rb
423
321
  - test/fixtures/sequel_has_one_target.rb
424
322
  - test/fixtures/sequel_object.rb
323
+ - test/fixtures/sequel_object_with_string_id.rb
425
324
  - test/fixtures/toystore_has_many_target.rb
426
325
  - test/fixtures/toystore_has_one_target.rb
427
326
  - test/fixtures/toystore_object.rb
@@ -456,7 +355,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
456
355
  requirements:
457
356
  - - ">="
458
357
  - !ruby/object:Gem::Version
459
- hash: 3
358
+ hash: -2063505334017830292
460
359
  segments:
461
360
  - 0
462
361
  version: "0"
@@ -465,11 +364,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
465
364
  requirements:
466
365
  - - ">="
467
366
  - !ruby/object:Gem::Version
468
- hash: 23
469
- segments:
470
- - 1
471
- - 3
472
- - 6
473
367
  version: 1.3.6
474
368
  requirements: []
475
369