tenacity 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 John Wood
1
+ Copyright (c) 2012 John Wood
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,3 +1,9 @@
1
+ == 0.5.5
2
+
3
+ * Bug fixes
4
+
5
+ * Modify association code to support qualified class names (Foo::Bar)
6
+
1
7
  == 0.5.4
2
8
 
3
9
  * Bug fixes
@@ -68,9 +68,9 @@ module Tenacity
68
68
  # Get the associated class
69
69
  def associate_class(object=nil)
70
70
  if @type == :t_belongs_to && polymorphic?
71
- Kernel.const_get(object.send(polymorphic_type))
71
+ qualified_const_get(object.send(polymorphic_type))
72
72
  else
73
- @clazz ||= Kernel.const_get(@class_name)
73
+ @clazz ||= qualified_const_get(@class_name)
74
74
  end
75
75
  end
76
76
 
@@ -109,11 +109,39 @@ module Tenacity
109
109
 
110
110
  private
111
111
 
112
+ # Shamelessly copied from http://redcorundum.blogspot.com/2006/05/kernelqualifiedconstget.html
113
+ def qualified_const_get(clazz)
114
+ path = clazz.to_s.split('::')
115
+ from_root = path[0].empty?
116
+
117
+ if from_root
118
+ from_root = []
119
+ path = path[1..-1]
120
+ else
121
+ start_ns = ((Class === self) || (Module === self)) ? self : self.class
122
+ from_root = start_ns.to_s.split('::')
123
+ end
124
+
125
+ until from_root.empty?
126
+ begin
127
+ return (from_root + path).inject(Object) { |ns,name| ns.const_get(name) }
128
+ rescue NameError
129
+ from_root.delete_at(-1)
130
+ end
131
+ end
132
+
133
+ path.inject(Object) { |ns,name| ns.const_get(name) }
134
+ end
135
+
136
+ def unqualified_class_name(clazz)
137
+ clazz.to_s.split('::').last
138
+ end
139
+
112
140
  def belongs_to_foreign_key
113
141
  if polymorphic?
114
142
  (name.to_s + "_id").to_sym
115
143
  else
116
- @class_name.underscore + "_id"
144
+ unqualified_class_name(@class_name).underscore + "_id"
117
145
  end
118
146
  end
119
147
 
@@ -122,7 +150,7 @@ module Tenacity
122
150
  if polymorphic?
123
151
  (@as.to_s + "_id").to_sym
124
152
  else
125
- "#{ActiveSupport::Inflector.underscore(clazz)}_id"
153
+ "#{ActiveSupport::Inflector.underscore(unqualified_class_name(clazz))}_id"
126
154
  end
127
155
  end
128
156
  end
