dm-core 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.autotest +29 -0
  2. data/.document +5 -0
  3. data/.gitignore +27 -0
  4. data/LICENSE +20 -0
  5. data/{README.txt → README.rdoc} +14 -3
  6. data/Rakefile +23 -22
  7. data/VERSION +1 -0
  8. data/dm-core.gemspec +201 -10
  9. data/lib/dm-core.rb +32 -23
  10. data/lib/dm-core/adapters.rb +0 -1
  11. data/lib/dm-core/adapters/data_objects_adapter.rb +230 -151
  12. data/lib/dm-core/adapters/mysql_adapter.rb +7 -8
  13. data/lib/dm-core/adapters/oracle_adapter.rb +39 -59
  14. data/lib/dm-core/adapters/postgres_adapter.rb +0 -1
  15. data/lib/dm-core/adapters/sqlite3_adapter.rb +5 -0
  16. data/lib/dm-core/adapters/sqlserver_adapter.rb +114 -0
  17. data/lib/dm-core/adapters/yaml_adapter.rb +0 -5
  18. data/lib/dm-core/associations/many_to_many.rb +118 -56
  19. data/lib/dm-core/associations/many_to_one.rb +48 -21
  20. data/lib/dm-core/associations/one_to_many.rb +8 -30
  21. data/lib/dm-core/associations/one_to_one.rb +1 -5
  22. data/lib/dm-core/associations/relationship.rb +89 -97
  23. data/lib/dm-core/collection.rb +299 -184
  24. data/lib/dm-core/core_ext/enumerable.rb +28 -0
  25. data/lib/dm-core/core_ext/kernel.rb +0 -2
  26. data/lib/dm-core/migrations.rb +314 -170
  27. data/lib/dm-core/model.rb +97 -66
  28. data/lib/dm-core/model/descendant_set.rb +1 -1
  29. data/lib/dm-core/model/hook.rb +0 -3
  30. data/lib/dm-core/model/property.rb +7 -10
  31. data/lib/dm-core/model/relationship.rb +79 -26
  32. data/lib/dm-core/model/scope.rb +3 -4
  33. data/lib/dm-core/property.rb +152 -90
  34. data/lib/dm-core/property_set.rb +18 -37
  35. data/lib/dm-core/query.rb +452 -153
  36. data/lib/dm-core/query/conditions/comparison.rb +266 -173
  37. data/lib/dm-core/query/conditions/operation.rb +499 -57
  38. data/lib/dm-core/query/direction.rb +0 -3
  39. data/lib/dm-core/query/operator.rb +0 -4
  40. data/lib/dm-core/query/path.rb +10 -12
  41. data/lib/dm-core/query/sort.rb +4 -10
  42. data/lib/dm-core/repository.rb +10 -6
  43. data/lib/dm-core/resource.rb +343 -148
  44. data/lib/dm-core/spec/adapter_shared_spec.rb +17 -1
  45. data/lib/dm-core/spec/data_objects_adapter_shared_spec.rb +277 -17
  46. data/lib/dm-core/support/chainable.rb +0 -2
  47. data/lib/dm-core/support/equalizer.rb +27 -3
  48. data/lib/dm-core/transaction.rb +75 -75
  49. data/lib/dm-core/type.rb +19 -5
  50. data/lib/dm-core/types/discriminator.rb +4 -4
  51. data/lib/dm-core/types/object.rb +2 -7
  52. data/lib/dm-core/types/paranoid_boolean.rb +8 -2
  53. data/lib/dm-core/types/paranoid_datetime.rb +8 -2
  54. data/lib/dm-core/version.rb +1 -1
  55. data/script/performance.rb +7 -7
  56. data/script/profile.rb +6 -6
  57. data/spec/lib/collection_helpers.rb +2 -2
  58. data/spec/lib/pending_helpers.rb +22 -3
  59. data/spec/lib/rspec_immediate_feedback_formatter.rb +1 -0
  60. data/spec/public/associations/many_to_many_spec.rb +6 -4
  61. data/spec/public/associations/many_to_one_spec.rb +10 -1
  62. data/spec/public/associations/many_to_one_with_boolean_cpk_spec.rb +39 -0
  63. data/spec/public/associations/one_to_many_spec.rb +4 -3
  64. data/spec/public/associations/one_to_one_spec.rb +19 -1
  65. data/spec/public/associations/one_to_one_with_boolean_cpk_spec.rb +45 -0
  66. data/spec/public/collection_spec.rb +4 -3
  67. data/spec/public/migrations_spec.rb +144 -0
  68. data/spec/public/model/relationship_spec.rb +115 -55
  69. data/spec/public/model_spec.rb +13 -13
  70. data/spec/public/property/object_spec.rb +106 -0
  71. data/spec/public/property_spec.rb +18 -14
  72. data/spec/public/resource_spec.rb +10 -1
  73. data/spec/public/sel_spec.rb +16 -49
  74. data/spec/public/setup_spec.rb +1 -1
  75. data/spec/public/shared/association_collection_shared_spec.rb +6 -14
  76. data/spec/public/shared/collection_finder_shared_spec.rb +267 -0
  77. data/spec/public/shared/collection_shared_spec.rb +214 -217
  78. data/spec/public/shared/finder_shared_spec.rb +259 -365
  79. data/spec/public/shared/resource_shared_spec.rb +524 -248
  80. data/spec/public/transaction_spec.rb +27 -3
  81. data/spec/public/types/discriminator_spec.rb +1 -1
  82. data/spec/rcov.opts +6 -0
  83. data/spec/semipublic/adapters/sqlserver_adapter_spec.rb +17 -0
  84. data/spec/semipublic/associations/many_to_one_spec.rb +3 -20
  85. data/spec/semipublic/associations_spec.rb +2 -2
  86. data/spec/semipublic/collection_spec.rb +0 -32
  87. data/spec/semipublic/model_spec.rb +96 -0
  88. data/spec/semipublic/property_spec.rb +3 -3
  89. data/spec/semipublic/query/conditions/comparison_spec.rb +1719 -0
  90. data/spec/semipublic/query/conditions/operation_spec.rb +1292 -0
  91. data/spec/semipublic/query_spec.rb +1285 -144
  92. data/spec/semipublic/resource_spec.rb +0 -24
  93. data/spec/semipublic/shared/resource_shared_spec.rb +103 -38
  94. data/spec/spec.opts +1 -1
  95. data/spec/spec_helper.rb +15 -6
  96. data/tasks/ci.rake +1 -0
  97. data/tasks/metrics.rake +37 -0
  98. data/tasks/spec.rake +41 -0
  99. data/tasks/yard.rake +9 -0
  100. data/tasks/yardstick.rake +19 -0
  101. metadata +99 -29
  102. data/CONTRIBUTING +0 -51
  103. data/FAQ +0 -93
  104. data/History.txt +0 -27
  105. data/MIT-LICENSE +0 -22
  106. data/Manifest.txt +0 -121
  107. data/QUICKLINKS +0 -11
  108. data/SPECS +0 -35
  109. data/TODO +0 -1
  110. data/spec/semipublic/query/conditions_spec.rb +0 -528
  111. data/tasks/ci.rb +0 -24
  112. data/tasks/dm.rb +0 -58
  113. data/tasks/doc.rb +0 -17
  114. data/tasks/gemspec.rb +0 -23
  115. data/tasks/hoe.rb +0 -45
  116. data/tasks/install.rb +0 -18
