motion-support 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +1 -1
  3. data/README.md +231 -2
  4. data/Rakefile +3 -3
  5. data/app/app_delegate.rb +0 -2
  6. data/examples/Inflector/.gitignore +16 -0
  7. data/examples/Inflector/Gemfile +5 -0
  8. data/examples/Inflector/Rakefile +13 -0
  9. data/examples/Inflector/app/app_delegate.rb +8 -0
  10. data/examples/Inflector/app/inflections.rb +5 -0
  11. data/examples/Inflector/app/inflector_view_controller.rb +120 -0
  12. data/examples/Inflector/app/words_view_controller.rb +101 -0
  13. data/examples/Inflector/resources/Default-568h@2x.png +0 -0
  14. data/examples/Inflector/spec/main_spec.rb +9 -0
  15. data/lib/motion-support/core_ext/array.rb +13 -0
  16. data/lib/motion-support/core_ext/class.rb +8 -0
  17. data/lib/motion-support/core_ext/hash.rb +16 -0
  18. data/lib/motion-support/core_ext/integer.rb +9 -0
  19. data/lib/motion-support/core_ext/module.rb +14 -0
  20. data/lib/motion-support/core_ext/numeric.rb +8 -0
  21. data/lib/motion-support/core_ext/object.rb +14 -0
  22. data/lib/motion-support/core_ext/range.rb +8 -0
  23. data/lib/motion-support/core_ext/string.rb +14 -0
  24. data/lib/motion-support/core_ext/time.rb +19 -0
  25. data/lib/motion-support/core_ext.rb +3 -0
  26. data/lib/motion-support/inflector.rb +12 -156
  27. data/lib/motion-support.rb +5 -5
  28. data/motion/_stdlib/cgi.rb +22 -0
  29. data/motion/_stdlib/date.rb +77 -0
  30. data/motion/_stdlib/time.rb +19 -0
  31. data/motion/core_ext/array/access.rb +28 -0
  32. data/motion/core_ext/array/conversions.rb +86 -0
  33. data/motion/core_ext/array/extract_options.rb +11 -0
  34. data/motion/core_ext/array/grouping.rb +99 -0
  35. data/motion/core_ext/array/prepend_and_append.rb +7 -0
  36. data/motion/core_ext/array/wrap.rb +45 -0
  37. data/{lib/motion-support → motion/core_ext}/array.rb +0 -4
  38. data/motion/core_ext/class/attribute.rb +119 -0
  39. data/motion/core_ext/class/attribute_accessors.rb +168 -0
  40. data/motion/core_ext/date/acts_like.rb +8 -0
  41. data/motion/core_ext/date/calculations.rb +117 -0
  42. data/motion/core_ext/date/conversions.rb +56 -0
  43. data/motion/core_ext/date_and_time/calculations.rb +232 -0
  44. data/motion/core_ext/enumerable.rb +90 -0
  45. data/motion/core_ext/hash/deep_merge.rb +27 -0
  46. data/motion/core_ext/hash/except.rb +15 -0
  47. data/motion/core_ext/hash/indifferent_access.rb +19 -0
  48. data/motion/core_ext/hash/keys.rb +138 -0
  49. data/motion/core_ext/hash/reverse_merge.rb +22 -0
  50. data/motion/core_ext/hash/slice.rb +40 -0
  51. data/motion/core_ext/integer/inflections.rb +27 -0
  52. data/motion/core_ext/integer/multiple.rb +10 -0
  53. data/motion/core_ext/integer/time.rb +41 -0
  54. data/{lib/motion-support → motion/core_ext}/metaclass.rb +0 -0
  55. data/motion/core_ext/module/aliasing.rb +69 -0
  56. data/motion/core_ext/module/anonymous.rb +19 -0
  57. data/motion/core_ext/module/attr_internal.rb +38 -0
  58. data/motion/core_ext/module/attribute_accessors.rb +64 -0
  59. data/motion/core_ext/module/delegation.rb +175 -0
  60. data/motion/core_ext/module/introspection.rb +60 -0
  61. data/motion/core_ext/module/reachable.rb +5 -0
  62. data/motion/core_ext/module/remove_method.rb +12 -0
  63. data/motion/core_ext/ns_dictionary.rb +11 -0
  64. data/motion/core_ext/numeric/bytes.rb +44 -0
  65. data/motion/core_ext/numeric/conversions.rb +7 -0
  66. data/motion/core_ext/numeric/time.rb +75 -0
  67. data/motion/core_ext/object/acts_like.rb +10 -0
  68. data/motion/core_ext/object/blank.rb +105 -0
  69. data/motion/core_ext/object/deep_dup.rb +44 -0
  70. data/motion/core_ext/object/duplicable.rb +83 -0
  71. data/motion/core_ext/object/instance_variables.rb +28 -0
  72. data/motion/core_ext/object/to_param.rb +58 -0
  73. data/motion/core_ext/object/to_query.rb +26 -0
  74. data/motion/core_ext/object/try.rb +78 -0
  75. data/motion/core_ext/range/include_range.rb +23 -0
  76. data/motion/core_ext/range/overlaps.rb +8 -0
  77. data/motion/core_ext/regexp.rb +5 -0
  78. data/motion/core_ext/string/access.rb +104 -0
  79. data/motion/core_ext/string/behavior.rb +6 -0
  80. data/motion/core_ext/string/exclude.rb +11 -0
  81. data/motion/core_ext/string/filters.rb +55 -0
  82. data/motion/core_ext/string/indent.rb +43 -0
  83. data/motion/core_ext/string/inflections.rb +195 -0
  84. data/motion/core_ext/string/starts_ends_with.rb +4 -0
  85. data/motion/core_ext/string/strip.rb +24 -0
  86. data/motion/core_ext/time/acts_like.rb +8 -0
  87. data/motion/core_ext/time/calculations.rb +215 -0
  88. data/motion/core_ext/time/conversions.rb +52 -0
  89. data/motion/duration.rb +104 -0
  90. data/motion/hash_with_indifferent_access.rb +251 -0
  91. data/motion/inflections.rb +67 -0
  92. data/motion/inflector/inflections.rb +203 -0
  93. data/motion/inflector/methods.rb +321 -0
  94. data/{lib/motion-support → motion}/logger.rb +0 -0
  95. data/{lib/motion-support → motion}/version.rb +1 -1
  96. data/motion-support.gemspec +2 -2
  97. data/spec/motion-support/_helpers/constantize_test_cases.rb +75 -0
  98. data/spec/motion-support/_helpers/inflector_test_cases.rb +313 -0
  99. data/spec/motion-support/core_ext/array/access_spec.rb +29 -0
  100. data/spec/motion-support/core_ext/array/conversion_spec.rb +60 -0
  101. data/spec/motion-support/core_ext/array/extract_options_spec.rb +15 -0
  102. data/spec/motion-support/core_ext/array/grouping_spec.rb +85 -0
  103. data/spec/motion-support/core_ext/array/prepend_and_append_spec.rb +25 -0
  104. data/spec/motion-support/core_ext/array/wrap_spec.rb +19 -0
  105. data/spec/motion-support/{array_spec.rb → core_ext/array_spec.rb} +0 -5
  106. data/spec/motion-support/core_ext/class/attribute_accessor_spec.rb +127 -0
  107. data/spec/motion-support/core_ext/class/attribute_spec.rb +92 -0
  108. data/spec/motion-support/core_ext/date/acts_like_spec.rb +11 -0
  109. data/spec/motion-support/core_ext/date/calculation_spec.rb +186 -0
  110. data/spec/motion-support/core_ext/date/conversion_spec.rb +18 -0
  111. data/spec/motion-support/core_ext/date_and_time/calculation_spec.rb +336 -0
  112. data/spec/motion-support/core_ext/enumerable_spec.rb +130 -0
  113. data/spec/motion-support/core_ext/hash/deep_merge_spec.rb +32 -0
  114. data/spec/motion-support/core_ext/hash/except_spec.rb +43 -0
  115. data/spec/motion-support/core_ext/hash/key_spec.rb +230 -0
  116. data/spec/motion-support/core_ext/hash/reverse_merge_spec.rb +26 -0
  117. data/spec/motion-support/core_ext/hash/slice_spec.rb +61 -0
  118. data/spec/motion-support/core_ext/integer/inflection_spec.rb +23 -0
  119. data/spec/motion-support/core_ext/integer/multiple_spec.rb +19 -0
  120. data/spec/motion-support/{metaclass_spec.rb → core_ext/metaclass_spec.rb} +0 -0
  121. data/spec/motion-support/core_ext/module/aliasing_spec.rb +143 -0
  122. data/spec/motion-support/core_ext/module/anonymous_spec.rb +29 -0
  123. data/spec/motion-support/core_ext/module/attr_internal_spec.rb +104 -0
  124. data/spec/motion-support/core_ext/module/attribute_accessor_spec.rb +86 -0
  125. data/spec/motion-support/core_ext/module/delegation_spec.rb +136 -0
  126. data/spec/motion-support/core_ext/module/introspection_spec.rb +70 -0
  127. data/spec/motion-support/core_ext/module/reachable_spec.rb +61 -0
  128. data/spec/motion-support/core_ext/module/remove_method_spec.rb +25 -0
  129. data/spec/motion-support/core_ext/numeric/bytes_spec.rb +43 -0
  130. data/spec/motion-support/core_ext/object/acts_like_spec.rb +21 -0
  131. data/spec/motion-support/core_ext/object/blank_spec.rb +54 -0
  132. data/spec/motion-support/core_ext/object/deep_dup_spec.rb +54 -0
  133. data/spec/motion-support/core_ext/object/duplicable_spec.rb +31 -0
  134. data/spec/motion-support/core_ext/object/instance_variable_spec.rb +19 -0
  135. data/spec/motion-support/core_ext/object/to_param_spec.rb +75 -0
  136. data/spec/motion-support/core_ext/object/to_query_spec.rb +37 -0
  137. data/spec/motion-support/core_ext/object/try_spec.rb +92 -0
  138. data/spec/motion-support/core_ext/range/include_range_spec.rb +31 -0
  139. data/spec/motion-support/core_ext/range/overlap_spec.rb +43 -0
  140. data/spec/motion-support/core_ext/regexp_spec.rb +7 -0
  141. data/spec/motion-support/core_ext/string/access_spec.rb +53 -0
  142. data/spec/motion-support/core_ext/string/behavior_spec.rb +7 -0
  143. data/spec/motion-support/core_ext/string/exclude_spec.rb +8 -0
  144. data/spec/motion-support/core_ext/string/filter_spec.rb +48 -0
  145. data/spec/motion-support/core_ext/string/indent_spec.rb +56 -0
  146. data/spec/motion-support/core_ext/string/inflection_spec.rb +142 -0
  147. data/spec/motion-support/core_ext/string/starts_end_with_spec.rb +14 -0
  148. data/spec/motion-support/core_ext/string/strip_spec.rb +34 -0
  149. data/spec/motion-support/core_ext/string_spec.rb +88 -0
  150. data/spec/motion-support/core_ext/time/acts_like_spec.rb +11 -0
  151. data/spec/motion-support/core_ext/time/calculation_spec.rb +201 -0
  152. data/spec/motion-support/core_ext/time/conversion_spec.rb +54 -0
  153. data/spec/motion-support/duration_spec.rb +107 -0
  154. data/spec/motion-support/hash_with_indifferent_access_spec.rb +605 -0
  155. data/spec/motion-support/inflector_spec.rb +474 -35
  156. data/spec/motion-support/ns_dictionary_spec.rb +29 -0
  157. metadata +212 -35
  158. data/lib/motion-support/cattr_accessor.rb +0 -19
  159. data/lib/motion-support/class_inheritable_accessor.rb +0 -23
  160. data/lib/motion-support/class_inheritable_array.rb +0 -29
  161. data/lib/motion-support/hash.rb +0 -31
  162. data/lib/motion-support/nilclass.rb +0 -5
  163. data/lib/motion-support/object.rb +0 -17
  164. data/lib/motion-support/string.rb +0 -71
  165. data/spec/motion-support/cattr_accessor_spec.rb +0 -49
  166. data/spec/motion-support/class_inheritable_accessor_spec.rb +0 -49
  167. data/spec/motion-support/class_inheritable_array_spec.rb +0 -61
  168. data/spec/motion-support/hash_spec.rb +0 -31
  169. data/spec/motion-support/nilclass_spec.rb +0 -5
  170. data/spec/motion-support/object_spec.rb +0 -43
  171. data/spec/motion-support/string_spec.rb +0 -145
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: motion-support
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas Kadauke
@@ -10,16 +10,16 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-03-14 00:00:00 Z
13
+ date: 2013-04-30 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: bubble-wrap
16
+ name: motion-require
17
17
  requirement: &id001 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: "0"
