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
@@ -1,7 +0,0 @@
1
- module DataMapper
2
- module More
3
- module Aggregates
4
- VERSION = "0.9.7"
5
- end
6
- end
7
- end
@@ -1,3 +0,0 @@
1
- module DataMapper
2
- VERSION = '0.9.7' unless defined?(DataMapper::VERSION)
3
- end
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env sh
2
- rake spec:unit
3
- ADAPTER=sqlite3 rake spec:integration
4
- ADAPTER=mysql rake spec:integration
5
- ADAPTER=postgres rake spec:integration
@@ -1,284 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), '..', 'lib', 'dm-core')
4
- require File.join(File.dirname(__FILE__), '..', 'lib', 'dm-core', 'version')
5
-
6
- require 'rubygems'
7
- require 'ftools'
8
-
9
- # sudo gem install rbench
10
- # OR git clone git://github.com/somebee/rbench.git , rake install
11
- gem 'rbench', '>=0.2.2'
12
- require 'rbench'
13
-
14
- gem 'faker', '>=0.3.1'
15
- require 'faker'
16
-
17
- gem 'activerecord', '>=2.1.0'
18
- require 'active_record'
19
-
20
- socket_file = Pathname.glob(%w[
21
- /opt/local/var/run/mysql5/mysqld.sock
22
- tmp/mysqld.sock
23
- /tmp/mysqld.sock
24
- tmp/mysql.sock
25
- /tmp/mysql.sock
26
- /var/mysql/mysql.sock
27
- /var/run/mysqld/mysqld.sock
28
- ]).find { |path| path.socket? }
29
-
30
- configuration_options = {
31
- :adapter => 'mysql',
32
- :username => 'root',
33
- :password => '',
34
- :database => 'data_mapper_1',
35
- }
36
-
37
- configuration_options[:socket] = socket_file unless socket_file.nil?
38
-
39
- log_dir = DataMapper.root / 'log'
40
- log_dir.mkdir unless log_dir.directory?
41
-
42
- DataMapper::Logger.new(log_dir / 'dm.log', :off)
43
- adapter = DataMapper.setup(:default, "mysql://root@localhost/data_mapper_1?socket=#{socket_file}")
44
-
45
- if configuration_options[:adapter]
46
- sqlfile = File.join(File.dirname(__FILE__),'..','tmp','performance.sql')
47
- mysql_bin = %w[mysql mysql5].select{|bin| `which #{bin}`.length > 0 }
48
- mysqldump_bin = %w[mysqldump mysqldump5].select{|bin| `which #{bin}`.length > 0 }
49
- end
50
-
51
- ActiveRecord::Base.logger = Logger.new(log_dir / 'ar.log')
52
- ActiveRecord::Base.logger.level = 0
53
-
54
- ActiveRecord::Base.establish_connection(configuration_options)
55
-
56
- class ARExhibit < ActiveRecord::Base #:nodoc:
57
- set_table_name 'exhibits'
58
-
59
- belongs_to :user, :class_name => 'ARUser', :foreign_key => 'user_id'
60
- end
61
-
62
- class ARUser < ActiveRecord::Base #:nodoc:
63
- set_table_name 'users'
64
-
65
- has_many :exhibits, :foreign_key => 'user_id'
66
-
67
- end
68
-
69
- ARExhibit.find_by_sql('SELECT 1')
70
-
71
- class Exhibit
72
- include DataMapper::Resource
73
-
74
- property :id, Serial
75
- property :name, String
76
- property :zoo_id, Integer
77
- property :user_id, Integer
78
- property :notes, Text, :lazy => true
79
- property :created_on, Date
80
-
81
- belongs_to :user
82
- # property :updated_at, DateTime
83
- end
84
-
85
- class User
86
- include DataMapper::Resource
87
-
88
- property :id, Serial
89
- property :name, String
90
- property :email, String
91
- property :about, Text, :lazy => true
92
- property :created_on, Date
93
-
94
- end
95
-
96
- touch_attributes = lambda do |exhibits|
97
- [*exhibits].each do |exhibit|
98
- exhibit.id
99
- exhibit.name
100
- exhibit.created_on
101
- end
102
- end
103
-
104
- touch_relationships = lambda do |exhibits|
105
- [*exhibits].each do |exhibit|
106
- exhibit.id
107
- exhibit.name
108
- exhibit.created_on
109
- exhibit.user
110
- end
111
- end
112
-
113
-
114
- c = configuration_options
115
-
116
- if sqlfile && File.exists?(sqlfile)
117
- puts "Found data-file. Importing from #{sqlfile}"
118
- #adapter.execute("LOAD DATA LOCAL INFILE '#{sqlfile}' INTO TABLE exhibits")
119
- `#{mysql_bin} -u #{c[:username]} #{"-p#{c[:password]}" unless c[:password].blank?} #{c[:database]} < #{sqlfile}`
120
- else
121
-
122
- puts "Generating data for benchmarking..."
123
-
124
- User.auto_migrate!
125
- Exhibit.auto_migrate!
126
-
127
- users = []
128
- exhibits = []
129
-
130
- # pre-compute the insert statements and fake data compilation,
131
- # so the benchmarks below show the actual runtime for the execute
132
- # method, minus the setup steps
133
-
134
- # Using the same paragraph for all exhibits because it is very slow
135
- # to generate unique paragraphs for all exhibits.
136
- paragraph = Faker::Lorem.paragraphs.join($/)
137
-
138
- 10_000.times do |i|
139
- users << [
140
- 'INSERT INTO `users` (`name`,`email`,`created_on`) VALUES (?, ?, ?)',
141
- Faker::Name.name,
142
- Faker::Internet.email,
143
- Date.today
144
- ]
145
-
146
- exhibits << [
147
- 'INSERT INTO `exhibits` (`name`, `zoo_id`, `user_id`, `notes`, `created_on`) VALUES (?, ?, ?, ?, ?)',
148
- Faker::Company.name,
149
- rand(10).ceil,
150
- i,
151
- paragraph,#Faker::Lorem.paragraphs.join($/),
152
- Date.today
153
- ]
154
- end
155
-
156
- puts "Inserting 10,000 users..."
157
- 10_000.times { |i| adapter.execute(*users.at(i)) }
158
- puts "Inserting 10,000 exhibits..."
159
- 10_000.times { |i| adapter.execute(*exhibits.at(i)) }
160
-
161
- if sqlfile
162
- answer = nil
163
- until answer && answer[/^$|y|yes|n|no/]
164
- print("Would you like to dump data into tmp/performance.sql (for faster setup)? [Yn]");
165
- STDOUT.flush
166
- answer = gets
167
- end
168
-
169
- if answer[/^$|y|yes/]
170
- File.makedirs(File.dirname(sqlfile))
171
- #adapter.execute("SELECT * INTO OUTFILE '#{sqlfile}' FROM exhibits;")
172
- `#{mysqldump_bin} -u #{c[:username]} #{"-p#{c[:password]}" unless c[:password].blank?} #{c[:database]} exhibits users > #{sqlfile}`
173
- puts "File saved\n"
174
- end
175
- end
176
-
177
- end
178
-
179
- TIMES = ENV['x'] ? ENV['x'].to_i : 10_000
180
-
181
- puts "You can specify how many times you want to run the benchmarks with rake:perf x=(number)"
182
- puts "Some tasks will be run 10 and 1000 times less than (number)"
183
- puts "Benchmarks will now run #{TIMES} times"
184
- # Inform about slow benchmark
185
- # answer = nil
186
- # until answer && answer[/^$|y|yes|n|no/]
187
- # print("A slow benchmark exposing problems with SEL is newly added. It takes approx. 20s\n");
188
- # print("you have scheduled it to run #{TIMES / 100} times.\nWould you still include the particular benchmark? [Yn]")
189
- # STDOUT.flush
190
- # answer = gets
191
- # end
192
- # run_rel_bench = answer[/^$|y|yes/] ? true : false
193
-
194
-
195
- RBench.run(TIMES) do
196
-
197
- column :times
198
- column :ar, :title => "AR 2.1"
199
- column :dm, :title => "DM #{DataMapper::VERSION}"
200
- column :diff, :compare => [:ar,:dm]
201
-
202
- report "Model.new (instantiation)" do
203
- ar { ARExhibit.new }
204
- dm { Exhibit.new }
205
- end
206
-
207
- report "Model.new (setting attributes)" do
208
- attrs = {:name => 'sam', :zoo_id => 1}
209
- ar { ARExhibit.new(attrs) }
210
- dm { Exhibit.new(attrs) }
211
- end
212
-
213
- report "Model.get specific (not cached)" do
214
- ActiveRecord::Base.uncached { ar { touch_attributes[ARExhibit.find(1)] } }
215
- dm { touch_attributes[Exhibit.get(1)] }
216
- end
217
-
218
- report "Model.get specific (cached)" do
219
- ActiveRecord::Base.cache { ar { touch_attributes[ARExhibit.find(1)] } }
220
- Exhibit.repository(:default) { dm { touch_attributes[Exhibit.get(1)] } }
221
- end
222
-
223
- report "Model.first" do
224
- ar { touch_attributes[ARExhibit.first] }
225
- dm { touch_attributes[Exhibit.first] }
226
- end
227
-
228
- report "Model.all limit(100)", (TIMES / 10.0).ceil do
229
- ar { touch_attributes[ARExhibit.find(:all, :limit => 100)] }
230
- dm { touch_attributes[Exhibit.all(:limit => 100)] }
231
- end
232
-
233
- report "Model.all limit(100) with relationship", (TIMES / 10.0).ceil do
234
- ar { touch_relationships[ARExhibit.all(:limit => 100, :include => [:user])] }
235
- dm { touch_relationships[Exhibit.all(:limit => 100)] }
236
- end
237
-
238
- report "Model.all limit(10,000)", (TIMES / 1000.0).ceil do
239
- ar { touch_attributes[ARExhibit.find(:all, :limit => 10_000)] }
240
- dm { touch_attributes[Exhibit.all(:limit => 10_000)] }
241
- end
242
-
243
- create_exhibit = {
244
- :name => Faker::Company.name,
245
- :zoo_id => rand(10).ceil,
246
- :notes => Faker::Lorem.paragraphs.join($/),
247
- :created_on => Date.today
248
- }
249
-
250
- report "Model.create" do
251
- ar { ARExhibit.create(create_exhibit) }
252
- dm { Exhibit.create(create_exhibit) }
253
- end
254
-
255
- report "Resource#attributes" do
256
- attrs_first = {:name => 'sam', :zoo_id => 1}
257
- attrs_second = {:name => 'tom', :zoo_id => 1}
258
- ar { e = ARExhibit.new(attrs_first); e.attributes = attrs_second }
259
- dm { e = Exhibit.new(attrs_first); e.attributes = attrs_second }
260
- end
261
-
262
- report "Resource#update" do
263
- ar { e = ARExhibit.find(1); e.name = 'bob'; e.save }
264
- dm { e = Exhibit.get(1); e.name = 'bob'; e.save }
265
- end
266
-
267
- report "Resource#destroy" do
268
- ar { ARExhibit.first.destroy }
269
- dm { Exhibit.first.destroy }
270
- end
271
-
272
- report "Model.transaction" do
273
- ar { ARExhibit.transaction { ARExhibit.new } }
274
- dm { Exhibit.transaction { Exhibit.new } }
275
- end
276
-
277
- summary "Total"
278
- end
279
-
280
- connection = adapter.send(:create_connection)
281
- command = connection.create_command("DROP TABLE exhibits")
282
- command = connection.create_command("DROP TABLE users")
283
- command.execute_non_query rescue nil
284
- connection.close
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.join(File.dirname(__FILE__), '..', 'lib', 'dm-core')
4
-
5
- require 'rubygems'
6
-
7
- gem 'ruby-prof', '>=0.6.0'
8
- require 'ruby-prof'
9
-
10
- gem 'faker', '>=0.3.1'
11
- require 'faker'
12
-
13
- OUTPUT = DataMapper.root / 'profile_results.txt'
14
- #OUTPUT = DataMapper.root / 'profile_results.html'
15
-
16
- SOCKET_FILE = Pathname.glob(%w[
17
- /opt/local/var/run/mysql5/mysqld.sock
18
- /tmp/mysqld.sock
19
- /tmp/mysql.sock
20
- /var/mysql/mysql.sock
21
- /var/run/mysqld/mysqld.sock
22
- ]).find { |path| path.socket? }
23
-
24
- DataMapper::Logger.new(DataMapper.root / 'log' / 'dm.log', :debug)
25
- DataMapper.setup(:default, "mysql://root@localhost/data_mapper_1?socket=#{SOCKET_FILE}")
26
-
27
- class Exhibit
28
- include DataMapper::Resource
29
-
30
- property :id, Serial
31
- property :name, String
32
- property :zoo_id, Integer
33
- property :notes, Text, :lazy => true
34
- property :created_on, Date
35
- # property :updated_at, DateTime
36
-
37
- auto_migrate!
38
- create # create one row for testing
39
- end
40
-
41
- touch_attributes = lambda do |exhibits|
42
- [*exhibits].each do |exhibit|
43
- exhibit.id
44
- exhibit.name
45
- exhibit.created_on
46
- exhibit.updated_at
47
- end
48
- end
49
-
50
- # RubyProf, making profiling Ruby pretty since 1899!
51
- def profile(&b)
52
- result = RubyProf.profile &b
53
- printer = RubyProf::FlatPrinter.new(result)
54
- #printer = RubyProf::GraphHtmlPrinter.new(result)
55
- printer.print(OUTPUT.open('w+'))
56
- end
57
-
58
- profile do
59
- # 10_000.times { touch_attributes[Exhibit.get(1)] }
60
- #
61
- # repository(:default) do
62
- # 10_000.times { touch_attributes[Exhibit.get(1)] }
63
- # end
64
- #
65
- # 1000.times { touch_attributes[Exhibit.all(:limit => 100)] }
66
- #
67
- # repository(:default) do
68
- # 1000.times { touch_attributes[Exhibit.all(:limit => 100)] }
69
- # end
70
- #
71
- # 10.times { touch_attributes[Exhibit.all(:limit => 10_000)] }
72
- #
73
- # repository(:default) do
74
- # 10.times { touch_attributes[Exhibit.all(:limit => 10_000)] }
75
- # end
76
-
77
- create_exhibit = {
78
- :name => Faker::Company.name,
79
- :zoo_id => rand(10).ceil,
80
- :notes => Faker::Lorem.paragraphs.join($/),
81
- :created_on => Date.today
82
- }
83
-
84
- 1000.times { Exhibit.create(create_exhibit) }
85
- end
86
-
87
- puts "Done!"
@@ -1,183 +0,0 @@
1
- require Pathname('rexml/document')
2
-
3
- begin
4
- require 'faster_csv'
5
- rescue LoadError
6
- nil
7
- end
8
-
9
- begin
10
- require Pathname('json/ext')
11
- rescue LoadError
12
- require Pathname('json/pure')
13
- end
14
-
15
- module DataMapper
16
- module Serialize
17
-
18
- # Serialize a Resource to JavaScript Object Notation (JSON; RFC 4627)
19
- #
20
- # @return <String> a JSON representation of the Resource
21
- def to_json(options = {})
22
- result = '{ '
23
- fields = []
24
-
25
- # FIXME: this should go into bunch of protected methods shared with other serialization methods
26
- only_properties = Array(options[:only])
27
- excluded_properties = Array(options[:exclude])
28
- exclude_read_only = options[:without_read_only_attributes] || false
29
-
30
- propset = self.class.properties(repository.name).reject do |p|
31
- next if only_properties.include? p.name
32
- excluded_properties.include?(p.name) || !(only_properties.empty? || only_properties.include?(p.name))
33
- end
34
-
35
- fields += propset.map do |property|
36
- "#{property.name.to_json}: #{send(property.getter).to_json}"
37
- end
38
-
39
- if self.respond_to?(:serialize_properties)
40
- self.serialize_properties.each do |k,v|
41
- fields << "#{k.to_json}: #{v.to_json}"
42
- end
43
- end
44
-
45
- if self.class.respond_to?(:read_only_attributes) && exclude_read_only
46
- self.class.read_only_attributes.each do |property|
47
- fields << "#{property.to_json}: #{send(property).to_json}"
48
- end
49
- end
50
-
51
- # add methods
52
- (options[:methods] || []).each do |meth|
53
- if self.respond_to?(meth)
54
- fields << "#{meth.to_json}: #{send(meth).to_json}"
55
- end
56
- end
57
-
58
- # Note: if you want to include a whole other model via relation, use :methods
59
- # comments.to_json(:relationships=>{:user=>{:include=>[:first_name],:methods=>[:age]}})
60
- # add relationships
61
- (options[:relationships] || {}).each do |rel,opts|
62
- if self.respond_to?(rel)
63
- fields << "#{rel.to_json}: #{send(rel).to_json(opts)}"
64
- end
65
- end
66
-
67
- result << fields.join(', ')
68
- result << ' }'
69
- result
70
- end
71
-
72
- # Serialize a Resource to comma-separated values (CSV).
73
- #
74
- # @return <String> a CSV representation of the Resource
75
- def to_csv(writer = '')
76
- FasterCSV.generate(writer) do |csv|
77
- row = []
78
- self.class.properties(repository.name).each do |property|
79
- row << send(property.name).to_s
80
- end
81
- csv << row
82
- end
83
- end
84
-
85
- # Serialize a Resource to XML
86
- #
87
- # @return <REXML::Document> an XML representation of this Resource
88
- def to_xml(opts = {})
89
-
90
- to_xml_document(opts).to_s
91
- end
92
-
93
- # Serialize a Resource to YAML
94
- #
95
- # @return <YAML> a YAML representation of this Resource
96
- def to_yaml(opts = {})
97
- YAML::quick_emit(object_id,opts) do |out|
98
- out.map(nil,to_yaml_style) do |map|
99
- self.class.properties(repository.name).each do |property|
100
- value = send(property.name.to_sym)
101
- map.add(property.name, value.is_a?(Class) ? value.to_s : value)
102
- end
103
- (instance_variable_get("@yaml_addes") || []).each do |k,v|
104
- map.add(k.to_s,v)
105
- end
106
- end
107
- end
108
- end
109
-
110
- protected
111
-
112
- # Return the name of this Resource - to be used as the root element name.
113
- # This can be overloaded.
114
- #
115
- # @return <String> name of this Resource
116
- def xml_element_name
117
- Extlib::Inflection.underscore(self.class.name)
118
- end
119
-
120
- # Return a REXML::Document representing this Resource
121
- #
122
- # @return <REXML::Document> an XML representation of this Resource
123
- def to_xml_document(opts={}, doc=nil)
124
- doc ||= REXML::Document.new
125
- root = doc.add_element(xml_element_name)
126
-
127
- #TODO old code base was converting single quote to double quote on attribs
128
-
129
- self.class.properties(repository.name).each do |property|
130
- value = send(property.name)
131
- node = root.add_element(property.name.to_s)
132
- unless property.type == String
133
- node.attributes["type"] = property.type.to_s.downcase
134
- end
135
- node << REXML::Text.new(value.to_s) unless value.nil?
136
- end
137
- doc
138
- end
139
-
140
- end # module Serialize
141
-
142
- module Resource
143
- include Serialize
144
- end # module Resource
145
-
146
- class Collection
147
- def to_yaml(opts = {})
148
- to_a.to_yaml(opts)
149
- end
150
-
151
- def to_json(opts = {})
152
- "[" << map {|e| e.to_json(opts)}.join(",") << "]"
153
- end
154
-
155
- def to_xml(opts = {})
156
- to_xml_document(opts).to_s
157
- end
158
-
159
- def to_csv
160
- result = ""
161
- each do |item|
162
- result << item.to_csv + "\n"
163
- end
164
- result
165
- end
166
-
167
- protected
168
- def xml_element_name
169
- Extlib::Inflection.tableize(self.model.to_s)
170
- end
171
-
172
- def to_xml_document(opts={})
173
- doc = REXML::Document.new
174
- root = doc.add_element(xml_element_name)
175
- root.attributes["type"] = 'array'
176
- each do |item|
177
- item.send(:to_xml_document, opts, root)
178
- end
179
- doc
180
- end
181
- end
182
-
183
- end # module DataMapper