mack-data_mapper 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/idna.rb +0 -0
  2. data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/uri.rb +62 -21
  3. data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/version.rb +1 -1
  4. data/lib/gems/addressable-2.0.1/tasks/clobber.rake +2 -0
  5. data/lib/gems/addressable-2.0.1/tasks/gem.rake +68 -0
  6. data/lib/gems/addressable-2.0.1/tasks/git.rake +40 -0
  7. data/lib/gems/addressable-2.0.1/tasks/metrics.rake +22 -0
  8. data/lib/gems/addressable-2.0.1/tasks/rdoc.rake +29 -0
  9. data/lib/gems/addressable-2.0.1/tasks/rubyforge.rake +89 -0
  10. data/lib/gems/addressable-2.0.1/tasks/spec.rake +64 -0
  11. data/lib/gems/data_objects-0.9.10.1/lib/data_objects.rb +46 -0
  12. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/command.rb +30 -0
  13. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/connection.rb +107 -0
  14. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/field.rb +19 -0
  15. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/logger.rb +233 -0
  16. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/quoting.rb +103 -0
  17. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/reader.rb +22 -0
  18. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/result.rb +13 -0
  19. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb +45 -0
  20. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/uri.rb +34 -0
  21. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/version.rb +3 -0
  22. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates.rb +1 -1
  23. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/adapters/data_objects_adapter.rb +0 -0
  24. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/aggregate_functions.rb +0 -0
  25. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/collection.rb +4 -0
  26. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/model.rb +4 -0
  27. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/repository.rb +0 -0
  28. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/support/symbol.rb +0 -0
  29. data/lib/gems/dm-aggregates-0.9.9/lib/dm-aggregates/version.rb +5 -0
  30. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core.rb +5 -5
  31. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters.rb +0 -0
  32. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/abstract_adapter.rb +0 -0
  33. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/data_objects_adapter.rb +1 -1
  34. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/in_memory_adapter.rb +0 -0
  35. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/mysql_adapter.rb +1 -1
  36. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/postgres_adapter.rb +1 -1
  37. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/sqlite3_adapter.rb +1 -1
  38. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations.rb +0 -0
  39. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/many_to_many.rb +0 -0
  40. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/many_to_one.rb +1 -1
  41. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/one_to_many.rb +3 -6
  42. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/one_to_one.rb +0 -0
  43. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/relationship.rb +0 -0
  44. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/relationship_chain.rb +0 -0
  45. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/auto_migrations.rb +0 -0
  46. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/collection.rb +26 -0
  47. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/dependency_queue.rb +0 -0
  48. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/hook.rb +0 -0
  49. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/identity_map.rb +0 -0
  50. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/is.rb +0 -0
  51. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/logger.rb +0 -0
  52. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/migrations/destructive_migrations.rb +0 -0
  53. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/migrator.rb +0 -0
  54. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/model.rb +29 -3
  55. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/naming_conventions.rb +0 -0
  56. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/property.rb +13 -0
  57. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/property_set.rb +0 -0
  58. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/query.rb +51 -3
  59. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/repository.rb +8 -0
  60. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/resource.rb +19 -6
  61. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/scope.rb +0 -0
  62. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support.rb +0 -0
  63. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/array.rb +0 -0
  64. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/assertions.rb +0 -0
  65. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/errors.rb +0 -0
  66. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/kernel.rb +0 -0
  67. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/symbol.rb +0 -0
  68. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/transaction.rb +0 -0
  69. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/type.rb +0 -0
  70. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/type_map.rb +0 -0
  71. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types.rb +0 -0
  72. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/boolean.rb +0 -0
  73. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/discriminator.rb +0 -0
  74. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/object.rb +0 -0
  75. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/paranoid_boolean.rb +0 -0
  76. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/paranoid_datetime.rb +0 -0
  77. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/serial.rb +0 -0
  78. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/text.rb +0 -0
  79. data/lib/gems/dm-core-0.9.9/lib/dm-core/version.rb +3 -0
  80. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/dm-migrations.rb +0 -0
  81. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/dm-migrations/version.rb +1 -1
  82. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/migration.rb +5 -3
  83. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/migration_runner.rb +0 -0
  84. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/spec/example/migration_example_group.rb +0 -0
  85. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/spec/matchers/migration_matchers.rb +0 -0
  86. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql.rb +0 -0
  87. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/column.rb +0 -0
  88. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/mysql.rb +0 -0
  89. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/postgresql.rb +0 -0
  90. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/sqlite3.rb +0 -0
  91. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table.rb +0 -0
  92. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table_creator.rb +0 -0
  93. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table_modifier.rb +0 -0
  94. data/lib/gems/dm-migrations-0.9.9/tasks/db.rb +22 -0
  95. data/lib/gems/dm-migrations-0.9.9/tasks/install.rb +13 -0
  96. data/lib/gems/dm-migrations-0.9.9/tasks/spec.rb +25 -0
  97. data/lib/gems/{dm-observer-0.9.7 → dm-observer-0.9.9}/lib/dm-observer.rb +1 -1
  98. data/lib/gems/{dm-observer-0.9.7 → dm-observer-0.9.9}/lib/dm-observer/version.rb +1 -1
  99. data/lib/gems/dm-observer-0.9.9/tasks/install.rb +13 -0
  100. data/lib/gems/dm-observer-0.9.9/tasks/spec.rb +25 -0
  101. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer.rb +4 -0
  102. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/common.rb +24 -0
  103. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_csv.rb +35 -0
  104. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_json.rb +73 -0
  105. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_xml.rb +61 -0
  106. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_yaml.rb +48 -0
  107. data/lib/gems/{dm-serializer-0.9.7 → dm-serializer-0.9.9}/lib/dm-serializer/version.rb +1 -1
  108. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers.rb +17 -0
  109. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/libxml.rb +29 -0
  110. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/nokogiri.rb +28 -0
  111. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/rexml.rb +23 -0
  112. data/lib/gems/dm-serializer-0.9.9/tasks/install.rb +13 -0
  113. data/lib/gems/dm-serializer-0.9.9/tasks/spec.rb +25 -0
  114. data/lib/gems/dm-timestamps-0.9.9/lib/dm-timestamps.rb +58 -0
  115. data/lib/gems/{dm-timestamps-0.9.7 → dm-timestamps-0.9.9}/lib/dm-timestamps/version.rb +1 -1
  116. data/lib/gems/dm-timestamps-0.9.9/tasks/install.rb +13 -0
  117. data/lib/gems/dm-timestamps-0.9.9/tasks/spec.rb +25 -0
  118. data/lib/gems/dm-types-0.9.9/lib/dm-types.rb +26 -0
  119. data/lib/gems/dm-types-0.9.9/lib/dm-types/bcrypt_hash.rb +33 -0
  120. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/csv.rb +0 -0
  121. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/enum.rb +4 -4
  122. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/epoch_time.rb +0 -0
  123. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/file_path.rb +0 -0
  124. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/flag.rb +0 -0
  125. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/ip_address.rb +0 -0
  126. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/json.rb +3 -6
  127. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/regexp.rb +0 -0
  128. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/serial.rb +0 -0
  129. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/slug.rb +0 -0
  130. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/uri.rb +2 -0
  131. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/uuid.rb +3 -0
  132. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/version.rb +1 -1
  133. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/yaml.rb +1 -2
  134. data/lib/gems/dm-types-0.9.9/tasks/install.rb +13 -0
  135. data/lib/gems/dm-types-0.9.9/tasks/spec.rb +25 -0
  136. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations.rb +1 -1
  137. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/absent_field_validator.rb +0 -0
  138. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/acceptance_validator.rb +0 -0
  139. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/auto_validate.rb +0 -0
  140. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/block_validator.rb +0 -0
  141. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/confirmation_validator.rb +0 -0
  142. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/contextual_validators.rb +2 -3
  143. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/custom_validator.rb +0 -0
  144. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/format_validator.rb +0 -0
  145. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/formats/email.rb +1 -0
  146. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/formats/url.rb +0 -0
  147. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/generic_validator.rb +0 -0
  148. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/length_validator.rb +0 -0
  149. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/method_validator.rb +0 -0
  150. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/numeric_validator.rb +0 -0
  151. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/primitive_validator.rb +0 -0
  152. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/required_field_validator.rb +0 -0
  153. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/support/object.rb +0 -0
  154. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/uniqueness_validator.rb +1 -1
  155. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/validation_errors.rb +0 -0
  156. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/version.rb +1 -1
  157. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/within_validator.rb +0 -0
  158. data/lib/gems/dm-validations-0.9.9/tasks/install.rb +13 -0
  159. data/lib/gems/dm-validations-0.9.9/tasks/spec.rb +25 -0
  160. data/lib/gems/json_pure-1.1.3/tools/fuzz.rb +140 -0
  161. data/lib/gems/json_pure-1.1.3/tools/server.rb +62 -0
  162. data/lib/mack-data_mapper/dm_patches/migrations.rb +22 -1
  163. data/lib/mack-data_mapper/migration_generator/templates/db/migrations/%=@migration_name%.rb.template +1 -1
  164. metadata +216 -172
  165. data/lib/gems/dm-aggregates-0.9.7/lib/dm-aggregates/version.rb +0 -7
  166. data/lib/gems/dm-core-0.9.7/lib/dm-core/version.rb +0 -3
  167. data/lib/gems/dm-core-0.9.7/script/all +0 -5
  168. data/lib/gems/dm-core-0.9.7/script/performance.rb +0 -284
  169. data/lib/gems/dm-core-0.9.7/script/profile.rb +0 -87
  170. data/lib/gems/dm-serializer-0.9.7/lib/dm-serializer.rb +0 -183
  171. data/lib/gems/dm-timestamps-0.9.7/lib/dm-timestamps.rb +0 -57
  172. data/lib/gems/dm-types-0.9.7/lib/dm-types.rb +0 -28
  173. data/lib/gems/dm-types-0.9.7/lib/dm-types/bcrypt_hash.rb +0 -31
  174. data/lib/gems/json_pure-1.1.3/GPL +0 -340
  175. data/lib/gems/uuidtools-1.0.3/lib/uuidtools.rb +0 -648
  176. data/lib/gems/uuidtools-1.0.3/lib/uuidtools/version.rb +0 -32
