ardm-core 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +29 -0
  3. data/.document +5 -0
  4. data/.gitignore +35 -0
  5. data/.travis.yml +23 -0
  6. data/.yardopts +1 -0
  7. data/Gemfile +63 -0
  8. data/LICENSE +20 -0
  9. data/README.rdoc +237 -0
  10. data/Rakefile +4 -0
  11. data/VERSION +1 -0
  12. data/ardm-core.gemspec +25 -0
  13. data/lib/ardm-core.rb +1 -0
  14. data/lib/dm-core.rb +285 -0
  15. data/lib/dm-core/adapters.rb +222 -0
  16. data/lib/dm-core/adapters/abstract_adapter.rb +236 -0
  17. data/lib/dm-core/adapters/in_memory_adapter.rb +113 -0
  18. data/lib/dm-core/associations/many_to_many.rb +496 -0
  19. data/lib/dm-core/associations/many_to_one.rb +296 -0
  20. data/lib/dm-core/associations/one_to_many.rb +345 -0
  21. data/lib/dm-core/associations/one_to_one.rb +86 -0
  22. data/lib/dm-core/associations/relationship.rb +663 -0
  23. data/lib/dm-core/backwards.rb +13 -0
  24. data/lib/dm-core/collection.rb +1514 -0
  25. data/lib/dm-core/core_ext/kernel.rb +23 -0
  26. data/lib/dm-core/core_ext/pathname.rb +6 -0
  27. data/lib/dm-core/core_ext/symbol.rb +10 -0
  28. data/lib/dm-core/identity_map.rb +7 -0
  29. data/lib/dm-core/model.rb +869 -0
  30. data/lib/dm-core/model/hook.rb +102 -0
  31. data/lib/dm-core/model/is.rb +32 -0
  32. data/lib/dm-core/model/property.rb +253 -0
  33. data/lib/dm-core/model/relationship.rb +377 -0
  34. data/lib/dm-core/model/scope.rb +89 -0
  35. data/lib/dm-core/property.rb +839 -0
  36. data/lib/dm-core/property/binary.rb +22 -0
  37. data/lib/dm-core/property/boolean.rb +31 -0
  38. data/lib/dm-core/property/class.rb +24 -0
  39. data/lib/dm-core/property/date.rb +45 -0
  40. data/lib/dm-core/property/date_time.rb +44 -0
  41. data/lib/dm-core/property/decimal.rb +50 -0
  42. data/lib/dm-core/property/discriminator.rb +46 -0
  43. data/lib/dm-core/property/float.rb +28 -0
  44. data/lib/dm-core/property/integer.rb +32 -0
  45. data/lib/dm-core/property/lookup.rb +29 -0
  46. data/lib/dm-core/property/numeric.rb +40 -0
  47. data/lib/dm-core/property/object.rb +28 -0
  48. data/lib/dm-core/property/serial.rb +13 -0
  49. data/lib/dm-core/property/string.rb +50 -0
  50. data/lib/dm-core/property/text.rb +12 -0
  51. data/lib/dm-core/property/time.rb +46 -0
  52. data/lib/dm-core/property/typecast/numeric.rb +32 -0
  53. data/lib/dm-core/property/typecast/time.rb +33 -0
  54. data/lib/dm-core/property_set.rb +177 -0
  55. data/lib/dm-core/query.rb +1444 -0
  56. data/lib/dm-core/query/conditions/comparison.rb +910 -0
  57. data/lib/dm-core/query/conditions/operation.rb +720 -0
  58. data/lib/dm-core/query/direction.rb +36 -0
  59. data/lib/dm-core/query/operator.rb +35 -0
  60. data/lib/dm-core/query/path.rb +114 -0
  61. data/lib/dm-core/query/sort.rb +39 -0
  62. data/lib/dm-core/relationship_set.rb +72 -0
  63. data/lib/dm-core/repository.rb +226 -0
  64. data/lib/dm-core/resource.rb +1228 -0
  65. data/lib/dm-core/resource/persistence_state.rb +75 -0
  66. data/lib/dm-core/resource/persistence_state/clean.rb +40 -0
  67. data/lib/dm-core/resource/persistence_state/deleted.rb +30 -0
  68. data/lib/dm-core/resource/persistence_state/dirty.rb +96 -0
  69. data/lib/dm-core/resource/persistence_state/immutable.rb +34 -0
  70. data/lib/dm-core/resource/persistence_state/persisted.rb +29 -0
  71. data/lib/dm-core/resource/persistence_state/transient.rb +78 -0
  72. data/lib/dm-core/spec/lib/adapter_helpers.rb +54 -0
  73. data/lib/dm-core/spec/lib/collection_helpers.rb +20 -0
  74. data/lib/dm-core/spec/lib/counter_adapter.rb +38 -0
  75. data/lib/dm-core/spec/lib/pending_helpers.rb +50 -0
  76. data/lib/dm-core/spec/lib/spec_helper.rb +74 -0
  77. data/lib/dm-core/spec/setup.rb +173 -0
  78. data/lib/dm-core/spec/shared/adapter_spec.rb +326 -0
  79. data/lib/dm-core/spec/shared/public/property_spec.rb +229 -0
  80. data/lib/dm-core/spec/shared/resource_spec.rb +1236 -0
  81. data/lib/dm-core/spec/shared/sel_spec.rb +111 -0
  82. data/lib/dm-core/spec/shared/semipublic/property_spec.rb +134 -0
  83. data/lib/dm-core/spec/shared/semipublic/query/conditions/abstract_comparison_spec.rb +261 -0
  84. data/lib/dm-core/support/assertions.rb +8 -0
  85. data/lib/dm-core/support/chainable.rb +18 -0
  86. data/lib/dm-core/support/deprecate.rb +12 -0
  87. data/lib/dm-core/support/descendant_set.rb +89 -0
  88. data/lib/dm-core/support/equalizer.rb +48 -0
  89. data/lib/dm-core/support/ext/array.rb +22 -0
  90. data/lib/dm-core/support/ext/blank.rb +25 -0
  91. data/lib/dm-core/support/ext/hash.rb +67 -0
  92. data/lib/dm-core/support/ext/module.rb +47 -0
  93. data/lib/dm-core/support/ext/object.rb +57 -0
  94. data/lib/dm-core/support/ext/string.rb +24 -0
  95. data/lib/dm-core/support/ext/try_dup.rb +12 -0
  96. data/lib/dm-core/support/hook.rb +402 -0
  97. data/lib/dm-core/support/inflections.rb +60 -0
  98. data/lib/dm-core/support/inflector/inflections.rb +211 -0
  99. data/lib/dm-core/support/inflector/methods.rb +151 -0
  100. data/lib/dm-core/support/lazy_array.rb +451 -0
  101. data/lib/dm-core/support/local_object_space.rb +12 -0
  102. data/lib/dm-core/support/logger.rb +199 -0
  103. data/lib/dm-core/support/mash.rb +176 -0
  104. data/lib/dm-core/support/naming_conventions.rb +90 -0
  105. data/lib/dm-core/support/ordered_set.rb +380 -0
  106. data/lib/dm-core/support/subject.rb +33 -0
  107. data/lib/dm-core/support/subject_set.rb +250 -0
  108. data/lib/dm-core/version.rb +3 -0
  109. data/script/performance.rb +275 -0
  110. data/script/profile.rb +218 -0
  111. data/spec/lib/rspec_immediate_feedback_formatter.rb +54 -0
  112. data/spec/public/associations/many_to_many/read_multiple_join_spec.rb +68 -0
  113. data/spec/public/associations/many_to_many_spec.rb +197 -0
  114. data/spec/public/associations/many_to_one_spec.rb +83 -0
  115. data/spec/public/associations/many_to_one_with_boolean_cpk_spec.rb +40 -0
  116. data/spec/public/associations/many_to_one_with_custom_fk_spec.rb +49 -0
  117. data/spec/public/associations/one_to_many_spec.rb +81 -0
  118. data/spec/public/associations/one_to_one_spec.rb +176 -0
  119. data/spec/public/associations/one_to_one_with_boolean_cpk_spec.rb +46 -0
  120. data/spec/public/collection_spec.rb +69 -0
  121. data/spec/public/finalize_spec.rb +76 -0
  122. data/spec/public/model/hook_spec.rb +246 -0
  123. data/spec/public/model/property_spec.rb +88 -0
  124. data/spec/public/model/relationship_spec.rb +1040 -0
  125. data/spec/public/model_spec.rb +458 -0
  126. data/spec/public/property/binary_spec.rb +41 -0
  127. data/spec/public/property/boolean_spec.rb +22 -0
  128. data/spec/public/property/class_spec.rb +28 -0
  129. data/spec/public/property/date_spec.rb +22 -0
  130. data/spec/public/property/date_time_spec.rb +22 -0
  131. data/spec/public/property/decimal_spec.rb +23 -0
  132. data/spec/public/property/discriminator_spec.rb +135 -0
  133. data/spec/public/property/float_spec.rb +22 -0
  134. data/spec/public/property/integer_spec.rb +22 -0
  135. data/spec/public/property/object_spec.rb +107 -0
  136. data/spec/public/property/serial_spec.rb +22 -0
  137. data/spec/public/property/string_spec.rb +22 -0
  138. data/spec/public/property/text_spec.rb +63 -0
  139. data/spec/public/property/time_spec.rb +22 -0
  140. data/spec/public/property_spec.rb +341 -0
  141. data/spec/public/resource_spec.rb +284 -0
  142. data/spec/public/sel_spec.rb +53 -0
  143. data/spec/public/setup_spec.rb +145 -0
  144. data/spec/public/shared/association_collection_shared_spec.rb +309 -0
  145. data/spec/public/shared/collection_finder_shared_spec.rb +267 -0
  146. data/spec/public/shared/collection_shared_spec.rb +1669 -0
  147. data/spec/public/shared/finder_shared_spec.rb +1629 -0
  148. data/spec/rcov.opts +6 -0
  149. data/spec/semipublic/adapters/abstract_adapter_spec.rb +30 -0
  150. data/spec/semipublic/adapters/in_memory_adapter_spec.rb +12 -0
  151. data/spec/semipublic/associations/many_to_many_spec.rb +94 -0
  152. data/spec/semipublic/associations/many_to_one_spec.rb +63 -0
  153. data/spec/semipublic/associations/one_to_many_spec.rb +55 -0
  154. data/spec/semipublic/associations/one_to_one_spec.rb +53 -0
  155. data/spec/semipublic/associations/relationship_spec.rb +200 -0
  156. data/spec/semipublic/associations_spec.rb +177 -0
  157. data/spec/semipublic/collection_spec.rb +110 -0
  158. data/spec/semipublic/model_spec.rb +96 -0
  159. data/spec/semipublic/property/binary_spec.rb +13 -0
  160. data/spec/semipublic/property/boolean_spec.rb +47 -0
  161. data/spec/semipublic/property/class_spec.rb +33 -0
  162. data/spec/semipublic/property/date_spec.rb +43 -0
  163. data/spec/semipublic/property/date_time_spec.rb +46 -0
  164. data/spec/semipublic/property/decimal_spec.rb +83 -0
  165. data/spec/semipublic/property/discriminator_spec.rb +19 -0
  166. data/spec/semipublic/property/float_spec.rb +82 -0
  167. data/spec/semipublic/property/integer_spec.rb +82 -0
  168. data/spec/semipublic/property/lookup_spec.rb +29 -0
  169. data/spec/semipublic/property/serial_spec.rb +13 -0
  170. data/spec/semipublic/property/string_spec.rb +13 -0
  171. data/spec/semipublic/property/text_spec.rb +31 -0
  172. data/spec/semipublic/property/time_spec.rb +50 -0
  173. data/spec/semipublic/property_spec.rb +114 -0
  174. data/spec/semipublic/query/conditions/comparison_spec.rb +1501 -0
  175. data/spec/semipublic/query/conditions/operation_spec.rb +1294 -0
  176. data/spec/semipublic/query/path_spec.rb +471 -0
  177. data/spec/semipublic/query_spec.rb +3777 -0
  178. data/spec/semipublic/resource/state/clean_spec.rb +88 -0
  179. data/spec/semipublic/resource/state/deleted_spec.rb +78 -0
  180. data/spec/semipublic/resource/state/dirty_spec.rb +156 -0
  181. data/spec/semipublic/resource/state/immutable_spec.rb +105 -0
  182. data/spec/semipublic/resource/state/transient_spec.rb +162 -0
  183. data/spec/semipublic/resource/state_spec.rb +230 -0
  184. data/spec/semipublic/resource_spec.rb +23 -0
  185. data/spec/semipublic/shared/condition_shared_spec.rb +9 -0
  186. data/spec/semipublic/shared/resource_shared_spec.rb +199 -0
  187. data/spec/semipublic/shared/resource_state_shared_spec.rb +79 -0
  188. data/spec/semipublic/shared/subject_shared_spec.rb +79 -0
  189. data/spec/spec.opts +5 -0
  190. data/spec/spec_helper.rb +37 -0
  191. data/spec/support/core_ext/hash.rb +10 -0
  192. data/spec/support/core_ext/inheritable_attributes.rb +46 -0
  193. data/spec/support/properties/huge_integer.rb +17 -0
  194. data/spec/unit/array_spec.rb +23 -0
  195. data/spec/unit/blank_spec.rb +73 -0
  196. data/spec/unit/data_mapper/ordered_set/append_spec.rb +26 -0
  197. data/spec/unit/data_mapper/ordered_set/clear_spec.rb +24 -0
  198. data/spec/unit/data_mapper/ordered_set/delete_spec.rb +28 -0
  199. data/spec/unit/data_mapper/ordered_set/each_spec.rb +19 -0
  200. data/spec/unit/data_mapper/ordered_set/empty_spec.rb +20 -0
  201. data/spec/unit/data_mapper/ordered_set/entries_spec.rb +22 -0
  202. data/spec/unit/data_mapper/ordered_set/eql_spec.rb +51 -0
  203. data/spec/unit/data_mapper/ordered_set/equal_value_spec.rb +84 -0
  204. data/spec/unit/data_mapper/ordered_set/hash_spec.rb +12 -0
  205. data/spec/unit/data_mapper/ordered_set/include_spec.rb +23 -0
  206. data/spec/unit/data_mapper/ordered_set/index_spec.rb +28 -0
  207. data/spec/unit/data_mapper/ordered_set/initialize_spec.rb +32 -0
  208. data/spec/unit/data_mapper/ordered_set/merge_spec.rb +36 -0
  209. data/spec/unit/data_mapper/ordered_set/shared/append_spec.rb +24 -0
  210. data/spec/unit/data_mapper/ordered_set/shared/clear_spec.rb +9 -0
  211. data/spec/unit/data_mapper/ordered_set/shared/delete_spec.rb +25 -0
  212. data/spec/unit/data_mapper/ordered_set/shared/each_spec.rb +17 -0
  213. data/spec/unit/data_mapper/ordered_set/shared/empty_spec.rb +9 -0
  214. data/spec/unit/data_mapper/ordered_set/shared/entries_spec.rb +9 -0
  215. data/spec/unit/data_mapper/ordered_set/shared/include_spec.rb +9 -0
  216. data/spec/unit/data_mapper/ordered_set/shared/index_spec.rb +13 -0
  217. data/spec/unit/data_mapper/ordered_set/shared/initialize_spec.rb +28 -0
  218. data/spec/unit/data_mapper/ordered_set/shared/merge_spec.rb +28 -0
  219. data/spec/unit/data_mapper/ordered_set/shared/size_spec.rb +13 -0
  220. data/spec/unit/data_mapper/ordered_set/shared/to_ary_spec.rb +11 -0
  221. data/spec/unit/data_mapper/ordered_set/size_spec.rb +27 -0
  222. data/spec/unit/data_mapper/ordered_set/to_ary_spec.rb +23 -0
  223. data/spec/unit/data_mapper/subject_set/append_spec.rb +47 -0
  224. data/spec/unit/data_mapper/subject_set/clear_spec.rb +34 -0
  225. data/spec/unit/data_mapper/subject_set/delete_spec.rb +40 -0
  226. data/spec/unit/data_mapper/subject_set/each_spec.rb +30 -0
  227. data/spec/unit/data_mapper/subject_set/empty_spec.rb +31 -0
  228. data/spec/unit/data_mapper/subject_set/entries_spec.rb +31 -0
  229. data/spec/unit/data_mapper/subject_set/get_spec.rb +34 -0
  230. data/spec/unit/data_mapper/subject_set/include_spec.rb +32 -0
  231. data/spec/unit/data_mapper/subject_set/named_spec.rb +33 -0
  232. data/spec/unit/data_mapper/subject_set/shared/append_spec.rb +18 -0
  233. data/spec/unit/data_mapper/subject_set/shared/clear_spec.rb +9 -0
  234. data/spec/unit/data_mapper/subject_set/shared/delete_spec.rb +9 -0
  235. data/spec/unit/data_mapper/subject_set/shared/each_spec.rb +9 -0
  236. data/spec/unit/data_mapper/subject_set/shared/empty_spec.rb +9 -0
  237. data/spec/unit/data_mapper/subject_set/shared/entries_spec.rb +9 -0
  238. data/spec/unit/data_mapper/subject_set/shared/get_spec.rb +9 -0
  239. data/spec/unit/data_mapper/subject_set/shared/include_spec.rb +9 -0
  240. data/spec/unit/data_mapper/subject_set/shared/named_spec.rb +9 -0
  241. data/spec/unit/data_mapper/subject_set/shared/size_spec.rb +13 -0
  242. data/spec/unit/data_mapper/subject_set/shared/to_ary_spec.rb +9 -0
  243. data/spec/unit/data_mapper/subject_set/shared/values_at_spec.rb +44 -0
  244. data/spec/unit/data_mapper/subject_set/size_spec.rb +42 -0
  245. data/spec/unit/data_mapper/subject_set/to_ary_spec.rb +34 -0
  246. data/spec/unit/data_mapper/subject_set/values_at_spec.rb +57 -0
  247. data/spec/unit/hash_spec.rb +28 -0
  248. data/spec/unit/hook_spec.rb +1235 -0
  249. data/spec/unit/lazy_array_spec.rb +1949 -0
  250. data/spec/unit/mash_spec.rb +312 -0
  251. data/spec/unit/module_spec.rb +71 -0
  252. data/spec/unit/object_spec.rb +38 -0
  253. data/spec/unit/try_dup_spec.rb +46 -0
  254. data/tasks/ci.rake +1 -0
  255. data/tasks/db.rake +11 -0
  256. data/tasks/spec.rake +38 -0
  257. data/tasks/yard.rake +9 -0
  258. data/tasks/yardstick.rake +19 -0
  259. metadata +491 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d88a1388e05bc0987ce1ea0fcfd902bd19a91b5
