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.
Files changed (194) hide show
  1. data/.autotest +17 -14
  2. data/.gitignore +3 -1
  3. data/FAQ +6 -5
  4. data/History.txt +5 -50
  5. data/Manifest.txt +66 -76
  6. data/QUICKLINKS +1 -1
  7. data/README.txt +21 -15
  8. data/Rakefile +6 -7
  9. data/SPECS +2 -29
  10. data/TODO +1 -1
  11. data/deps.rip +2 -0
  12. data/dm-core.gemspec +11 -15
  13. data/lib/dm-core.rb +105 -110
  14. data/lib/dm-core/adapters.rb +135 -16
  15. data/lib/dm-core/adapters/abstract_adapter.rb +251 -181
  16. data/lib/dm-core/adapters/data_objects_adapter.rb +482 -534
  17. data/lib/dm-core/adapters/in_memory_adapter.rb +90 -69
  18. data/lib/dm-core/adapters/mysql_adapter.rb +22 -115
  19. data/lib/dm-core/adapters/oracle_adapter.rb +249 -0
  20. data/lib/dm-core/adapters/postgres_adapter.rb +7 -173
  21. data/lib/dm-core/adapters/sqlite3_adapter.rb +4 -97
  22. data/lib/dm-core/adapters/yaml_adapter.rb +116 -0
  23. data/lib/dm-core/associations/many_to_many.rb +372 -90
  24. data/lib/dm-core/associations/many_to_one.rb +220 -73
  25. data/lib/dm-core/associations/one_to_many.rb +319 -255
  26. data/lib/dm-core/associations/one_to_one.rb +66 -53
  27. data/lib/dm-core/associations/relationship.rb +561 -156
  28. data/lib/dm-core/collection.rb +1101 -379
  29. data/lib/dm-core/core_ext/kernel.rb +12 -0
  30. data/lib/dm-core/core_ext/symbol.rb +10 -0
  31. data/lib/dm-core/identity_map.rb +4 -34
  32. data/lib/dm-core/migrations.rb +1283 -0
  33. data/lib/dm-core/model.rb +570 -369
  34. data/lib/dm-core/model/descendant_set.rb +81 -0
  35. data/lib/dm-core/model/hook.rb +45 -0
  36. data/lib/dm-core/model/is.rb +32 -0
  37. data/lib/dm-core/model/property.rb +247 -0
  38. data/lib/dm-core/model/relationship.rb +335 -0
  39. data/lib/dm-core/model/scope.rb +90 -0
  40. data/lib/dm-core/property.rb +808 -273
  41. data/lib/dm-core/property_set.rb +141 -98
  42. data/lib/dm-core/query.rb +1037 -483
  43. data/lib/dm-core/query/conditions/comparison.rb +872 -0
  44. data/lib/dm-core/query/conditions/operation.rb +221 -0
  45. data/lib/dm-core/query/direction.rb +43 -0
  46. data/lib/dm-core/query/operator.rb +84 -0
  47. data/lib/dm-core/query/path.rb +138 -0
  48. data/lib/dm-core/query/sort.rb +45 -0
  49. data/lib/dm-core/repository.rb +210 -94
  50. data/lib/dm-core/resource.rb +641 -421
  51. data/lib/dm-core/spec/adapter_shared_spec.rb +294 -0
  52. data/lib/dm-core/spec/data_objects_adapter_shared_spec.rb +106 -0
  53. data/lib/dm-core/support/chainable.rb +22 -0
  54. data/lib/dm-core/support/deprecate.rb +12 -0
  55. data/lib/dm-core/support/logger.rb +13 -0
  56. data/lib/dm-core/{naming_conventions.rb → support/naming_conventions.rb} +6 -6
  57. data/lib/dm-core/transaction.rb +333 -92
  58. data/lib/dm-core/type.rb +98 -60
  59. data/lib/dm-core/types/boolean.rb +1 -1
  60. data/lib/dm-core/types/discriminator.rb +34 -20
  61. data/lib/dm-core/types/object.rb +7 -4
  62. data/lib/dm-core/types/paranoid_boolean.rb +11 -9
  63. data/lib/dm-core/types/paranoid_datetime.rb +11 -9
  64. data/lib/dm-core/types/serial.rb +3 -3
  65. data/lib/dm-core/types/text.rb +3 -4
  66. data/lib/dm-core/version.rb +1 -1
  67. data/script/performance.rb +102 -109
  68. data/script/profile.rb +169 -38
  69. data/spec/lib/adapter_helpers.rb +105 -0
  70. data/spec/lib/collection_helpers.rb +18 -0
  71. data/spec/lib/counter_adapter.rb +34 -0
  72. data/spec/lib/pending_helpers.rb +27 -0
  73. data/spec/lib/rspec_immediate_feedback_formatter.rb +53 -0
  74. data/spec/public/associations/many_to_many_spec.rb +193 -0
  75. data/spec/public/associations/many_to_one_spec.rb +73 -0
  76. data/spec/public/associations/one_to_many_spec.rb +77 -0
  77. data/spec/public/associations/one_to_one_spec.rb +156 -0
  78. data/spec/public/collection_spec.rb +65 -0
  79. data/spec/public/migrations_spec.rb +359 -0
  80. data/spec/public/model/relationship_spec.rb +924 -0
  81. data/spec/public/model_spec.rb +159 -0
  82. data/spec/public/property_spec.rb +829 -0
  83. data/spec/public/resource_spec.rb +71 -0
  84. data/spec/public/sel_spec.rb +44 -0
  85. data/spec/public/setup_spec.rb +145 -0
  86. data/spec/public/shared/association_collection_shared_spec.rb +317 -0
  87. data/spec/public/shared/collection_shared_spec.rb +1670 -0
  88. data/spec/public/shared/finder_shared_spec.rb +1619 -0
  89. data/spec/public/shared/resource_shared_spec.rb +924 -0
  90. data/spec/public/shared/sel_shared_spec.rb +112 -0
  91. data/spec/public/transaction_spec.rb +129 -0
  92. data/spec/public/types/discriminator_spec.rb +130 -0
  93. data/spec/semipublic/adapters/abstract_adapter_spec.rb +30 -0
  94. data/spec/semipublic/adapters/in_memory_adapter_spec.rb +12 -0
  95. data/spec/semipublic/adapters/mysql_adapter_spec.rb +17 -0
  96. data/spec/semipublic/adapters/oracle_adapter_spec.rb +194 -0
  97. data/spec/semipublic/adapters/postgres_adapter_spec.rb +17 -0
  98. data/spec/semipublic/adapters/sqlite3_adapter_spec.rb +17 -0
  99. data/spec/semipublic/adapters/yaml_adapter_spec.rb +12 -0
  100. data/spec/semipublic/associations/many_to_one_spec.rb +53 -0
  101. data/spec/semipublic/associations/relationship_spec.rb +194 -0
  102. data/spec/semipublic/associations_spec.rb +177 -0
  103. data/spec/semipublic/collection_spec.rb +142 -0
  104. data/spec/semipublic/property_spec.rb +61 -0
  105. data/spec/semipublic/query/conditions_spec.rb +528 -0
  106. data/spec/semipublic/query/path_spec.rb +443 -0
  107. data/spec/semipublic/query_spec.rb +2626 -0
  108. data/spec/semipublic/resource_spec.rb +47 -0
  109. data/spec/semipublic/shared/condition_shared_spec.rb +9 -0
  110. data/spec/semipublic/shared/resource_shared_spec.rb +126 -0
  111. data/spec/spec.opts +3 -1
  112. data/spec/spec_helper.rb +80 -57
  113. data/tasks/ci.rb +19 -31
  114. data/tasks/dm.rb +43 -48
  115. data/tasks/doc.rb +8 -11
  116. data/tasks/gemspec.rb +5 -5
  117. data/tasks/hoe.rb +15 -16
  118. data/tasks/install.rb +8 -10
  119. metadata +74 -111
  120. data/lib/dm-core/associations.rb +0 -207
  121. data/lib/dm-core/associations/relationship_chain.rb +0 -81
  122. data/lib/dm-core/auto_migrations.rb +0 -105
  123. data/lib/dm-core/dependency_queue.rb +0 -32
  124. data/lib/dm-core/hook.rb +0 -11
  125. data/lib/dm-core/is.rb +0 -16
  126. data/lib/dm-core/logger.rb +0 -232
  127. data/lib/dm-core/migrations/destructive_migrations.rb +0 -17
  128. data/lib/dm-core/migrator.rb +0 -29
  129. data/lib/dm-core/scope.rb +0 -58
  130. data/lib/dm-core/support.rb +0 -7
  131. data/lib/dm-core/support/array.rb +0 -13
  132. data/lib/dm-core/support/assertions.rb +0 -8
  133. data/lib/dm-core/support/errors.rb +0 -23
  134. data/lib/dm-core/support/kernel.rb +0 -11
  135. data/lib/dm-core/support/symbol.rb +0 -41
  136. data/lib/dm-core/type_map.rb +0 -80
  137. data/lib/dm-core/types.rb +0 -19
  138. data/script/all +0 -4
  139. data/spec/integration/association_spec.rb +0 -1382
  140. data/spec/integration/association_through_spec.rb +0 -203
  141. data/spec/integration/associations/many_to_many_spec.rb +0 -449
  142. data/spec/integration/associations/many_to_one_spec.rb +0 -163
  143. data/spec/integration/associations/one_to_many_spec.rb +0 -188
  144. data/spec/integration/auto_migrations_spec.rb +0 -413
  145. data/spec/integration/collection_spec.rb +0 -1073
  146. data/spec/integration/data_objects_adapter_spec.rb +0 -32
  147. data/spec/integration/dependency_queue_spec.rb +0 -46
  148. data/spec/integration/model_spec.rb +0 -197
  149. data/spec/integration/mysql_adapter_spec.rb +0 -85
  150. data/spec/integration/postgres_adapter_spec.rb +0 -731
  151. data/spec/integration/property_spec.rb +0 -253
  152. data/spec/integration/query_spec.rb +0 -514
  153. data/spec/integration/repository_spec.rb +0 -61
  154. data/spec/integration/resource_spec.rb +0 -513
  155. data/spec/integration/sqlite3_adapter_spec.rb +0 -352
  156. data/spec/integration/sti_spec.rb +0 -273
  157. data/spec/integration/strategic_eager_loading_spec.rb +0 -156
  158. data/spec/integration/transaction_spec.rb +0 -75
  159. data/spec/integration/type_spec.rb +0 -275
  160. data/spec/lib/logging_helper.rb +0 -18
  161. data/spec/lib/mock_adapter.rb +0 -27
  162. data/spec/lib/model_loader.rb +0 -100
  163. data/spec/lib/publicize_methods.rb +0 -28
  164. data/spec/models/content.rb +0 -16
  165. data/spec/models/vehicles.rb +0 -34
  166. data/spec/models/zoo.rb +0 -48
  167. data/spec/unit/adapters/abstract_adapter_spec.rb +0 -133
  168. data/spec/unit/adapters/adapter_shared_spec.rb +0 -15
  169. data/spec/unit/adapters/data_objects_adapter_spec.rb +0 -632
  170. data/spec/unit/adapters/in_memory_adapter_spec.rb +0 -98
  171. data/spec/unit/adapters/postgres_adapter_spec.rb +0 -133
  172. data/spec/unit/associations/many_to_many_spec.rb +0 -32
  173. data/spec/unit/associations/many_to_one_spec.rb +0 -159
  174. data/spec/unit/associations/one_to_many_spec.rb +0 -393
  175. data/spec/unit/associations/one_to_one_spec.rb +0 -7
  176. data/spec/unit/associations/relationship_spec.rb +0 -71
  177. data/spec/unit/associations_spec.rb +0 -242
  178. data/spec/unit/auto_migrations_spec.rb +0 -111
  179. data/spec/unit/collection_spec.rb +0 -182
  180. data/spec/unit/data_mapper_spec.rb +0 -35
  181. data/spec/unit/identity_map_spec.rb +0 -126
  182. data/spec/unit/is_spec.rb +0 -80
  183. data/spec/unit/migrator_spec.rb +0 -33
  184. data/spec/unit/model_spec.rb +0 -321
  185. data/spec/unit/naming_conventions_spec.rb +0 -36
  186. data/spec/unit/property_set_spec.rb +0 -90
  187. data/spec/unit/property_spec.rb +0 -753
  188. data/spec/unit/query_spec.rb +0 -571
  189. data/spec/unit/repository_spec.rb +0 -93
  190. data/spec/unit/resource_spec.rb +0 -649
  191. data/spec/unit/scope_spec.rb +0 -142
  192. data/spec/unit/transaction_spec.rb +0 -493
  193. data/spec/unit/type_map_spec.rb +0 -114
  194. data/spec/unit/type_spec.rb +0 -119