@@ -0,0 +1,22 @@
1
+ module DataObjects
2
+ class Reader
3
+
4
+ def fields
5
+ raise NotImplementedError.new
6
+ end
7
+
8
+ def values
9
+ raise NotImplementedError.new
10
+ end
11
+
12
+ def close
13
+ raise NotImplementedError.new
14
+ end
15
+
16
+ # Moves the cursor forward.
17
+ def next!
18
+ raise NotImplementedError.new
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ module DataObjects
2
+ class Result
3
+ attr_accessor :insert_id, :affected_rows
4
+
5
+ def initialize(command, affected_rows, insert_id = nil)
6
+ @command, @affected_rows, @insert_id = command, affected_rows, insert_id
7
+ end
8
+
9
+ def to_i
10
+ @affected_rows
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,45 @@
1
+ require 'digest'
2
+ require 'digest/sha2'
3
+
4
+ module DataObjects
5
+
6
+ class Transaction
7
+
8
+ HOST = "#{Socket::gethostbyname(Socket::gethostname)[0]}" rescue "localhost"
9
+ @@counter = 0
10
+
11
+ attr_reader :connection
12
+ attr_reader :id
13
+
14
+ def self.create_for_uri(uri)
15
+ uri = uri.is_a?(String) ? URI::parse(uri) : uri
16
+ DataObjects.const_get(uri.scheme.capitalize)::Transaction.new(uri)
17
+ end
18
+
19
+ #
20
+ # Creates a Transaction bound to the given connection
21
+ #
22
+ # ==== Parameters
23
+ # conn<DataObjects::Connection>:: The Connection to bind the new Transaction to
24
+ #
25
+ def initialize(uri)
26
+ @connection = DataObjects::Connection.new(uri)
27
+ @id = Digest::SHA256.hexdigest("#{HOST}:#{$$}:#{Time.now.to_f}:#{@@counter += 1}")
28
+ end
29
+
30
+ def close
31
+ @connection.close
32
+ end
33
+
34
+ [:begin, :commit, :rollback, :rollback_prepared, :prepare].each do |method_name|
35
+
36
+ eval <<EOF
37
+ def #{method_name}
38
+ raise NotImplementedError
39
+ end
40
+ EOF
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,34 @@
1
+ gem 'addressable', '~>2.0'
2
+ require 'addressable/uri'
3
+
4
+ module DataObjects
5
+ URI = Struct.new(:scheme, :user, :password, :host, :port, :path, :query, :fragment)
6
+
7
+ class URI
8
+ def self.parse(uri)
9
+ return uri if uri.kind_of?(self)
10
+ uri = Addressable::URI::parse(uri) unless uri.kind_of?(Addressable::URI)
11
+ self.new(uri.scheme, uri.user, uri.password, uri.host, uri.port, uri.path, uri.query_values, uri.fragment)
12
+ end
13
+
14
+ def to_s
15
+ string = ""
16
+ string << "#{scheme}://" if scheme
17
+ if user
18
+ string << "#{user}"
19
+ string << ":#{password}" if password
20
+ string << "@"
21
+ end
22
+ string << "#{host}" if host
23
+ string << ":#{port}" if port
24
+ string << path.to_s
25
+ if query
26
+ string << "?" << query.map do |key, value|
27
+ "#{key}=#{value}"
28
+ end.join("&")
29
+ end
30
+ string << "##{fragment}" if fragment
31
+ string
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module DataObjects
2
+ VERSION = "0.9.10.1" unless defined?(DataObjects::VERSION)
3
+ end
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  dir = Pathname(__FILE__).dirname.expand_path + 'dm-aggregates'
4
4
 
