public
Fork of sam/dm-core
Description: DataMapper - Core
Homepage: http://datamapper.org
Clone URL: git://github.com/thewordnerd/dm-core.git
Stripped whitespace with "sake strip"
dkubb (author)
Mon Jul 14 21:59:19 -0700 2008
commit  6dfffdc0692091e54a68472e326261d3b669f873
tree    bf4f1e407aee7df4e73a31f2ec8ea20aecda299f
parent  71e9871f9dd60eb79656a2c28e97695171cb9be2
...
142
143
144
145
146
 
...
142
143
144
 
145
146
0
@@ -142,4 +142,4 @@
0
 * Added benchmarks comparing ActiveRecord::Base::find_by_sql with Session#query
0
 
0
 == 0.1.0
0
-* Initial Public Release
0
\ No newline at end of file
0
+* Initial Public Release
...
26
27
28
29
30
 
...
26
27
28
 
29
30
0
@@ -26,4 +26,4 @@ require ROOT + 'tasks/hoe'
0
 require ROOT + 'tasks/install'
0
 require ROOT + 'tasks/dm'
0
 require ROOT + 'tasks/doc'
0
-require ROOT + 'tasks/ci'
0
\ No newline at end of file
0
+require ROOT + 'tasks/ci'
...
338
339
340
341
 
342
343
344
...
367
368
369
370
 
371
372
373
...
338
339
340
 
341
342
343
344
...
367
368
369
 
370
371
372
373
0
@@ -338,7 +338,7 @@ module DataMapper
0
     def default_repository_name
0
       Repository.default_name
0
     end
0
-
0
+
0
     def paranoid_properties
0
       @paranoid_properties ||= {}
0
       @paranoid_properties
0
@@ -367,7 +367,7 @@ module DataMapper
0
         merge_with_default_scope(query)
0
       end
0
     end
0
-
0
+
0
     def set_paranoid_property(name, &block)
0
       self.paranoid_properties[name] = block
0
     end
...
47
48
49
50
 
51
52
53
 
54
55
56
...
47
48
49
 
50
51
52
 
53
54
55
56
0
@@ -47,10 +47,10 @@ module DataMapper
0
       scope_stack_for = Thread.current[:dm_scope_stack] ||= Hash.new { |h,model| h[model] = [] }
0
       scope_stack_for[self]
0
     end
0
-
0
+
0
     # @api private
0
     def default_scope_for_query(query)
0
- repository_name = query.repository.name
0
+ repository_name = query.repository.name
0
       default_repository_name = query.model.default_repository_name
0
       self.default_scope(default_repository_name).merge(self.default_scope(repository_name))
0
     end
...
12
13
14
15
 
16
17
18
19
20
21
 
22
23
24
...
12
13
14
 
15
16
17
18
19
20
 
21
22
23
24
0
@@ -12,13 +12,13 @@ module DataMapper
0
         model.send(:set_paranoid_property, property.name){true}
0
 
0
         model.class_eval <<-EOS, __FILE__, __LINE__
0
-
0
+
0
           def self.with_deleted