@@ -1,20 +1,17 @@
1
1
  # when yard's ready, it'll have to come back, but for now...
2
- Rake::RDocTask.new("doc") do |t|
3
- t.rdoc_dir = 'doc'
4
- t.title = "DataMapper - Ruby Object Relational Mapper"
5
- t.options = ['--line-numbers', '--inline-source', '--all']
6
- t.rdoc_files.include("README.txt", "QUICKLINKS", "FAQ", "lib/**/**/*.rb")
2
+ Rake::RDocTask.new('doc') do |config|
3
+ config.rdoc_dir = 'doc'
4
+ config.title = 'DataMapper - Ruby Object Relational Mapper'
5
+ config.options = %w[ --line-numbers --inline-source --all ]
6
+ config.rdoc_files.include('README.txt', 'QUICKLINKS', 'FAQ', 'lib/**/**/*.rb')
7
7
  end
8
8
 
9
9
  begin
10
- gem 'yard', '>=0.2.1'
11
10
  require 'yard'
12
11
 
13
- YARD::Rake::YardocTask.new("yardoc") do |t|
14
- t.options << '--protected'
15
- # t.options << '-q'
16
- # t.files << '...anyglobshere...'
12
+ YARD::Rake::YardocTask.new('yardoc') do |config|
13
+ config.files << 'lib/**/*.rb'
17
14
  end