5
5
  require dir + 'version'
6
- gem 'dm-core', DataMapper::More::Aggregates::VERSION
6
+ gem 'dm-core', '~>0.9.9'
7
7
  require 'dm-core'
8
8
 
9
9
 
@@ -2,6 +2,10 @@ module DataMapper
2
2
  class Collection
3
3
  include AggregateFunctions
4
4
 
5
+ # def size
6
+ # loaded? ? super : count
7
+ # end
8
+
5
9
  private
6
10
 
7
11
  def property_by_name(property_name)
@@ -2,6 +2,10 @@ module DataMapper
2
2
  module Model
3
3
  include AggregateFunctions
4
4
 
5
+ # def size
6
+ # count
7
+ # end
8
+
5
9
  private
6
10
 
7
11
  def property_by_name(property_name)
@@ -0,0 +1,5 @@
1
+ module DataMapper
2
+ module Aggregates
3
+ VERSION = '0.9.9'
4
+ end
5
+ end
@@ -11,20 +11,20 @@
11
11
 
12
12
  require 'date'
13
13
  require 'pathname'
14
+ require 'rubygems'
14
15
  require 'set'
15
16
  require 'time'
16
17
  require 'yaml'
17
18
 
18
- require 'rubygems'
19
-
20
- gem 'addressable', '~>2.0'
19
+ gem 'addressable', '~>2.0.1'
21
20
  require 'addressable/uri'