data/.autotest ADDED
@@ -0,0 +1,29 @@
1
+ Autotest.add_hook :initialize do |at|
2
+ %w[ .git log script tasks LICENSE README.rdoc ].each do |exception|
3
+ at.add_exception(exception)
4
+ end
5
+
6
+ at.clear_mappings
7
+
8
+ spec_folders = /(?:semi)?public/
9
+
10
+ # when a file is updated, make sure it's dependent public and semipublic specs pass
11
+ at.add_mapping %r{\Alib/dm\-core/(.+)\.rb\z} do |_,match|
12
+ at.files_matching %r{\Aspec/#{spec_folders}/#{match[1]}_spec\.rb\z}
13
+ end
14
+
15
+ # when the spec configuration changes make sure all specs pass
16
+ at.add_mapping %r{\Aspec/spec_helper\.rb\z} do
17
+ at.files_matching %r{\Aspec/.+_spec\.rb\z}
18
+ end
19
+
20
+ # when a spec is updated, make sure it passes
21
+ at.add_mapping %r{\Aspec/#{spec_folders}/(.+)_spec\.rb\z} do |filename,_|
22
+ filename
23
+ end
24
+
25
+ # when the collection shared spec is update, make sure all dependent specs pass
26
+ at.add_mapping %r{\Aspec/lib/collection_shared_spec\.rb\z} do
27
+ at.files_matching %r{\Aspec/#{spec_folders}/collection_spec\.rb\z}
28
+ end
29
+ end
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,27 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ tmp
21
+ doc
22
+ log
23
+ .yardoc
24
+
25
+ ## PROJECT::SPECIFIC
26
+
27
+ spec/db/
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Dan Kubb
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,6 +1,3 @@
1
-
2
- :include:QUICKLINKS
3
-
4
1
  = Why DataMapper?
5
2
 
6
3
  == Open Development
@@ -191,3 +188,17 @@ need other comparisons though? Try these:
191
188
 
192
189
  See? Fewer SQL fragments dirtying your Ruby code. And that's just a few of the
193
190
  nice syntax tweaks DataMapper delivers out of the box...
191
+
192
+ == Note on Patches/Pull Requests
193
+
194
+ * Fork the project.
195
+ * Make your feature addition or bug fix.
196
+ * Add tests for it. This is important so I don't break it in a
197
+ future version unintentionally.
198
+ * Commit, do not mess with rakefile, version, or history.
199
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
200
+ * Send me a pull request. Bonus points for topic branches.
201
+
202
+ == Copyright
203
+
204
+ Copyright (c) 2009 Dan Kubb. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,29 +1,30 @@
1
- require 'pathname'
2
1
  require 'rubygems'
3
2
  require 'rake'
4
- require 'rake/rdoctask'
5
3
 
6
- ROOT = Pathname(__FILE__).dirname.expand_path
4
+ begin
5
+ gem 'jeweler', '~> 1.4'
6
+ require 'jeweler'
7
7
 
8
- require ROOT + 'lib/dm-core/version'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = 'dm-core'
10
+ gem.summary = 'An Object/Relational Mapper for Ruby'
11
+ gem.description = 'Faster, Better, Simpler.'
12
+ gem.email = 'dan.kubb@gmail.com'
13
+ gem.homepage = 'http://github.com/datamapper/dm-core'
14
+ gem.authors = [ 'Dan Kubb' ]
9
15
 
10
- AUTHOR = 'Dan Kubb'
11
- EMAIL = 'dan.kubb@gmail.com'
12
- GEM_NAME = 'dm-core'
13
- GEM_VERSION = DataMapper::VERSION
14
- GEM_DEPENDENCIES = [
15
- %w[ extlib ~>0.9.13 ],
16
- %w[ addressable ~>2.1 ],
17
- ]
16
+ gem.rubyforge_project = 'datamapper'
18
17
 
19
- PROJECT_NAME = 'datamapper'
20
- PROJECT_DESCRIPTION = 'Faster, Better, Simpler.'
21
- PROJECT_SUMMARY = 'An Object/Relational Mapper for Ruby'
22
- PROJECT_URL = 'http://datamapper.org'
18
+ gem.add_dependency 'extlib', '~> 0.9.14'
19
+ gem.add_dependency 'addressable', '~> 2.1'
23
20
 
24
- require ROOT + 'tasks/hoe'
25
- require ROOT + 'tasks/gemspec'
26
- require ROOT + 'tasks/install'
27
- require ROOT + 'tasks/dm'
28
- require ROOT + 'tasks/doc'
29
- require ROOT + 'tasks/ci'
21
+ gem.add_development_dependency 'rspec', '~> 1.2.9'
22
+ gem.add_development_dependency 'yard', '~> 0.4.0'
23
+ end
24
+
25
+ Jeweler::GemcutterTasks.new
26
+
27
+ FileList['tasks/**/*.rake'].each { |task| import task }
28
+ rescue LoadError
29
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
30
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.10.2
data/dm-core.gemspec CHANGED
@@ -1,36 +1,227 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{dm-core}
5
- s.version = "0.10.1"
8
+ s.version = "0.10.2"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Dan Kubb"]
9
- s.date = %q{2009-09-30}
12
+ s.date = %q{2009-12-11}
10
13
  s.description = %q{Faster, Better, Simpler.}
11
- s.email = ["dan.kubb@gmail.com"]
12
- s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
13
- s.files = [".autotest", ".gitignore", "CONTRIBUTING", "FAQ", "History.txt", "MIT-LICENSE", "Manifest.txt", "QUICKLINKS", "README.txt", "Rakefile", "SPECS", "TODO", "deps.rip", "dm-core.gemspec", "lib/dm-core.rb", "lib/dm-core/adapters.rb", "lib/dm-core/adapters/abstract_adapter.rb", "lib/dm-core/adapters/data_objects_adapter.rb", "lib/dm-core/adapters/in_memory_adapter.rb", "lib/dm-core/adapters/mysql_adapter.rb", "lib/dm-core/adapters/oracle_adapter.rb", "lib/dm-core/adapters/postgres_adapter.rb", "lib/dm-core/adapters/sqlite3_adapter.rb", "lib/dm-core/adapters/yaml_adapter.rb", "lib/dm-core/associations/many_to_many.rb", "lib/dm-core/associations/many_to_one.rb", "lib/dm-core/associations/one_to_many.rb", "lib/dm-core/associations/one_to_one.rb", "lib/dm-core/associations/relationship.rb", "lib/dm-core/collection.rb", "lib/dm-core/core_ext/kernel.rb", "lib/dm-core/core_ext/symbol.rb", "lib/dm-core/identity_map.rb", "lib/dm-core/migrations.rb", "lib/dm-core/model.rb", "lib/dm-core/model/descendant_set.rb", "lib/dm-core/model/hook.rb", "lib/dm-core/model/is.rb", "lib/dm-core/model/property.rb", "lib/dm-core/model/relationship.rb", "lib/dm-core/model/scope.rb", "lib/dm-core/property.rb", "lib/dm-core/property_set.rb", "lib/dm-core/query.rb", "lib/dm-core/query/conditions/comparison.rb", "lib/dm-core/query/conditions/operation.rb", "lib/dm-core/query/direction.rb", "lib/dm-core/query/operator.rb", "lib/dm-core/query/path.rb", "lib/dm-core/query/sort.rb", "lib/dm-core/repository.rb", "lib/dm-core/resource.rb", "lib/dm-core/spec/adapter_shared_spec.rb", "lib/dm-core/spec/data_objects_adapter_shared_spec.rb", "lib/dm-core/support/chainable.rb", "lib/dm-core/support/deprecate.rb", "lib/dm-core/support/equalizer.rb", "lib/dm-core/support/logger.rb", "lib/dm-core/support/naming_conventions.rb", "lib/dm-core/transaction.rb", "lib/dm-core/type.rb", "lib/dm-core/types/boolean.rb", "lib/dm-core/types/discriminator.rb", "lib/dm-core/types/object.rb", "lib/dm-core/types/paranoid_boolean.rb", "lib/dm-core/types/paranoid_datetime.rb", "lib/dm-core/types/serial.rb", "lib/dm-core/types/text.rb", "lib/dm-core/version.rb", "script/performance.rb", "script/profile.rb", "spec/lib/adapter_helpers.rb", "spec/lib/collection_helpers.rb", "spec/lib/counter_adapter.rb", "spec/lib/pending_helpers.rb", "spec/lib/rspec_immediate_feedback_formatter.rb", "spec/public/associations/many_to_many_spec.rb", "spec/public/associations/many_to_one_spec.rb", "spec/public/associations/one_to_many_spec.rb", "spec/public/associations/one_to_one_spec.rb", "spec/public/collection_spec.rb", "spec/public/migrations_spec.rb", "spec/public/model/relationship_spec.rb", "spec/public/model_spec.rb", "spec/public/property_spec.rb", "spec/public/resource_spec.rb", "spec/public/sel_spec.rb", "spec/public/setup_spec.rb", "spec/public/shared/association_collection_shared_spec.rb", "spec/public/shared/collection_shared_spec.rb", "spec/public/shared/finder_shared_spec.rb", "spec/public/shared/resource_shared_spec.rb", "spec/public/shared/sel_shared_spec.rb", "spec/public/transaction_spec.rb", "spec/public/types/discriminator_spec.rb", "spec/semipublic/adapters/abstract_adapter_spec.rb", "spec/semipublic/adapters/in_memory_adapter_spec.rb", "spec/semipublic/adapters/mysql_adapter_spec.rb", "spec/semipublic/adapters/oracle_adapter_spec.rb", "spec/semipublic/adapters/postgres_adapter_spec.rb", "spec/semipublic/adapters/sqlite3_adapter_spec.rb", "spec/semipublic/adapters/yaml_adapter_spec.rb", "spec/semipublic/associations/many_to_one_spec.rb", "spec/semipublic/associations/relationship_spec.rb", "spec/semipublic/associations_spec.rb", "spec/semipublic/collection_spec.rb", "spec/semipublic/property_spec.rb", "spec/semipublic/query/conditions_spec.rb", "spec/semipublic/query/path_spec.rb", "spec/semipublic/query_spec.rb", "spec/semipublic/resource_spec.rb", "spec/semipublic/shared/condition_shared_spec.rb", "spec/semipublic/shared/resource_shared_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/ci.rb", "tasks/dm.rb", "tasks/doc.rb", "tasks/gemspec.rb", "tasks/hoe.rb", "tasks/install.rb"]
14
- s.homepage = %q{http://datamapper.org}
15
- s.rdoc_options = ["--main", "README.txt"]
14
+ s.email = %q{dan.kubb@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".autotest",
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "deps.rip",
28
+ "dm-core.gemspec",
29
+ "lib/dm-core.rb",
30
+ "lib/dm-core/adapters.rb",
31
+ "lib/dm-core/adapters/abstract_adapter.rb",
32
+ "lib/dm-core/adapters/data_objects_adapter.rb",
33
+ "lib/dm-core/adapters/in_memory_adapter.rb",
34
+ "lib/dm-core/adapters/mysql_adapter.rb",
35
+ "lib/dm-core/adapters/oracle_adapter.rb",
36
+ "lib/dm-core/adapters/postgres_adapter.rb",
37
+ "lib/dm-core/adapters/sqlite3_adapter.rb",
38
+ "lib/dm-core/adapters/sqlserver_adapter.rb",
39
+ "lib/dm-core/adapters/yaml_adapter.rb",
40
+ "lib/dm-core/associations/many_to_many.rb",
41
+ "lib/dm-core/associations/many_to_one.rb",
42
+ "lib/dm-core/associations/one_to_many.rb",
43
+ "lib/dm-core/associations/one_to_one.rb",
44
+ "lib/dm-core/associations/relationship.rb",
45
+ "lib/dm-core/collection.rb",
46
+ "lib/dm-core/core_ext/enumerable.rb",
47
+ "lib/dm-core/core_ext/kernel.rb",
48
+ "lib/dm-core/core_ext/symbol.rb",
49
+ "lib/dm-core/identity_map.rb",
50
+ "lib/dm-core/migrations.rb",
51
+ "lib/dm-core/model.rb",
52
+ "lib/dm-core/model/descendant_set.rb",
53
+ "lib/dm-core/model/hook.rb",
54
+ "lib/dm-core/model/is.rb",
55
+ "lib/dm-core/model/property.rb",
56
+ "lib/dm-core/model/relationship.rb",
57
+ "lib/dm-core/model/scope.rb",
58
+ "lib/dm-core/property.rb",
59
+ "lib/dm-core/property_set.rb",
60
+ "lib/dm-core/query.rb",
61
+ "lib/dm-core/query/conditions/comparison.rb",
62
+ "lib/dm-core/query/conditions/operation.rb",
63
+ "lib/dm-core/query/direction.rb",
64
+ "lib/dm-core/query/operator.rb",
65
+ "lib/dm-core/query/path.rb",
66
+ "lib/dm-core/query/sort.rb",
67
+ "lib/dm-core/repository.rb",
68
+ "lib/dm-core/resource.rb",
69
+ "lib/dm-core/spec/adapter_shared_spec.rb",
70
+ "lib/dm-core/spec/data_objects_adapter_shared_spec.rb",
71
+ "lib/dm-core/support/chainable.rb",
72
+ "lib/dm-core/support/deprecate.rb",
73
+ "lib/dm-core/support/equalizer.rb",
74
+ "lib/dm-core/support/logger.rb",
75
+ "lib/dm-core/support/naming_conventions.rb",
76
+ "lib/dm-core/transaction.rb",
77
+ "lib/dm-core/type.rb",
78
+ "lib/dm-core/types/boolean.rb",
79
+ "lib/dm-core/types/discriminator.rb",
80
+ "lib/dm-core/types/object.rb",
81
+ "lib/dm-core/types/paranoid_boolean.rb",
82
+ "lib/dm-core/types/paranoid_datetime.rb",
83
+ "lib/dm-core/types/serial.rb",
84
+ "lib/dm-core/types/text.rb",
85
+ "lib/dm-core/version.rb",
86
+ "script/performance.rb",
87
+ "script/profile.rb",
88
+ "spec/lib/adapter_helpers.rb",
89
+ "spec/lib/collection_helpers.rb",
90
+ "spec/lib/counter_adapter.rb",
91
+ "spec/lib/pending_helpers.rb",
92
+ "spec/lib/rspec_immediate_feedback_formatter.rb",
93
+ "spec/public/associations/many_to_many_spec.rb",
94
+ "spec/public/associations/many_to_one_spec.rb",
95
+ "spec/public/associations/many_to_one_with_boolean_cpk_spec.rb",
96
+ "spec/public/associations/one_to_many_spec.rb",
97
+ "spec/public/associations/one_to_one_spec.rb",
98
+ "spec/public/associations/one_to_one_with_boolean_cpk_spec.rb",
99
+ "spec/public/collection_spec.rb",
100
+ "spec/public/migrations_spec.rb",
101
+ "spec/public/model/relationship_spec.rb",
102
+ "spec/public/model_spec.rb",
103
+ "spec/public/property/object_spec.rb",
104
+ "spec/public/property_spec.rb",
105
+ "spec/public/resource_spec.rb",
106
+ "spec/public/sel_spec.rb",
107
+ "spec/public/setup_spec.rb",
108
+ "spec/public/shared/association_collection_shared_spec.rb",
109
+ "spec/public/shared/collection_finder_shared_spec.rb",
110
+ "spec/public/shared/collection_shared_spec.rb",
111
+ "spec/public/shared/finder_shared_spec.rb",
112
+ "spec/public/shared/resource_shared_spec.rb",
113
+ "spec/public/shared/sel_shared_spec.rb",
114
+ "spec/public/transaction_spec.rb",
115
+ "spec/public/types/discriminator_spec.rb",
116
+ "spec/rcov.opts",
117
+ "spec/semipublic/adapters/abstract_adapter_spec.rb",
118
+ "spec/semipublic/adapters/in_memory_adapter_spec.rb",
119
+ "spec/semipublic/adapters/mysql_adapter_spec.rb",
120
+ "spec/semipublic/adapters/oracle_adapter_spec.rb",
121
+ "spec/semipublic/adapters/postgres_adapter_spec.rb",
122
+ "spec/semipublic/adapters/sqlite3_adapter_spec.rb",
123
+ "spec/semipublic/adapters/sqlserver_adapter_spec.rb",
124
+ "spec/semipublic/adapters/yaml_adapter_spec.rb",
125
+ "spec/semipublic/associations/many_to_one_spec.rb",
126
+ "spec/semipublic/associations/relationship_spec.rb",
127
+ "spec/semipublic/associations_spec.rb",
128
+ "spec/semipublic/collection_spec.rb",
129
+ "spec/semipublic/model_spec.rb",
130
+ "spec/semipublic/property_spec.rb",
131
+ "spec/semipublic/query/conditions/comparison_spec.rb",
132
+ "spec/semipublic/query/conditions/operation_spec.rb",
133
+ "spec/semipublic/query/path_spec.rb",
134
+ "spec/semipublic/query_spec.rb",
135
+ "spec/semipublic/resource_spec.rb",
136
+ "spec/semipublic/shared/condition_shared_spec.rb",
137
+ "spec/semipublic/shared/resource_shared_spec.rb",
138
+ "spec/spec.opts",
139
+ "spec/spec_helper.rb",
140
+ "tasks/ci.rake",
141
+ "tasks/metrics.rake",
142
+ "tasks/spec.rake",
143
+ "tasks/yard.rake",
144
+ "tasks/yardstick.rake"
145
+ ]
146
+ s.homepage = %q{http://github.com/datamapper/dm-core}
147
+ s.rdoc_options = ["--charset=UTF-8"]
16
148
  s.require_paths = ["lib"]
17
149
  s.rubyforge_project = %q{datamapper}
18
150
  s.rubygems_version = %q{1.3.5}
19
151
  s.summary = %q{An Object/Relational Mapper for Ruby}
152
+ s.test_files = [
153
+ "spec/lib/adapter_helpers.rb",
154
+ "spec/lib/collection_helpers.rb",
155
+ "spec/lib/counter_adapter.rb",
156
+ "spec/lib/pending_helpers.rb",
157
+ "spec/lib/rspec_immediate_feedback_formatter.rb",
158
+ "spec/public/associations/many_to_many_spec.rb",
159
+ "spec/public/associations/many_to_one_spec.rb",
160
+ "spec/public/associations/many_to_one_with_boolean_cpk_spec.rb",
161
+ "spec/public/associations/one_to_many_spec.rb",
162
+ "spec/public/associations/one_to_one_spec.rb",
163
+ "spec/public/associations/one_to_one_with_boolean_cpk_spec.rb",
164
+ "spec/public/collection_spec.rb",
165
+ "spec/public/migrations_spec.rb",
166
+ "spec/public/model/relationship_spec.rb",
167
+ "spec/public/model_spec.rb",
168
+ "spec/public/property/object_spec.rb",
169
+ "spec/public/property_spec.rb",
170
+ "spec/public/resource_spec.rb",
171
+ "spec/public/sel_spec.rb",
172
+ "spec/public/setup_spec.rb",
173
+ "spec/public/shared/association_collection_shared_spec.rb",
174
+ "spec/public/shared/collection_finder_shared_spec.rb",
175
+ "spec/public/shared/collection_shared_spec.rb",
176
+ "spec/public/shared/finder_shared_spec.rb",
177
+ "spec/public/shared/resource_shared_spec.rb",
178
+ "spec/public/shared/sel_shared_spec.rb",
179
+ "spec/public/transaction_spec.rb",
180
+ "spec/public/types/discriminator_spec.rb",
181
+ "spec/semipublic/adapters/abstract_adapter_spec.rb",
182
+ "spec/semipublic/adapters/in_memory_adapter_spec.rb",
183
+ "spec/semipublic/adapters/mysql_adapter_spec.rb",
184
+ "spec/semipublic/adapters/oracle_adapter_spec.rb",
185
+ "spec/semipublic/adapters/postgres_adapter_spec.rb",
186
+ "spec/semipublic/adapters/sqlite3_adapter_spec.rb",
187
+ "spec/semipublic/adapters/sqlserver_adapter_spec.rb",
188
+ "spec/semipublic/adapters/yaml_adapter_spec.rb",
189
+ "spec/semipublic/associations/many_to_one_spec.rb",
190
+ "spec/semipublic/associations/relationship_spec.rb",
191
+ "spec/semipublic/associations_spec.rb",
192
+ "spec/semipublic/collection_spec.rb",
193
+ "spec/semipublic/model_spec.rb",
194
+ "spec/semipublic/property_spec.rb",
195
+ "spec/semipublic/query/conditions/comparison_spec.rb",
196
+ "spec/semipublic/query/conditions/operation_spec.rb",
197
+ "spec/semipublic/query/path_spec.rb",
198
+ "spec/semipublic/query_spec.rb",
199
+ "spec/semipublic/resource_spec.rb",
200
+ "spec/semipublic/shared/condition_shared_spec.rb",
201
+ "spec/semipublic/shared/resource_shared_spec.rb",
202
+ "spec/spec_helper.rb"
203
+ ]
20
204
 
21
205
  if s.respond_to? :specification_version then
22
206
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
207
  s.specification_version = 3
24
208
 
25
209
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<extlib>, ["~> 0.9.13"])
210
+ s.add_runtime_dependency(%q<extlib>, ["~> 0.9.14"])
27
211
  s.add_runtime_dependency(%q<addressable>, ["~> 2.1"])
212
+ s.add_development_dependency(%q<rspec>, ["~> 1.2.9"])
213
+ s.add_development_dependency(%q<yard>, ["~> 0.4.0"])
28
214
  else
29
- s.add_dependency(%q<extlib>, ["~> 0.9.13"])
215
+ s.add_dependency(%q<extlib>, ["~> 0.9.14"])
30
216
  s.add_dependency(%q<addressable>, ["~> 2.1"])
217
+ s.add_dependency(%q<rspec>, ["~> 1.2.9"])
218
+ s.add_dependency(%q<yard>, ["~> 0.4.0"])
31
219
  end
32
220
  else
33
- s.add_dependency(%q<extlib>, ["~> 0.9.13"])
221
+ s.add_dependency(%q<extlib>, ["~> 0.9.14"])
34
222
  s.add_dependency(%q<addressable>, ["~> 2.1"])
223
+ s.add_dependency(%q<rspec>, ["~> 1.2.9"])
224
+ s.add_dependency(%q<yard>, ["~> 0.4.0"])
35
225
  end
36
226
  end
227
+
data/lib/dm-core.rb CHANGED
@@ -30,6 +30,15 @@ require dir / 'model' / 'property'
30
30
 
31
31
  require dir / 'collection'
32
32
 
33
+ require dir / 'type'
34
+ require dir / 'types' / 'boolean'
35
+ require dir / 'types' / 'discriminator'
36
+ require dir / 'types' / 'text'
37
+ require dir / 'types' / 'paranoid_datetime' # TODO: move to dm-more
38
+ require dir / 'types' / 'paranoid_boolean' # TODO: move to dm-more
39
+ require dir / 'types' / 'object'
40
+ require dir / 'types' / 'serial'
41
+
33
42
  require dir / 'adapters'
34
43
  require dir / 'adapters' / 'abstract_adapter'
35
44
  require dir / 'associations' / 'relationship'
@@ -53,22 +62,19 @@ require dir / 'resource'
53
62
  require dir / 'support' / 'logger'
54
63
  require dir / 'support' / 'naming_conventions'
55
64
  require dir / 'transaction' # TODO: move to dm-more
56
- require dir / 'type'
57
- require dir / 'types' / 'boolean'
58
- require dir / 'types' / 'discriminator'
59
- require dir / 'types' / 'text'
60
- require dir / 'types' / 'paranoid_datetime' # TODO: move to dm-more
61
- require dir / 'types' / 'paranoid_boolean' # TODO: move to dm-more
62
- require dir / 'types' / 'object'
63
- require dir / 'types' / 'serial'
64
65
  require dir / 'version'
65
66
 
67
+ require dir / 'core_ext' / 'enumerable'
66
68
  require dir / 'core_ext' / 'kernel' # TODO: do not load automatically
67
69
  require dir / 'core_ext' / 'symbol' # TODO: do not load automatically
68
70
 
69
71
  # A logger should always be present. Lets be consistent with DO
70
72
  DataMapper::Logger.new(StringIO.new, :fatal)
71
73
 
74
+ unless defined?(Infinity)
75
+ Infinity = 1.0/0
76
+ end
77
+
72
78
  # == Setup and Configuration
73
79
  # DataMapper uses URIs or a connection hash to connect to your data-store.
74
80
  # URI connections takes the form of:
@@ -117,21 +123,20 @@ DataMapper::Logger.new(StringIO.new, :fatal)
117
123
  module DataMapper
118
124
  extend Extlib::Assertions
119
125
 
120
- # TODO: move to dm-validations
121
- class ValidationError < StandardError; end
122
-
123
- class ObjectNotFoundError < StandardError; end
124
-
125
126
  class RepositoryNotSetupError < StandardError; end
126
127
 
127
128
  class IncompleteModelError < StandardError; end
128
129
 
129
130
  class PluginNotFoundError < StandardError; end
130
131
 
131
- class UpdateConflictError < StandardError; end
132
-
133
132
  class UnknownRelationshipError < StandardError; end
134
133
 
134
+ class ObjectNotFoundError < RuntimeError; end
135
+
136
+ class PersistenceError < RuntimeError; end
137
+
138
+ class UpdateConflictError < PersistenceError; end
139
+
135
140
  # Raised on attempt to operate on collection of child objects
136
141
  # when parent object is not yet saved.
137
142
  # For instance, if your article object is not saved,
@@ -139,9 +144,8 @@ module DataMapper
139
144
  # publications (n:m case), operation cannot be completed
140
145
  # because parent object's keys are not yet persisted,
141
146
  # and thus there is no FK value to use in the query.
142
- class UnsavedParentError < RuntimeError; end
147
+ class UnsavedParentError < PersistenceError; end
143
148
 
144
- # TODO: document
145
149
  # @api private
146
150
  def self.root
147
151
  @root ||= Pathname(__FILE__).dirname.parent.expand_path.freeze
@@ -165,10 +169,10 @@ module DataMapper
165
169
  #
166
170
  # @api public
167
171
  def self.setup(*args)
168
- adapter = if args.first.kind_of?(Adapters::AbstractAdapter)
169
- args.first
170
- else
171
- DataMapper::Adapters.new(*args)
172
+ adapter = args.first
173
+
174
+ unless adapter.kind_of?(Adapters::AbstractAdapter)
175
+ adapter = Adapters.new(*args)
172
176
  end
173
177
 
174
178
  Repository.adapters[adapter.name] = adapter
@@ -188,13 +192,18 @@ module DataMapper
188
192
  #
189
193
  # @api public
190
194
  def self.repository(name = nil)
195
+ context = Repository.context
196
+
191
197
  current_repository = if name
192
198
  assert_kind_of 'name', name, Symbol
193
- Repository.context.detect { |repository| repository.name == name } || Repository.new(name)
199
+ context.detect { |repository| repository.name == name }
194
200
  else
195
- Repository.context.last || Repository.new(Repository.default_name)
201
+ name = Repository.default_name
202
+ context.last
196
203
  end
197
204
 
205
+ current_repository ||= Repository.new(name)
206
+
198
207
  if block_given?
199
208
  current_repository.scope { |*block_args| yield(*block_args) }
200
209
  else