18
- rescue Exception
15
+ rescue LoadError
19
16
  # yard not installed
20
17
  end
@@ -1,20 +1,20 @@
1
- desc "Generate gemspec"
2
- task :gemspec do |x|
1
+ desc 'Generate gemspec'
2
+ task :gemspec do
3
3
  # Clean up extraneous files before checking manifest
4
4
  %x[rake clean]
5
5
 
6
6
  # Check the manifest before generating the gemspec
7
7
  manifest = %x[rake check_manifest]
8
- manifest.gsub!("(in /usr/local/projects/dm/dm-core)\n", "")
8
+ manifest.gsub!("(in /usr/local/projects/dm/dm-core)\n", '')
9
9
 
10
10
  unless manifest.empty?
11
- print "\n", "#"*68, "\n"
11
+ print "\n", '#' * 68, "\n"
12
12
  print <<-EOS
13
13
  Manifest.txt is not up-to-date. Please review the changes below.
14
14
  If the changes are correct, run 'rake check_manifest | patch'
15
15
  and then run this command again.
16
16
  EOS
17
- print "#"*68, "\n\n"
17
+ print '#' * 68, "\n\n"
18
18
  puts manifest
19
19
  else
20
20
  %x[rake debug_gem > #{GEM_NAME}.gemspec]
@@ -1,8 +1,8 @@
1
1
  require 'hoe'
2
2
 
3
- @config_file = "~/.rubyforge/user-config.yml"
3
+ @config_file = '~/.rubyforge/user-config.yml'
4
4
  @config = nil
5
- RUBYFORGE_USERNAME = "unknown"
5
+ RUBYFORGE_USERNAME = 'unknown'
6
6
  def rubyforge_username
7
7
  unless @config
8
8
  begin
@@ -16,31 +16,30 @@ Run 'rubyforge setup' to prepare your env for access to Rubyforge
16
16
  exit
17
17
  end
18
18
  end
19
- RUBYFORGE_USERNAME.replace @config["username"]
19
+ RUBYFORGE_USERNAME.replace @config['username']
20
20
  end
21
21
 
22
22
  # Remove hoe dependency
23
23
  class Hoe
24
24
  def extra_dev_deps
25
- @extra_dev_deps.reject! { |dep| dep[0] == "hoe" }
25
+ @extra_dev_deps.reject! { |dep| dep[0] == 'hoe' }
26
26
  @extra_dev_deps
27
27
  end
28
28
  end
29
29
 
30
- hoe = Hoe.new(GEM_NAME, GEM_VERSION) do |p|
30
+ # Don't use Hoe's test task
31
+ Hoe.plugins.delete(:test)
31
32
 
32
- p.developer(AUTHOR, EMAIL)
33
+ hoe = Hoe.spec(GEM_NAME) do
34
+ developer(AUTHOR, EMAIL)
33
35
 
34
- p.description = PROJECT_DESCRIPTION
35
- p.summary = PROJECT_SUMMARY
36
- p.url = PROJECT_URL
36
+ self.version = GEM_VERSION
37
+ self.description = PROJECT_DESCRIPTION
38
+ self.summary = PROJECT_SUMMARY
39
+ self.url = PROJECT_URL
37
40
 
38
- p.rubyforge_name = PROJECT_NAME if PROJECT_NAME
39
-
40
- p.clean_globs |= ["{coverage,doc,log,tmp}", "**/*.{log,db}", "profile_results.*", "**/.DS_Store"]
41
-
42
- GEM_DEPENDENCIES.each do |dep|
43
- p.extra_deps << dep
44
- end
41
+ self.rubyforge_name = PROJECT_NAME
45
42
 
43
+ clean_globs |= %w[ {coverage,doc,log,tmp} **/*.{log,db} profile_results.* **/.DS_Store spec/db ]
44
+ extra_deps |= GEM_DEPENDENCIES
46
45
  end
@@ -1,20 +1,18 @@
1
1
  WIN32 = (RUBY_PLATFORM =~ /win32|mingw|bccwin|cygwin/) rescue nil
2
2
  SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
3
3
 
4
- desc "Install #{GEM_NAME}"
4
+ def sudo_gem(cmd)
5
+ sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
6
+ end
7
+
5
8
  if WIN32
9
+ desc "Install #{GEM_NAME}"
6
10
  task :install => :gem do
7
- system %{gem install --no-rdoc --no-ri -l pkg/#{GEM_NAME}-#{GEM_VERSION}.gem}
8
- end
9
- namespace :dev do
10
- desc 'Install for development (for windows)'
11
- task :winstall => :gem do
12
- warn "You can now call 'rake install' instead of 'rake dev:winstall'."
13
- system %{gem install --no-rdoc --no-ri -l pkg/#{GEM_NAME}-#{GEM_VERSION}.gem}
14
- end
11
+ sudo_gem "install --no-rdoc --no-ri pkg/#{GEM_NAME}-#{GEM_VERSION}.gem"
15
12
  end
16
13
  else
14
+ desc "Install #{GEM_NAME}"
17
15
  task :install => :package do
18
- sh %{#{SUDO} gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION}.gem}
16
+ sudo_gem "install --no-rdoc --no-ri pkg/#{GEM_NAME}-#{GEM_VERSION}.gem"
19
17
  end
20
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Kubb
@@ -9,39 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-29 00:00:00 -07:00
12
+ date: 2009-09-16 00:00:00 -07:00
13
13
  default_executable:
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.11
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: extlib
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 0.9.11
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: addressable
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 2.0.2
44
- version:
14
+ dependencies: []
15
+
45
16
  description: Faster, Better, Simpler.
46
17
  email:
47
18
  - dan.kubb@gmail.com
@@ -66,6 +37,7 @@ files:
66
37
  - Rakefile
67
38
  - SPECS
68
39
  - TODO
40
+ - deps.rip
69
41
  - dm-core.gemspec
70
42
  - lib/dm-core.rb
71
43
  - lib/dm-core/adapters.rb
@@ -73,42 +45,46 @@ files:
73
45
  - lib/dm-core/adapters/data_objects_adapter.rb
74
46
  - lib/dm-core/adapters/in_memory_adapter.rb
75
47
  - lib/dm-core/adapters/mysql_adapter.rb
48
+ - lib/dm-core/adapters/oracle_adapter.rb
76
49
  - lib/dm-core/adapters/postgres_adapter.rb
77
50
  - lib/dm-core/adapters/sqlite3_adapter.rb
78
- - lib/dm-core/associations.rb
51
+ - lib/dm-core/adapters/yaml_adapter.rb
79
52
  - lib/dm-core/associations/many_to_many.rb
80
53
  - lib/dm-core/associations/many_to_one.rb
81
54
  - lib/dm-core/associations/one_to_many.rb
82
55
  - lib/dm-core/associations/one_to_one.rb
83
56
  - lib/dm-core/associations/relationship.rb
84
- - lib/dm-core/associations/relationship_chain.rb
85
- - lib/dm-core/auto_migrations.rb
86
57
  - lib/dm-core/collection.rb
87
- - lib/dm-core/dependency_queue.rb
88
- - lib/dm-core/hook.rb
58
+ - lib/dm-core/core_ext/kernel.rb
59
+ - lib/dm-core/core_ext/symbol.rb
89
60
  - lib/dm-core/identity_map.rb
90
- - lib/dm-core/is.rb
91
- - lib/dm-core/logger.rb
92
- - lib/dm-core/migrations/destructive_migrations.rb
93
- - lib/dm-core/migrator.rb
61
+ - lib/dm-core/migrations.rb
94
62
  - lib/dm-core/model.rb
95
- - lib/dm-core/naming_conventions.rb
63
+ - lib/dm-core/model/descendant_set.rb
64
+ - lib/dm-core/model/hook.rb
65
+ - lib/dm-core/model/is.rb
66
+ - lib/dm-core/model/property.rb
67
+ - lib/dm-core/model/relationship.rb
68
+ - lib/dm-core/model/scope.rb
96
69
  - lib/dm-core/property.rb
97
70
  - lib/dm-core/property_set.rb
98
71
  - lib/dm-core/query.rb
72
+ - lib/dm-core/query/conditions/comparison.rb
73
+ - lib/dm-core/query/conditions/operation.rb
74
+ - lib/dm-core/query/direction.rb
75
+ - lib/dm-core/query/operator.rb
76
+ - lib/dm-core/query/path.rb
77
+ - lib/dm-core/query/sort.rb
99
78
  - lib/dm-core/repository.rb
100
79
  - lib/dm-core/resource.rb
101
- - lib/dm-core/scope.rb
102
- - lib/dm-core/support.rb
103
- - lib/dm-core/support/array.rb
104
- - lib/dm-core/support/assertions.rb
105
- - lib/dm-core/support/errors.rb
106
- - lib/dm-core/support/kernel.rb
107
- - lib/dm-core/support/symbol.rb
80
+ - lib/dm-core/spec/adapter_shared_spec.rb
81
+ - lib/dm-core/spec/data_objects_adapter_shared_spec.rb
82
+ - lib/dm-core/support/chainable.rb
83
+ - lib/dm-core/support/deprecate.rb
84
+ - lib/dm-core/support/logger.rb
85
+ - lib/dm-core/support/naming_conventions.rb
108
86
  - lib/dm-core/transaction.rb
109
87
  - lib/dm-core/type.rb
110
- - lib/dm-core/type_map.rb
111
- - lib/dm-core/types.rb
112
88
  - lib/dm-core/types/boolean.rb
113
89
  - lib/dm-core/types/discriminator.rb
114
90
  - lib/dm-core/types/object.rb
@@ -117,67 +93,52 @@ files:
117
93
  - lib/dm-core/types/serial.rb
118
94
  - lib/dm-core/types/text.rb
119
95
  - lib/dm-core/version.rb
120
- - script/all
121
96
  - script/performance.rb
122
97
  - script/profile.rb
123
- - spec/integration/association_spec.rb
124
- - spec/integration/association_through_spec.rb
125
- - spec/integration/associations/many_to_many_spec.rb
126
- - spec/integration/associations/many_to_one_spec.rb
127
- - spec/integration/associations/one_to_many_spec.rb
128
- - spec/integration/auto_migrations_spec.rb
129
- - spec/integration/collection_spec.rb
130
- - spec/integration/data_objects_adapter_spec.rb
131
- - spec/integration/dependency_queue_spec.rb
132
- - spec/integration/model_spec.rb
133
- - spec/integration/mysql_adapter_spec.rb
134
- - spec/integration/postgres_adapter_spec.rb
135
- - spec/integration/property_spec.rb
136
- - spec/integration/query_spec.rb
137
- - spec/integration/repository_spec.rb
138
- - spec/integration/resource_spec.rb
139
- - spec/integration/sqlite3_adapter_spec.rb
140
- - spec/integration/sti_spec.rb
141
- - spec/integration/strategic_eager_loading_spec.rb
142
- - spec/integration/transaction_spec.rb
143
- - spec/integration/type_spec.rb
144
- - spec/lib/logging_helper.rb
145
- - spec/lib/mock_adapter.rb
146
- - spec/lib/model_loader.rb
147
- - spec/lib/publicize_methods.rb
148
- - spec/models/content.rb
149
- - spec/models/vehicles.rb
150
- - spec/models/zoo.rb
98
+ - spec/lib/adapter_helpers.rb
99
+ - spec/lib/collection_helpers.rb
100
+ - spec/lib/counter_adapter.rb
101
+ - spec/lib/pending_helpers.rb
102
+ - spec/lib/rspec_immediate_feedback_formatter.rb
103
+ - spec/public/associations/many_to_many_spec.rb
104
+ - spec/public/associations/many_to_one_spec.rb
105
+ - spec/public/associations/one_to_many_spec.rb
106
+ - spec/public/associations/one_to_one_spec.rb
107
+ - spec/public/collection_spec.rb
108
+ - spec/public/migrations_spec.rb
109
+ - spec/public/model/relationship_spec.rb
110
+ - spec/public/model_spec.rb
111
+ - spec/public/property_spec.rb
112
+ - spec/public/resource_spec.rb
113
+ - spec/public/sel_spec.rb
114
+ - spec/public/setup_spec.rb
115
+ - spec/public/shared/association_collection_shared_spec.rb
116
+ - spec/public/shared/collection_shared_spec.rb
117
+ - spec/public/shared/finder_shared_spec.rb
118
+ - spec/public/shared/resource_shared_spec.rb
119
+ - spec/public/shared/sel_shared_spec.rb
120
+ - spec/public/transaction_spec.rb
121
+ - spec/public/types/discriminator_spec.rb
122
+ - spec/semipublic/adapters/abstract_adapter_spec.rb
123
+ - spec/semipublic/adapters/in_memory_adapter_spec.rb
124
+ - spec/semipublic/adapters/mysql_adapter_spec.rb
125
+ - spec/semipublic/adapters/oracle_adapter_spec.rb
126
+ - spec/semipublic/adapters/postgres_adapter_spec.rb
127
+ - spec/semipublic/adapters/sqlite3_adapter_spec.rb
128
+ - spec/semipublic/adapters/yaml_adapter_spec.rb
129
+ - spec/semipublic/associations/many_to_one_spec.rb
130
+ - spec/semipublic/associations/relationship_spec.rb
131
+ - spec/semipublic/associations_spec.rb
132
+ - spec/semipublic/collection_spec.rb
133
+ - spec/semipublic/property_spec.rb
134
+ - spec/semipublic/query/conditions_spec.rb
135
+ - spec/semipublic/query/path_spec.rb
136
+ - spec/semipublic/query_spec.rb
137
+ - spec/semipublic/resource_spec.rb
138
+ - spec/semipublic/shared/condition_shared_spec.rb
139
+ - spec/semipublic/shared/resource_shared_spec.rb
151
140
  - spec/spec.opts
152
141
  - 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
142
  - tasks/ci.rb
182
143
  - tasks/dm.rb
183
144
  - tasks/doc.rb
@@ -186,6 +147,8 @@ files:
186
147
  - tasks/install.rb
187
148
  has_rdoc: true
188
149
  homepage: http://datamapper.org
150
+ licenses: []
151
+
189
152
  post_install_message:
190
153
  rdoc_options:
191
154
  - --main
@@ -207,9 +170,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
170
  requirements: []
208
171
 
209
172
  rubyforge_project: datamapper
210
- rubygems_version: 1.3.1
173
+ rubygems_version: 1.3.5
211
174
  signing_key:
212
- specification_version: 2
175
+ specification_version: 3
213
176
  summary: An Object/Relational Mapper for Ruby
214
177
  test_files: []
215
178
 
@@ -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