22
+ version: 0.0.6
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: *id001
@@ -49,30 +49,157 @@ files:
49
49
  - README.md
50
50
  - Rakefile
51
51
  - app/app_delegate.rb
52
+ - examples/Inflector/.gitignore
53
+ - examples/Inflector/Gemfile
54
+ - examples/Inflector/Rakefile
55
+ - examples/Inflector/app/app_delegate.rb
56
+ - examples/Inflector/app/inflections.rb
57
+ - examples/Inflector/app/inflector_view_controller.rb
58
+ - examples/Inflector/app/words_view_controller.rb
59
+ - examples/Inflector/resources/Default-568h@2x.png
60
+ - examples/Inflector/spec/main_spec.rb
52
61
  - lib/motion-support.rb
53
- - lib/motion-support/array.rb
54
- - lib/motion-support/cattr_accessor.rb
55
- - lib/motion-support/class_inheritable_accessor.rb
56
- - lib/motion-support/class_inheritable_array.rb
57
- - lib/motion-support/hash.rb
62
+ - lib/motion-support/core_ext.rb
63
+ - lib/motion-support/core_ext/array.rb
64
+ - lib/motion-support/core_ext/class.rb
65
+ - lib/motion-support/core_ext/hash.rb
66
+ - lib/motion-support/core_ext/integer.rb
67
+ - lib/motion-support/core_ext/module.rb
68
+ - lib/motion-support/core_ext/numeric.rb
69
+ - lib/motion-support/core_ext/object.rb
70
+ - lib/motion-support/core_ext/range.rb
71
+ - lib/motion-support/core_ext/string.rb
72
+ - lib/motion-support/core_ext/time.rb
58
73
  - lib/motion-support/inflector.rb
