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.
- data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/idna.rb +0 -0
- data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/uri.rb +62 -21
- data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/version.rb +1 -1
- data/lib/gems/addressable-2.0.1/tasks/clobber.rake +2 -0
- data/lib/gems/addressable-2.0.1/tasks/gem.rake +68 -0
- data/lib/gems/addressable-2.0.1/tasks/git.rake +40 -0
- data/lib/gems/addressable-2.0.1/tasks/metrics.rake +22 -0
- data/lib/gems/addressable-2.0.1/tasks/rdoc.rake +29 -0
- data/lib/gems/addressable-2.0.1/tasks/rubyforge.rake +89 -0
- data/lib/gems/addressable-2.0.1/tasks/spec.rake +64 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects.rb +46 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/command.rb +30 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/connection.rb +107 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/field.rb +19 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/logger.rb +233 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/quoting.rb +103 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/reader.rb +22 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/result.rb +13 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb +45 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/uri.rb +34 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/version.rb +3 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates.rb +1 -1
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/adapters/data_objects_adapter.rb +0 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/aggregate_functions.rb +0 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/collection.rb +4 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/model.rb +4 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/repository.rb +0 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/support/symbol.rb +0 -0
- data/lib/gems/dm-aggregates-0.9.9/lib/dm-aggregates/version.rb +5 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core.rb +5 -5
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/abstract_adapter.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/data_objects_adapter.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/in_memory_adapter.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/mysql_adapter.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/postgres_adapter.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/sqlite3_adapter.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/many_to_many.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/many_to_one.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/one_to_many.rb +3 -6
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/one_to_one.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/relationship.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/relationship_chain.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/auto_migrations.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/collection.rb +26 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/dependency_queue.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/hook.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/identity_map.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/is.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/logger.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/migrations/destructive_migrations.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/migrator.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/model.rb +29 -3
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/naming_conventions.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/property.rb +13 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/property_set.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/query.rb +51 -3
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/repository.rb +8 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/resource.rb +19 -6
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/scope.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/array.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/assertions.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/errors.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/kernel.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/symbol.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/transaction.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/type.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/type_map.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/boolean.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/discriminator.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/object.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/paranoid_boolean.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/paranoid_datetime.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/serial.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/text.rb +0 -0
- data/lib/gems/dm-core-0.9.9/lib/dm-core/version.rb +3 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/dm-migrations.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/dm-migrations/version.rb +1 -1
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/migration.rb +5 -3
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/migration_runner.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/spec/example/migration_example_group.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/spec/matchers/migration_matchers.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/column.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/mysql.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/postgresql.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/sqlite3.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table_creator.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table_modifier.rb +0 -0
- data/lib/gems/dm-migrations-0.9.9/tasks/db.rb +22 -0
- data/lib/gems/dm-migrations-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-migrations-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/{dm-observer-0.9.7 → dm-observer-0.9.9}/lib/dm-observer.rb +1 -1
- data/lib/gems/{dm-observer-0.9.7 → dm-observer-0.9.9}/lib/dm-observer/version.rb +1 -1
- data/lib/gems/dm-observer-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-observer-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer.rb +4 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/common.rb +24 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_csv.rb +35 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_json.rb +73 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_xml.rb +61 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_yaml.rb +48 -0
- data/lib/gems/{dm-serializer-0.9.7 → dm-serializer-0.9.9}/lib/dm-serializer/version.rb +1 -1
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers.rb +17 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/libxml.rb +29 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/nokogiri.rb +28 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/rexml.rb +23 -0
- data/lib/gems/dm-serializer-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-serializer-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/dm-timestamps-0.9.9/lib/dm-timestamps.rb +58 -0
- data/lib/gems/{dm-timestamps-0.9.7 → dm-timestamps-0.9.9}/lib/dm-timestamps/version.rb +1 -1
- data/lib/gems/dm-timestamps-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-timestamps-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/dm-types-0.9.9/lib/dm-types.rb +26 -0
- data/lib/gems/dm-types-0.9.9/lib/dm-types/bcrypt_hash.rb +33 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/csv.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/enum.rb +4 -4
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/epoch_time.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/file_path.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/flag.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/ip_address.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/json.rb +3 -6
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/regexp.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/serial.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/slug.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/uri.rb +2 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/uuid.rb +3 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/version.rb +1 -1
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/yaml.rb +1 -2
- data/lib/gems/dm-types-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-types-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations.rb +1 -1
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/absent_field_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/acceptance_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/auto_validate.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/block_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/confirmation_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/contextual_validators.rb +2 -3
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/custom_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/format_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/formats/email.rb +1 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/formats/url.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/generic_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/length_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/method_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/numeric_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/primitive_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/required_field_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/support/object.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/uniqueness_validator.rb +1 -1
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/validation_errors.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/version.rb +1 -1
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/within_validator.rb +0 -0
- data/lib/gems/dm-validations-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-validations-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/json_pure-1.1.3/tools/fuzz.rb +140 -0
- data/lib/gems/json_pure-1.1.3/tools/server.rb +62 -0
- data/lib/mack-data_mapper/dm_patches/migrations.rb +22 -1
- data/lib/mack-data_mapper/migration_generator/templates/db/migrations/%=@migration_name%.rb.template +1 -1
- metadata +216 -172
- data/lib/gems/dm-aggregates-0.9.7/lib/dm-aggregates/version.rb +0 -7
- data/lib/gems/dm-core-0.9.7/lib/dm-core/version.rb +0 -3
- data/lib/gems/dm-core-0.9.7/script/all +0 -5
- data/lib/gems/dm-core-0.9.7/script/performance.rb +0 -284
- data/lib/gems/dm-core-0.9.7/script/profile.rb +0 -87
- data/lib/gems/dm-serializer-0.9.7/lib/dm-serializer.rb +0 -183
- data/lib/gems/dm-timestamps-0.9.7/lib/dm-timestamps.rb +0 -57
- data/lib/gems/dm-types-0.9.7/lib/dm-types.rb +0 -28
- data/lib/gems/dm-types-0.9.7/lib/dm-types/bcrypt_hash.rb +0 -31
- data/lib/gems/json_pure-1.1.3/GPL +0 -340
- data/lib/gems/uuidtools-1.0.3/lib/uuidtools.rb +0 -648
- data/lib/gems/uuidtools-1.0.3/lib/uuidtools/version.rb +0 -32
@@ -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
|