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,46 @@
1
+ require 'rubygems'
2
+
3
+ gem 'extlib', '~>0.9.8'
4
+ require 'extlib'
5
+
6
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'version'))
7
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'logger'))
8
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'connection'))
9
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'uri'))
10
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'transaction'))
11
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'command'))
12
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'result'))
13
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'reader'))
14
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'field'))
15
+ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'quoting'))
16
+
17
+
18
+ module DataObjects
19
+ class LengthMismatchError < StandardError; end
20
+
21
+ def self.root
22
+ @root ||= Pathname(__FILE__).dirname.parent.expand_path
23
+ end
24
+
25
+ def self.find_const(name)
26
+ klass = Object
27
+ name.to_s.split('::').each do |part|
28
+ klass = klass.const_get(part)
29
+ end
30
+ klass
31
+ end
32
+ end
33
+
34
+ # class ConnectionFailed < StandardError; end
35
+ #
36
+ # class ReaderClosed < StandardError; end
37
+ #
38
+ # class ReaderError < StandardError; end
39
+ #
40
+ # class QueryError < StandardError; end
41
+ #
42
+ # class NoInsertError < StandardError; end
43
+ #
44
+ # class LostConnectionError < StandardError; end
45
+ #
46
+ # class UnknownError < StandardError; end
@@ -0,0 +1,30 @@
1
+ module DataObjects
2
+ class Command
3
+
4
+ attr_reader :connection
5
+
6
+ # initialize creates a new Command object
7
+ def initialize(connection, text)
8
+ raise ArgumentError.new("+connection+ must be a DataObjects::Connection") unless DataObjects::Connection === connection
9
+ @connection, @text = connection, text
10
+ end
11
+
12
+ def execute_non_query(*args)
13
+ raise NotImplementedError.new
14
+ end
15
+
16
+ def execute_reader(*args)
17
+ raise NotImplementedError.new
18
+ end
19
+
20
+ def set_types(column_types)
21
+ raise NotImplementedError.new
22
+ end
23
+
24
+ def to_s
25
+ @text
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,107 @@
1
+ require 'set'
2
+
3
+ begin
4
+ require 'fastthread'
5
+ rescue LoadError
6
+ end
7
+
8
+ module DataObjects
9
+ class Connection
10
+
11
+ def self.new(uri_s)
12
+ uri = DataObjects::URI::parse(uri_s)
13
+
14
+ case uri.scheme.to_sym
15
+ when :java
16
+ warn 'JNDI URLs (connection strings) are only for use with JRuby' unless RUBY_PLATFORM =~ /java/
17
+ # TODO: handle jndi connection strings
18
+ when :jdbc
19
+ warn 'JDBC URLs (connection strings) are only for use with JRuby' unless RUBY_PLATFORM =~ /java/
20
+
21
+ driver_name = if uri.path.split(':').first == 'sqlite'
22
+ 'sqlite3'
23
+ elsif uri.path.split(':').first == 'postgresql'
24
+ 'postgres'
25
+ else
26
+ uri.path.split(':').first
27
+ end
28
+
29
+ conn_uri = uri_s # NOTE: for now, do not reformat this JDBC connection
30
+ # string -- or, in other words, do not let
31
+ # DataObjects::URI#to_s be called -- as it is not
32
+ # correctly handling JDBC URLs, and in doing so, causing
33
+ # java.sql.DriverManager.getConnection to throw a
34
+ # 'No suitable driver found for...' exception.
35
+ else
36
+ driver_name = uri.scheme
37
+ conn_uri = uri
38
+ end
39
+
40
+ DataObjects.const_get(driver_name.capitalize)::Connection.new(conn_uri)
41
+ end
42
+
43
+ def self.inherited(target)
44
+ target.class_eval do
45
+
46
+ def self.new(*args)
47
+ instance = allocate
48
+ instance.send(:initialize, *args)
49
+ instance
50
+ end
51
+
52
+ include Extlib::Pooling
53
+ alias close release
54
+ end
55
+
56
+ if driver_module_name = target.name.split('::')[-2]
57
+ driver_module = DataObjects::const_get(driver_module_name)
58
+ driver_module.class_eval <<-EOS, __FILE__, __LINE__
59
+ def self.logger
60
+ @logger
61
+ end
62
+
63
+ def self.logger=(logger)
64
+ @logger = logger
65
+ end
66
+ EOS
67
+
68
+ driver_module.logger = DataObjects::Logger.new(nil, :off)
69
+ end
70
+ end
71
+
72
+ #####################################################
73
+ # Standard API Definition
74
+ #####################################################
75
+ def to_s
76
+ @uri.to_s
77
+ end
78
+
79
+ def initialize(uri)
80
+ raise NotImplementedError.new
81
+ end
82
+
83
+ def dispose
84
+ raise NotImplementedError.new
85
+ end
86
+
87
+ def create_command(text)
88
+ concrete_command.new(self, text)
89
+ end
90
+
91
+ private
92
+ def concrete_command
93
+ @concrete_command || begin
94
+
95
+ class << self
96
+ private
97
+ def concrete_command
98
+ @concrete_command
99
+ end
100
+ end
101
+
102
+ @concrete_command = DataObjects::const_get(self.class.name.split('::')[-2]).const_get('Command')
103
+ end
104
+ end
105
+
106
+ end
107
+ end
@@ -0,0 +1,19 @@
1
+ module DataObjects
2
+
3
+ class Field
4
+
5
+ def initialize(name, type)
6
+ @name, @type = name, type
7
+ end
8
+
9
+ def name
10
+ @name
11
+ end
12
+
13
+ def type
14
+ @type
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,233 @@
1
+ require "time" # httpdate
2
+ # ==== Public DataObjects Logger API
3
+ #
4
+ # Logger taken from Merb :)
5
+ #
6
+ # To replace an existing logger with a new one:
7
+ # DataObjects::Logger.set_log(log{String, IO},level{Symbol, String})
8
+ #
9
+ # Available logging levels are
10
+ # DataObjects::Logger::{ Fatal, Error, Warn, Info, Debug }
11
+ #
12
+ # Logging via:
13
+ # DataObjects.logger.fatal(message<String>)
14
+ # DataObjects.logger.error(message<String>)
15
+ # DataObjects.logger.warn(message<String>)
16
+ # DataObjects.logger.info(message<String>)
17
+ # DataObjects.logger.debug(message<String>)
18
+ #
19
+ # Flush the buffer to
20
+ # DataObjects.logger.flush
21
+ #
22
+ # Remove the current log object
23
+ # DataObjects.logger.close
24
+ #
25
+ # ==== Private DataObjects Logger API
26
+ #
27
+ # To initialize the logger you create a new object, proxies to set_log.
28
+ # DataObjects::Logger.new(log{String, IO},level{Symbol, String})
29
+ #
30
+ # Logger will not create the file until something is actually logged
31
+ # This avoids file creation on DataObjects init when it creates the
32
+ # default logger.
33
+ module DataObjects
34
+
35
+ class << self #:nodoc:
36
+ attr_accessor :logger
37
+ end
38
+
39
+ class Logger
40
+
41
+ attr_accessor :aio
42
+ attr_accessor :delimiter
43
+ attr_reader :level
44
+ attr_reader :buffer
45
+ attr_reader :log
46
+
47
+ # @note
48
+ # Ruby (standard) logger levels:
49
+ # off: absolutely nothing
50
+ # fatal: an unhandleable error that results in a program crash
51
+ # error: a handleable error condition
52
+ # warn: a warning
53
+ # info: generic (useful) information about system operation
54
+ # debug: low-level information for developers
55
+ #
56
+ # DataObjects::Logger::LEVELS[:off, :fatal, :error, :warn, :info, :debug]
57
+ LEVELS =
58
+ {
59
+ :off => 99999,
60
+ :fatal => 7,
61
+ :error => 6,
62
+ :warn => 4,
63
+ :info => 3,
64
+ :debug => 0
65
+ }
66
+
67
+ def level=(new_level)
68
+ @level = LEVELS[new_level.to_sym]
69
+ reset_methods(:close)
70
+ end
71
+
72
+ private
73
+
74
+ # The idea here is that instead of performing an 'if' conditional check on
75
+ # each logging we do it once when the log object is setup
76
+ def set_write_method
77
+ @log.instance_eval do
78
+
79
+ # Determine if asynchronous IO can be used
80
+ def aio?
81
+ @aio = !RUBY_PLATFORM.match(/java|mswin/) &&
82
+ !(@log == STDOUT) &&
83
+ @log.respond_to?(:write_nonblock)
84
+ end
85
+
86
+ # Define the write method based on if aio an be used
87
+ undef write_method if defined? write_method
88
+ if aio?
89
+ alias :write_method :write_nonblock
90
+ else
91
+ alias :write_method :write
92
+ end
93
+ end
94
+ end
95
+
96
+ def initialize_log(log)
97
+ close if @log # be sure that we don't leave open files laying around.
98
+ @log = log || "log/dm.log"
99
+ end
100
+
101
+ def reset_methods(o_or_c)
102
+ if o_or_c == :open
103
+ alias internal_push push_opened
104
+ elsif o_or_c == :close
105
+ alias internal_push push_closed
106
+ end
107
+ end
108
+
109
+ def push_opened(string)
110
+ message = Time.now.httpdate
111
+ message << delimiter
112
+ message << string
113
+ message << "\n" unless message[-1] == ?\n
114
+ @buffer << message
115
+ flush # Force a flush for now until we figure out where we want to use the buffering.
116
+ end
117
+
118
+ def push_closed(string)
119
+ unless @log.respond_to?(:write)
120
+ log = Pathname(@log)
121
+ log.dirname.mkpath
122
+ @log = log.open('a')
123
+ @log.sync = true
124
+ end
125
+ set_write_method
126
+ reset_methods(:open)
127
+ push(string)
128
+ end
129
+
130
+ alias internal_push push_closed
131
+
132
+ def prep_msg(message, level)
133
+ level << delimiter << message
134
+ end
135
+
136
+ public
137
+
138
+ # To initialize the logger you create a new object, proxies to set_log.
139
+ # DataObjects::Logger.new(log{String, IO},level{Symbol, String})
140
+ #
141
+ # @param log<IO,String> either an IO object or a name of a logfile.
142
+ # @param log_level<String> the message string to be logged
143
+ # @param delimiter<String> delimiter to use between message sections
144
+ # @param log_creation<Boolean> log that the file is being created
145
+ def initialize(*args)
146
+ set_log(*args)
147
+ end
148
+
149
+ # To replace an existing logger with a new one:
150
+ # DataObjects::Logger.set_log(log{String, IO},level{Symbol, String})
151
+ #
152
+ #
153
+ # @param log<IO,String> either an IO object or a name of a logfile.
154
+ # @param log_level<Symbol> a symbol representing the log level from
155
+ # {:off, :fatal, :error, :warn, :info, :debug}
156
+ # @param delimiter<String> delimiter to use between message sections
157
+ # @param log_creation<Boolean> log that the file is being created
158
+ def set_log(log, log_level = :off, delimiter = " ~ ", log_creation = false)
159
+ delimiter ||= " ~ "
160
+
161
+ if log_level && LEVELS[log_level.to_sym]
162
+ self.level = log_level.to_sym
163
+ else
164
+ self.level = :debug
165
+ end
166
+
167
+ @buffer = []
168
+ @delimiter = delimiter
169
+
170
+ initialize_log(log)
171
+
172
+ DataObjects.logger = self
173
+
174
+ self.info("Logfile created") if log_creation
175
+ end
176
+
177
+ # Flush the entire buffer to the log object.
178
+ # DataObjects.logger.flush
179
+ #
180
+ def flush
181
+ return unless @buffer.size > 0
182
+ @log.write_method(@buffer.slice!(0..-1).to_s)
183
+ end
184
+
185
+ # Close and remove the current log object.
186
+ # DataObjects.logger.close
187
+ #
188
+ def close
189
+ flush
190
+ @log.close if @log.respond_to?(:close)
191
+ @log = nil
192
+ end
193
+
194
+ # Appends a string and log level to logger's buffer.
195
+
196
+ # @note
197
+ # Note that the string is discarded if the string's log level less than the
198
+ # logger's log level.
199
+ # @note
200
+ # Note that if the logger is aio capable then the logger will use
201
+ # non-blocking asynchronous writes.
202
+ #
203
+ # @param level<Fixnum> the logging level as an integer
204
+ # @param string<String> the message string to be logged
205
+ def push(string)
206
+ internal_push(string)
207
+ end
208
+ alias << push
209
+
210
+ # Generate the following logging methods for DataObjects.logger as described
211
+ # in the API:
212
+ # :fatal, :error, :warn, :info, :debug
213
+ # :off only gets an off? method
214
+ LEVELS.each_pair do |name, number|
215
+ unless name.to_sym == :off
216
+ class_eval <<-EOS, __FILE__, __LINE__
217
+ # DOC
218
+ def #{name}(message)
219
+ self.<<( prep_msg(message, "#{name}") ) if #{name}?
220
+ end
221
+ EOS
222
+ end
223
+
224
+ class_eval <<-EOS, __FILE__, __LINE__
225
+ # DOC
226
+ def #{name}?
227
+ #{number} >= level
228
+ end
229
+ EOS
230
+ end
231
+
232
+ end # class Logger
233
+ end # module DataObjects
@@ -0,0 +1,103 @@
1
+ module DataObjects
2
+
3
+ module Quoting
4
+ # Escape a string of SQL with a set of arguments.
5
+ # The first argument is assumed to be the SQL to escape,
6
+ # the remaining arguments (if any) are assumed to be
7
+ # values to escape and interpolate.
8
+ #
9
+ # ==== Examples
10
+ # escape_sql("SELECT * FROM zoos")
11
+ # # => "SELECT * FROM zoos"
12
+ #
13
+ # escape_sql("SELECT * FROM zoos WHERE name = ?", "Dallas")
14
+ # # => "SELECT * FROM zoos WHERE name = `Dallas`"
15
+ #
16
+ # escape_sql("SELECT * FROM zoos WHERE name = ? AND acreage > ?", "Dallas", 40)
17
+ # # => "SELECT * FROM zoos WHERE name = `Dallas` AND acreage > 40"
18
+ #
19
+ # ==== Warning
20
+ # This method is meant mostly for adapters that don't support
21
+ # bind-parameters.
22
+ def escape_sql(args)
23
+ sql = @text.dup
24
+
25
+ unless args.empty?
26
+ sql.gsub!(/\?/) do |x|
27
+ quote_value(args.shift)
28
+ end
29
+ end
30
+
31
+ sql
32
+ end
33
+
34
+ def quote_value(value)
35
+ return 'NULL' if value.nil?
36
+
37
+ case value
38
+ when Numeric then quote_numeric(value)
39
+ when String then quote_string(value)
40
+ when Class then quote_class(value)
41
+ when Time then quote_time(value)
42
+ when DateTime then quote_datetime(value)
43
+ when Date then quote_date(value)
44
+ when TrueClass, FalseClass then quote_boolean(value)
45
+ when Array then quote_array(value)
46
+ when Range then quote_range(value)
47
+ when Symbol then quote_symbol(value)
48
+ when Regexp then quote_regexp(value)
49
+ else
50
+ if value.respond_to?(:to_sql)
51
+ value.to_sql
52
+ else
53
+ raise "Don't know how to quote #{value.inspect}"
54
+ end
55
+ end
56
+ end
57
+
58
+ def quote_symbol(value)
59
+ quote_string(value.to_s)
60
+ end
61
+
62
+ def quote_numeric(value)
63
+ value.to_s
64
+ end
65
+
66
+ def quote_string(value)
67
+ "'#{value.gsub("'", "''")}'"
68
+ end
69
+
70
+ def quote_class(value)
71
+ quote_string(value.name)
72
+ end
73
+
74
+ def quote_time(value)
75
+ "'#{value.strftime('%Y-%m-%d %H:%M:%S')}" + (value.usec > 0 ? ".#{value.usec.to_s.rjust(6, '0')}'" : "'")
76
+ end
77
+
78
+ def quote_datetime(value)
79
+ "'#{value.dup}'"
80
+ end
81
+
82
+ def quote_date(value)
83
+ "'#{value.strftime("%Y-%m-%d")}'"
84
+ end
85
+
86
+ def quote_boolean(value)
87
+ value.to_s.upcase
88
+ end
89
+
90
+ def quote_array(value)
91
+ "(#{value.map { |entry| quote_value(entry) }.join(', ')})"
92
+ end
93
+
94
+ def quote_range(value)
95
+ "#{quote_value(value.first)} AND #{quote_value(value.last)}"
96
+ end
97
+
98
+ def quote_regexp(value)
99
+ quote_string(value.source)
100
+ end
101
+ end
102
+
103
+ end