22
21
 
23
- gem 'extlib', '~>0.9.8'
22
+ gem 'extlib', '~>0.9.9'
24
23
  require 'extlib'
25
- require "extlib/inflection"
24
+ require 'extlib/inflection'
26
25
 
27
26
  begin
27
+ gem 'fastthread', '~>1.0.1'
28
28
  require 'fastthread'
29
29
  rescue LoadError
30
30
  # fastthread not installed
@@ -1,4 +1,4 @@
1
- gem 'data_objects', '~>0.9.7'
1
+ gem 'data_objects', '~>0.9.10'
2
2
  require 'data_objects'
3
3
 
4
4
  module DataMapper
@@ -1,4 +1,4 @@
1
- gem 'do_mysql', '~>0.9.7'
1
+ gem 'do_mysql', '~>0.9.10'
2
2
  require 'do_mysql'
3
3
 
4
4
  module DataMapper
@@ -1,4 +1,4 @@
1
- gem 'do_postgres', '~>0.9.7'
1
+ gem 'do_postgres', '~>0.9.10'
2
2
  require 'do_postgres'
3
3
 
4
4
  module DataMapper
@@ -1,4 +1,4 @@
1
- gem 'do_sqlite3', '~>0.9.7'
1
+ gem 'do_sqlite3', '~>0.9.10'
2
2
  require 'do_sqlite3'