0
             with_exclusive_scope(#{property.name.inspect} => true) do
0
               yield
0
             end
0
           end
0
-
0
+
0
           def destroy
0
             self.class.paranoid_properties.each do |name, blk|
0
               attribute_set(name, blk.call(self))
...
7
8
9
10
 
11
12
13
14
 
15
16
17
18
19
20
 
21
22
23
...
30
31
32
33
34
 
...
7
8
9
 
10
11
12
13
 
14
15
16
17
18
19
 
20
21
22
23
...
30
31
32
 
33
34
0
@@ -7,17 +7,17 @@ module DataMapper
0
       def self.bind(property)
0
         model = property.model
0
         repository = property.repository
0
-
0
+
0
         model.send(:set_paranoid_property, property.name){DateTime.now}
0
 
0
         model.class_eval <<-EOS, __FILE__, __LINE__
0
-
0
+
0
           def self.with_deleted
0
             with_exclusive_scope(#{property.name.inspect}.not => nil) do
0
               yield
0
             end
0
           end
0
-
0
+
0
           def destroy
0
             self.class.paranoid_properties.each do |name, blk|
0
               attribute_set(name, blk.call(self))
0
@@ -30,4 +30,4 @@ module DataMapper
0
       end
0
     end # class ParanoidDateTime
0
   end # module Types
0
-end # module DataMapper
0
\ No newline at end of file
0
+end # module DataMapper
...
8
9
10
11
 
12
13
14
...
118
119
120
121
 
122
123
124
125
126
127
 
128
129
130
...
134
135
136
137
 
138
139
140
141
142
143
144
 
145
146
147
148
149
 
150
151
152
153
154
155
156
 
157
158
159
...
176
177
178
179
 
180
181
182
...
186
187
188
189
 
190
191
192
193
194
195
196
 
197
198
199
200
 
201
202
203
...
213
214
215
216
 
217
218
219
 
220
221
222
223
 
224
225
226
227
 
228
229
230
231
 
232
233
234
235
 
236
237
238
...
240
241
242
243
 
244
245
246
247
248
249
250
 
251
252
253
254
255
256
 
257
258
259
260
261
262
263
 
264
265
266
267
 
268
269
270
...
8
9
10
 
11
12
13
14
...
118
119
120
 
121
122
123
124
125
126
 
127
128
129
130
...
134
135
136
 
137
138
139
140
141
142
143
 
144
145
146
147
148
 
149
150
151
152
153
154
155
 
156
157
158
159
...
176
177
178
 
179
180
181
182
...
186
187
188
 
189
190
191
192
193
194
195
 
196
197
198
199
 
200
201
202
203
...
213
214
215
 
216
217
218
 
219
220
221
222
 
223
224
225
226
 
227
228
229
230
 
231
232
233
234
 
235
236
237
238
...
240
241
242
 
243
244
245
246
247
248
249
 
250
251
252
253
254
255
 
256
257
258
259
260
261
262
 
263
264
265
266
 
267
268
269
270
0
@@ -8,7 +8,7 @@ if ADAPTER
0
     class Impostor < DataMapper::Type
0
       primitive String
0
     end
0
-
0
+
0
     class Coconut
0
       include DataMapper::Resource
0
 
0
@@ -118,13 +118,13 @@ if ADAPTER
0
 
0
         lemon.deleted_at.should be_kind_of(DateTime)
0
       end
0
-
0
+
0
       repository(ADAPTER) do |repository|
0
         Lemon.all.should be_empty
0
         Lemon.get(lemon.id).should be_nil
0
       end
0
     end
0
-
0
+
0
     it "should provide access to paranoid items with DateTime" do
0
       Lemon.auto_migrate!(ADAPTER)
0
 
0
@@ -134,26 +134,26 @@ if ADAPTER
0
         %w(red green yellow blue).each do |color|
0
           Lemon.create(:color => color)
0
         end
0
-
0
+
0
         Lemon.all.size.should == 4
0
         Lemon.first.destroy
0
         Lemon.all.size.should == 3
0
         Lemon.with_deleted{Lemon.all.size.should == 1}
0
       end
0
     end
0
-
0
+
0
     it "should set paranoid datetime to a date time" do
0
       tmp = (DateTime.now - 0.5)
0
       dt = DateTime.now
0
       DateTime.stub!(:now).and_return(tmp)
0
-
0
+
0
       repository(ADAPTER) do |repository|
0
         lemon = Lemon.new
0
         lemon.color = 'green'
0
         lemon.save
0
         lemon.destroy
0
         lemon.deleted_at.should == tmp
0
- end
0
+ end
0
     end
0
 
0
     it "should respect paranoia with a boolean" do
0
@@ -176,7 +176,7 @@ if ADAPTER
0
         Lime.get(lime.id).should be_nil
0
       end
0
     end
0
-
0
+
0
     it "should provide access to paranoid items with Boolean" do
0
       Lime.auto_migrate!(ADAPTER)
0
 
0
@@ -186,18 +186,18 @@ if ADAPTER
0
         %w(red green yellow blue).each do |color|
0
           Lime.create(:color => color)
0
         end
0
-
0
+
0
         Lime.all.size.should == 4
0
         Lime.first.destroy
0
         Lime.all.size.should == 3
0
         Lime.with_deleted{Lime.all.size.should == 1}
0
       end
0
     end
0
-
0
+
0
     describe "paranoid types across repositories" do
0
       before(:all) do
0
         DataMapper::Repository.adapters[:alternate_paranoid] = repository(ADAPTER).adapter.dup
0
-
0
+
0
         class Orange
0
           include DataMapper::Resource
0
 
0
@@ -213,26 +213,26 @@ if ADAPTER
0
             property :deleted_at, DataMapper::Types::ParanoidDateTime
0
           end
0
         end
0
-
0
+
0
         repository(:alternate_paranoid){Orange.auto_migrate!}
0
       end
0
-
0
+
0
       before(:each) do
0
         %w(red orange blue green).each{|color| o = Orange.create(:color => color)}
0
       end
0
-
0
+
0
       after(:each) do
0
         Orange.repository.adapter.execute("DELETE FROM oranges")
0
       end
0
-
0
+
0
       it "should setup the correct objects for the spec" do
0
         repository(:alternate_paranoid){Orange.all.should have(4).items}
0
       end
0
-
0
+
0
       it "should allow access the the default repository" do
0
         Orange.all.should have(4).items
0
       end
0
-
0
+
0
       it "should mark the objects as deleted in the alternate_paranoid repository" do
0
         repository(:alternate_paranoid) do
0
           Orange.first.destroy
0
@@ -240,31 +240,31 @@ if ADAPTER
0
           Orange.find_by_sql("SELECT * FROM oranges").should have(4).items
0
         end
0
       end
0
-
0
+
0
       it "should mark the objects as deleted in the alternate_paranoid repository but ignore it in the #{ADAPTER} repository" do
0
         repository(:alternate_paranoid) do
0
           Orange.first.destroy
0
         end
0
         Orange.all.should have(4).items
0
       end
0
-
0
+
0
       it "should raise an error when trying to destroy from a repository that is not paranoid" do
0
         lambda do
0
           Orange.first.destroy
0
         end.should raise_error(ArgumentError)
0
       end
0
-
0
+
0
       it "should set all paranoid attributes on delete" do
0
         repository(:alternate_paranoid) do
0
           orange = Orange.first
0
           orange.deleted.should be_false
0
           orange.deleted_at.should be_nil
0
           orange.destroy
0
-
0
+
0
           orange.deleted.should be_true
0
           orange.deleted_at.should be_a_kind_of(DateTime)
0
         end
0
- end
0
+ end
0
     end
0
   end
0
 end
...
15
16
17
18
19
 
...
15
16
17
 
18
19
0
@@ -15,4 +15,4 @@ module LoggingHelper
0
       File.delete(log_path)
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
35
36
37
38
 
39
40
41
42
43
44
45
 
46
47
 
48
49
50
51
 
52
53
 
54
55
 
56
57
58
 
59
60
61
62
63
 
64
65
66
67
68
69
 
70
71
72
73
 
74
75
76
...
78
79
80
81
 
82
83
84
...
88
89
90
91
92
 
...
35
36
37
 
38
39
40
41
42
43
44
 
45
46
 
47
48
49
50
 
51
52
 
53
54
 
55
56
57
 
58
59
60
61
62
 
63
64
65
66
67
68
 
69
70
71
72
 
73
74
75
76
...
78
79
80
 
81
82
83
84
...
88
89
90
 
91
92
0
@@ -35,42 +35,42 @@
0
 # end
0
 # end
0
 module ModelLoader
0
-
0
+
0
   def self.included(base)
0
     base.extend(ClassMethods)
0
     base.class_eval { include InstanceMethods }
0
     # base.before(:each) { load_models(:global) }
0
     base.after(:each) { unload_models }
0
   end
0
-
0
+
0
   module ClassMethods
0
-
0
+
0
     def load_models_for_metaphor(*metaphors)
0
       before(:each) { load_models_for_metaphor(*metaphors) }
0
     end
0
-
0
+
0
   end
0
-
0
+
0
   module InstanceMethods
0
-
0
+
0
     def load_models_for_metaphor(*metaphors)
0
       files = metaphors.map { |m| DataMapper.root / "spec" / "models" / "#{m}.rb" }
0
-
0
+
0
       klasses = object_space_classes.dup
0
       files.each { |file| load file }
0
       loaded_models.concat(object_space_classes - klasses)
0
     end
0
-
0
+
0
     def unload_models
0
       while model = loaded_models.pop
0
         remove_model(model)
0
       end
0
     end
0
-
0
+
0
     def loaded_models
0
       @loaded_models ||= []
0
     end
0
-
0
+
0
   private
0
 
0
     def object_space_classes
0
@@ -78,7 +78,7 @@ module ModelLoader
0
       ObjectSpace.each_object(Class) {|o| klasses << o}
0
       klasses
0
     end
0
-
0
+
0
     def remove_model(klass)
0
       DataMapper::Resource.descendants.delete(klass)
0
       Object.module_eval { remove_const klass.to_s }
0
@@ -88,4 +88,4 @@ end
0
 
0
 Spec::Runner.configure do |config|
0
   config.include(ModelLoader)
0
-end
0
\ No newline at end of file
0
+end
...
25
26
27
28
29
 
...
25
26
27
 
28
29
0
@@ -25,4 +25,4 @@ class Class
0
       end
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
70
71
72
73
74
 
...
70
71
72
 
73
74
0
@@ -70,4 +70,4 @@ end
0
 
0
 class NormalClass
0
   # should not include DataMapper::Resource
0
-end
0
\ No newline at end of file
0
+end
...
1
2
3
4
 
5
6
 
7
8
9
...
1
2
3
 
4
5
 
6
7
8
9
0
@@ -1,9 +1,9 @@
0
 require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
0
 
0
 describe DataMapper::Associations::ManyToMany do
0
-
0
+
0
   load_models_for_metaphor :vehicles
0
-
0
+
0
   it 'should allow a declaration' do
0
     lambda do
0
       class Supplier
...
1
2
3
4
 
5
6
 
7
8
9
...
14
15
16
17
 
18
19
 
20
21
22
...
1
2
3
 
4
5
 
6
7
8
9
...
14
15
16
 
17
18
 
19
20
21
22
0
@@ -1,9 +1,9 @@
0
 require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
0
 
0
 describe DataMapper::Associations::ManyToOne do
0
-
0
+
0
   load_models_for_metaphor :vehicles
0
-
0
+
0
   it 'should allow a declaration' do
0
     lambda do
0
       class Vehicle
0
@@ -14,9 +14,9 @@ describe DataMapper::Associations::ManyToOne do
0
 end
0
 
0
 describe DataMapper::Associations::ManyToOne::Proxy do
0
-
0
+
0
   load_models_for_metaphor :vehicles
0
-
0
+
0
   before do
0
     @child = mock('child', :kind_of? => true)
0
     @parent = mock('parent')
...
1
2
3
4
 
5
6
 
7
8
9
...
1
2
3
 
4
5
 
6
7
8
9
0
@@ -1,9 +1,9 @@
0
 require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
0
 
0
 describe DataMapper::Associations::OneToMany do
0
-
0
+
0
   load_models_for_metaphor :vehicles
0
-
0
+
0
   before do
0
     @class = Class.new do
0
       def self.name
...
1
2
3
4
 
5
6
 
7
8
9
...
53
54
55
56
 
57
58
59
...
1
2
3
 
4
5
 
6
7
8
9
...
53
54
55
 
56
57
58
59
0
@@ -1,9 +1,9 @@
0
 require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
0
 
0
 describe DataMapper::Associations::Relationship do
0
-
0
+
0
   load_models_for_metaphor :vehicles
0
-
0
+
0
   it "should describe an association" do
0
     belongs_to = DataMapper::Associations::Relationship.new(
0
       :manufacturer,
0
@@ -53,7 +53,7 @@ describe DataMapper::Associations::Relationship do
0
     has_many.with_repository do |r|
0
       r.name.should == :mock
0
     end
0
-
0
+
0
     has_many.child_key.should be_a_kind_of(DataMapper::PropertySet)
0
     has_many.parent_key.should be_a_kind_of(DataMapper::PropertySet)
0
     # Vehicle.has n, :models, :class_name => 'Manufacturer', :child_key => "models_id"
...
1
2
3
4
 
5
6
 
7
8
9
...
1
2
3
 
4
5
 
6
7
8
9
0
@@ -1,9 +1,9 @@
0
 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
0
 
0
 describe "DataMapper::Associations" do
0
-
0
+
0
   load_models_for_metaphor :vehicles
0
-
0
+
0
   before do
0
     @relationship = mock(DataMapper::Associations::Relationship)
0
     @n = 1.0/0
...
75
76
77
78
 
79
80
81
...
85
86
87
88
 
89
90
91
...
75
76
77
 
78
79
80
81
...
85
86
87
 
88
89
90
91
0
@@ -75,7 +75,7 @@ describe DataMapper::Scope do
0
         Article.query.should be_nil
0
       end
0
     end
0
-
0
+
0
     it "should ignore the default_scope when using an exclusive scope" do
0
       Article.default_scope.update(:blog_id => 1)
0
       Article.publicize_methods do
0
@@ -85,7 +85,7 @@ describe DataMapper::Scope do
0
       end
0
       Article.default_scope.delete(:blog_id)
0
     end
0
-
0
+
0
   end
0
 
0
   describe '.scope_stack' do
...
35
36
37
38
39
 
...
35
36
37
 
38
39
0
@@ -35,4 +35,4 @@ hoe = Hoe.new(GEM_NAME, GEM_VERSION) do |p|
0
     p.extra_deps << dep
0
   end
0
 
0
-end
0
\ No newline at end of file
0
+end

Comments

    No one has commented yet.