datamapper 0.3.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/History.txt +0 -0
  2. data/Manifest.txt +5 -0
  3. data/README.txt +11 -0
  4. data/Rakefile +70 -0
  5. data/lib/datamapper.rb +8 -0
  6. metadata +152 -319
  7. data/CHANGELOG +0 -145
  8. data/FAQ +0 -96
  9. data/MIT-LICENSE +0 -22
  10. data/QUICKLINKS +0 -12
  11. data/README +0 -105
  12. data/environment.rb +0 -62
  13. data/example.rb +0 -156
  14. data/lib/data_mapper.rb +0 -88
  15. data/lib/data_mapper/adapters/abstract_adapter.rb +0 -43
  16. data/lib/data_mapper/adapters/data_object_adapter.rb +0 -480
  17. data/lib/data_mapper/adapters/mysql_adapter.rb +0 -72
  18. data/lib/data_mapper/adapters/postgresql_adapter.rb +0 -258
  19. data/lib/data_mapper/adapters/sql/coersion.rb +0 -134
  20. data/lib/data_mapper/adapters/sql/commands/load_command.rb +0 -545
  21. data/lib/data_mapper/adapters/sql/mappings/associations_set.rb +0 -34
  22. data/lib/data_mapper/adapters/sql/mappings/column.rb +0 -279
  23. data/lib/data_mapper/adapters/sql/mappings/conditions.rb +0 -172
  24. data/lib/data_mapper/adapters/sql/mappings/schema.rb +0 -60
  25. data/lib/data_mapper/adapters/sql/mappings/table.rb +0 -459
  26. data/lib/data_mapper/adapters/sql/quoting.rb +0 -24
  27. data/lib/data_mapper/adapters/sqlite3_adapter.rb +0 -159
  28. data/lib/data_mapper/associations.rb +0 -106
  29. data/lib/data_mapper/associations/belongs_to_association.rb +0 -160
  30. data/lib/data_mapper/associations/has_and_belongs_to_many_association.rb +0 -437
  31. data/lib/data_mapper/associations/has_many_association.rb +0 -283
  32. data/lib/data_mapper/associations/has_n_association.rb +0 -143
  33. data/lib/data_mapper/associations/reference.rb +0 -47
  34. data/lib/data_mapper/attributes.rb +0 -73
  35. data/lib/data_mapper/auto_migrations.rb +0 -36
  36. data/lib/data_mapper/base.rb +0 -17
  37. data/lib/data_mapper/callbacks.rb +0 -107
  38. data/lib/data_mapper/context.rb +0 -112
  39. data/lib/data_mapper/database.rb +0 -234
  40. data/lib/data_mapper/dependency_queue.rb +0 -28
  41. data/lib/data_mapper/embedded_value.rb +0 -145
  42. data/lib/data_mapper/identity_map.rb +0 -47
  43. data/lib/data_mapper/is/tree.rb +0 -121
  44. data/lib/data_mapper/migration.rb +0 -155
  45. data/lib/data_mapper/persistence.rb +0 -852
  46. data/lib/data_mapper/property.rb +0 -310
  47. data/lib/data_mapper/query.rb +0 -164
  48. data/lib/data_mapper/support/blank.rb +0 -35
  49. data/lib/data_mapper/support/connection_pool.rb +0 -117
  50. data/lib/data_mapper/support/enumerable.rb +0 -35
  51. data/lib/data_mapper/support/errors.rb +0 -16
  52. data/lib/data_mapper/support/inflector.rb +0 -265
  53. data/lib/data_mapper/support/object.rb +0 -54
  54. data/lib/data_mapper/support/serialization.rb +0 -96
  55. data/lib/data_mapper/support/silence.rb +0 -10
  56. data/lib/data_mapper/support/string.rb +0 -72
  57. data/lib/data_mapper/support/struct.rb +0 -7
  58. data/lib/data_mapper/support/symbol.rb +0 -82
  59. data/lib/data_mapper/support/typed_set.rb +0 -65
  60. data/lib/data_mapper/types/base.rb +0 -44
  61. data/lib/data_mapper/types/string.rb +0 -34
  62. data/lib/data_mapper/validatable_extensions/errors.rb +0 -12
  63. data/lib/data_mapper/validatable_extensions/macros.rb +0 -7
  64. data/lib/data_mapper/validatable_extensions/validatable_instance_methods.rb +0 -62
  65. data/lib/data_mapper/validatable_extensions/validation_base.rb +0 -18
  66. data/lib/data_mapper/validatable_extensions/validations/formats/email.rb +0 -43
  67. data/lib/data_mapper/validatable_extensions/validations/validates_acceptance_of.rb +0 -7
  68. data/lib/data_mapper/validatable_extensions/validations/validates_confirmation_of.rb +0 -7
  69. data/lib/data_mapper/validatable_extensions/validations/validates_each.rb +0 -7
  70. data/lib/data_mapper/validatable_extensions/validations/validates_format_of.rb +0 -28
  71. data/lib/data_mapper/validatable_extensions/validations/validates_length_of.rb +0 -15
  72. data/lib/data_mapper/validatable_extensions/validations/validates_numericality_of.rb +0 -7
  73. data/lib/data_mapper/validatable_extensions/validations/validates_presence_of.rb +0 -7
  74. data/lib/data_mapper/validatable_extensions/validations/validates_true_for.rb +0 -7
  75. data/lib/data_mapper/validatable_extensions/validations/validates_uniqueness_of.rb +0 -40
  76. data/lib/data_mapper/validations.rb +0 -20
  77. data/lib/data_mapper/validations/number_validator.rb +0 -40
  78. data/lib/data_mapper/validations/string_validator.rb +0 -20
  79. data/lib/data_mapper/validations/validator.rb +0 -13
  80. data/performance.rb +0 -307
  81. data/plugins/can_has_sphinx/LICENSE +0 -23
  82. data/plugins/can_has_sphinx/README +0 -4
  83. data/plugins/can_has_sphinx/REVISION +0 -1
  84. data/plugins/can_has_sphinx/Rakefile +0 -22
  85. data/plugins/can_has_sphinx/init.rb +0 -1
  86. data/plugins/can_has_sphinx/install.rb +0 -1
  87. data/plugins/can_has_sphinx/lib/acts_as_sphinx.rb +0 -123
  88. data/plugins/can_has_sphinx/lib/sphinx.rb +0 -460
  89. data/plugins/can_has_sphinx/scripts/sphinx.sh +0 -47
  90. data/plugins/can_has_sphinx/tasks/acts_as_sphinx_tasks.rake +0 -41
  91. data/profile_data_mapper.rb +0 -40
  92. data/rakefile.rb +0 -159
  93. data/spec/acts_as_tree_spec.rb +0 -67
  94. data/spec/adapters/data_object_adapter_spec.rb +0 -31
  95. data/spec/associations/belongs_to_association_spec.rb +0 -98
  96. data/spec/associations/has_and_belongs_to_many_association_spec.rb +0 -377
  97. data/spec/associations/has_many_association_spec.rb +0 -337
  98. data/spec/attributes_spec.rb +0 -52
  99. data/spec/auto_migrations_spec.rb +0 -101
  100. data/spec/callbacks_spec.rb +0 -186
  101. data/spec/can_has_sphinx.rb +0 -5
  102. data/spec/coersion_spec.rb +0 -41
  103. data/spec/column_spec.rb +0 -114
  104. data/spec/count_command_spec.rb +0 -45
  105. data/spec/database_spec.rb +0 -18
  106. data/spec/dataobjects_spec.rb +0 -27
  107. data/spec/delete_command_spec.rb +0 -11
  108. data/spec/dependency_spec.rb +0 -29
  109. data/spec/embedded_value_spec.rb +0 -161
  110. data/spec/fixtures/animals.yaml +0 -33
  111. data/spec/fixtures/animals_exhibits.yaml +0 -2
  112. data/spec/fixtures/careers.yaml +0 -5
  113. data/spec/fixtures/comments.yaml +0 -1
  114. data/spec/fixtures/exhibits.yaml +0 -90
  115. data/spec/fixtures/fruit.yaml +0 -6
  116. data/spec/fixtures/people.yaml +0 -37
  117. data/spec/fixtures/posts.yaml +0 -3
  118. data/spec/fixtures/projects.yaml +0 -13
  119. data/spec/fixtures/sections.yaml +0 -5
  120. data/spec/fixtures/serializers.yaml +0 -6
  121. data/spec/fixtures/tasks.yaml +0 -6
  122. data/spec/fixtures/tasks_tasks.yaml +0 -2
  123. data/spec/fixtures/tomatoes.yaml +0 -1
  124. data/spec/fixtures/users.yaml +0 -1
  125. data/spec/fixtures/zoos.yaml +0 -24
  126. data/spec/is_a_tree_spec.rb +0 -149
  127. data/spec/legacy_spec.rb +0 -16
  128. data/spec/load_command_spec.rb +0 -322
  129. data/spec/magic_columns_spec.rb +0 -26
  130. data/spec/migration_spec.rb +0 -267
  131. data/spec/mock_adapter.rb +0 -20
  132. data/spec/models/animal.rb +0 -12
  133. data/spec/models/candidate.rb +0 -8
  134. data/spec/models/career.rb +0 -7
  135. data/spec/models/chain.rb +0 -8
  136. data/spec/models/comment.rb +0 -6
  137. data/spec/models/exhibit.rb +0 -14
  138. data/spec/models/fence.rb +0 -7
  139. data/spec/models/fruit.rb +0 -8
  140. data/spec/models/job.rb +0 -8
  141. data/spec/models/person.rb +0 -30
  142. data/spec/models/post.rb +0 -14
  143. data/spec/models/project.rb +0 -41
  144. data/spec/models/sales_person.rb +0 -5
  145. data/spec/models/section.rb +0 -8
  146. data/spec/models/serializer.rb +0 -5
  147. data/spec/models/task.rb +0 -9
  148. data/spec/models/tomato.rb +0 -27
  149. data/spec/models/user.rb +0 -12
  150. data/spec/models/zoo.rb +0 -13
  151. data/spec/natural_key_spec.rb +0 -36
  152. data/spec/paranoia_spec.rb +0 -38
  153. data/spec/persistence_spec.rb +0 -479
  154. data/spec/postgres_spec.rb +0 -96
  155. data/spec/property_spec.rb +0 -151
  156. data/spec/query_spec.rb +0 -77
  157. data/spec/save_command_spec.rb +0 -94
  158. data/spec/schema_spec.rb +0 -8
  159. data/spec/serialize_spec.rb +0 -19
  160. data/spec/single_table_inheritance_spec.rb +0 -43
  161. data/spec/spec_helper.rb +0 -45
  162. data/spec/support/blank_spec.rb +0 -8
  163. data/spec/support/inflector_spec.rb +0 -41
  164. data/spec/support/object_spec.rb +0 -9
  165. data/spec/support/serialization_spec.rb +0 -61
  166. data/spec/support/silence_spec.rb +0 -15
  167. data/spec/support/string_spec.rb +0 -7
  168. data/spec/support/struct_spec.rb +0 -12
  169. data/spec/support/typed_set_spec.rb +0 -66
  170. data/spec/symbolic_operators_spec.rb +0 -27
  171. data/spec/table_spec.rb +0 -79
  172. data/spec/types/string.rb +0 -81
  173. data/spec/validates_confirmation_of_spec.rb +0 -55
  174. data/spec/validates_format_of_spec.rb +0 -78
  175. data/spec/validates_length_of_spec.rb +0 -117
  176. data/spec/validates_uniqueness_of_spec.rb +0 -92
  177. data/spec/validations/number_validator.rb +0 -59
  178. data/spec/validations/string_validator.rb +0 -14
  179. data/spec/validations_spec.rb +0 -141
  180. data/tasks/fixtures.rb +0 -53