4
+ data.tar.gz: 185295c3d88d126fcefe257eb50894cb9fccb99f
5
+ SHA512:
6
+ metadata.gz: e3244f70503a3c2174bb896dda56ab841690761edfa2dd21b0009be74d5bd20bd7f125bb088b37066084d27ccb61677eb376817f97e7e8d560dacd26fbfdf56a
7
+ data.tar.gz: 65012a3e5de43b6923fb0ac9a5e8333fb77315ebdf1bcb7ee5bab75c68127762ce8c35fbf3fb2f966d5be691cf66e6175d79e88f5287f970d5d0a7a57b85e942
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
+ lib/**/*.rb
2
+ bin/*
3
+ --
4
+ README.rdoc
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,35 @@
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
+ ## Rubinius
17
+ *.rbc
18
+
19
+ ## PROJECT::GENERAL
20
+ *.gem
21
+ coverage
22
+ rdoc
23
+ pkg
24
+ tmp
25
+ doc
26
+ log
27
+ .yardoc
28
+ measurements
29
+
30
+ ## BUNDLER
31
+ .bundle
32
+ Gemfile.*
33
+
34
+ ## PROJECT::SPECIFIC
35
+ spec/db/
data/.travis.yml ADDED
@@ -0,0 +1,23 @@
1
+ language: ruby
2
+ sudo: false
3
+ services:
4
+ - mysql
5
+ before_script:
6
+ - "bundle exec rake db:create"
7
+ before_install:
8
+ - gem install bundler
9
+ script: "bundle exec rake spec"
10
+ env:
11
+ - "ADAPTER=in_memory"
12
+ - "ADAPTER=yaml"
13
+ - "ADAPTER=sqlite"
14
+ - "ADAPTER=mysql DM_DB_USER=root DM_DB_PASSWORD=''"
15
+ rvm:
16
+ - 1.9.3
17
+ - 2.0.0
18
+ - 2.1.5
19
+ - 2.2.0
20
+ matrix:
21
+ allow_failures:
22
+ - rvm: 2.1.5
23
+ - rvm: 2.2.0
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup rdoc --title 'DataMapper Documentation' --protected
data/Gemfile ADDED
@@ -0,0 +1,63 @@
1
+ require File.expand_path('../lib/dm-core/version', __FILE__)
2
+
3
+ require 'pathname'
4
+
5
+ source 'https://rubygems.org'
6
+
7
+ gemspec
8
+
9
+ SOURCE = ENV.fetch('SOURCE', :git).to_sym
10
+ REPO_POSTFIX = SOURCE == :path ? '' : '.git'
11
+ DATAMAPPER = SOURCE == :path ? Pathname(__FILE__).dirname.parent : 'http://github.com/ar-dm'
12
+ DM_VERSION = '~> 1.2.0'
13
+ DO_VERSION = '~> 0.10.6'
14
+ DM_DO_ADAPTERS = %w[ sqlite postgres mysql oracle sqlserver ]
15
+ CURRENT_BRANCH = ENV.fetch('GIT_BRANCH', 'master')
16
+
17
+ platforms :mri_18 do
18
+ group :quality do
19
+
20
+ gem 'rcov', '~> 0.9.10'
21
+ gem 'yard', '~> 0.7.2'
22
+ gem 'yardstick', '~> 0.4'
23
+
24
+ end
25
+ end
26
+
27
+ group :datamapper do
28
+
29
+ adapters = ENV['ADAPTERS'] || ENV['ADAPTER']
30
+ adapters = adapters.to_s.tr(',', ' ').split.uniq - %w[ in_memory ]
31
+
32
+ if (do_adapters = DM_DO_ADAPTERS & adapters).any?
33
+ do_options = {}
34
+ do_options[:git] = "#{DATAMAPPER}/do#{REPO_POSTFIX}" if ENV['DO_GIT'] == 'true'
35
+
36
+ gem 'data_objects', DO_VERSION, do_options.dup
37
+
38
+ do_adapters.each do |adapter|
39
+ adapter = 'sqlite3' if adapter == 'sqlite'
40
+ gem "do_#{adapter}", DO_VERSION, do_options.dup
41
+ end
42
+
43
+ gem 'ardm-do-adapter', DM_VERSION,
44
+ SOURCE => "#{DATAMAPPER}/ardm-do-adapter#{REPO_POSTFIX}",
45
+ :branch => CURRENT_BRANCH
46
+ end
47
+
48
+ adapters.each do |adapter|
49
+ gem "ardm-#{adapter}-adapter", ENV.fetch('ADAPTER_VERSION', DM_VERSION),
50
+ SOURCE => "#{DATAMAPPER}/ardm-#{adapter}-adapter#{REPO_POSTFIX}",
51
+ :branch => CURRENT_BRANCH
52
+ end
53
+
54
+ plugins = ENV['PLUGINS'] || ENV['PLUGIN']
55
+ plugins = plugins.to_s.tr(',', ' ').split.push('ardm-migrations').uniq
56
+
57
+ plugins.each do |plugin|
58
+ gem plugin, DM_VERSION,
59
+ SOURCE => "#{DATAMAPPER}/#{plugin}#{REPO_POSTFIX}",
60
+ :branch => CURRENT_BRANCH
61
+ end
62
+
63
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 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.
data/README.rdoc ADDED
@@ -0,0 +1,237 @@
1
+ = Why DataMapper?
2
+
3
+ == Open Development
4
+
5
+ DataMapper sports a very accessible code-base and a welcoming community.
6
+ Outside contributions and feedback are welcome and encouraged, especially
7
+ constructive criticism. Make your voice heard! Submit a
8
+ ticket[https://github.com/datamapper/dm-core/issues] or
9
+ patch[http://datamapper.lighthouseapp.com], speak up
10
+ on our mailing-list[http://groups.google.com/group/datamapper/], chat with us
11
+ on irc[irc://irc.freenode.net/#datamapper], write a spec, get it reviewed, ask
12
+ for commit rights. It's as easy as that to become a contributor.
13
+
14
+ == Identity Map
15
+
16
+ One row in the data-store should equal one object reference. Pretty simple idea.
17
+ Pretty profound impact. If you run the following code in ActiveRecord you'll
18
+ see all <tt>false</tt> results. Do the same in DataMapper and it's
19
+ <tt>true</tt> all the way down.
20
+
21
+ repository do
22
+ @parent = Tree.first(:name => 'bob')
23
+
24
+ @parent.children.each do |child|
25
+ puts @parent.equal?(child.parent) # => true
26
+ end
27
+ end
28
+
29
+ This makes DataMapper faster and allocate less resources to get things done.
30
+
31
+ == Dirty Tracking
32
+
33
+ When you save a model back to your data-store, DataMapper will only write
34
+ the fields that actually changed. So it plays well with others. You can
35
+ use it in an Integration data-store without worrying that your application will
36
+ be a bad actor causing trouble for all of your other processes.
37
+
38
+ == Eager Loading
39
+
40
+ Ready for something amazing? The following example executes only two queries
41
+ regardless of how many rows the inner and outer queries return.
42
+
43
+ repository do
44
+ Zoo.all.each { |zoo| zoo.exhibits.to_a }
45
+ end
46
+
47
+ Pretty impressive huh? The idea is that you aren't going to load a set of
48
+ objects and use only an association in just one of them. This should hold up
49
+ pretty well against a 99% rule. When you don't want it to work like this, just
50
+ load the item you want in it's own set. So the DataMapper thinks ahead. We
51
+ like to call it "performant by default". This feature single-handedly wipes
52
+ out the "N+1 Query Problem". No need to specify an <tt>:include</tt> option in
53
+ your finders.
54
+
55
+ == Laziness Can Be A Virtue
56
+
57
+ Text fields are expensive in data-stores. They're generally stored in a
58
+ different place than the rest of your data. So instead of a fast sequential
59
+ read from your hard-drive, your data-store server has to hop around all over the
60
+ place to get what it needs. Since ActiveRecord returns everything by default,
61
+ adding a text field to a table slows everything down drastically, across the
62
+ board.
63
+
64
+ Not so with the DataMapper. Text fields are lazily loaded, meaning they
65
+ only load when you need them. If you want more control you can enable or
66
+ disable this feature for any field (not just text-fields) by passing a
67
+ <tt>:lazy</tt> option to your field mapping with a value of <tt>true</tt> or
68
+ <tt>false</tt>.
69
+
70
+ class Animal
71
+ include DataMapper::Resource
72
+
73
+ property :name, String
74
+ property :description, Text, :lazy => false
75
+ end
76
+
77
+ Plus, lazy-loading of Text fields happens automatically and intelligently when
78
+ working with associations. The following only issues 2 queries to load up all
79
+ of the notes fields on each animal:
80
+
81
+ repository do
82
+ Animal.all.each { |animal| animal.description.to_a }
83
+ end
84
+
85
+ Did you notice the <tt>#to_a</tt> call in the above example? That
86
+ was necessary because even DataMapper collections are lazy. If you don't
87
+ iterate over them, or in this case ask them to become Arrays, they won't
88
+ execute until you need them. We needed to call <tt>#to_a</tt> to force
89
+ the lazy load because without it, the above example would have only
90
+ executed one query. This extra bit of laziness can come in very handy,
91
+ for example:
92
+
93
+ animals = Animal.all
94
+ description = 'foo'
95
+
96
+ animals.each do |animal|
97
+ animal.update(:description => description)
98
+ end
99
+
100
+ In the above example, the Animals won't be retrieved until you actually
101
+ need them. This comes in handy in cases where you initialize the
102
+ collection before you know if you need it, like in a web app controller.
103
+
104
+ == Collection Chaining
105
+
106
+ DataMapper's lazy collections are also handy because you can get the
107
+ same effect as named scopes, without any special syntax, eg:
108
+
109
+ class Animal
110
+ # ... setup ...
111
+
112
+ def self.mammals
113
+ all(:mammal => true)
114
+ end
115
+
116
+ def self.zoo(zoo)
117
+ all(:zoo => zoo)
118
+ end
119
+ end
120
+
121
+ zoo = Zoo.first(:name => 'Greater Vancouver Zoo')
122
+
123
+ Animal.mammals.zoo(zoo).to_a # => executes one query
124
+
125
+ In the above example, we ask the Animal model for all the mammals,
126
+ and then all the animals in a specific zoo, and DataMapper will chain
127
+ the collection queries together and execute a single query to retrieve
128
+ the matching records. There's no special syntax, and no custom DSLs
129
+ to learn, it's just plain ruby all the way down.
130
+
131
+ You can even use this on association collections, eg:
132
+
133
+ zoo.animals.mammals.to_a # => executes one query
134
+
135
+ == Custom Properties
136
+
137
+ With DataMapper it is possible to create custom properties for your models.
138
+ Consider this example:
139
+
140
+ module DataMapper
141
+ class Property
142
+ class Email < String
143
+ required true
144
+ format /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
145
+ end
146
+ end
147
+ end
148
+
149
+ class User
150
+ include DataMapper::Resource
151
+
152
+ property :id, Serial
153
+ property :email, Email
154
+ end
155
+
156
+ This way there won't be a need to repeat same property options every time you
157
+ add an email to a model. In the example above we create an Email property which
158
+ is just a String with additional pre-configured options: <tt>required</tt> and
159
+ <tt>format</tt>. Please note that it is possible to override these options when
160
+ declaring a property, like this:
161
+
162
+ class Member
163
+ include DataMapper::Resource
164
+
165
+ property :id, Serial
166
+ property :email, Email, :required => false
167
+ end
168
+
169
+ == Plays Well With Others
170
+
171
+ In ActiveRecord, all your fields are mapped, whether you want them or not.
172
+ This slows things down. In the DataMapper you define your mappings in your
173
+ model. So instead of an _ALTER TABLE ADD field_ in your data-store, you simply
174
+ add a <tt>property :name, String</tt> to your model. DRY. No schema.rb. No
175
+ migration files to conflict or die without reverting changes. Your model
176
+ drives the data-store, not the other way around.
177
+
178
+ Unless of course you want to map to a legacy data-store. Raise your hand if you
179
+ like seeing a method called <tt>col2Name</tt> on your model just because
180
+ that's what it's called in an old data-store you can't afford to change right
181
+ now? In DataMapper you control the mappings:
182
+
183
+ class Fruit
184
+ include DataMapper::Resource
185
+
186
+ storage_names[:repo] = 'frt'
187
+
188
+ property :name, String, :field => 'col2Name'
189
+ end
190
+
191
+ == All Ruby, All The Time
192
+
193
+ It's great that ActiveRecord allows you to write SQL when you need to, but
194
+ should we have to so often?
195
+
196
+ DataMapper supports issuing your own query, but it also provides more helpers
197
+ and a unique hash-based condition syntax to cover more of the use-cases where
198
+ issuing your own SQL would have been the only way to go. For example, any
199
+ finder option that's non-standard is considered a condition. So you can write
200
+ <tt>Zoo.all(:name => 'Dallas')</tt> and DataMapper will look for zoos with the
201
+ name of 'Dallas'.
202
+
203
+ It's just a little thing, but it's so much nicer than writing
204
+ <tt>Zoo.find(:all, :conditions => ['name = ?', 'Dallas'])</tt>. What if you
205
+ need other comparisons though? Try these:
206
+
207
+ # 'gt' means greater-than. We also do 'lt'.
208
+ Person.all(:age.gt => 30)
209
+
210
+ # 'gte' means greather-than-or-equal-to. We also do 'lte'.
211
+ Person.all(:age.gte => 30)
212
+
213
+ # 'not' allows you to match all people without the name "bob"
214
+ Person.all(:name.not => 'bob')
215
+
216
+ # If the value of a pair is an Array, we do an IN-clause for you.
217
+ Person.all(:name.like => 'S%', :id => [ 1, 2, 3, 4, 5 ])
218
+
219
+ # Does a NOT IN () clause for you.
220
+ Person.all(:name.not => [ 'bob', 'rick', 'steve' ])
221
+
222
+ See? Fewer SQL fragments dirtying your Ruby code. And that's just a few of the
223
+ nice syntax tweaks DataMapper delivers out of the box...
224
+
225
+ == Note on Patches/Pull Requests
226
+
227
+ * Fork the project.
228
+ * Make your feature addition or bug fix.
229
+ * Add tests for it. This is important so I don't break it in a
230
+ future version unintentionally.
231
+ * Commit, do not mess with rakefile, version, or history.
232
+ (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)
233
+ * Send me a pull request. Bonus points for topic branches.
234
+
235
+ == Copyright
236
+
237
+ Copyright (c) 2011 Dan Kubb. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ FileList['tasks/**/*.rake'].each { |task| import task }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.2.0
data/ardm-core.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/dm-core/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "ardm-core"
6
+ s.version = DataMapper::VERSION
7
+
8
+ s.summary = "Ardm fork of dm-core"
9
+ s.description = s.summary
10
+
11
+ s.authors = [ "Martin Emde", "Dan Kubb" ]
12
+ s.email = [ "me@martinemde.com", "dan.kubb@gmail.com" ]
13
+ s.homepage = "https://github.com/ar-dm/ardm-core"
14
+ s.license = "MIT"
15
+
16
+ s.require_paths = [ "lib" ]
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- spec/*`.split("\n")
19
+ s.extra_rdoc_files = %w[LICENSE README.rdoc]
20
+
21
+ s.add_dependency('addressable', "~> 2.3")
22
+
23
+ s.add_development_dependency('rake', '~> 0.9')
24
+ s.add_development_dependency('rspec', '~> 1.3')
25
+ end