datamapper-dm-core 0.9.11 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. data/.autotest +17 -14
  2. data/.gitignore +3 -1
  3. data/FAQ +6 -5
  4. data/History.txt +5 -39
  5. data/Manifest.txt +67 -76
  6. data/QUICKLINKS +1 -1
  7. data/README.txt +21 -15
  8. data/Rakefile +16 -15
  9. data/SPECS +2 -29
  10. data/TODO +1 -1
  11. data/dm-core.gemspec +11 -15
  12. data/lib/dm-core/adapters/abstract_adapter.rb +182 -185
  13. data/lib/dm-core/adapters/data_objects_adapter.rb +482 -534
  14. data/lib/dm-core/adapters/in_memory_adapter.rb +90 -69
  15. data/lib/dm-core/adapters/mysql_adapter.rb +22 -115
  16. data/lib/dm-core/adapters/oracle_adapter.rb +249 -0
  17. data/lib/dm-core/adapters/postgres_adapter.rb +7 -173
  18. data/lib/dm-core/adapters/sqlite3_adapter.rb +4 -97
  19. data/lib/dm-core/adapters/yaml_adapter.rb +116 -0
  20. data/lib/dm-core/adapters.rb +135 -16
  21. data/lib/dm-core/associations/many_to_many.rb +372 -90
  22. data/lib/dm-core/associations/many_to_one.rb +220 -73
  23. data/lib/dm-core/associations/one_to_many.rb +319 -255
  24. data/lib/dm-core/associations/one_to_one.rb +66 -53
  25. data/lib/dm-core/associations/relationship.rb +560 -158
  26. data/lib/dm-core/collection.rb +1104 -381
  27. data/lib/dm-core/core_ext/kernel.rb +12 -0
  28. data/lib/dm-core/core_ext/symbol.rb +10 -0
  29. data/lib/dm-core/identity_map.rb +4 -34
  30. data/lib/dm-core/migrations.rb +1283 -0
  31. data/lib/dm-core/model/descendant_set.rb +81 -0
  32. data/lib/dm-core/model/hook.rb +45 -0
  33. data/lib/dm-core/model/is.rb +32 -0
  34. data/lib/dm-core/model/property.rb +248 -0
  35. data/lib/dm-core/model/relationship.rb +335 -0
  36. data/lib/dm-core/model/scope.rb +90 -0
  37. data/lib/dm-core/model.rb +570 -369
  38. data/lib/dm-core/property.rb +753 -280
  39. data/lib/dm-core/property_set.rb +141 -98
  40. data/lib/dm-core/query/conditions/comparison.rb +814 -0
  41. data/lib/dm-core/query/conditions/operation.rb +247 -0
  42. data/lib/dm-core/query/direction.rb +43 -0
  43. data/lib/dm-core/query/operator.rb +42 -0
  44. data/lib/dm-core/query/path.rb +102 -0
  45. data/lib/dm-core/query/sort.rb +45 -0
  46. data/lib/dm-core/query.rb +974 -492
  47. data/lib/dm-core/repository.rb +147 -107
  48. data/lib/dm-core/resource.rb +644 -429
  49. data/lib/dm-core/spec/adapter_shared_spec.rb +294 -0
  50. data/lib/dm-core/spec/data_objects_adapter_shared_spec.rb +106 -0
  51. data/lib/dm-core/support/chainable.rb +20 -0
  52. data/lib/dm-core/support/deprecate.rb +12 -0
  53. data/lib/dm-core/support/equalizer.rb +23 -0
  54. data/lib/dm-core/support/logger.rb +13 -0
  55. data/lib/dm-core/{naming_conventions.rb → support/naming_conventions.rb} +6 -6
  56. data/lib/dm-core/transaction.rb +333 -92
  57. data/lib/dm-core/type.rb +98 -60
  58. data/lib/dm-core/types/boolean.rb +1 -1
  59. data/lib/dm-core/types/discriminator.rb +34 -20
  60. data/lib/dm-core/types/object.rb +7 -4
  61. data/lib/dm-core/types/paranoid_boolean.rb +11 -9
  62. data/lib/dm-core/types/paranoid_datetime.rb +11 -9
  63. data/lib/dm-core/types/serial.rb +3 -3
  64. data/lib/dm-core/types/text.rb +3 -4
  65. data/lib/dm-core/version.rb +1 -1
  66. data/lib/dm-core.rb +106 -110
  67. data/script/performance.rb +102 -109
  68. data/script/profile.rb +169 -38
  69. data/spec/lib/adapter_helpers.rb +105 -0
  70. data/spec/lib/collection_helpers.rb +18 -0
  71. data/spec/lib/counter_adapter.rb +34 -0
  72. data/spec/lib/pending_helpers.rb +27 -0
  73. data/spec/lib/rspec_immediate_feedback_formatter.rb +53 -0
  74. data/spec/public/associations/many_to_many_spec.rb +193 -0
  75. data/spec/public/associations/many_to_one_spec.rb +73 -0
  76. data/spec/public/associations/one_to_many_spec.rb +77 -0
  77. data/spec/public/associations/one_to_one_spec.rb +156 -0
  78. data/spec/public/collection_spec.rb +65 -0
  79. data/spec/public/model/relationship_spec.rb +924 -0
  80. data/spec/public/model_spec.rb +159 -0
  81. data/spec/public/property_spec.rb +829 -0
  82. data/spec/public/resource_spec.rb +71 -0
  83. data/spec/public/sel_spec.rb +44 -0
  84. data/spec/public/setup_spec.rb +145 -0
  85. data/spec/public/shared/association_collection_shared_spec.rb +317 -0
  86. data/spec/public/shared/collection_shared_spec.rb +1723 -0
  87. data/spec/public/shared/finder_shared_spec.rb +1619 -0
  88. data/spec/public/shared/resource_shared_spec.rb +924 -0
  89. data/spec/public/shared/sel_shared_spec.rb +112 -0
  90. data/spec/public/transaction_spec.rb +129 -0
  91. data/spec/public/types/discriminator_spec.rb +130 -0
  92. data/spec/semipublic/adapters/abstract_adapter_spec.rb +30 -0
  93. data/spec/semipublic/adapters/in_memory_adapter_spec.rb +12 -0
  94. data/spec/semipublic/adapters/mysql_adapter_spec.rb +17 -0
  95. data/spec/semipublic/adapters/oracle_adapter_spec.rb +194 -0
  96. data/spec/semipublic/adapters/postgres_adapter_spec.rb +17 -0
  97. data/spec/semipublic/adapters/sqlite3_adapter_spec.rb +17 -0
  98. data/spec/semipublic/adapters/yaml_adapter_spec.rb +12 -0
  99. data/spec/semipublic/associations/many_to_one_spec.rb +53 -0
  100. data/spec/semipublic/associations/relationship_spec.rb +194 -0
  101. data/spec/semipublic/associations_spec.rb +177 -0
  102. data/spec/semipublic/collection_spec.rb +142 -0
  103. data/spec/semipublic/property_spec.rb +61 -0
  104. data/spec/semipublic/query/conditions_spec.rb +528 -0
  105. data/spec/semipublic/query/path_spec.rb +443 -0
  106. data/spec/semipublic/query_spec.rb +2626 -0
  107. data/spec/semipublic/resource_spec.rb +47 -0
  108. data/spec/semipublic/shared/resource_shared_spec.rb +126 -0
  109. data/spec/spec.opts +3 -1
  110. data/spec/spec_helper.rb +80 -57
  111. data/tasks/ci.rb +19 -31
  112. data/tasks/dm.rb +43 -48
  113. data/tasks/doc.rb +8 -11
  114. data/tasks/gemspec.rb +5 -5
  115. data/tasks/hoe.rb +15 -16
  116. data/tasks/install.rb +8 -10
  117. metadata +72 -93
  118. data/lib/dm-core/associations/relationship_chain.rb +0 -81
  119. data/lib/dm-core/associations.rb +0 -207
  120. data/lib/dm-core/auto_migrations.rb +0 -105
  121. data/lib/dm-core/dependency_queue.rb +0 -32
  122. data/lib/dm-core/hook.rb +0 -11
  123. data/lib/dm-core/is.rb +0 -16
  124. data/lib/dm-core/logger.rb +0 -232
  125. data/lib/dm-core/migrations/destructive_migrations.rb +0 -17
  126. data/lib/dm-core/migrator.rb +0 -29
  127. data/lib/dm-core/scope.rb +0 -58
  128. data/lib/dm-core/support/array.rb +0 -13
  129. data/lib/dm-core/support/assertions.rb +0 -8
  130. data/lib/dm-core/support/errors.rb +0 -23
  131. data/lib/dm-core/support/kernel.rb +0 -11
  132. data/lib/dm-core/support/symbol.rb +0 -41
  133. data/lib/dm-core/support.rb +0 -7
  134. data/lib/dm-core/type_map.rb +0 -80
  135. data/lib/dm-core/types.rb +0 -19
  136. data/script/all +0 -4
  137. data/spec/integration/association_spec.rb +0 -1382
  138. data/spec/integration/association_through_spec.rb +0 -203
  139. data/spec/integration/associations/many_to_many_spec.rb +0 -449
  140. data/spec/integration/associations/many_to_one_spec.rb +0 -163
  141. data/spec/integration/associations/one_to_many_spec.rb +0 -188
  142. data/spec/integration/auto_migrations_spec.rb +0 -413
  143. data/spec/integration/collection_spec.rb +0 -1073
  144. data/spec/integration/data_objects_adapter_spec.rb +0 -32
  145. data/spec/integration/dependency_queue_spec.rb +0 -46
  146. data/spec/integration/model_spec.rb +0 -197
  147. data/spec/integration/mysql_adapter_spec.rb +0 -85
  148. data/spec/integration/postgres_adapter_spec.rb +0 -731
  149. data/spec/integration/property_spec.rb +0 -253
  150. data/spec/integration/query_spec.rb +0 -514
  151. data/spec/integration/repository_spec.rb +0 -61
  152. data/spec/integration/resource_spec.rb +0 -513
  153. data/spec/integration/sqlite3_adapter_spec.rb +0 -352
  154. data/spec/integration/sti_spec.rb +0 -273
  155. data/spec/integration/strategic_eager_loading_spec.rb +0 -156
  156. data/spec/integration/transaction_spec.rb +0 -75
  157. data/spec/integration/type_spec.rb +0 -275
  158. data/spec/lib/logging_helper.rb +0 -18
  159. data/spec/lib/mock_adapter.rb +0 -27
  160. data/spec/lib/model_loader.rb +0 -100
  161. data/spec/lib/publicize_methods.rb +0 -28
  162. data/spec/models/content.rb +0 -16
  163. data/spec/models/vehicles.rb +0 -34
  164. data/spec/models/zoo.rb +0 -48
  165. data/spec/unit/adapters/abstract_adapter_spec.rb +0 -133
  166. data/spec/unit/adapters/adapter_shared_spec.rb +0 -15
  167. data/spec/unit/adapters/data_objects_adapter_spec.rb +0 -632
  168. data/spec/unit/adapters/in_memory_adapter_spec.rb +0 -98
  169. data/spec/unit/adapters/postgres_adapter_spec.rb +0 -133
  170. data/spec/unit/associations/many_to_many_spec.rb +0 -32
  171. data/spec/unit/associations/many_to_one_spec.rb +0 -159
  172. data/spec/unit/associations/one_to_many_spec.rb +0 -393
  173. data/spec/unit/associations/one_to_one_spec.rb +0 -7
  174. data/spec/unit/associations/relationship_spec.rb +0 -71
  175. data/spec/unit/associations_spec.rb +0 -242
  176. data/spec/unit/auto_migrations_spec.rb +0 -111
  177. data/spec/unit/collection_spec.rb +0 -182
  178. data/spec/unit/data_mapper_spec.rb +0 -35
  179. data/spec/unit/identity_map_spec.rb +0 -126
  180. data/spec/unit/is_spec.rb +0 -80
  181. data/spec/unit/migrator_spec.rb +0 -33
  182. data/spec/unit/model_spec.rb +0 -321
  183. data/spec/unit/naming_conventions_spec.rb +0 -36
  184. data/spec/unit/property_set_spec.rb +0 -90
  185. data/spec/unit/property_spec.rb +0 -753
  186. data/spec/unit/query_spec.rb +0 -571
  187. data/spec/unit/repository_spec.rb +0 -93
  188. data/spec/unit/resource_spec.rb +0 -649
  189. data/spec/unit/scope_spec.rb +0 -142
  190. data/spec/unit/transaction_spec.rb +0 -493
  191. data/spec/unit/type_map_spec.rb +0 -114
  192. data/spec/unit/type_spec.rb +0 -119