59
- - lib/motion-support/logger.rb
60
- - lib/motion-support/metaclass.rb
61
- - lib/motion-support/nilclass.rb
62
- - lib/motion-support/object.rb
63
- - lib/motion-support/string.rb
64
- - lib/motion-support/version.rb
65
74
  - motion-support.gemspec
66
- - spec/motion-support/array_spec.rb
67
- - spec/motion-support/cattr_accessor_spec.rb
68
- - spec/motion-support/class_inheritable_accessor_spec.rb
69
- - spec/motion-support/class_inheritable_array_spec.rb
70
- - spec/motion-support/hash_spec.rb
75
+ - motion/_stdlib/cgi.rb
76
+ - motion/_stdlib/date.rb
77
+ - motion/_stdlib/time.rb
78
+ - motion/core_ext/array.rb
79
+ - motion/core_ext/array/access.rb
80
+ - motion/core_ext/array/conversions.rb
81
+ - motion/core_ext/array/extract_options.rb
82
+ - motion/core_ext/array/grouping.rb
83
+ - motion/core_ext/array/prepend_and_append.rb
84
+ - motion/core_ext/array/wrap.rb
85
+ - motion/core_ext/class/attribute.rb
86
+ - motion/core_ext/class/attribute_accessors.rb
87
+ - motion/core_ext/date/acts_like.rb
88
+ - motion/core_ext/date/calculations.rb
89
+ - motion/core_ext/date/conversions.rb
90
+ - motion/core_ext/date_and_time/calculations.rb
91
+ - motion/core_ext/enumerable.rb
92
+ - motion/core_ext/hash/deep_merge.rb
93
+ - motion/core_ext/hash/except.rb
94
+ - motion/core_ext/hash/indifferent_access.rb
95
+ - motion/core_ext/hash/keys.rb
96
+ - motion/core_ext/hash/reverse_merge.rb
97
+ - motion/core_ext/hash/slice.rb
98
+ - motion/core_ext/integer/inflections.rb
99
+ - motion/core_ext/integer/multiple.rb
100
+ - motion/core_ext/integer/time.rb
101
+ - motion/core_ext/metaclass.rb
102
+ - motion/core_ext/module/aliasing.rb
103
+ - motion/core_ext/module/anonymous.rb
104
+ - motion/core_ext/module/attr_internal.rb
105
+ - motion/core_ext/module/attribute_accessors.rb
106
+ - motion/core_ext/module/delegation.rb
107
+ - motion/core_ext/module/introspection.rb
108
+ - motion/core_ext/module/reachable.rb
109
+ - motion/core_ext/module/remove_method.rb
110
+ - motion/core_ext/ns_dictionary.rb
111
+ - motion/core_ext/numeric/bytes.rb
112
+ - motion/core_ext/numeric/conversions.rb
113
+ - motion/core_ext/numeric/time.rb
114
+ - motion/core_ext/object/acts_like.rb
115
+ - motion/core_ext/object/blank.rb
116
+ - motion/core_ext/object/deep_dup.rb
117
+ - motion/core_ext/object/duplicable.rb
118
+ - motion/core_ext/object/instance_variables.rb
119
+ - motion/core_ext/object/to_param.rb
120
+ - motion/core_ext/object/to_query.rb
121
+ - motion/core_ext/object/try.rb
122
+ - motion/core_ext/range/include_range.rb
123
+ - motion/core_ext/range/overlaps.rb
124
+ - motion/core_ext/regexp.rb
125
+ - motion/core_ext/string/access.rb
126
+ - motion/core_ext/string/behavior.rb
127
+ - motion/core_ext/string/exclude.rb
128
+ - motion/core_ext/string/filters.rb
129
+ - motion/core_ext/string/indent.rb
130
+ - motion/core_ext/string/inflections.rb
131
+ - motion/core_ext/string/starts_ends_with.rb
132
+ - motion/core_ext/string/strip.rb
133
+ - motion/core_ext/time/acts_like.rb
134
+ - motion/core_ext/time/calculations.rb
135
+ - motion/core_ext/time/conversions.rb
136
+ - motion/duration.rb
137
+ - motion/hash_with_indifferent_access.rb
138
+ - motion/inflections.rb
139
+ - motion/inflector/inflections.rb
140
+ - motion/inflector/methods.rb
141
+ - motion/logger.rb
142
+ - motion/version.rb
143
+ - spec/motion-support/_helpers/constantize_test_cases.rb
144
+ - spec/motion-support/_helpers/inflector_test_cases.rb
145
+ - spec/motion-support/core_ext/array/access_spec.rb
146
+ - spec/motion-support/core_ext/array/conversion_spec.rb
147
+ - spec/motion-support/core_ext/array/extract_options_spec.rb
148
+ - spec/motion-support/core_ext/array/grouping_spec.rb
149
+ - spec/motion-support/core_ext/array/prepend_and_append_spec.rb
150
+ - spec/motion-support/core_ext/array/wrap_spec.rb
151
+ - spec/motion-support/core_ext/array_spec.rb
152
+ - spec/motion-support/core_ext/class/attribute_accessor_spec.rb
153
+ - spec/motion-support/core_ext/class/attribute_spec.rb
154
+ - spec/motion-support/core_ext/date/acts_like_spec.rb
155
+ - spec/motion-support/core_ext/date/calculation_spec.rb
156
+ - spec/motion-support/core_ext/date/conversion_spec.rb
157
+ - spec/motion-support/core_ext/date_and_time/calculation_spec.rb
158
+ - spec/motion-support/core_ext/enumerable_spec.rb
159
+ - spec/motion-support/core_ext/hash/deep_merge_spec.rb
160
+ - spec/motion-support/core_ext/hash/except_spec.rb
161
+ - spec/motion-support/core_ext/hash/key_spec.rb
162
+ - spec/motion-support/core_ext/hash/reverse_merge_spec.rb
163
+ - spec/motion-support/core_ext/hash/slice_spec.rb
164
+ - spec/motion-support/core_ext/integer/inflection_spec.rb
165
+ - spec/motion-support/core_ext/integer/multiple_spec.rb
166
+ - spec/motion-support/core_ext/metaclass_spec.rb
167
+ - spec/motion-support/core_ext/module/aliasing_spec.rb
168
+ - spec/motion-support/core_ext/module/anonymous_spec.rb
169
+ - spec/motion-support/core_ext/module/attr_internal_spec.rb
170
+ - spec/motion-support/core_ext/module/attribute_accessor_spec.rb
171
+ - spec/motion-support/core_ext/module/delegation_spec.rb
172
+ - spec/motion-support/core_ext/module/introspection_spec.rb
173
+ - spec/motion-support/core_ext/module/reachable_spec.rb
174
+ - spec/motion-support/core_ext/module/remove_method_spec.rb
175
+ - spec/motion-support/core_ext/numeric/bytes_spec.rb
176
+ - spec/motion-support/core_ext/object/acts_like_spec.rb
177
+ - spec/motion-support/core_ext/object/blank_spec.rb
178
+ - spec/motion-support/core_ext/object/deep_dup_spec.rb
179
+ - spec/motion-support/core_ext/object/duplicable_spec.rb
180
+ - spec/motion-support/core_ext/object/instance_variable_spec.rb
181
+ - spec/motion-support/core_ext/object/to_param_spec.rb
182
+ - spec/motion-support/core_ext/object/to_query_spec.rb
183
+ - spec/motion-support/core_ext/object/try_spec.rb
184
+ - spec/motion-support/core_ext/range/include_range_spec.rb
185
+ - spec/motion-support/core_ext/range/overlap_spec.rb
186
+ - spec/motion-support/core_ext/regexp_spec.rb
187
+ - spec/motion-support/core_ext/string/access_spec.rb
188
+ - spec/motion-support/core_ext/string/behavior_spec.rb
189
+ - spec/motion-support/core_ext/string/exclude_spec.rb
190
+ - spec/motion-support/core_ext/string/filter_spec.rb
191
+ - spec/motion-support/core_ext/string/indent_spec.rb
192
+ - spec/motion-support/core_ext/string/inflection_spec.rb
193
+ - spec/motion-support/core_ext/string/starts_end_with_spec.rb
194
+ - spec/motion-support/core_ext/string/strip_spec.rb
195
+ - spec/motion-support/core_ext/string_spec.rb
196
+ - spec/motion-support/core_ext/time/acts_like_spec.rb
197
+ - spec/motion-support/core_ext/time/calculation_spec.rb
198
+ - spec/motion-support/core_ext/time/conversion_spec.rb
199
+ - spec/motion-support/duration_spec.rb
200
+ - spec/motion-support/hash_with_indifferent_access_spec.rb
71
201
  - spec/motion-support/inflector_spec.rb