data/CHANGELOG DELETED
@@ -1,145 +0,0 @@
1
- -- 0.1.0
2
- * Initial Public Release
3
-
4
- -- 0.1.1
5
- * Removed /lib/data_mapper/extensions
6
- * Moved ActiveRecordImpersonation into DataMapper::Support module
7
- * Moved CallbackHelper methods into DataMapper::Base class
8
- * Moved ValidationHelper into DataMapper::Validations module
9
- * Removed LoadedSet since it's not necessary for it to reference the Database, so it's nothing more than an array now; Replaced with Array
10
- * Modified data_mapper.rb to load DataMapper::Support::Enumerable
11
- * Modified example.rb and performance.rb to require 'lib/data_mapper' instead of modifying $LOADPATH
12
- * Created SqlAdapter base-class
13
- * Refactored MysqlAdapter to use SqlAdapter superclass
14
- * Refactored Sqlite3Adapter to use SqlAdapter superclass
15
- * Moved /lib/data_mapper/queries to /lib/data_mapper/adapters/sql/queries
16
- * Moved Connection, Result and Reader classes along with Coersion and Quoting modules to DataMapper::Adapters::Sql module
17
- * Moved DataMapper::Adapters::Sql::Queries to ::Commands
18
- * Moved Mappings to SqlAdapter
19
- * Added monolithic DeleteCommand
20
- * Added monolithic SaveCommand
21
- * Added TableExistsCommand
22
- * Moved save/delete logic out of Session
23
- * Added create-table functionality to SaveCommand
24
- * Cleaned up Session; #find no longer supported, use #all or #first
25
- * Moved object materialization into LoadCommand
26
- * Migrated Sqlite3Adapter::Commands
27
- * Added Session#query support back in
28
- * Removed Connection/Reader/Result classes
29
- * Set DataMapper::Base#key on load to avoid double-hit against Schema
30
- * Added DataMapper::Support::Struct for increased Session#query performance
31
- * Added AdvancedHasManyAssociation (preview status)
32
- * Added benchmarks comparing ActiveRecord::Base::find_by_sql with Session#query
33
-
34
- -- 0.2.0
35
- * AdvancedHasManyAssociation now functional for fetches
36
- * AdvancedHasManyAssociation renamed to HasNAssociation
37
- * HasManyAssociation refactored to use HasNAssociation superclass
38
- * Slight spec tweaks to accomodate the updates
39
- * HasOneAssociation refactored to use HasNAssociation superclass
40
- * Added HasAndBelongsToManyAssociation, using HasNAssociation as a basis; Need to add corresponding SQL generation code in AdvancedLoadCommand
41
- * Added spec for habtm query generation
42
- * HasNAssociation#foreign_key returns a DataMapper::Adapters::Sql::Mappings::Column instance instead of a raw String now
43
- * Added table, association, association_table and to_sql methods to HasNAssociation
44
- * Added associations_spec.rb
45
- * Added a forced table-recreation to spec_helper.rb so the tests could run with a clean version of the database, including any new columns added to the models
46
- * Added HasAndBelongsToManyAssociation#to_sql (all current specs pass now!)
47
- * Minor tweaks to Callbacks
48
- * Added CallbacksHelper to declare class-method ::callbacks on DataMapper::Base
49
- * Implemented before_validate and after_validate hooks in ValidationHelper
50
- * Minor documentation additions in callbacks.rb
51
- * Added callbacks_spec
52
- * Moved class-method declarations for built-in callbacks to the callbacks helper instead of DataMapper::Base
53
- * Renamed :before/after_validate callback to :before/after_validation to match ActiveRecord
54
- * Callbacks#add now accepts a Symbol which maps a callback to a method call on the targetted instance, also added a spec to verify this behavior
55
- * Documented callbacks.rb
56
- * Added DataMapper::Associations::Reference class
57
- * Documented DataMapper::Associations::Reference class
58
- * Upgraded BelongsToAssociation to new style
59
- * Added AssociationsSet to handle simple "last-in" for association bindings
60
- * Fixed extra spec loading
61
- * Added *Association#columns
62
- * Some refactoring in AdvancedLoadCommand regarding :include options
63
- * Added support for class-less Mappings::Table instances, with just a string name
64
- * HasAndBelongsToManyAssociation#join_table #left_foreign_key and #right_foreign_key reference actual Table or Column objects now
65
- * Added :shallow_include option for HABTM joins in AdvancedLoadCommand and corresponding spec
66
- * Added Commands::AdvancedConditions
67
- * Added ORDER, LIMIT, OFFSET and WHERE support to AdvancedLoadCommand
68
- * Renamed spec/has_many.rb to spec/has_many_spec.rb
69
- * Tweaked the loading of has_many relationships; big performance boost; got rid of an extra query
70
- * Added EmbeddedValue support, and accompanying spec
71
- * Fleshed out AdvancedConditions a bit; added conditions_spec.rb
72
- * Added more AdvancedConditions specs
73
- * Added Loader to handle multi-instanced rows
74
- * AdvancedLoadCommand replaced LoadCommand; down to 3 failing specs
75
- * All specs pass
76
- * Added :intercept_load finder option and accompanying spec
77
- * Modified :intercept_load block signature to |instance,columns,row|
78
- * HasAndBelongsToMany works, all specs pass
79
- * Fixed a couple bugs with keys; Added DataMapper::Base#key= method
80
- * Made DataMapper::Base#lazy_load! a little more flexible
81
- * Removed LoadCommand overwrites from MysqlAdapter
82
- * Default Database#single_threaded mode is true now
83
- * Removed MysqlAdapter#initialize, which only served to setup the connections, moved to SqlAdapter
84
- * Added SqlAdapter#create_connection and SqlAdapter#close_connection abstract methods
85
- * Added MysqlAdapter#create_connection and MysqlAdapter#close_connection concrete methods
86
- * Made SqlAdapter#connection a concrete method (instead of abstract), with support for single_threaded operation
87
- * Database#setup now takes a Hash of options instead of a block-initializer
88
- * Validation chaining should work for all association types
89
- * Save chaining should work for has_many associations
90
- * Added benchmarks for in-session performance to performance.rb
91
- * Removed block conditions; They're slower and don't offer any real advantages
92
- * Removed DeleteCommand
93
- * Removed SaveCommand
94
- * Removed TableExistsCommand
95
- * Session renamed to Context
96
- * Most command implementations moved to methods in SqlAdapter
97
- * Removed UnitOfWork module, instead moving a slightly refactored implementation into Base
98
-
99
- -- 0.2.1
100
- * Added :float column support
101
- * Added association proxies: ie: Zoo.first.exhibits.animals
102
- * Columns stored in SortedSet
103
- * Swig files are no longer RDOCed
104
- * Added :date column support
105
- * BUG: Fixed UTC issues with datetimes
106
- * Added #to_yaml method
107
- * Added #to_xml method
108
- * Added #to_json method
109
- * BUG: Fixed HasManyAssociation::Set#inspect
110
- * BUG: Fixed #reload!
111
- * BUG: Column copy for STI moved into Table#initialize to better handle STI with multiple mapped databases
112
- * BUG: before_create callbacks moved in the execution flow since they weren't guaranteed to fire before
113
- * Threading enhancements: Removed single_threaded_mode, #database block form adjusted for thread-safety
114
- * BUG: Fixed String#blank? when a multi-line string contained a blank line (thanks zapnap!)
115
- * Performance enhancements: (thanks wycats!)
116
-
117
- -- 0.2.2
118
- * Removed C extension bundles and log files from package
119
-
120
- -- 0.2.3
121
- * Added String#t for translation and overrides for default validation messages
122
- * Give credit where it's due: zapnap, not pimpmaster, submitted the String#blank? patch. My bad. :-(
123
- * MAJOR: Resolve issue with non-unique-hash values and #dirty?; now frozen original values are stored instead
124
- * Added Base#update_attributes
125
- * MAJOR: Queries are now passed to the database drivers in a parameterized fashion
126
- * Updated PostgreSQL driver and adapter to current
127
-
128
- -- 0.2.4
129
- * Bug fixes
130
- * Added paranoia
131
-
132
- -- 0.2.5
133
- * has_one bugfixes
134
- * Added syntax for setting CHECK-constraints directly in your properties (Postgres)
135
- * You can now set indexes with :index => true and :index => :unique
136
- * Support for composite indexes (thanks to Jeffrey Gelens)
137
- * Add composite scope to validates_uniqueness
138
- * Added private/protected properties
139
- * Remove HasOneAssociation, Make HasManyAssociation impersonate has_one relationships
140
- * Added #get method
141
- * Persistence module added, inheriting from DataMapper::Base no longer necessary
142
-
143
- -- 0.3.0
144
- * HasManyAssociation::Set now has a nil? method, so we can do stuff like cage.animal.nil?
145
-
data/FAQ DELETED
@@ -1,96 +0,0 @@
1
- :include:QUICKLINKS
2
-
3
- = FAQ
4
-
5
- === I don't want to use :id as a primary key, but I don't see <tt>set_primary_key</tt> anywhere. What do I do?
6
-
7
- If you're working with a table that doesn't have a <tt>:id</tt> column, you can declare your properties as you usually do, and declare one of them as a natural key.
8
-
9
- property :name, :string, :key => true
10
-
11
- You should now be able to do <tt>Class['name_string']</tt> as well. Remember: this column should be unique, so treat it that way. This is the equivalent to using <tt>set_primary_key</tt> in ActiveRecord.
12
-
13
-
14
- === How do I make a model paranoid?
15
-
16
- property :deleted_at, :datetime
17
-
18
- If you've got deleted_at, your model is paranoid auto-magically. All of your calls to <tt>##all()</tt>, <tt>##first()</tt>, and <tt>##count()</tt> will be scoped with <tt>where deleted_at is null</tt>. Plus, you won't see deleted objects in your associations.
19
-
20
- === Does DataMapper support Has Many Through?
21
-
22
- Write me!
23
-
24
- === What about Self-Referential Has And Belongs to Many?
25
-
26
- Sure does. Here's an example implementation:
27
-
28
- class Task < DataMapper::Base
29
- has_and_belongs_to_many :tasks,
30
- :join_table => "task_relationships",
31
- :left_foreign_key => "parent_id",
32
- :right_foreign_key => "child_id"
33
- end
34
-
35
- You'll notice that instead of <tt>foreign_key</tt> and <tt>association_foreign_key</tt>, DataMapper uses the "database-y" terms <tt>left_foreign_key</tt>, and <tt>right_foreign_key</tt>.
36
-
37
- === Does DataMapper do Single Table Inheritance?
38
-
39
- Oh yes, and particularly well too.
40
-
41
- class Person < Datamapper::Base
42
- property :type, :class
43
- ## other shared properties here
44
- end
45
-
46
- class Salesperson < Person; end
47
-
48
- You can claim a column to have the type <tt>:class</tt> and DataMapper will automatically drop the class name of the inherited classes into that column of the database.
49
-
50
- === What about Class Table Inheritance?
51
-
52
- Class Table Inheritance is on the drawing board and everyone's drooling over it. So no, not yet, but soon.
53
-
54
- === How do I run my own commands?
55
-
56
- You're probably asking for <tt>find_by_sql</tt>, and DataMapper has that in it's ActiveRecordImpersonation, but if you want to go straight-up DataMapper, you'll want to use <tt>database.query</tt>
57
-
58
- database.query("select * from users where clue > 0")
59
-
60
- This does not return any Users (har har), but rather Struct's that will quack like Users. They'll be read-only as well.
61
-
62
- <tt>database.query</tt> shouldn't be used if you aren't expecting a result set back. If you want to just execute something against the database, use <tt>database.execute</tt> instead.
63
-
64
- === Can I batch-process a ton of records at once?
65
-
66
- User.each(:performance_rating => "low") do |u|
67
- u.employment_status = "fired"
68
- u.save
69
- end
70
-
71
- With ActiveRecord, doing a <tt>User.find(:all).each{}</tt> would execute the find, instantiate an object for EVERY result, THEN apply your transformations to each object in turn. Doesn't sound too horrible unless you have a TON of records; you WILL grind your system to a screeching and bloody halt.
72
-
73
- Datamapper's <tt>#each</tt> works in sets of 500 so the amount of objects instantiated at a time won't make your computer think it's a victim in a Saw movie. Once it's done executing your block on the first set of 500, it moves on to the next.
74
-
75
- What's more is <tt>#each</tt> is secretly a finder too. You can pass it an options hash and it'll only iterate on 500-item sets matching your query. Don't send it <tt>:offset</tt> though, because that's how it pages. You can overload the page size by sending it <tt>:limit</tt>
76
-
77
- === Can I get an SQL log of what queries DataMapper is issuing?
78
-
79
- Yup, when you issue <tt>Database.setup</tt>, tack on the <tt>log_stream</tt> and <tt>log_level</tt>:
80
-
81
- DataMapper::Database.setup({
82
- :adapter => 'mysql',
83
- :host => 'localhost',
84
- :username => 'root',
85
- :password => 'R00tPaswooooord',
86
- :database => 'myspiffyblog_development',
87
- :log_stream => 'log/sql.log',
88
- :log_level => 0
89
- })
90
-
91
- By supplying the <tt>log_stream</tt> you're telling DataMapper what file you want to see your sql logs in. <tt>log_level</tt> is the Logger[http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/] level of output you want to see there. 0, in this case, says that you want to see all DEBUG level messages (and higher) sent to the logger. For more information on how to work with Logger[http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/], hit up http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/.
92
-
93
- Incidentally, if you'd like to send a message into the Datamapper logger, do:
94
-
95
- database.adapter.logger.info "your message here"
96
-
@@ -1,22 +0,0 @@
1
- Copyright (c) 2007 Sam Smoot
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
data/QUICKLINKS DELETED
@@ -1,12 +0,0 @@
1
- = Quick Links
2
-
3
- * Finders and CRUD - DataMapper::Persistence::ConvenienceMethods::ClassMethods
4
- * Properties - DataMapper::Property
5
- * Validations - Validatable
6
- * Migrations
7
- * FAQ[link:/files/FAQ.html]
8
- * Contact Us
9
- * Website - http://www.datamapper.org
10
- * Bug Reports - http://wm.lighthouseapp.com/projects/4819-datamapper/overview
11
- * IRC Channel - <tt>##datamapper</tt> on irc.freenode.net
12
- * Mailing List - http://groups.google.com/group/datamapper/
data/README DELETED
@@ -1,105 +0,0 @@
1
-
2
- :include:QUICKLINKS
3
-
4
- = Why DataMapper?
5
-
6
- == Open Development
7
-
8
- Datamapper sports a very accessible code-base and a welcoming community. Outside contributions and feedback are welcome and encouraged, especially constructive criticism. Make your voice heard! Submit a ticket[http://wm.lighthouseapp.com/projects/4819-datamapper/overview] or patch[http://wm.lighthouseapp.com/projects/4819-datamapper/overview], speak up on our mailing-list[http://groups.google.com/group/datamapper/], chat with us on irc[irc://irc.freenode.net/#datamapper], write a spec, get it reviewed, ask for commit rights. It's as easy as that to become a contributor.
9
-
10
- == Identity Map
11
-
12
- One row in the database should equal one object reference. Pretty simple idea. Pretty profound impact. If you run the following code in ActiveRecord you'll see all <tt>false</tt> results. Do the same in DataMapper and it's <tt>true</tt> all the way down.
13
-
14
-
15
- @parent = Tree.find(:first, :conditions => ['name = ?', 'bob'])
16
-
17
- @parent.children.each do |child|
18
- puts @parent.object_id == child.parent.object_id
19
- end
20
-
21
- This makes DataMapper faster and allocate less resources to get things done.
22
-
23
- == Don't Do What You Don't Have To
24
-
25
- ActiveRecord updates every column in a row during a save whether that column changed or not. So it performs work it doesn't really need to making it much slower, and more likely to eat data during concurrent access if you don't go around adding locking support to everything.
26
-
27
- DataMapper only does what it needs to. So it plays well with others. You can use it in an Integration Database without worrying that your application will be a bad actor causing trouble for all of your other processes.
28
-
29
- == Eager Loading
30
-
31
- Ready for something amazing? The following example executes only two queries.
32
-
33
- zoos = Zoo.all
34
- first = zoos.first
35
- first.exhibits # Loads the exhibits for all the Zoo objects in the zoos variable.
36
-
37
- Pretty impressive huh? The idea is that you aren't going to load a set of objects and use only an association in just one of them. This should hold up pretty well against a 99% rule. When you don't want it to work like this, just load the item you want in it's own set. So the DataMapper thinks ahead. We like to call it "performant by default". This feature single-handedly wipes out the "N+1 Query Problem". No need to specify an <tt>include</tt> option in your finders.
38
-
39
- == Laziness Can Be A Virtue
40
-
41
- Text columns are expensive in databases. They're generally stored in a different place than the rest of your data. So instead of a fast sequential read from your hard-drive, your database server has to hop around all over the place to get what it needs. Since ActiveRecord returns everything by default, adding a text column to a table slows everything down drastically, across the board.
42
-
43
- Not so with the DataMapper. Text fields are treated like in-row associations by default, meaning they only load when you need them. If you want more control you can enable or disable this feature for any column (not just text-fields) by passing a @lazy@ option to your column mapping with a value of <tt>true</tt> or <tt>false</tt>.
44
-
45
-
46
- class Animal < DataMapper::Base
47
- property :name, :string
48
- property :notes, :text, :lazy => false
49
- end
50
-
51
-
52
- Plus, lazy-loading of text fields happens automatically and intelligently when working with associations. The following only issues 2 queries to load up all of the notes fields on each animal:
53
-
54
- animals = Animal.all
55
- animals.each do |pet|
56
- pet.notes
57
- end
58
-
59
- == Plays Well With Others
60
-
61
- In ActiveRecord, all your columns are mapped, whether you want them or not. This slows things down. In the DataMapper you define your mappings in your model. So instead of an _ALTER TABLE ADD COLUMN_ in your Database, you simply add a <tt>property :name, :string</tt> to your model. DRY. No schema.rb. No migration files to conflict or die without reverting changes. Your model drives the database, not the other way around.
62
-
63
- Unless of course you want to map to a legacy database. Raise your hand if you like seeing a method called <tt>col2Name</tt> on your model just because that's what it's called in an old database you can't afford to change right now? In DataMapper you control the mappings:
64
-
65
-
66
- class Fruit < DataMapper::Base
67
- set_table_name 'frt'
68
- property :name, :string, :column => 'col2'
69
- end
70
-
71
-
72
- == All Ruby, All The Time
73
-
74
- It's great that ActiveRecord allows you to write SQL when you need to, but should we have to so often?
75
-
76
- DataMapper supports issuing your own SQL, but it also provides more helpers and a unique hash-based condition syntax to cover more of the use-cases where issuing your own SQL would have been the only way to go. For example, any finder option that's non-standard is considered a condition. So you can write <tt>Zoo.all(:name => 'Dallas')</tt> and DataMapper will look for zoos with the name of 'Dallas'.
77
-
78
- It's just a little thing, but it's so much nicer than writing <tt>Zoo.find(:all, :conditions => ['name = ?', 'Dallas'])</tt>. What if you need other comparisons though? Try these:
79
-
80
-
81
- Zoo.first(:name => 'Galveston')
82
-
83
- # 'gt' means greater-than. We also do 'lt'.
84
- Person.all(:age.gt => 30)
85
-
86
- # 'gte' means greather-than-or-equal-to. We also do 'lte'.
87
- Person.all(:age.gte => 30)
88
-
89
- Person.all(:name.not => 'bob')
90
-
91
- # If the value of a pair is an Array, we do an IN-clause for you.
92
- Person.all(:name.like => 'S%', :id => [1, 2, 3, 4, 5])
93
-
94
- # An alias for Zoo.find(11)
95
- Zoo[11]
96
-
97
- # Does a NOT IN () clause for you.
98
- Person.all(:name.not => ['bob','rick','steve'])
99
-
100
-
101
- See? Fewer SQL fragments dirtying your Ruby code. And that's just a few of the nice syntax tweaks DataMapper delivers out of the box...
102
-
103
- == Better Is Great, But Familiar Is Nice
104
-
105
- The DataMapper also supports a lot of old-fashioned ActiveRecord syntax. We want to make it easy for you to get started, so aside from mapping your columns and changing the base-class your models inherit from, much of AR syntax for finders are supported as well, making your transition easy.
@@ -1,62 +0,0 @@
1
- unless defined?(INITIAL_CLASSES)
2
- # Require the DataMapper, and a Mock Adapter.
3
- require File.dirname(__FILE__) + '/lib/data_mapper'
4
- require File.dirname(__FILE__) + '/spec/mock_adapter'
5
-
6
- adapter = ENV['ADAPTER'] || 'sqlite3'
7
-
8
- configuration_options = {
9
- :adapter => adapter,
10
- :database => (ENV['DATABASE'] || 'data_mapper_1').dup
11
- }
12
-
13
- # Prepare the log path, and remove the existing spec.log
14
- require 'fileutils'
15
-
16
- if ENV['LOG_NAME']
17
- log_path = nil
18
-
19
- if ENV['LOG_NAME'] != 'STDOUT'
20
- FileUtils::mkdir_p(File.dirname(__FILE__) + '/log')
21
- log_path = File.dirname(__FILE__) + "/log/#{ENV['LOG_NAME']}.log"
22
- FileUtils::rm log_path if File.exists?(log_path)
23
- else
24
- log_path = 'STDOUT'
25
- end
26
-
27
- configuration_options.merge!(:log_stream => log_path, :log_level => Logger::DEBUG)
28
- end
29
-
30
- case adapter
31
- when 'postgresql' then
32
- configuration_options[:username] = ENV['USERNAME'] || 'postgres'
33
- when 'mysql' then
34
- configuration_options[:username] = 'root'
35
- when 'sqlite3' then
36
- unless configuration_options[:database] == ':memory:'
37
- configuration_options[:database] << '.db'
38
- end
39
- end
40
-
41
- load_models = lambda do
42
- Dir[File.dirname(__FILE__) + '/spec/models/*.rb'].sort.each { |path| load path }
43
- end
44
-
45
- secondary_configuration_options = configuration_options.dup
46
- secondary_configuration_options.merge!(:database => (adapter == 'sqlite3' ? 'data_mapper_2.db' : 'data_mapper_2'))
47
-
48
- DataMapper::Database.setup(configuration_options)
49
- DataMapper::Database.setup(:secondary, secondary_configuration_options)
50
- DataMapper::Database.setup(:mock, :adapter => MockAdapter)
51
-
52
- [:default, :secondary, :mock].each { |name| database(name) { load_models.call } }
53
-
54
- # Reset the test database.
55
- unless ENV['AUTO_MIGRATE'] == 'false'
56
- [:default, :secondary].each { |name| database(name) { DataMapper::Persistence.auto_migrate! } }
57
- end
58
-
59
- # Save the initial database layout so we can put everything back together
60
- # after auto migrations testing
61
- INITIAL_CLASSES = Array.new(DataMapper::Persistence.subclasses.to_a)
62
- end