data/lib/dm-core/is.rb DELETED
@@ -1,16 +0,0 @@
1
- module DataMapper
2
- module Is
3
-
4
- def is(plugin, *pars, &block)
5
- generator_method = "is_#{plugin}".to_sym
6
-
7
- if self.respond_to?(generator_method)
8
- self.send(generator_method, *pars, &block)
9
- else
10
- raise PluginNotFoundError, "could not find plugin named #{plugin}"
11
- end
12
- end
13
-
14
- Model.send(:include, self)
15
- end # module Is
16
- end # module DataMapper
@@ -1,232 +0,0 @@
1
- require "time" # httpdate
2
- # ==== Public DataMapper Logger API
3
- #
4
- # Logger taken from Merb :)
5
- #
6
- # To replace an existing logger with a new one:
7
- # DataMapper.logger.set_log(log{String, IO},level{Symbol, String})
8
- #
9
- # Available logging levels are:
10
- # :off, :fatal, :error, :warn, :info, :debug
11
- #
12
- # Logging via:
13
- # DataMapper.logger.fatal(message<String>)
14
- # DataMapper.logger.error(message<String>)
15
- # DataMapper.logger.warn(message<String>)
16
- # DataMapper.logger.info(message<String>)
17
- # DataMapper.logger.debug(message<String>)
18
- #
19
- # Flush the buffer to
20
- # DataMapper.logger.flush
21
- #
22
- # Remove the current log object
23
- # DataMapper.logger.close
24
- #
25
- # ==== Private DataMapper Logger API
26
- #
27
- # To initialize the logger you create a new object, proxies to set_log.
28
- # DataMapper::Logger.new(log{String, IO}, level{Symbol, String})
29
- #
30
- # Logger will not create the file until something is actually logged
31
- # This avoids file creation on DataMapper init when it creates the
32
- # default logger.
33
- module DataMapper
34
-
35
- class << self #:nodoc:
36
- attr_accessor :logger
37
- end
38
-
39
- class Logger
40
-
41
- attr_accessor :aio
42
- attr_accessor :delimiter
43
- attr_reader :level
44
- attr_reader :buffer
45
- attr_reader :log
46
-
47
- # @note
48
- # Ruby (standard) logger levels:
49
- # off: absolutely nothing
50
- # fatal: an unhandleable error that results in a program crash
51
- # error: a handleable error condition
52
- # warn: a warning
53
- # info: generic (useful) information about system operation
54
- # debug: low-level information for developers
55
- #
56
- # DataMapper::Logger::LEVELS[:off, :fatal, :error, :warn, :info, :debug]
57
- LEVELS =
58
- {
59
- :off => 99999,
60
- :fatal => 7,
61
- :error => 6,
62
- :warn => 4,
63
- :info => 3,
64
- :debug => 0
65
- }
66
-
67
- def level=(new_level)
68
- @level = LEVELS[new_level.to_sym]
69
- reset_methods(:close)
70
- end
71
-
72
- private
73
-
74
- # The idea here is that instead of performing an 'if' conditional check on
75
- # each logging we do it once when the log object is setup
76
- def set_write_method
77
- @log.instance_eval do
78
-
79
- # Determine if asynchronous IO can be used
80
- def aio?
81
- @aio = !RUBY_PLATFORM.match(/java|mswin/) &&
82
- !(@log == STDOUT) &&
83
- @log.respond_to?(:write_nonblock)
84
- end
85
-
86
- # Define the write method based on if aio an be used
87
- undef write_method if defined? write_method
88
- if aio?
89
- alias :write_method :write_nonblock
90
- else
91
- alias :write_method :write
92
- end
93
- end
94
- end
95
-
96
- def initialize_log(log)
97
- close if @log # be sure that we don't leave open files laying around.
98
- @log = log || "log/dm.log"
99
- end
100
-
101
- def reset_methods(o_or_c)
102
- if o_or_c == :open
103
- alias internal_push push_opened
104
- elsif o_or_c == :close
105
- alias internal_push push_closed
106
- end
107
- end
108
-
109
- def push_opened(string)
110
- message = Time.now.httpdate
111
- message << delimiter
112
- message << string
113
- message << "\n" unless message[-1] == ?\n
114
- @buffer << message
115
- flush # Force a flush for now until we figure out where we want to use the buffering.
116
- end
117
-
118
- def push_closed(string)
119
- unless @log.respond_to?(:write)
120
- log = Pathname(@log)
121
- log.dirname.mkpath
122
- @log = log.open('a')
123
- @log.sync = true
124
- end
125
- set_write_method
126
- reset_methods(:open)
127
- push(string)
128
- end
129
-
130
- alias internal_push push_closed
131
-
132
- def prep_msg(message, level)
133
- level << delimiter << message
134
- end
135
-
136
- public
137
-
138
- # To initialize the logger you create a new object, proxies to set_log.
139
- # DataMapper::Logger.new(log{String, IO},level{Symbol, String})
140
- #
141
- # @param log<IO,String> either an IO object or a name of a logfile.
142
- # @param log_level<String> the message string to be logged
143
- # @param delimiter<String> delimiter to use between message sections
144
- # @param log_creation<Boolean> log that the file is being created
145
- def initialize(*args)
146
- set_log(*args)
147
- end
148
-
149
- # To replace an existing logger with a new one:
150
- # DataMapper.logger.set_log(log{String, IO},level{Symbol, String})
151
- #
152
- # @param log<IO,String> either an IO object or a name of a logfile.
153
- # @param log_level<Symbol> a symbol representing the log level from
154
- # {:off, :fatal, :error, :warn, :info, :debug}
155
- # @param delimiter<String> delimiter to use between message sections
156
- # @param log_creation<Boolean> log that the file is being created
157
- def set_log(log, log_level = :off, delimiter = " ~ ", log_creation = false)
158
- delimiter ||= " ~ "
159
-
160
- if log_level && LEVELS[log_level.to_sym]
161
- self.level = log_level.to_sym
162
- else
163
- self.level = :debug
164
- end
165
-
166
- @buffer = []
167
- @delimiter = delimiter
168
-
169
- initialize_log(log)
170
-
171
- DataMapper.logger = self
172
-
173
- self.info("Logfile created") if log_creation
174
- end
175
-
176
- # Flush the entire buffer to the log object.
177
- # DataMapper.logger.flush
178
- #
179
- def flush
180
- return unless @buffer.size > 0
181
- @log.write_method(@buffer.slice!(0..-1).join)
182
- end
183
-
184
- # Close and remove the current log object.
185
- # DataMapper.logger.close
186
- #
187
- def close
188
- flush
189
- @log.close if @log.respond_to?(:close)
190
- @log = nil
191
- end
192
-
193
- # Appends a string and log level to logger's buffer.
194
-
195
- # @note
196
- # Note that the string is discarded if the string's log level less than the
197
- # logger's log level.
198
- # @note
199
- # Note that if the logger is aio capable then the logger will use
200
- # non-blocking asynchronous writes.
201
- #
202
- # @param level<Fixnum> the logging level as an integer
203
- # @param string<String> the message string to be logged
204
- def push(string)
205
- internal_push(string)
206
- end
207
- alias << push
208
-
209
- # Generate the following logging methods for DataMapper.logger as described
210
- # in the API:
211
- # :fatal, :error, :warn, :info, :debug
212
- # :off only gets a off? method
213
- LEVELS.each_pair do |name, number|
214
- unless name.to_s == 'off'
215
- class_eval <<-EOS, __FILE__, __LINE__
216
- # DOC
217
- def #{name}(message)
218
- self.<<( prep_msg(message, "#{name}") ) if #{name}?
219
- end
220
- EOS
221
- end
222
-
223
- class_eval <<-EOS, __FILE__, __LINE__
224
- # DOC
225
- def #{name}?
226
- #{number} >= level
227
- end
228
- EOS
229
- end
230
-
231
- end # class Logger
232
- end # module DataMapper
@@ -1,17 +0,0 @@
1
- # TODO: move to dm-more/dm-migrations
2
-
3
- module DataMapper
4
- module DestructiveMigrations
5
- def self.included(model)
6
- DestructiveMigrator.models << model
7
- end
8
- end # module DestructiveMigrations
9
-
10
- class DestructiveMigrator < Migrator
11
- def self.migrate(repository_name)
12
- models.each do |model|
13
- model.auto_migrate!
14
- end
15
- end
16
- end # class DestructiveMigrator
17
- end # module DataMapper
@@ -1,29 +0,0 @@
1
- # TODO: move to dm-more/dm-migrations
2
-
3
- module DataMapper
4
- class Migrator
5
- def self.subclasses
6
- @@subclasses ||= []
7
- end
8
-
9
- def self.subclasses=(obj)
10
- @@subclasses = obj
11
- end
12
-
13
- def self.inherited(klass)
14
- subclasses << klass
15
-
16
- class << klass
17
- def models
18
- @models ||= []
19
- end
20
- end
21
- end
22
-
23
- def self.migrate(repository_name)
24
- subclasses.collect do |migrator|
25
- migrator.migrate(repository_name)
26
- end.flatten
27
- end
28
- end # class Migrator
29
- end # module DataMapper
data/lib/dm-core/scope.rb DELETED
@@ -1,58 +0,0 @@
1
- module DataMapper
2
- module Scope
3
- Model.append_extensions self
4
-
5
- # @api private
6
- def default_scope(repository_name = nil)
7
- repository_name = self.default_repository_name if repository_name == :default || repository_name.nil?
8
- @default_scope ||= {}
9
- @default_scope[repository_name] ||= {}
10
- end
11
-
12
- # @api private
13
- def query
14
- scope_stack.last
15
- end
16
-
17
- protected
18
-
19
- # @api semipublic
20
- def with_scope(query)
21
- # merge the current scope with the passed in query
22
- with_exclusive_scope(self.query ? self.query.merge(query) : query) {|*block_args| yield(*block_args) }
23
- end
24
-
25
- # @api semipublic
26
- def with_exclusive_scope(query)
27
- query = DataMapper::Query.new(repository, self, query) if query.kind_of?(Hash)
28
-
29
- scope_stack << query
30
-
31
- begin
32
- return yield(query)
33
- ensure
34
- scope_stack.pop
35
- end
36
- end
37
-
38
- private
39
-
40
- # @api private
41
- def merge_with_default_scope(query)
42
- DataMapper::Query.new(query.repository, query.model, default_scope_for_query(query)).update(query)
43
- end
44
-
45
- # @api private
46
- def scope_stack
47
- scope_stack_for = Thread.current[:dm_scope_stack] ||= {}
48
- scope_stack_for[self] ||= []
49
- end
50
-
51
- # @api private
52
- def default_scope_for_query(query)
53
- repository_name = query.repository.name
54
- default_repository_name = query.model.default_repository_name
55
- self.default_scope(default_repository_name).merge(self.default_scope(repository_name))
56
- end
57
- end # module Scope
58
- end # module DataMapper
@@ -1,13 +0,0 @@
1
- class Array
2
-
3
- ##
4
- # atm it assumes self is an array of [key,value]-arrays
5
- # this is just a better way to make hashes than Hash[*array.flatten]
6
- # since you cannot flatten only one level in ruby 1.8.6
7
- #
8
- def to_hash
9
- h = {}
10
- self.each{ |k,v| h[k] = v }
11
- h
12
- end
13
- end # class Symbol
@@ -1,8 +0,0 @@
1
- module DataMapper
2
- module Assertions
3
- def assert_kind_of(name, value, *klasses)
4
- klasses.each { |k| return if value.kind_of?(k) }
5
- raise ArgumentError, "+#{name}+ should be #{klasses.map { |k| k.name } * ' or '}, but was #{value.class.name}", caller(2)
6
- end
7
- end
8
- end # module DataMapper
@@ -1,23 +0,0 @@
1
- #Some useful errors types
2
- module DataMapper
3
- class ValidationError < StandardError; end
4
-
5
- class ObjectNotFoundError < StandardError; end
6
-
7
- class MaterializationError < StandardError; end
8
-
9
- class RepositoryNotSetupError < StandardError; end
10
-
11
- class IncompleteResourceError < StandardError; end
12
-
13
- class PersistenceError < StandardError; end
14
-
15
- class PluginNotFoundError < StandardError; end
16
- end # module DataMapper
17
-
18
- class StandardError
19
- # Displays the specific error message and the backtrace associated with it.
20
- def display
21
- "#{message}\n\t#{backtrace.join("\n\t")}"
22
- end
23
- end # class StandardError
@@ -1,11 +0,0 @@
1
- module Kernel
2
- # Delegates to DataMapper::repository.
3
- # Will not overwrite if a method of the same name is pre-defined.
4
- def repository(*args)
5
- if block_given?
6
- DataMapper.repository(*args) { |*block_args| yield(*block_args) }
7
- else
8
- DataMapper.repository(*args)
9
- end
10
- end
11
- end # module Kernel
@@ -1,41 +0,0 @@
1
- class Symbol
2
- def gt
3
- DataMapper::Query::Operator.new(self, :gt)
4
- end
5
-
6
- def gte
7
- DataMapper::Query::Operator.new(self, :gte)
8
- end
9
-
10
- def lt
11
- DataMapper::Query::Operator.new(self, :lt)
12
- end
13
-
14
- def lte
15
- DataMapper::Query::Operator.new(self, :lte)
16
- end
17
-
18
- def not
19
- DataMapper::Query::Operator.new(self, :not)
20
- end
21
-
22
- def eql
23
- DataMapper::Query::Operator.new(self, :eql)
24
- end
25
-
26
- def like
27
- DataMapper::Query::Operator.new(self, :like)
28
- end
29
-
30
- def in
31
- DataMapper::Query::Operator.new(self, :in)
32
- end
33
-
34
- def asc
35
- DataMapper::Query::Operator.new(self, :asc)
36
- end
37
-
38
- def desc
39
- DataMapper::Query::Operator.new(self, :desc)
40
- end
41
- end # class Symbol
@@ -1,7 +0,0 @@
1
- dir = Pathname(__FILE__).dirname.expand_path / 'support'
2
-
3
- require dir / 'array'
4
- require dir / 'assertions'
5
- require dir / 'errors'
6
- require dir / 'kernel'
7
- require dir / 'symbol'
@@ -1,80 +0,0 @@
1
- # TODO: move to dm-more/dm-migrations
2
-
3
- module DataMapper
4
- class TypeMap
5
-
6
- attr_accessor :parent, :chains
7
-
8
- def initialize(parent = nil, &blk)
9
- @parent, @chains = parent, {}
10
-
11
- blk.call(self) unless blk.nil?
12
- end
13
-
14
- def map(type)
15
- @chains[type] ||= TypeChain.new
16
- end
17
-
18
- def lookup(type)
19
- if type_mapped?(type)
20
- lookup_from_map(type)
21
- else
22
- lookup_by_type(type)
23
- end
24
- end
25
-
26
- def lookup_from_map(type)
27
- lookup_from_parent(type).merge(map(type).translate)
28
- end
29
-
30
- def lookup_from_parent(type)
31
- if !@parent.nil? && @parent.type_mapped?(type)
32
- @parent[type]
33
- else
34
- {}
35
- end
36
- end
37
-
38
- # @raise <DataMapper::TypeMap::Error> if the type is not a default primitive or has a type map entry.
39
- def lookup_by_type(type)
40
- raise DataMapper::TypeMap::Error.new(type) unless type.respond_to?(:primitive) && !type.primitive.nil?
41
-
42
- lookup(type.primitive).merge(Type::PROPERTY_OPTIONS.inject({}) {|h, k| h[k] = type.send(k); h})
43
- end
44
-
45
- alias [] lookup
46
-
47
- def type_mapped?(type)
48
- @chains.has_key?(type) || (@parent.nil? ? false : @parent.type_mapped?(type))
49
- end
50
-
51
- class TypeChain
52
- attr_accessor :primitive, :attributes
53
-
54
- def initialize
55
- @attributes = {}
56
- end
57
-
58
- def to(primitive)
59
- @primitive = primitive
60
- self
61
- end
62
-
63
- def with(attributes)
64
- raise "method 'with' expects a hash" unless attributes.kind_of?(Hash)
65
- @attributes.merge!(attributes)
66
- self
67
- end
68
-
69
- def translate
70
- @attributes.merge((@primitive.nil? ? {} : {:primitive => @primitive}))
71
- end
72
- end # class TypeChain
73
-
74
- class Error < StandardError
75
- def initialize(type)
76
- super("Type #{type} must have a default primitive or type map entry")
77
- end
78
- end
79
- end # class TypeMap
80
- end # module DataMapper
data/lib/dm-core/types.rb DELETED
@@ -1,19 +0,0 @@
1
- dir = Pathname(__FILE__).dirname.expand_path / 'types'
2
-
3
- require dir / 'boolean'
4
- require dir / 'discriminator'
5
- require dir / 'text'
6
- require dir / 'paranoid_datetime'
7
- require dir / 'paranoid_boolean'
8
- require dir / 'object'
9
- require dir / 'serial'
10
-
11
- unless defined?(DM)
12
- DM = DataMapper::Types
13
- end
14
-
15
- module DataMapper
16
- module Resource
17
- include Types
18
- end # module Resource
19
- end # module DataMapper
data/script/all DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- ADAPTER=sqlite3 rake spec
3
- ADAPTER=mysql rake spec
4
- ADAPTER=postgres rake spec