72
- - spec/motion-support/metaclass_spec.rb
73
- - spec/motion-support/nilclass_spec.rb
74
- - spec/motion-support/object_spec.rb
75
- - spec/motion-support/string_spec.rb
202
+ - spec/motion-support/ns_dictionary_spec.rb
76
203
  homepage: https://github.com/tkadauke/motion-support
77
204
  licenses: []
78
205
 
@@ -86,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
213
  requirements:
87
214
  - - ">="
88
215
  - !ruby/object:Gem::Version
89
- hash: -605165508006699025
216
+ hash: -2446191825511853208
90
217
  segments:
91
218
  - 0
92
219
  version: "0"
@@ -95,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
222
  requirements:
96
223
  - - ">="
97
224
  - !ruby/object:Gem::Version
98
- hash: -605165508006699025
225
+ hash: -2446191825511853208
99
226
  segments:
100
227
  - 0
101
228
  version: "0"
@@ -107,13 +234,63 @@ signing_key:
107
234
  specification_version: 3
108
235
  summary: Commonly useful extensions to the standard library for RubyMotion
109
236
  test_files:
110
- - spec/motion-support/array_spec.rb
111
- - spec/motion-support/cattr_accessor_spec.rb
112
- - spec/motion-support/class_inheritable_accessor_spec.rb
113
- - spec/motion-support/class_inheritable_array_spec.rb
114
- - spec/motion-support/hash_spec.rb
237
+ - spec/motion-support/_helpers/constantize_test_cases.rb
238
+ - spec/motion-support/_helpers/inflector_test_cases.rb
239
+ - spec/motion-support/core_ext/array/access_spec.rb
240
+ - spec/motion-support/core_ext/array/conversion_spec.rb
241
+ - spec/motion-support/core_ext/array/extract_options_spec.rb
242
+ - spec/motion-support/core_ext/array/grouping_spec.rb
243
+ - spec/motion-support/core_ext/array/prepend_and_append_spec.rb
244
+ - spec/motion-support/core_ext/array/wrap_spec.rb
245
+ - spec/motion-support/core_ext/array_spec.rb
246
+ - spec/motion-support/core_ext/class/attribute_accessor_spec.rb
247
+ - spec/motion-support/core_ext/class/attribute_spec.rb
248
+ - spec/motion-support/core_ext/date/acts_like_spec.rb
249
+ - spec/motion-support/core_ext/date/calculation_spec.rb
250
+ - spec/motion-support/core_ext/date/conversion_spec.rb
251
+ - spec/motion-support/core_ext/date_and_time/calculation_spec.rb
252
+ - spec/motion-support/core_ext/enumerable_spec.rb
253
+ - spec/motion-support/core_ext/hash/deep_merge_spec.rb
254
+ - spec/motion-support/core_ext/hash/except_spec.rb
255
+ - spec/motion-support/core_ext/hash/key_spec.rb
256
+ - spec/motion-support/core_ext/hash/reverse_merge_spec.rb
257
+ - spec/motion-support/core_ext/hash/slice_spec.rb
258
+ - spec/motion-support/core_ext/integer/inflection_spec.rb
259
+ - spec/motion-support/core_ext/integer/multiple_spec.rb
260
+ - spec/motion-support/core_ext/metaclass_spec.rb
261
+ - spec/motion-support/core_ext/module/aliasing_spec.rb
262
+ - spec/motion-support/core_ext/module/anonymous_spec.rb
263
+ - spec/motion-support/core_ext/module/attr_internal_spec.rb
264
+ - spec/motion-support/core_ext/module/attribute_accessor_spec.rb
265
+ - spec/motion-support/core_ext/module/delegation_spec.rb
266
+ - spec/motion-support/core_ext/module/introspection_spec.rb
267
+ - spec/motion-support/core_ext/module/reachable_spec.rb
268
+ - spec/motion-support/core_ext/module/remove_method_spec.rb
269
+ - spec/motion-support/core_ext/numeric/bytes_spec.rb
270
+ - spec/motion-support/core_ext/object/acts_like_spec.rb
271
+ - spec/motion-support/core_ext/object/blank_spec.rb
272
+ - spec/motion-support/core_ext/object/deep_dup_spec.rb
273
+ - spec/motion-support/core_ext/object/duplicable_spec.rb
274
+ - spec/motion-support/core_ext/object/instance_variable_spec.rb
275
+ - spec/motion-support/core_ext/object/to_param_spec.rb
276
+ - spec/motion-support/core_ext/object/to_query_spec.rb
277
+ - spec/motion-support/core_ext/object/try_spec.rb
278
+ - spec/motion-support/core_ext/range/include_range_spec.rb
279
+ - spec/motion-support/core_ext/range/overlap_spec.rb
280
+ - spec/motion-support/core_ext/regexp_spec.rb
281
+ - spec/motion-support/core_ext/string/access_spec.rb
282
+ - spec/motion-support/core_ext/string/behavior_spec.rb
283
+ - spec/motion-support/core_ext/string/exclude_spec.rb
284
+ - spec/motion-support/core_ext/string/filter_spec.rb
285
+ - spec/motion-support/core_ext/string/indent_spec.rb
286
+ - spec/motion-support/core_ext/string/inflection_spec.rb
287
+ - spec/motion-support/core_ext/string/starts_end_with_spec.rb
288
+ - spec/motion-support/core_ext/string/strip_spec.rb
289
+ - spec/motion-support/core_ext/string_spec.rb
290
+ - spec/motion-support/core_ext/time/acts_like_spec.rb
291
+ - spec/motion-support/core_ext/time/calculation_spec.rb
292
+ - spec/motion-support/core_ext/time/conversion_spec.rb
293
+ - spec/motion-support/duration_spec.rb
294
+ - spec/motion-support/hash_with_indifferent_access_spec.rb
115
295
  - spec/motion-support/inflector_spec.rb
116
- - spec/motion-support/metaclass_spec.rb
117
- - spec/motion-support/nilclass_spec.rb
118
- - spec/motion-support/object_spec.rb
119
- - spec/motion-support/string_spec.rb
296
+ - spec/motion-support/ns_dictionary_spec.rb
@@ -1,19 +0,0 @@
1
- class Class
2
- # Defines class-level attribute readers as specified in fields. Fields can be one or more
3
- # symbols specifying the names of the readers.
4
- def cattr_reader(*fields)
5
- metaclass.send :attr_reader, *fields
6
- end
7
-
8
- # Defines class-level attribute writers as specified in fields. Fields can be one or more
9
- # symbols specifying the names of the writers.
10
- def cattr_writer(*fields)
11
- metaclass.send :attr_writer, *fields
12
- end
13
-
14
- # Defines class-level attribute readers and writers as specified in fields. Fields can be
15
- # one or more symbols specifying the names of the accessors.
16
- def cattr_accessor(*fields)
17
- metaclass.send :attr_accessor, *fields
18
- end
19
- end
@@ -1,23 +0,0 @@
1
- class Class
2
- # Defines class-level inheritable accessors as specified in fields. Fields can be one or more
3
- # symbols specifying the names of the accessors.
4
- #
5
- # The inheritance semantics of inheritable accessors are similar to methods. Consider an inheritable
6
- # accessor :acc defined in class Base and a class Derived, inheriting from class Base.
7
- #
8
- # 0. :acc is never set. Then Base.acc and Derived.acc are both nil
9
- # 1. :acc is set in class Base. Then Base.acc and Derived.acc are equal
10
- # 2. :acc is set in class Derived. Then Base.acc is nil and Derived.acc is set
11
- # 3. :acc is set in both Base and Derived, but to different values. Then Base.acc and Derived.acc
12
- # have their respective set values.
13
- def class_inheritable_accessor(*fields)
14
- fields.each do |field|
15
- metaclass.send :define_method, field do
16
- ivar = instance_variable_get("@#{field}")
17
- ivar || (superclass.send(field) if superclass.respond_to?(field))
18
- end
19
- end
20
-
21
- cattr_writer *fields
22
- end
23
- end
@@ -1,29 +0,0 @@
1
- class Class
2
- # Defines class-level inheritable array accessors as specified in fields. Fields can be one or more
3
- # symbols specifying the names of the accessors.
4
- #
5
- # Consider an inheritable array accessor :acc defined in class Base and a class Derived, inheriting
6
- # from class Base.
7
- #
8
- # 0. :acc is never set. Then Base.acc and Derived.acc are both empty []
9
- # 1. :acc is set in class Base. Then Base.acc and Derived.acc both contain the same elements
10
- # 2. :acc is set in class Derived. Then Base.acc is empty [] and Derived.acc is not
11
- # 3. :acc is set in both Base and Derived, but with different values. Then Base.acc returns the set
12
- # value(s) and Derived.acc returns an array containing both the values set to Base.acc as well as
13
- # the values set to Derived.acc, in that order.
14
- #
15
- # Inheritable array setters accept both single values or arrays. When setters are used, they overwrite
16
- # any previously set values for this class within the hierarchy (and therefore influencing any subclasses),
17
- # but do not modify any base classes.
18
- def class_inheritable_array(*fields)
19
- fields.each do |field|
20
- metaclass.send :define_method, field do
21
- array = instance_variable_get("@#{field}") || []
22
- super_array = (superclass.send(field) if superclass.respond_to?(field)) || []
23
- [super_array, array].flatten
24
- end
25
- end
26
-
27
- cattr_writer *fields
28
- end
29
- end
@@ -1,31 +0,0 @@
1
- class NSDictionary
2
- # Returns a new Hash which is a copy of this hash, except that all keys have turned into symbols,
3
- # if possible. That is all keys that respond to to_sym.
4
- def symbolize_keys
5
- inject({}) do |hash, pair|
6
- if pair.first.respond_to?(:to_sym)
7
- hash[pair.first.to_sym] = pair.last
8
- else
9
- hash[pair.first] = pair.last
10
- end
11
- hash
12
- end
13
- end
14
- end
15
-
16
- class Hash
17
- # Changes all keys in this hash into symbols, if possible. That is all keys that respond to to_sym.
18
- def symbolize_keys!
19
- replace(symbolize_keys)
20
- end
21
-
22
- def empty?
23
- self.length < 1
24
- end
25
-
26
- # Returns the contents of the hash, with the exception
27
- # of the keys specified in the keys array.
28
- def except(*keys)
29
- self.dup.reject{|k, v| keys.include?(k)}
30
- end
31
- end
@@ -1,5 +0,0 @@
1
- class NilClass
2
- def blank?
3
- true
4
- end
5
- end
@@ -1,17 +0,0 @@
1
- class Object
2
- # True for objects that are considered blank or empty, such as nil, empty string, empty array
3
- # or the empty hash. When the object responds to empty?, then blank? delegates to empty?,
4
- # otherwise it returns false, except for nil.
5
- def blank?
6
- if respond_to?(:empty?)
7
- empty?
8
- else
9
- false
10
- end
11
- end
12
-
13
- # Opposite of blank?
14
- def present?
15
- !blank?
16
- end
17
- end
@@ -1,71 +0,0 @@
1
- class String
2
- def humanize
3
- self.gsub(/(_|-)+/, ' ').strip
4
- end
5
-
6
- def titleize
7
- self.humanize.split(' ').map { |word| word.capitalize }.join(' ')
8
- end
9
-
10
- def dasherize
11
- self.underscore.humanize.split(' ').join('-')
12
- end
13
-
14
- def empty?
15
- self.length < 1
16
- end
17
-
18
- def blank?
19
- self.strip.empty?
20
- end
21
-
22
- def pluralize
23
- Inflector.inflections.pluralize self
24
- end
25
-
26
- def singularize
27
- Inflector.inflections.singularize self
28
- end
29
-
30
- def camelize(uppercase_first_letter = true)
31
- string = self.dup
32
- string.gsub!(/(?:_|-|(\/))([a-z\d]*)/i) do
33
- new_word = $2.downcase
34
- new_word[0] = new_word[0].upcase
35
- new_word = "/#{new_word}" if $1 == '/'
36
- new_word
37
- end
38
- if uppercase_first_letter && uppercase_first_letter != :lower
39
- string[0] = string[0].upcase
40
- else
41
- string[0] = string[0].downcase
42
- end
43
- string.gsub!('/', '::')
44
- string
45
- end
46
-
47
- def underscore
48
- word = self.dup
49
- word.gsub!(/::/, '/')
50
- word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
51
- word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
52
- word.tr!("-", "_")
53
- word.downcase!
54
- word
55
- end
56
-
57
- # Make a string *named* like a class name. This means
58
- # an under_scored string will become a CamelizedString, also it
59
- # will be singularized, if it is plural.
60
- def classify
61
- singularize.camelize
62
- end
63
-
64
- # This method looks up a class name in the ObjectSpace's constants
65
- # allowing you to do something like this:
66
- #
67
- # "under_scored".classify.contantize.new
68
- def constantize
69
- Object.const_get(self)
70
- end
71
- end
@@ -1,49 +0,0 @@
1
- class CAttrAccessorBase
2
- cattr_accessor :empty_accessor
3
- cattr_accessor :base_accessor, :derived_accessor, :both_accessor
4
- end
5
-
6
- class CAttrAccessorDerived < CAttrAccessorBase
7
- end
8
-
9
- describe "cattr accessor" do
10
- it "should be accessible in the base class and the derived class" do
11
- CAttrAccessorBase.respond_to?(:empty_accessor).should == true
12
- CAttrAccessorDerived.respond_to?(:empty_accessor).should == true
13
- end
14
-
15
- it "should return nil for an unset accessor in the base class" do
16
- CAttrAccessorBase.empty_accessor.should == nil
17
- end
18
-
19
- it "should return nil for an unset accessor in the derived class" do
20
- CAttrAccessorDerived.empty_accessor.should == nil
21
- end
22
-
23
- it "should return a value for an accessor set in the base class in the base class" do
24
- CAttrAccessorBase.base_accessor = 10
25
- CAttrAccessorBase.base_accessor.should == 10
26
- end
27
-
28
- it "should return nil for an accessor set in the base class in the derived class" do
29
- CAttrAccessorBase.base_accessor = 10
30
- CAttrAccessorDerived.base_accessor.should == nil
31
- end
32
-
33
- it "should return nil for the base class if set for the derived class" do
34
- CAttrAccessorDerived.derived_accessor = 20
35
- CAttrAccessorBase.derived_accessor.should == nil
36
- end
37
-
38
- it "should return a value for an accessor set in the derived class in the derived class" do
39
- CAttrAccessorDerived.derived_accessor = 20
40
- CAttrAccessorDerived.derived_accessor.should == 20
41
- end
42
-
43
- it "should return different values for base and derived class if both were set independently" do
44
- CAttrAccessorBase.both_accessor = 30
45
- CAttrAccessorDerived.both_accessor = 40
46
- CAttrAccessorBase.both_accessor.should == 30
47
- CAttrAccessorDerived.both_accessor.should == 40
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- class ClassInheritableAccessorBase
2
- class_inheritable_accessor :empty_accessor
3
- class_inheritable_accessor :base_accessor, :derived_accessor, :both_accessor
4
- end
5
-
6
- class ClassInheritableAccessorDerived < ClassInheritableAccessorBase
7
- end
8
-
9
- describe "class inheritable accessor" do
10
- it "should be accessible in the base class and the derived class" do
11
- ClassInheritableAccessorBase.respond_to?(:empty_accessor).should == true
12
- ClassInheritableAccessorDerived.respond_to?(:empty_accessor).should == true
13
- end
14
-
15
- it "should return nil for an unset accessor in the base class" do
16
- ClassInheritableAccessorBase.empty_accessor.should == nil
17
- end
18
-
19
- it "should return nil for an unset accessor in the derived class" do
20
- ClassInheritableAccessorDerived.empty_accessor.should == nil
21
- end
22
-
23
- it "should return a value for an accessor set in the base class in the base class" do
24
- ClassInheritableAccessorBase.base_accessor = 10
25
- ClassInheritableAccessorBase.base_accessor.should == 10
26
- end
27
-
28
- it "should return a value for an accessor set in the base class in the derived class" do
29
- ClassInheritableAccessorBase.base_accessor = 10
30
- ClassInheritableAccessorDerived.base_accessor.should == 10
31
- end
32
-
33
- it "should return nil for the base class if only set for the derived class" do
34
- ClassInheritableAccessorDerived.derived_accessor = 20
35
- ClassInheritableAccessorBase.derived_accessor.should == nil
36
- end
37
-
38
- it "should return a value for an accessor set in the derived class in the derived class" do
39
- ClassInheritableAccessorDerived.derived_accessor = 20
40
- ClassInheritableAccessorDerived.derived_accessor.should == 20
41
- end
42
-
43
- it "should return different values for base and derived class if both were set independently" do
44
- ClassInheritableAccessorBase.both_accessor = 30
45
- ClassInheritableAccessorDerived.both_accessor = 40
46
- ClassInheritableAccessorBase.both_accessor.should == 30
47
- ClassInheritableAccessorDerived.both_accessor.should == 40
48
- end
49
- end
@@ -1,61 +0,0 @@
1
- class ClassInheritableArrayBase
2
- class_inheritable_array :empty_array
3
- class_inheritable_array :value_array, :multi_array, :reset_array
4
- class_inheritable_array :base_array, :derived_array, :both_array
5
- end
6
-
7
- class ClassInheritableArrayDerived < ClassInheritableArrayBase
8
- end
9
-
10
- describe "class inheritable array" do
11
- it "should be accessible in the base class and the derived class" do
12
- ClassInheritableArrayBase.respond_to?(:empty_array).should == true
13
- ClassInheritableArrayDerived.respond_to?(:empty_array).should == true
14
- end
15
-
16
- it "should return empty array for an unset array in the base class" do
17
- ClassInheritableArrayBase.empty_array.should == []
18
- end
19
-
20
- it "should return empty array for an unset array in the derived class" do
21
- ClassInheritableArrayDerived.empty_array.should == []
22
- end
23
-
24
- it "should allow setting array with one value" do
25
- ClassInheritableArrayBase.value_array = 10
26
- ClassInheritableArrayBase.value_array.should == [10]
27
- end
28
-
29
- it "should allow setting array with multi values" do
30
- ClassInheritableArrayBase.multi_array = [10, 20, 30]
31
- ClassInheritableArrayBase.multi_array.should == [10, 20, 30]
32
- end
33
-
34
- it "should allow resetting array" do
35
- ClassInheritableArrayBase.reset_array = 10
36
- ClassInheritableArrayBase.reset_array = 20
37
- ClassInheritableArrayBase.reset_array.should == [20]
38
- end
39
-
40
- it "should return a value for an array set in the base class in the derived class" do
41
- ClassInheritableArrayBase.base_array = 10
42
- ClassInheritableArrayDerived.base_array.should == [10]
43
- end
44
-
45
- it "should return nil for the base class if only set for the derived class" do
46
- ClassInheritableArrayDerived.derived_array = 20
47
- ClassInheritableArrayBase.derived_array.should == []
48
- end
49
-
50
- it "should return a value for an array set in the derived class in the derived class" do
51
- ClassInheritableArrayDerived.derived_array = 20
52
- ClassInheritableArrayDerived.derived_array.should == [20]
53
- end
54
-
55
- it "should return values from both the base and derived arrays for derived array if both were set independently" do
56
- ClassInheritableArrayBase.both_array = 30
57
- ClassInheritableArrayDerived.both_array = 40
58
- ClassInheritableArrayBase.both_array.should == [30]
59
- ClassInheritableArrayDerived.both_array.should == [30, 40]
60
- end
61
- end