dm-core 1.1.0.rc2 → 1.1.0.rc3

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 (71) hide show
  1. data/Gemfile +1 -8
  2. data/VERSION +1 -1
  3. data/dm-core.gemspec +24 -15
  4. data/lib/dm-core.rb +9 -48
  5. data/lib/dm-core/adapters.rb +1 -1
  6. data/lib/dm-core/adapters/abstract_adapter.rb +2 -1
  7. data/lib/dm-core/associations/many_to_many.rb +3 -3
  8. data/lib/dm-core/associations/many_to_one.rb +15 -4
  9. data/lib/dm-core/associations/one_to_many.rb +1 -1
  10. data/lib/dm-core/associations/relationship.rb +7 -6
  11. data/lib/dm-core/collection.rb +7 -2
  12. data/lib/dm-core/core_ext/pathname.rb +0 -14
  13. data/lib/dm-core/ext/array.rb +41 -0
  14. data/lib/dm-core/ext/blank.rb +24 -0
  15. data/lib/dm-core/ext/hash.rb +67 -0
  16. data/lib/dm-core/ext/module.rb +49 -0
  17. data/lib/dm-core/ext/object.rb +57 -0
  18. data/lib/dm-core/ext/singleton_class.rb +8 -0
  19. data/lib/dm-core/ext/string.rb +24 -0
  20. data/lib/dm-core/ext/try_dup.rb +12 -0
  21. data/lib/dm-core/model.rb +2 -1
  22. data/lib/dm-core/model/property.rb +3 -2
  23. data/lib/dm-core/property.rb +1 -1
  24. data/lib/dm-core/property/class.rb +1 -1
  25. data/lib/dm-core/property/date.rb +3 -3
  26. data/lib/dm-core/property/date_time.rb +3 -3
  27. data/lib/dm-core/property/time.rb +3 -3
  28. data/lib/dm-core/property/typecast/time.rb +2 -2
  29. data/lib/dm-core/property_set.rb +1 -1
  30. data/lib/dm-core/query.rb +9 -12
  31. data/lib/dm-core/resource.rb +2 -2
  32. data/lib/dm-core/spec/lib/counter_adapter.rb +1 -1
  33. data/lib/dm-core/spec/lib/spec_helper.rb +1 -1
  34. data/lib/dm-core/spec/shared/resource_spec.rb +2 -1
  35. data/lib/dm-core/support/equalizer.rb +1 -1
  36. data/lib/dm-core/support/hook.rb +0 -15
  37. data/lib/dm-core/support/inflections.rb +60 -0
  38. data/lib/dm-core/support/inflector.rb +3 -0
  39. data/lib/dm-core/support/inflector/inflections.rb +211 -0
  40. data/lib/dm-core/support/inflector/methods.rb +151 -0
  41. data/lib/dm-core/support/lazy_array.rb +4 -4
  42. data/lib/dm-core/support/mash.rb +176 -0
  43. data/lib/dm-core/support/subject.rb +1 -1
  44. data/lib/dm-core/version.rb +1 -1
  45. data/spec/public/model/relationship_spec.rb +2 -1
  46. data/spec/public/shared/collection_shared_spec.rb +5 -2
  47. data/spec/public/shared/finder_shared_spec.rb +10 -6
  48. data/spec/semipublic/adapters/in_memory_adapter_spec.rb +1 -1
  49. data/spec/semipublic/query_spec.rb +2 -2
  50. data/spec/semipublic/resource/state/immutable_spec.rb +2 -1
  51. data/spec/semipublic/resource/state_spec.rb +1 -3
  52. data/spec/semipublic/shared/resource_state_shared_spec.rb +2 -1
  53. data/spec/semipublic/shared/subject_shared_spec.rb +1 -1
  54. data/spec/support/core_ext/hash.rb +10 -0
  55. data/spec/support/core_ext/inheritable_attributes.rb +46 -0
  56. data/spec/unit/array_spec.rb +8 -20
  57. data/spec/unit/blank_spec.rb +62 -0
  58. data/spec/unit/data_mapper/ordered_set/hash_spec.rb +1 -1
  59. data/spec/unit/hash_spec.rb +8 -16
  60. data/spec/unit/lazy_array_spec.rb +3 -14
  61. data/spec/unit/mash_spec.rb +312 -0
  62. data/spec/unit/module_spec.rb +15 -15
  63. data/spec/unit/object_spec.rb +9 -9
  64. data/spec/unit/try_dup_spec.rb +8 -8
  65. metadata +32 -39
  66. data/lib/dm-core/core_ext/array.rb +0 -36
  67. data/lib/dm-core/core_ext/hash.rb +0 -30
  68. data/lib/dm-core/core_ext/module.rb +0 -46
  69. data/lib/dm-core/core_ext/object.rb +0 -31
  70. data/lib/dm-core/core_ext/string.rb +0 -22
  71. data/lib/dm-core/core_ext/try_dup.rb +0 -44
@@ -1,31 +0,0 @@
1
- class Object
2
-
3
- # @param name<String> The name of the constant to get, e.g. "Merb::Router".
4
- #
5
- # @return [Object] The constant corresponding to the name.
6
- def full_const_get(name)
7
- list = name.split("::")
8
- list.shift if list.first.blank?
9
- obj = self
10
- list.each do |x|
11
- # This is required because const_get tries to look for constants in the
12
- # ancestor chain, but we only want constants that are HERE
13
- obj = obj.const_defined?(x) ? obj.const_get(x) : obj.const_missing(x)
14
- end
15
- obj
16
- end
17
-
18
- # @param name<String> The name of the constant to get, e.g. "Merb::Router".
19
- # @param value<Object> The value to assign to the constant.
20
- #
21
- # @return [Object] The constant corresponding to the name.
22
- def full_const_set(name, value)
23
- list = name.split("::")
24
- toplevel = list.first.blank?
25
- list.shift if toplevel
26
- last = list.pop
27
- obj = list.empty? ? Object : Object.full_const_get(list.join("::"))
28
- obj.const_set(last, value) if obj && !obj.const_defined?(last)
29
- end
30
-
31
- end
@@ -1,22 +0,0 @@
1
- class String
2
-
3
- ##
4
- # Replace sequences of whitespace (including newlines) with either
5
- # a single space or remove them entirely (according to param _spaced_)
6
- #
7
- # <<QUERY.compress_lines
8
- # SELECT name
9
- # FROM users
10
- # QUERY => "SELECT name FROM users"
11
- #
12
- # @param [TrueClass, FalseClass] spaced (default=true)
13
- # Determines whether returned string has whitespace collapsed or removed
14
- #
15
- # @return [String] Receiver with whitespace (including newlines) replaced
16
- #
17
- # @api public
18
- def compress_lines(spaced = true)
19
- split($/).map { |line| line.strip }.join(spaced ? ' ' : '')
20
- end
21
-
22
- end
@@ -1,44 +0,0 @@
1
- class Object
2
- # Override this in a child if it cannot be dup'ed
3
- #
4
- # @return [Object]
5
- def try_dup
6
- self.dup
7
- end
8
- end
9
-
10
- class TrueClass
11
- def try_dup
12
- self
13
- end
14
- end
15
-
16
- class FalseClass
17
- def try_dup
18
- self
19
- end
20
- end
21
-
22
- class Module
23
- def try_dup
24
- self
25
- end
26
- end
27
-
28
- class NilClass
29
- def try_dup
30
- self
31
- end
32
- end
33
-
34
- class Numeric
35
- def try_dup
36
- self
37
- end
38
- end
39
-
40
- class Symbol
41
- def try_dup
42
- self
43
- end
44
- end