3
3
 
4
4
  module DataMapper
@@ -48,7 +48,7 @@ module DataMapper
48
48
  class Proxy
49
49
  include Assertions
50
50
 
51
- instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m) }
51
+ instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }
52
52
 
53
53
  def replace(parent)
54
54
  @parent = parent
@@ -72,7 +72,7 @@ module DataMapper
72
72
  class Proxy
73
73
  include Assertions
74
74
 
75
- instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m) }
75
+ instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }
76
76
 
77
77
  # FIXME: remove when RelationshipChain#get_children can return a Collection
78
78
  def all(query = {})
@@ -306,11 +306,8 @@ module DataMapper
306
306
  end
307
307
 
308
308
  def method_missing(method, *args, &block)
309
- results = children.__send__(method, *args, &block) if children.respond_to?(method)
310
-
311
- return self if LazyArray::RETURN_SELF.include?(method) && results.kind_of?(Array)
312
-
313
- results
309
+ results = children.send(method, *args, &block)
310
+ results.equal?(children) ? self : results
314
311
  end
315
312
  end # class Proxy
316
313
  end # module OneToMany
@@ -494,6 +494,32 @@ module DataMapper
494
494
  super || model.public_methods(false).include?(method.to_s) || relationships.has_key?(method)
495
495
  end
496
496
 
497
+ # TODO: add docs
498
+ # @api private
499
+ def _dump(*)
500
+ Marshal.dump([ query, to_a ])
501
+ end
502
+
503
+ # TODO: add docs
504
+ # @api private
505
+ def self._load(marshalled)
506
+ query, array = Marshal.load(marshalled)
507
+
508
+ # XXX: IMHO it is a code smell to be forced to use allocate
509
+ # and instance_variable_set to load an object. You should
510
+ # be able to use a constructor to provide all the info needed
511
+ # to initialize an object. This should be fixed in the edge
512
+ # branch dkubb/dm-core
513
+
514
+ collection = allocate
515
+ collection.instance_variable_set(:@query, query)
516
+ collection.instance_variable_set(:@array, array)
517
+ collection.instance_variable_set(:@loaded, true)
518
+ collection.instance_variable_set(:@key_properties, collection.send(:model).key(collection.repository.name))
519
+ collection.instance_variable_set(:@cache, {})
520
+ collection
521
+ end
522
+
497
523
  protected
498
524
 
499
525
  ##
@@ -306,11 +306,30 @@ module DataMapper
306
306
  resource
307
307
  end
308
308
 
309
- # TODO SPEC
309
+ ##
310
+ # Copy a set of records from one repository to another.
311
+ #
312
+ # @param [String] source
313
+ # The name of the Repository the resources should be copied _from_
314
+ # @param [String] destination
315
+ # The name of the Repository the resources should be copied _to_
316
+ # @param [Hash] query
317
+ # The conditions with which to find the records to copy. These
318
+ # conditions are merged with Model.query
319
+ #
320
+ # @return [DataMapper::Collection]
321
+ # A Collection of the Resource instances created in the operation
322
+ #
323
+ # @api public
310
324
  def copy(source, destination, query = {})
325
+
326
+ # get the list of properties that exist in the source and destination
327
+ destination_properties = properties(destination)
328
+ fields = query[:fields] ||= properties(source).select { |p| destination_properties.has_property?(p.name) }
329
+
311
330
  repository(destination) do
312
- repository(source).read_many(scoped_query(query)).each do |resource|
313
- self.create(resource.attributes)
331
+ all(query.merge(:repository => repository(source))).map do |resource|
332
+ create(fields.map { |p| [ p.name, p.get(resource) ] }.to_hash)
314
333
  end