@@ -1,3 +1,3 @@
1
1
  module Tenacity
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tenacity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-11 00:00:00.000000000Z
12
+ date: 2012-04-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &2166742780 !ruby/object:Gem::Requirement
16
+ requirement: &2156358940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2166742780
24
+ version_requirements: *2156358940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &2166741660 !ruby/object:Gem::Requirement
27
+ requirement: &2156355320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2166741660
35
+ version_requirements: *2156355320
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2166740640 !ruby/object:Gem::Requirement
38
+ requirement: &2156353760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.8.7
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2166740640
46
+ version_requirements: *2156353760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &2166740020 !ruby/object:Gem::Requirement
49
+ requirement: &2156339720 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.9.9
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2166740020
57
+ version_requirements: *2156339720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: shoulda
60
- requirement: &2166739380 !ruby/object:Gem::Requirement
60
+ requirement: &2156338680 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.11.3
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2166739380
68
+ version_requirements: *2156338680
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mocha
71
- requirement: &2166738740 !ruby/object:Gem::Requirement
71
+ requirement: &2156337580 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.9.10
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2166738740
79
+ version_requirements: *2156337580
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: yard
82
- requirement: &2166738120 !ruby/object:Gem::Requirement
82
+ requirement: &2156336420 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.6.4
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2166738120
90
+ version_requirements: *2156336420
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: sqlite3-ruby
93
- requirement: &2166737440 !ruby/object:Gem::Requirement
93
+ requirement: &2156335080 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.3.1
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2166737440
101
+ version_requirements: *2156335080
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: activerecord
104
- requirement: &2166736600 !ruby/object:Gem::Requirement
104
+ requirement: &2156333400 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 3.0.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2166736600
112
+ version_requirements: *2156333400
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: datamapper
115
- requirement: &2166731420 !ruby/object:Gem::Requirement
115
+ requirement: &2156325060 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 1.0.2
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2166731420
123
+ version_requirements: *2156325060
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: dm-sqlite-adapter
126
- requirement: &2166728920 !ruby/object:Gem::Requirement
126
+ requirement: &2156316080 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 1.0.2
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2166728920
134
+ version_requirements: *2156316080
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: sequel
137
- requirement: &2166728280 !ruby/object:Gem::Requirement
137
+ requirement: &2156314280 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ~>
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: 3.19.0
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *2166728280
145
+ version_requirements: *2156314280
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: mongo_mapper
148
- requirement: &2166727680 !ruby/object:Gem::Requirement
148
+ requirement: &2156313060 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ~>
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: 0.9.0
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *2166727680
156
+ version_requirements: *2156313060
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: bson_ext
159
- requirement: &2166727060 !ruby/object:Gem::Requirement
159
+ requirement: &2156311420 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ~>
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: 1.3.0
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *2166727060
167
+ version_requirements: *2156311420
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: mongoid
170
- requirement: &2166726400 !ruby/object:Gem::Requirement
170
+ requirement: &2156293240 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ~>
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: 2.0.0
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *2166726400
178
+ version_requirements: *2156293240
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: couchrest
181
- requirement: &2166725820 !ruby/object:Gem::Requirement
181
+ requirement: &2156291780 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ~>
@@ -186,10 +186,10 @@ dependencies:
186
186
  version: 1.0.0
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *2166725820
189
+ version_requirements: *2156291780
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: couchrest_model
192
- requirement: &2166725080 !ruby/object:Gem::Requirement
192
+ requirement: &2156290520 !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
195
195
  - - ~>
@@ -197,10 +197,10 @@ dependencies:
197
197
  version: 1.0.0
198
198
  type: :development
199
199
  prerelease: false
200
- version_requirements: *2166725080
200
+ version_requirements: *2156290520
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: ripple
203
- requirement: &2166724480 !ruby/object:Gem::Requirement
203
+ requirement: &2156288920 !ruby/object:Gem::Requirement
204
204
  none: false
205
205
  requirements:
206
206
  - - ~>
@@ -208,10 +208,10 @@ dependencies:
208
208
  version: 0.9.2
209
209
  type: :development
210
210
  prerelease: false
211
- version_requirements: *2166724480
211
+ version_requirements: *2156288920
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: toystore
214
- requirement: &2166723920 !ruby/object:Gem::Requirement
214
+ requirement: &2156286980 !ruby/object:Gem::Requirement
215
215
  none: false
216
216
  requirements:
217
217
  - - ~>
@@ -219,10 +219,10 @@ dependencies:
219
219
  version: 0.8.0
220
220
  type: :development
221
221
  prerelease: false
222
- version_requirements: *2166723920
222
+ version_requirements: *2156286980
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: adapter-mongo
225
- requirement: &2166721320 !ruby/object:Gem::Requirement
225
+ requirement: &2156284020 !ruby/object:Gem::Requirement
226
226
  none: false
227
227
  requirements:
228
228
  - - ~>
@@ -230,7 +230,7 @@ dependencies:
230
230
  version: 0.5.2
231
231
  type: :development
232
232
  prerelease: false
233
- version_requirements: *2166721320
233
+ version_requirements: *2156284020
234
234
  description: Tenacity provides a database client independent way of specifying simple
235
235
  relationships between models backed by different databases.
236
236
  email:
@@ -353,7 +353,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
353
353
  version: '0'
354
354
  segments:
355
355
  - 0
356
- hash: 2735830648188006742
356
+ hash: 3771239550566841949
357
357
  required_rubygems_version: !ruby/object:Gem::Requirement
358
358
  none: false
359
359
  requirements: