datamapper-dm-core 0.9.11 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +17 -14
- data/.gitignore +3 -1
- data/FAQ +6 -5
- data/History.txt +5 -39
- data/Manifest.txt +67 -76
- data/QUICKLINKS +1 -1
- data/README.txt +21 -15
- data/Rakefile +16 -15
- data/SPECS +2 -29
- data/TODO +1 -1
- data/dm-core.gemspec +11 -15
- data/lib/dm-core/adapters/abstract_adapter.rb +182 -185
- data/lib/dm-core/adapters/data_objects_adapter.rb +482 -534
- data/lib/dm-core/adapters/in_memory_adapter.rb +90 -69
- data/lib/dm-core/adapters/mysql_adapter.rb +22 -115
- data/lib/dm-core/adapters/oracle_adapter.rb +249 -0
- data/lib/dm-core/adapters/postgres_adapter.rb +7 -173
- data/lib/dm-core/adapters/sqlite3_adapter.rb +4 -97
- data/lib/dm-core/adapters/yaml_adapter.rb +116 -0
- data/lib/dm-core/adapters.rb +135 -16
- data/lib/dm-core/associations/many_to_many.rb +372 -90
- data/lib/dm-core/associations/many_to_one.rb +220 -73
- data/lib/dm-core/associations/one_to_many.rb +319 -255
- data/lib/dm-core/associations/one_to_one.rb +66 -53
- data/lib/dm-core/associations/relationship.rb +560 -158
- data/lib/dm-core/collection.rb +1104 -381
- data/lib/dm-core/core_ext/kernel.rb +12 -0
- data/lib/dm-core/core_ext/symbol.rb +10 -0
- data/lib/dm-core/identity_map.rb +4 -34
- data/lib/dm-core/migrations.rb +1283 -0
- data/lib/dm-core/model/descendant_set.rb +81 -0
- data/lib/dm-core/model/hook.rb +45 -0
- data/lib/dm-core/model/is.rb +32 -0
- data/lib/dm-core/model/property.rb +248 -0
- data/lib/dm-core/model/relationship.rb +335 -0
- data/lib/dm-core/model/scope.rb +90 -0
- data/lib/dm-core/model.rb +570 -369
- data/lib/dm-core/property.rb +753 -280
- data/lib/dm-core/property_set.rb +141 -98
- data/lib/dm-core/query/conditions/comparison.rb +814 -0
- data/lib/dm-core/query/conditions/operation.rb +247 -0
- data/lib/dm-core/query/direction.rb +43 -0
- data/lib/dm-core/query/operator.rb +42 -0
- data/lib/dm-core/query/path.rb +102 -0
- data/lib/dm-core/query/sort.rb +45 -0
- data/lib/dm-core/query.rb +974 -492
- data/lib/dm-core/repository.rb +147 -107
- data/lib/dm-core/resource.rb +644 -429
- data/lib/dm-core/spec/adapter_shared_spec.rb +294 -0
- data/lib/dm-core/spec/data_objects_adapter_shared_spec.rb +106 -0
- data/lib/dm-core/support/chainable.rb +20 -0
- data/lib/dm-core/support/deprecate.rb +12 -0
- data/lib/dm-core/support/equalizer.rb +23 -0
- data/lib/dm-core/support/logger.rb +13 -0
- data/lib/dm-core/{naming_conventions.rb → support/naming_conventions.rb} +6 -6
- data/lib/dm-core/transaction.rb +333 -92
- data/lib/dm-core/type.rb +98 -60
- data/lib/dm-core/types/boolean.rb +1 -1
- data/lib/dm-core/types/discriminator.rb +34 -20
- data/lib/dm-core/types/object.rb +7 -4
- data/lib/dm-core/types/paranoid_boolean.rb +11 -9
- data/lib/dm-core/types/paranoid_datetime.rb +11 -9
- data/lib/dm-core/types/serial.rb +3 -3
- data/lib/dm-core/types/text.rb +3 -4
- data/lib/dm-core/version.rb +1 -1
- data/lib/dm-core.rb +106 -110
- data/script/performance.rb +102 -109
- data/script/profile.rb +169 -38
- data/spec/lib/adapter_helpers.rb +105 -0
- data/spec/lib/collection_helpers.rb +18 -0
- data/spec/lib/counter_adapter.rb +34 -0
- data/spec/lib/pending_helpers.rb +27 -0
- data/spec/lib/rspec_immediate_feedback_formatter.rb +53 -0
- data/spec/public/associations/many_to_many_spec.rb +193 -0
- data/spec/public/associations/many_to_one_spec.rb +73 -0
- data/spec/public/associations/one_to_many_spec.rb +77 -0
- data/spec/public/associations/one_to_one_spec.rb +156 -0
- data/spec/public/collection_spec.rb +65 -0
- data/spec/public/model/relationship_spec.rb +924 -0
- data/spec/public/model_spec.rb +159 -0
- data/spec/public/property_spec.rb +829 -0
- data/spec/public/resource_spec.rb +71 -0
- data/spec/public/sel_spec.rb +44 -0
- data/spec/public/setup_spec.rb +145 -0
- data/spec/public/shared/association_collection_shared_spec.rb +317 -0
- data/spec/public/shared/collection_shared_spec.rb +1723 -0
- data/spec/public/shared/finder_shared_spec.rb +1619 -0
- data/spec/public/shared/resource_shared_spec.rb +924 -0
- data/spec/public/shared/sel_shared_spec.rb +112 -0
- data/spec/public/transaction_spec.rb +129 -0
- data/spec/public/types/discriminator_spec.rb +130 -0
- data/spec/semipublic/adapters/abstract_adapter_spec.rb +30 -0
- data/spec/semipublic/adapters/in_memory_adapter_spec.rb +12 -0
- data/spec/semipublic/adapters/mysql_adapter_spec.rb +17 -0
- data/spec/semipublic/adapters/oracle_adapter_spec.rb +194 -0
- data/spec/semipublic/adapters/postgres_adapter_spec.rb +17 -0
- data/spec/semipublic/adapters/sqlite3_adapter_spec.rb +17 -0
- data/spec/semipublic/adapters/yaml_adapter_spec.rb +12 -0
- data/spec/semipublic/associations/many_to_one_spec.rb +53 -0
- data/spec/semipublic/associations/relationship_spec.rb +194 -0
- data/spec/semipublic/associations_spec.rb +177 -0
- data/spec/semipublic/collection_spec.rb +142 -0
- data/spec/semipublic/property_spec.rb +61 -0
- data/spec/semipublic/query/conditions_spec.rb +528 -0
- data/spec/semipublic/query/path_spec.rb +443 -0
- data/spec/semipublic/query_spec.rb +2626 -0
- data/spec/semipublic/resource_spec.rb +47 -0
- data/spec/semipublic/shared/resource_shared_spec.rb +126 -0
- data/spec/spec.opts +3 -1
- data/spec/spec_helper.rb +80 -57
- data/tasks/ci.rb +19 -31
- data/tasks/dm.rb +43 -48
- data/tasks/doc.rb +8 -11
- data/tasks/gemspec.rb +5 -5
- data/tasks/hoe.rb +15 -16
- data/tasks/install.rb +8 -10
- metadata +72 -93
- data/lib/dm-core/associations/relationship_chain.rb +0 -81
- data/lib/dm-core/associations.rb +0 -207
- data/lib/dm-core/auto_migrations.rb +0 -105
- data/lib/dm-core/dependency_queue.rb +0 -32
- data/lib/dm-core/hook.rb +0 -11
- data/lib/dm-core/is.rb +0 -16
- data/lib/dm-core/logger.rb +0 -232
- data/lib/dm-core/migrations/destructive_migrations.rb +0 -17
- data/lib/dm-core/migrator.rb +0 -29
- data/lib/dm-core/scope.rb +0 -58
- data/lib/dm-core/support/array.rb +0 -13
- data/lib/dm-core/support/assertions.rb +0 -8
- data/lib/dm-core/support/errors.rb +0 -23
- data/lib/dm-core/support/kernel.rb +0 -11
- data/lib/dm-core/support/symbol.rb +0 -41
- data/lib/dm-core/support.rb +0 -7
- data/lib/dm-core/type_map.rb +0 -80
- data/lib/dm-core/types.rb +0 -19
- data/script/all +0 -4
- data/spec/integration/association_spec.rb +0 -1382
- data/spec/integration/association_through_spec.rb +0 -203
- data/spec/integration/associations/many_to_many_spec.rb +0 -449
- data/spec/integration/associations/many_to_one_spec.rb +0 -163
- data/spec/integration/associations/one_to_many_spec.rb +0 -188
- data/spec/integration/auto_migrations_spec.rb +0 -413
- data/spec/integration/collection_spec.rb +0 -1073
- data/spec/integration/data_objects_adapter_spec.rb +0 -32
- data/spec/integration/dependency_queue_spec.rb +0 -46
- data/spec/integration/model_spec.rb +0 -197
- data/spec/integration/mysql_adapter_spec.rb +0 -85
- data/spec/integration/postgres_adapter_spec.rb +0 -731
- data/spec/integration/property_spec.rb +0 -253
- data/spec/integration/query_spec.rb +0 -514
- data/spec/integration/repository_spec.rb +0 -61
- data/spec/integration/resource_spec.rb +0 -513
- data/spec/integration/sqlite3_adapter_spec.rb +0 -352
- data/spec/integration/sti_spec.rb +0 -273
- data/spec/integration/strategic_eager_loading_spec.rb +0 -156
- data/spec/integration/transaction_spec.rb +0 -75
- data/spec/integration/type_spec.rb +0 -275
- data/spec/lib/logging_helper.rb +0 -18
- data/spec/lib/mock_adapter.rb +0 -27
- data/spec/lib/model_loader.rb +0 -100
- data/spec/lib/publicize_methods.rb +0 -28
- data/spec/models/content.rb +0 -16
- data/spec/models/vehicles.rb +0 -34
- data/spec/models/zoo.rb +0 -48
- data/spec/unit/adapters/abstract_adapter_spec.rb +0 -133
- data/spec/unit/adapters/adapter_shared_spec.rb +0 -15
- data/spec/unit/adapters/data_objects_adapter_spec.rb +0 -632
- data/spec/unit/adapters/in_memory_adapter_spec.rb +0 -98
- data/spec/unit/adapters/postgres_adapter_spec.rb +0 -133
- data/spec/unit/associations/many_to_many_spec.rb +0 -32
- data/spec/unit/associations/many_to_one_spec.rb +0 -159
- data/spec/unit/associations/one_to_many_spec.rb +0 -393
- data/spec/unit/associations/one_to_one_spec.rb +0 -7
- data/spec/unit/associations/relationship_spec.rb +0 -71
- data/spec/unit/associations_spec.rb +0 -242
- data/spec/unit/auto_migrations_spec.rb +0 -111
- data/spec/unit/collection_spec.rb +0 -182
- data/spec/unit/data_mapper_spec.rb +0 -35
- data/spec/unit/identity_map_spec.rb +0 -126
- data/spec/unit/is_spec.rb +0 -80
- data/spec/unit/migrator_spec.rb +0 -33
- data/spec/unit/model_spec.rb +0 -321
- data/spec/unit/naming_conventions_spec.rb +0 -36
- data/spec/unit/property_set_spec.rb +0 -90
- data/spec/unit/property_spec.rb +0 -753
- data/spec/unit/query_spec.rb +0 -571
- data/spec/unit/repository_spec.rb +0 -93
- data/spec/unit/resource_spec.rb +0 -649
- data/spec/unit/scope_spec.rb +0 -142
- data/spec/unit/transaction_spec.rb +0 -493
- data/spec/unit/type_map_spec.rb +0 -114
- data/spec/unit/type_spec.rb +0 -119
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datamapper-dm-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kubb
|
@@ -9,19 +9,9 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: data_objects
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.12
|
24
|
-
version:
|
25
15
|
- !ruby/object:Gem::Dependency
|
26
16
|
name: extlib
|
27
17
|
type: :runtime
|
@@ -30,7 +20,7 @@ dependencies:
|
|
30
20
|
requirements:
|
31
21
|
- - ~>
|
32
22
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.
|
23
|
+
version: 0.9.13
|
34
24
|
version:
|
35
25
|
- !ruby/object:Gem::Dependency
|
36
26
|
name: addressable
|
@@ -40,7 +30,7 @@ dependencies:
|
|
40
30
|
requirements:
|
41
31
|
- - ~>
|
42
32
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.0
|
33
|
+
version: "2.0"
|
44
34
|
version:
|
45
35
|
description: Faster, Better, Simpler.
|
46
36
|
email:
|
@@ -73,42 +63,47 @@ files:
|
|
73
63
|
- lib/dm-core/adapters/data_objects_adapter.rb
|
74
64
|
- lib/dm-core/adapters/in_memory_adapter.rb
|
75
65
|
- lib/dm-core/adapters/mysql_adapter.rb
|
66
|
+
- lib/dm-core/adapters/oracle_adapter.rb
|
76
67
|
- lib/dm-core/adapters/postgres_adapter.rb
|
77
68
|
- lib/dm-core/adapters/sqlite3_adapter.rb
|
78
|
-
- lib/dm-core/
|
69
|
+
- lib/dm-core/adapters/yaml_adapter.rb
|
79
70
|
- lib/dm-core/associations/many_to_many.rb
|
80
71
|
- lib/dm-core/associations/many_to_one.rb
|
81
72
|
- lib/dm-core/associations/one_to_many.rb
|
82
73
|
- lib/dm-core/associations/one_to_one.rb
|
83
74
|
- lib/dm-core/associations/relationship.rb
|
84
|
-
- lib/dm-core/associations/relationship_chain.rb
|
85
|
-
- lib/dm-core/auto_migrations.rb
|
86
75
|
- lib/dm-core/collection.rb
|
87
|
-
- lib/dm-core/
|
88
|
-
- lib/dm-core/
|
76
|
+
- lib/dm-core/core_ext/kernel.rb
|
77
|
+
- lib/dm-core/core_ext/symbol.rb
|
89
78
|
- lib/dm-core/identity_map.rb
|
90
|
-
- lib/dm-core/
|
91
|
-
- lib/dm-core/logger.rb
|
92
|
-
- lib/dm-core/migrations/destructive_migrations.rb
|
93
|
-
- lib/dm-core/migrator.rb
|
79
|
+
- lib/dm-core/migrations.rb
|
94
80
|
- lib/dm-core/model.rb
|
95
|
-
- lib/dm-core/
|
81
|
+
- lib/dm-core/model/descendant_set.rb
|
82
|
+
- lib/dm-core/model/hook.rb
|
83
|
+
- lib/dm-core/model/is.rb
|
84
|
+
- lib/dm-core/model/property.rb
|
85
|
+
- lib/dm-core/model/relationship.rb
|
86
|
+
- lib/dm-core/model/scope.rb
|
96
87
|
- lib/dm-core/property.rb
|
97
88
|
- lib/dm-core/property_set.rb
|
98
89
|
- lib/dm-core/query.rb
|
90
|
+
- lib/dm-core/query/conditions/comparison.rb
|
91
|
+
- lib/dm-core/query/conditions/operation.rb
|
92
|
+
- lib/dm-core/query/direction.rb
|
93
|
+
- lib/dm-core/query/operator.rb
|
94
|
+
- lib/dm-core/query/path.rb
|
95
|
+
- lib/dm-core/query/sort.rb
|
99
96
|
- lib/dm-core/repository.rb
|
100
97
|
- lib/dm-core/resource.rb
|
101
|
-
- lib/dm-core/
|
102
|
-
- lib/dm-core/
|
103
|
-
- lib/dm-core/support/
|
104
|
-
- lib/dm-core/support/
|
105
|
-
- lib/dm-core/support/
|
106
|
-
- lib/dm-core/support/
|
107
|
-
- lib/dm-core/support/
|
98
|
+
- lib/dm-core/spec/adapter_shared_spec.rb
|
99
|
+
- lib/dm-core/spec/data_objects_adapter_shared_spec.rb
|
100
|
+
- lib/dm-core/support/chainable.rb
|
101
|
+
- lib/dm-core/support/deprecate.rb
|
102
|
+
- lib/dm-core/support/equalizer.rb
|
103
|
+
- lib/dm-core/support/logger.rb
|
104
|
+
- lib/dm-core/support/naming_conventions.rb
|
108
105
|
- lib/dm-core/transaction.rb
|
109
106
|
- lib/dm-core/type.rb
|
110
|
-
- lib/dm-core/type_map.rb
|
111
|
-
- lib/dm-core/types.rb
|
112
107
|
- lib/dm-core/types/boolean.rb
|
113
108
|
- lib/dm-core/types/discriminator.rb
|
114
109
|
- lib/dm-core/types/object.rb
|
@@ -117,75 +112,59 @@ files:
|
|
117
112
|
- lib/dm-core/types/serial.rb
|
118
113
|
- lib/dm-core/types/text.rb
|
119
114
|
- lib/dm-core/version.rb
|
120
|
-
- script/all
|
121
115
|
- script/performance.rb
|
122
116
|
- script/profile.rb
|
123
|
-
- spec/
|
124
|
-
- spec/
|
125
|
-
- spec/
|
126
|
-
- spec/
|
127
|
-
- spec/
|
128
|
-
- spec/
|
129
|
-
- spec/
|
130
|
-
- spec/
|
131
|
-
- spec/
|
132
|
-
- spec/
|
133
|
-
- spec/
|
134
|
-
- spec/
|
135
|
-
- spec/
|
136
|
-
- spec/
|
137
|
-
- spec/
|
138
|
-
- spec/
|
139
|
-
- spec/
|
140
|
-
- spec/
|
141
|
-
- spec/
|
142
|
-
- spec/
|
143
|
-
- spec/
|
144
|
-
- spec/
|
145
|
-
- spec/
|
146
|
-
- spec/
|
147
|
-
- spec/
|
148
|
-
- spec/
|
149
|
-
- spec/
|
150
|
-
- spec/
|
117
|
+
- spec/lib/adapter_helpers.rb
|
118
|
+
- spec/lib/collection_helpers.rb
|
119
|
+
- spec/lib/counter_adapter.rb
|
120
|
+
- spec/lib/pending_helpers.rb
|
121
|
+
- spec/lib/rspec_immediate_feedback_formatter.rb
|
122
|
+
- spec/public/associations/many_to_many_spec.rb
|
123
|
+
- spec/public/associations/many_to_one_spec.rb
|
124
|
+
- spec/public/associations/one_to_many_spec.rb
|
125
|
+
- spec/public/associations/one_to_one_spec.rb
|
126
|
+
- spec/public/collection_spec.rb
|
127
|
+
- spec/public/model/relationship_spec.rb
|
128
|
+
- spec/public/model_spec.rb
|
129
|
+
- spec/public/property_spec.rb
|
130
|
+
- spec/public/resource_spec.rb
|
131
|
+
- spec/public/sel_spec.rb
|
132
|
+
- spec/public/setup_spec.rb
|
133
|
+
- spec/public/shared/association_collection_shared_spec.rb
|
134
|
+
- spec/public/shared/collection_shared_spec.rb
|
135
|
+
- spec/public/shared/finder_shared_spec.rb
|
136
|
+
- spec/public/shared/resource_shared_spec.rb
|
137
|
+
- spec/public/shared/sel_shared_spec.rb
|
138
|
+
- spec/public/transaction_spec.rb
|
139
|
+
- spec/public/types/discriminator_spec.rb
|
140
|
+
- spec/semipublic/adapters/abstract_adapter_spec.rb
|
141
|
+
- spec/semipublic/adapters/in_memory_adapter_spec.rb
|
142
|
+
- spec/semipublic/adapters/mysql_adapter_spec.rb
|
143
|
+
- spec/semipublic/adapters/oracle_adapter_spec.rb
|
144
|
+
- spec/semipublic/adapters/postgres_adapter_spec.rb
|
145
|
+
- spec/semipublic/adapters/sqlite3_adapter_spec.rb
|
146
|
+
- spec/semipublic/adapters/yaml_adapter_spec.rb
|
147
|
+
- spec/semipublic/associations/many_to_one_spec.rb
|
148
|
+
- spec/semipublic/associations/relationship_spec.rb
|
149
|
+
- spec/semipublic/associations_spec.rb
|
150
|
+
- spec/semipublic/collection_spec.rb
|
151
|
+
- spec/semipublic/property_spec.rb
|
152
|
+
- spec/semipublic/query/conditions_spec.rb
|
153
|
+
- spec/semipublic/query/path_spec.rb
|
154
|
+
- spec/semipublic/query_spec.rb
|
155
|
+
- spec/semipublic/resource_spec.rb
|
156
|
+
- spec/semipublic/shared/resource_shared_spec.rb
|
151
157
|
- spec/spec.opts
|
152
158
|
- spec/spec_helper.rb
|
153
|
-
- spec/unit/adapters/abstract_adapter_spec.rb
|
154
|
-
- spec/unit/adapters/adapter_shared_spec.rb
|
155
|
-
- spec/unit/adapters/data_objects_adapter_spec.rb
|
156
|
-
- spec/unit/adapters/in_memory_adapter_spec.rb
|
157
|
-
- spec/unit/adapters/postgres_adapter_spec.rb
|
158
|
-
- spec/unit/associations/many_to_many_spec.rb
|
159
|
-
- spec/unit/associations/many_to_one_spec.rb
|
160
|
-
- spec/unit/associations/one_to_many_spec.rb
|
161
|
-
- spec/unit/associations/one_to_one_spec.rb
|
162
|
-
- spec/unit/associations/relationship_spec.rb
|
163
|
-
- spec/unit/associations_spec.rb
|
164
|
-
- spec/unit/auto_migrations_spec.rb
|
165
|
-
- spec/unit/collection_spec.rb
|
166
|
-
- spec/unit/data_mapper_spec.rb
|
167
|
-
- spec/unit/identity_map_spec.rb
|
168
|
-
- spec/unit/is_spec.rb
|
169
|
-
- spec/unit/migrator_spec.rb
|
170
|
-
- spec/unit/model_spec.rb
|
171
|
-
- spec/unit/naming_conventions_spec.rb
|
172
|
-
- spec/unit/property_set_spec.rb
|
173
|
-
- spec/unit/property_spec.rb
|
174
|
-
- spec/unit/query_spec.rb
|
175
|
-
- spec/unit/repository_spec.rb
|
176
|
-
- spec/unit/resource_spec.rb
|
177
|
-
- spec/unit/scope_spec.rb
|
178
|
-
- spec/unit/transaction_spec.rb
|
179
|
-
- spec/unit/type_map_spec.rb
|
180
|
-
- spec/unit/type_spec.rb
|
181
159
|
- tasks/ci.rb
|
182
160
|
- tasks/dm.rb
|
183
161
|
- tasks/doc.rb
|
184
162
|
- tasks/gemspec.rb
|
185
163
|
- tasks/hoe.rb
|
186
164
|
- tasks/install.rb
|
187
|
-
has_rdoc:
|
165
|
+
has_rdoc: false
|
188
166
|
homepage: http://datamapper.org
|
167
|
+
licenses:
|
189
168
|
post_install_message:
|
190
169
|
rdoc_options:
|
191
170
|
- --main
|
@@ -207,9 +186,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
186
|
requirements: []
|
208
187
|
|
209
188
|
rubyforge_project: datamapper
|
210
|
-
rubygems_version: 1.
|
189
|
+
rubygems_version: 1.3.5
|
211
190
|
signing_key:
|
212
|
-
specification_version:
|
191
|
+
specification_version: 3
|
213
192
|
summary: An Object/Relational Mapper for Ruby
|
214
193
|
test_files: []
|
215
194
|
|
@@ -1,81 +0,0 @@
|
|
1
|
-
module DataMapper
|
2
|
-
module Associations
|
3
|
-
class RelationshipChain < Relationship
|
4
|
-
OPTIONS = [
|
5
|
-
:repository_name, :near_relationship_name, :remote_relationship_name,
|
6
|
-
:child_model, :parent_model, :parent_key, :child_key,
|
7
|
-
:min, :max
|
8
|
-
]
|
9
|
-
|
10
|
-
undef_method :get_parent
|
11
|
-
undef_method :attach_parent
|
12
|
-
|
13
|
-
# @api private
|
14
|
-
def child_model
|
15
|
-
near_relationship.child_model
|
16
|
-
end
|
17
|
-
|
18
|
-
# @api private
|
19
|
-
def get_children(parent, options = {}, finder = :all, *args)
|
20
|
-
query = @query.merge(options).merge(child_key.to_query(parent_key.get(parent)))
|
21
|
-
|
22
|
-
query[:links] = links
|
23
|
-
query[:unique] = true
|
24
|
-
|
25
|
-
with_repository(parent) do
|
26
|
-
results = grandchild_model.send(finder, *(args << query))
|
27
|
-
# FIXME: remove the need for the uniq.freeze
|
28
|
-
finder == :all ? (@mutable ? results : results.freeze) : results
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# @api private
|
35
|
-
def initialize(options)
|
36
|
-
if (missing_options = OPTIONS - [ :min, :max ] - options.keys ).any?
|
37
|
-
raise ArgumentError, "The options #{missing_options * ', '} are required", caller
|
38
|
-
end
|
39
|
-
|
40
|
-
@repository_name = options.fetch(:repository_name)
|
41
|
-
@near_relationship_name = options.fetch(:near_relationship_name)
|
42
|
-
@remote_relationship_name = options.fetch(:remote_relationship_name)
|
43
|
-
@child_model = options.fetch(:child_model)
|
44
|
-
@parent_model = options.fetch(:parent_model)
|
45
|
-
@parent_properties = options.fetch(:parent_key)
|
46
|
-
@child_properties = options.fetch(:child_key)
|
47
|
-
@mutable = options.delete(:mutable) || false
|
48
|
-
|
49
|
-
@name = near_relationship.name
|
50
|
-
@query = options.reject{ |key,val| OPTIONS.include?(key) }
|
51
|
-
@extra_links = []
|
52
|
-
@options = options
|
53
|
-
end
|
54
|
-
|
55
|
-
# @api private
|
56
|
-
def near_relationship
|
57
|
-
parent_model.relationships[@near_relationship_name]
|
58
|
-
end
|
59
|
-
|
60
|
-
# @api private
|
61
|
-
def links
|
62
|
-
if remote_relationship.kind_of?(RelationshipChain)
|
63
|
-
remote_relationship.send(:links) + [ remote_relationship.send(:near_relationship) ]
|
64
|
-
else
|
65
|
-
[ remote_relationship ]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# @api private
|
70
|
-
def remote_relationship
|
71
|
-
near_relationship.child_model.relationships[@remote_relationship_name] ||
|
72
|
-
near_relationship.child_model.relationships[@remote_relationship_name.to_s.singularize.to_sym]
|
73
|
-
end
|
74
|
-
|
75
|
-
# @api private
|
76
|
-
def grandchild_model
|
77
|
-
Class === @child_model ? @child_model : (Class === @parent_model ? @parent_model.find_const(@child_model) : Object.find_const(@child_model))
|
78
|
-
end
|
79
|
-
end # class Relationship
|
80
|
-
end # module Associations
|
81
|
-
end # module DataMapper
|
data/lib/dm-core/associations.rb
DELETED
@@ -1,207 +0,0 @@
|
|
1
|
-
dir = Pathname(__FILE__).dirname.expand_path / 'associations'
|
2
|
-
|
3
|
-
require dir / 'relationship'
|
4
|
-
require dir / 'relationship_chain'
|
5
|
-
require dir / 'many_to_many'
|
6
|
-
require dir / 'many_to_one'
|
7
|
-
require dir / 'one_to_many'
|
8
|
-
require dir / 'one_to_one'
|
9
|
-
|
10
|
-
module DataMapper
|
11
|
-
module Associations
|
12
|
-
include Assertions
|
13
|
-
|
14
|
-
class ImmutableAssociationError < RuntimeError
|
15
|
-
end
|
16
|
-
|
17
|
-
class UnsavedParentError < RuntimeError
|
18
|
-
end
|
19
|
-
|
20
|
-
# Returns all relationships that are many-to-one for this model.
|
21
|
-
#
|
22
|
-
# Used to find the relationships that require properties in any Repository.
|
23
|
-
#
|
24
|
-
# Example:
|
25
|
-
# class Plur
|
26
|
-
# include DataMapper::Resource
|
27
|
-
# def self.default_repository_name
|
28
|
-
# :plur_db
|
29
|
-
# end
|
30
|
-
# repository(:plupp_db) do
|
31
|
-
# has 1, :plupp
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# This resource has a many-to-one to the Plupp resource residing in the :plupp_db repository,
|
36
|
-
# but the Plur resource needs the plupp_id property no matter what repository itself lives in,
|
37
|
-
# ie we need to create that property when we migrate etc.
|
38
|
-
#
|
39
|
-
# Used in DataMapper::Model.properties_with_subclasses
|
40
|
-
#
|
41
|
-
# @api private
|
42
|
-
def many_to_one_relationships
|
43
|
-
relationships unless @relationships # needs to be initialized!
|
44
|
-
@relationships.values.collect do |rels| rels.values end.flatten.select do |relationship| relationship.child_model == self end
|
45
|
-
end
|
46
|
-
|
47
|
-
def relationships(repository_name = default_repository_name)
|
48
|
-
@relationships ||= {}
|
49
|
-
@relationships[repository_name] ||= repository_name == Repository.default_name ? {} : relationships(Repository.default_name).dup
|
50
|
-
end
|
51
|
-
|
52
|
-
def n
|
53
|
-
1.0/0
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
# A shorthand, clear syntax for defining one-to-one, one-to-many and
|
58
|
-
# many-to-many resource relationships.
|
59
|
-
#
|
60
|
-
# @example [Usage]
|
61
|
-
# * has 1, :friend # one friend
|
62
|
-
# * has n, :friends # many friends
|
63
|
-
# * has 1..3, :friends
|
64
|
-
# # many friends (at least 1, at most 3)
|
65
|
-
# * has 3, :friends
|
66
|
-
# # many friends (exactly 3)
|
67
|
-
# * has 1, :friend, :class_name => 'User'
|
68
|
-
# # one friend with the class name User
|
69
|
-
# * has 3, :friends, :through => :friendships
|
70
|
-
# # many friends through the friendships relationship
|
71
|
-
# * has n, :friendships => :friends
|
72
|
-
# # identical to above example
|
73
|
-
#
|
74
|
-
# @param cardinality [Integer, Range, Infinity]
|
75
|
-
# cardinality that defines the association type and constraints
|
76
|
-
# @param name <Symbol> the name that the association will be referenced by
|
77
|
-
# @param opts <Hash> an options hash
|
78
|
-
#
|
79
|
-
# @option :through[Symbol] A association that this join should go through to form
|
80
|
-
# a many-to-many association
|
81
|
-
# @option :class_name[String] The name of the class to associate with, if omitted
|
82
|
-
# then the association name is assumed to match the class name
|
83
|
-
# @option :remote_name[Symbol] In the case of a :through option being present, the
|
84
|
-
# name of the relationship on the other end of the :through-relationship
|
85
|
-
# to be linked to this relationship.
|
86
|
-
#
|
87
|
-
# @return [DataMapper::Association::Relationship] the relationship that was
|
88
|
-
# created to reflect either a one-to-one, one-to-many or many-to-many
|
89
|
-
# relationship
|
90
|
-
# @raise [ArgumentError] if the cardinality was not understood. Should be a
|
91
|
-
# Integer, Range or Infinity(n)
|
92
|
-
#
|
93
|
-
# @api public
|
94
|
-
def has(cardinality, name, options = {})
|
95
|
-
|
96
|
-
# NOTE: the reason for this fix is that with the ability to pass in two
|
97
|
-
# hashes into has() there might be instances where people attempt to
|
98
|
-
# pass in the options into the name part and not know why things aren't
|
99
|
-
# working for them.
|
100
|
-
if name.kind_of?(Hash)
|
101
|
-
name_through, through = name.keys.first, name.values.first
|
102
|
-
cardinality_string = cardinality.to_s == 'Infinity' ? 'n' : cardinality.inspect
|
103
|
-
warn("In #{self.name} 'has #{cardinality_string}, #{name_through.inspect} => #{through.inspect}' is deprecated. Use 'has #{cardinality_string}, #{name_through.inspect}, :through => #{through.inspect}' instead")
|
104
|
-
end
|
105
|
-
|
106
|
-
options = options.merge(extract_min_max(cardinality))
|
107
|
-
options = options.merge(extract_throughness(name))
|
108
|
-
|
109
|
-
# do not remove this. There is alot of confusion on people's
|
110
|
-
# part about what the first argument to has() is. For the record it
|
111
|
-
# is the min cardinality and max cardinality of the association.
|
112
|
-
# simply put, it constraints the number of resources that will be
|
113
|
-
# returned by the association. It is not, as has been assumed,
|
114
|
-
# the number of results on the left and right hand side of the
|
115
|
-
# reltionship.
|
116
|
-
if options[:min] == n && options[:max] == n
|
117
|
-
raise ArgumentError, 'Cardinality may not be n..n. The cardinality specifies the min/max number of results from the association', caller
|
118
|
-
end
|
119
|
-
|
120
|
-
klass = options[:max] == 1 ? OneToOne : OneToMany
|
121
|
-
klass = ManyToMany if options[:through] == DataMapper::Resource
|
122
|
-
relationship = klass.setup(options.delete(:name), self, options)
|
123
|
-
|
124
|
-
# Please leave this in - I will release contextual serialization soon
|
125
|
-
# which requires this -- guyvdb
|
126
|
-
# TODO convert this to a hook in the plugin once hooks work on class
|
127
|
-
# methods
|
128
|
-
self.init_has_relationship_for_serialization(relationship) if self.respond_to?(:init_has_relationship_for_serialization)
|
129
|
-
|
130
|
-
relationship
|
131
|
-
end
|
132
|
-
|
133
|
-
##
|
134
|
-
# A shorthand, clear syntax for defining many-to-one resource relationships.
|
135
|
-
#
|
136
|
-
# @example [Usage]
|
137
|
-
# * belongs_to :user # many_to_one, :friend
|
138
|
-
# * belongs_to :friend, :class_name => 'User' # many_to_one :friends
|
139
|
-
#
|
140
|
-
# @param name [Symbol] The name that the association will be referenced by
|
141
|
-
# @see #has
|
142
|
-
#
|
143
|
-
# @return [DataMapper::Association::ManyToOne] The association created
|
144
|
-
# should not be accessed directly
|
145
|
-
#
|
146
|
-
# @api public
|
147
|
-
def belongs_to(name, options={})
|
148
|
-
@_valid_relations = false
|
149
|
-
|
150
|
-
if options.key?(:class_name) && !options.key?(:child_key)
|
151
|
-
warn "The inferred child_key will changing to be prefixed with the relationship name #{name}. " \
|
152
|
-
"When using :class_name in belongs_to specify the :child_key explicitly to avoid problems." \
|
153
|
-
"#{caller(0)[1]}"
|
154
|
-
end
|
155
|
-
|
156
|
-
relationship = ManyToOne.setup(name, self, options)
|
157
|
-
# Please leave this in - I will release contextual serialization soon
|
158
|
-
# which requires this -- guyvdb
|
159
|
-
# TODO convert this to a hook in the plugin once hooks work on class
|
160
|
-
# methods
|
161
|
-
self.init_belongs_relationship_for_serialization(relationship) if self.respond_to?(:init_belongs_relationship_for_serialization)
|
162
|
-
|
163
|
-
relationship
|
164
|
-
end
|
165
|
-
|
166
|
-
private
|
167
|
-
|
168
|
-
def extract_throughness(name)
|
169
|
-
assert_kind_of 'name', name, Hash, Symbol
|
170
|
-
|
171
|
-
case name
|
172
|
-
when Hash
|
173
|
-
unless name.keys.size == 1
|
174
|
-
raise ArgumentError, "name must have only one key, but had #{name.keys.size}", caller(2)
|
175
|
-
end
|
176
|
-
|
177
|
-
{ :name => name.keys.first, :through => name.values.first }
|
178
|
-
when Symbol
|
179
|
-
{ :name => name }
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
# A support method form converting Integer, Range or Infinity values into a
|
184
|
-
# { :min => x, :max => y } hash.
|
185
|
-
#
|
186
|
-
# @api private
|
187
|
-
def extract_min_max(constraints)
|
188
|
-
assert_kind_of 'constraints', constraints, Integer, Range unless constraints == n
|
189
|
-
|
190
|
-
case constraints
|
191
|
-
when Integer
|
192
|
-
{ :min => constraints, :max => constraints }
|
193
|
-
when Range
|
194
|
-
if constraints.first > constraints.last
|
195
|
-
raise ArgumentError, "Constraint min (#{constraints.first}) cannot be larger than the max (#{constraints.last})"
|
196
|
-
end
|
197
|
-
|
198
|
-
{ :min => constraints.first, :max => constraints.last }
|
199
|
-
when n
|
200
|
-
{ :min => 0, :max => n }
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end # module Associations
|
204
|
-
|
205
|
-
Model.append_extensions DataMapper::Associations
|
206
|
-
|
207
|
-
end # module DataMapper
|
@@ -1,105 +0,0 @@
|
|
1
|
-
# TODO: move to dm-more/dm-migrations
|
2
|
-
|
3
|
-
module DataMapper
|
4
|
-
class AutoMigrator
|
5
|
-
##
|
6
|
-
# Destructively automigrates the data-store to match the model.
|
7
|
-
# First migrates all models down and then up.
|
8
|
-
# REPEAT: THIS IS DESTRUCTIVE
|
9
|
-
#
|
10
|
-
# @param Symbol repository_name the repository to be migrated
|
11
|
-
def self.auto_migrate(repository_name = nil, *descendants)
|
12
|
-
auto_migrate_down(repository_name, *descendants)
|
13
|
-
auto_migrate_up(repository_name, *descendants)
|
14
|
-
end
|
15
|
-
|
16
|
-
##
|
17
|
-
# Destructively automigrates the data-store down
|
18
|
-
# REPEAT: THIS IS DESTRUCTIVE
|
19
|
-
#
|
20
|
-
# @param Symbol repository_name the repository to be migrated
|
21
|
-
# @calls DataMapper::Resource#auto_migrate_down!
|
22
|
-
# @api private
|
23
|
-
def self.auto_migrate_down(repository_name = nil, *descendants)
|
24
|
-
descendants = DataMapper::Resource.descendants.to_a if descendants.empty?
|
25
|
-
descendants.reverse.each do |model|
|
26
|
-
model.auto_migrate_down!(repository_name)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
##
|
31
|
-
# Automigrates the data-store up
|
32
|
-
#
|
33
|
-
# @param Symbol repository_name the repository to be migrated
|
34
|
-
# @calls DataMapper::Resource#auto_migrate_up!
|
35
|
-
# @api private
|
36
|
-
def self.auto_migrate_up(repository_name = nil, *descendants)
|
37
|
-
descendants = DataMapper::Resource.descendants.to_a if descendants.empty?
|
38
|
-
descendants.each do |model|
|
39
|
-
model.auto_migrate_up!(repository_name)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
##
|
44
|
-
# Safely migrates the data-store to match the model
|
45
|
-
# preserving data already in the data-store
|
46
|
-
#
|
47
|
-
# @param Symbol repository_name the repository to be migrated
|
48
|
-
# @calls DataMapper::Resource#auto_upgrade!
|
49
|
-
def self.auto_upgrade(repository_name = nil)
|
50
|
-
DataMapper::Resource.descendants.each do |model|
|
51
|
-
model.auto_upgrade!(repository_name)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end # class AutoMigrator
|
55
|
-
|
56
|
-
module AutoMigrations
|
57
|
-
##
|
58
|
-
# Destructively automigrates the data-store to match the model
|
59
|
-
# REPEAT: THIS IS DESTRUCTIVE
|
60
|
-
#
|
61
|
-
# @param Symbol repository_name the repository to be migrated
|
62
|
-
def auto_migrate!(repository_name = self.repository_name)
|
63
|
-
auto_migrate_down!(repository_name)
|
64
|
-
auto_migrate_up!(repository_name)
|
65
|
-
end
|
66
|
-
|
67
|
-
##
|
68
|
-
# Destructively migrates the data-store down, which basically
|
69
|
-
# deletes all the models.
|
70
|
-
# REPEAT: THIS IS DESTRUCTIVE
|
71
|
-
#
|
72
|
-
# @param Symbol repository_name the repository to be migrated
|
73
|
-
# @api private
|
74
|
-
def auto_migrate_down!(repository_name = self.repository_name)
|
75
|
-
# repository_name ||= default_repository_name
|
76
|
-
repository(repository_name) do |r|
|
77
|
-
r.adapter.destroy_model_storage(r, self.base_model)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
##
|
82
|
-
# Auto migrates the data-store to match the model
|
83
|
-
#
|
84
|
-
# @param Symbol repository_name the repository to be migrated
|
85
|
-
# @api private
|
86
|
-
def auto_migrate_up!(repository_name = self.repository_name)
|
87
|
-
repository(repository_name) do |r|
|
88
|
-
r.adapter.create_model_storage(r, self.base_model)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
##
|
93
|
-
# Safely migrates the data-store to match the model
|
94
|
-
# preserving data already in the data-store
|
95
|
-
#
|
96
|
-
# @param Symbol repository_name the repository to be migrated
|
97
|
-
def auto_upgrade!(repository_name = self.repository_name)
|
98
|
-
repository(repository_name) do |r|
|
99
|
-
r.adapter.upgrade_model_storage(r, self)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
Model.send(:include, self)
|
104
|
-
end # module AutoMigrations
|
105
|
-
end # module DataMapper
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module DataMapper
|
2
|
-
##
|
3
|
-
#
|
4
|
-
# DataMapper's DependencyQueue is used to store callbacks for classes which
|
5
|
-
# may or may not be loaded already.
|
6
|
-
#
|
7
|
-
class DependencyQueue
|
8
|
-
def initialize
|
9
|
-
@dependencies = {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def add(class_name, &callback)
|
13
|
-
@dependencies[class_name] ||= []
|
14
|
-
@dependencies[class_name] << callback
|
15
|
-
resolve!
|
16
|
-
end
|
17
|
-
|
18
|
-
def resolve!
|
19
|
-
@dependencies.each do |class_name, callbacks|
|
20
|
-
begin
|
21
|
-
klass = Object.find_const(class_name)
|
22
|
-
callbacks.each do |callback|
|
23
|
-
callback.call(klass)
|
24
|
-
end
|
25
|
-
callbacks.clear
|
26
|
-
rescue NameError
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end # class DependencyQueue
|
32
|
-
end # module DataMapper
|
data/lib/dm-core/hook.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
module DataMapper
|
2
|
-
module Hook
|
3
|
-
def self.included(model)
|
4
|
-
model.class_eval <<-EOS, __FILE__, __LINE__
|
5
|
-
include Extlib::Hook
|
6
|
-
register_instance_hooks :save, :create, :update, :destroy
|
7
|
-
EOS
|
8
|
-
end
|
9
|
-
end
|
10
|
-
DataMapper::Resource.append_inclusions Hook
|
11
|
-
end # module DataMapper
|