315
334
  end
316
335
  end
@@ -366,6 +385,13 @@ module DataMapper
366
385
  Query.new(repository, self, query.merge(conditions))
367
386
  end
368
387
 
388
+ # TODO: add docs
389
+ # @api private
390
+ def _load(marshalled)
391
+ repository_name, attributes = Marshal.load(marshalled)
392
+ repository(repository_name) { new(attributes) }
393
+ end
394
+
369
395
  def typecast_key(key)
370
396
  self.key(repository_name).zip(key).map { |k, v| k.typecast(v) }
371
397
  end
@@ -512,6 +512,19 @@ module DataMapper
512
512
  "#<Property:#{@model}:#{@name}>"
513
513
  end
514
514
 
515
+ # TODO: add docs
516
+ # @api private
517
+ def _dump(*)
518
+ Marshal.dump([ repository, model, name ])
519
+ end
520
+
521
+ # TODO: add docs
522
+ # @api private
523
+ def self._load(marshalled)
524
+ repository, model, name = Marshal.load(marshalled)
525
+ model.properties(repository.name)[name]
526
+ end
527
+
515
528
  private
516
529
 
517
530
  def initialize(model, name, type, options = {})
@@ -51,11 +51,10 @@ module DataMapper
51
51
  @limit = other.limit unless other.limit == nil
52
52
  @order = other.order unless other.order == model.default_order
53
53
  @add_reversed = other.add_reversed? unless other.add_reversed? == false
54
+ @fields = other.fields unless other.fields == @properties.defaults
54
55
  @links = other.links unless other.links == []
55
56
  @includes = other.includes unless other.includes == []
56
57
 
57
- @fields == @properties.defaults ? @fields = other.fields : @fields |= other.fields
58
-
59
58
  update_conditions(other)
60
59
 
61
60
  self
@@ -152,6 +151,55 @@ module DataMapper
152
151
  "#<#{self.class.name} #{attrs.map { |(k,v)| "@#{k}=#{v.inspect}" } * ' '}>"
153
152
  end
154
153
 
154
+ # TODO: add docs
155
+ # @api public
156
+ def to_hash
157
+ hash = {
158
+ :reload => reload?,
159
+ :unique => unique?,
160
+ :offset => offset,
161
+ :order => order,
162
+ :add_reversed => add_reversed?,
163
+ :fields => fields,
164
+ }
165
+
166
+ hash[:limit] = limit unless limit == nil
167
+ hash[:links] = links unless links == []
168
+ hash[:includes] = includes unless includes == []
169
+
170
+ conditions = {}
171
+ raw_queries = []
172
+ bind_values = []
173
+
174
+ conditions.each do |condition|
175
+ if condition[0] == :raw
176
+ raw_queries << condition[1]
177
+ bind_values << condition[2]
178
+ else
179
+ operator, property, bind_value = condition
180
+ conditions[ Query::Operator.new(property, operator) ] = bind_value
181
+ end
182
+ end
183
+
184
+ if raw_queries.any?
185
+ hash[:conditions] = [ raw_queries.join(' ') ].concat(bind_values)
186
+ end
187
+
188
+ hash.update(conditions)
189
+ end
190
+
191
+ # TODO: add docs
192
+ # @api private
193
+ def _dump(*)
194
+ Marshal.dump([ repository, model, to_hash ])
195
+ end
196
+
197
+ # TODO: add docs
198
+ # @api private
199
+ def self._load(marshalled)
200
+ new(*Marshal.load(marshalled))
201
+ end
202
+
155
203
  private
156
204
 
157
205
  def initialize(repository, model, options = {})
@@ -574,7 +622,7 @@ module DataMapper
574
622
  class Path
575
623
  include Assertions
576
624
 
577
- %w[ id type ].each { |m| undef_method m }
625
+ instance_methods.each { |m| undef_method m if %w[ id type ].include?(m.to_s) }
578
626
 
579
627
  attr_reader :relationships, :model, :property, :operator
580
628