motion_blender-support 0.2.7

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 (182) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +4 -0
  5. data/HACKS.md +7 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +359 -0
  8. data/Rakefile +14 -0
  9. data/app/app_delegate.rb +5 -0
  10. data/examples/Inflector/.gitignore +16 -0
  11. data/examples/Inflector/Gemfile +5 -0
  12. data/examples/Inflector/Rakefile +13 -0
  13. data/examples/Inflector/app/app_delegate.rb +8 -0
  14. data/examples/Inflector/app/inflections.rb +5 -0
  15. data/examples/Inflector/app/inflector_view_controller.rb +109 -0
  16. data/examples/Inflector/app/words_view_controller.rb +101 -0
  17. data/examples/Inflector/resources/Default-568h@2x.png +0 -0
  18. data/examples/Inflector/spec/main_spec.rb +9 -0
  19. data/lib/motion-support/callbacks.rb +8 -0
  20. data/lib/motion-support/concern.rb +4 -0
  21. data/lib/motion-support/core_ext/array.rb +10 -0
  22. data/lib/motion-support/core_ext/class.rb +5 -0
  23. data/lib/motion-support/core_ext/hash.rb +13 -0
  24. data/lib/motion-support/core_ext/integer.rb +6 -0
  25. data/lib/motion-support/core_ext/module.rb +11 -0
  26. data/lib/motion-support/core_ext/numeric.rb +6 -0
  27. data/lib/motion-support/core_ext/object.rb +12 -0
  28. data/lib/motion-support/core_ext/range.rb +5 -0
  29. data/lib/motion-support/core_ext/string.rb +13 -0
  30. data/lib/motion-support/core_ext/time.rb +16 -0
  31. data/lib/motion-support/core_ext.rb +13 -0
  32. data/lib/motion-support/inflector.rb +8 -0
  33. data/lib/motion-support.rb +81 -0
  34. data/motion/_stdlib/array.rb +13 -0
  35. data/motion/_stdlib/cgi.rb +22 -0
  36. data/motion/_stdlib/date.rb +81 -0
  37. data/motion/_stdlib/enumerable.rb +9 -0
  38. data/motion/_stdlib/time.rb +19 -0
  39. data/motion/callbacks.rb +511 -0
  40. data/motion/concern.rb +122 -0
  41. data/motion/core_ext/array/access.rb +28 -0
  42. data/motion/core_ext/array/conversions.rb +86 -0
  43. data/motion/core_ext/array/extract_options.rb +11 -0
  44. data/motion/core_ext/array/grouping.rb +99 -0
  45. data/motion/core_ext/array/prepend_and_append.rb +7 -0
  46. data/motion/core_ext/array/wrap.rb +45 -0
  47. data/motion/core_ext/array.rb +19 -0
  48. data/motion/core_ext/class/attribute.rb +119 -0
  49. data/motion/core_ext/class/attribute_accessors.rb +168 -0
  50. data/motion/core_ext/date/acts_like.rb +8 -0
  51. data/motion/core_ext/date/calculations.rb +117 -0
  52. data/motion/core_ext/date/conversions.rb +56 -0
  53. data/motion/core_ext/date_and_time/calculations.rb +232 -0
  54. data/motion/core_ext/enumerable.rb +90 -0
  55. data/motion/core_ext/hash/deep_delete_if.rb +23 -0
  56. data/motion/core_ext/hash/deep_merge.rb +27 -0
  57. data/motion/core_ext/hash/except.rb +15 -0
  58. data/motion/core_ext/hash/indifferent_access.rb +19 -0
  59. data/motion/core_ext/hash/keys.rb +150 -0
  60. data/motion/core_ext/hash/reverse_merge.rb +22 -0
  61. data/motion/core_ext/hash/slice.rb +40 -0
  62. data/motion/core_ext/integer/inflections.rb +27 -0
  63. data/motion/core_ext/integer/multiple.rb +10 -0
  64. data/motion/core_ext/integer/time.rb +41 -0
  65. data/motion/core_ext/kernel/singleton_class.rb +6 -0
  66. data/motion/core_ext/metaclass.rb +8 -0
  67. data/motion/core_ext/module/aliasing.rb +69 -0
  68. data/motion/core_ext/module/anonymous.rb +19 -0
  69. data/motion/core_ext/module/attr_internal.rb +38 -0
  70. data/motion/core_ext/module/attribute_accessors.rb +64 -0
  71. data/motion/core_ext/module/delegation.rb +175 -0
  72. data/motion/core_ext/module/introspection.rb +60 -0
  73. data/motion/core_ext/module/reachable.rb +5 -0
  74. data/motion/core_ext/module/remove_method.rb +12 -0
  75. data/motion/core_ext/ns_dictionary.rb +14 -0
  76. data/motion/core_ext/ns_string.rb +14 -0
  77. data/motion/core_ext/numeric/bytes.rb +44 -0
  78. data/motion/core_ext/numeric/conversions.rb +49 -0
  79. data/motion/core_ext/numeric/time.rb +75 -0
  80. data/motion/core_ext/object/acts_like.rb +10 -0
  81. data/motion/core_ext/object/blank.rb +105 -0
  82. data/motion/core_ext/object/deep_dup.rb +44 -0
  83. data/motion/core_ext/object/duplicable.rb +87 -0
  84. data/motion/core_ext/object/inclusion.rb +15 -0
  85. data/motion/core_ext/object/instance_variables.rb +28 -0
  86. data/motion/core_ext/object/to_param.rb +58 -0
  87. data/motion/core_ext/object/to_query.rb +26 -0
  88. data/motion/core_ext/object/try.rb +78 -0
  89. data/motion/core_ext/range/include_range.rb +23 -0
  90. data/motion/core_ext/range/overlaps.rb +8 -0
  91. data/motion/core_ext/regexp.rb +5 -0
  92. data/motion/core_ext/string/access.rb +104 -0
  93. data/motion/core_ext/string/behavior.rb +6 -0
  94. data/motion/core_ext/string/exclude.rb +11 -0
  95. data/motion/core_ext/string/filters.rb +55 -0
  96. data/motion/core_ext/string/indent.rb +43 -0
  97. data/motion/core_ext/string/inflections.rb +178 -0
  98. data/motion/core_ext/string/starts_ends_with.rb +4 -0
  99. data/motion/core_ext/string/strip.rb +24 -0
  100. data/motion/core_ext/time/acts_like.rb +8 -0
  101. data/motion/core_ext/time/calculations.rb +215 -0
  102. data/motion/core_ext/time/conversions.rb +52 -0
  103. data/motion/descendants_tracker.rb +50 -0
  104. data/motion/duration.rb +104 -0
  105. data/motion/hash_with_indifferent_access.rb +253 -0
  106. data/motion/inflections.rb +67 -0
  107. data/motion/inflector/inflections.rb +203 -0
  108. data/motion/inflector/methods.rb +321 -0
  109. data/motion/logger.rb +47 -0
  110. data/motion/number_helper.rb +54 -0
  111. data/motion/version.rb +3 -0
  112. data/motion_blender-support.gemspec +21 -0
  113. data/spec/motion-support/_helpers/constantize_test_cases.rb +75 -0
  114. data/spec/motion-support/_helpers/inflector_test_cases.rb +270 -0
  115. data/spec/motion-support/callback_spec.rb +702 -0
  116. data/spec/motion-support/concern_spec.rb +93 -0
  117. data/spec/motion-support/core_ext/array/access_spec.rb +29 -0
  118. data/spec/motion-support/core_ext/array/conversion_spec.rb +60 -0
  119. data/spec/motion-support/core_ext/array/extract_options_spec.rb +15 -0
  120. data/spec/motion-support/core_ext/array/grouping_spec.rb +85 -0
  121. data/spec/motion-support/core_ext/array/prepend_and_append_spec.rb +25 -0
  122. data/spec/motion-support/core_ext/array/wrap_spec.rb +19 -0
  123. data/spec/motion-support/core_ext/array_spec.rb +16 -0
  124. data/spec/motion-support/core_ext/class/attribute_accessor_spec.rb +127 -0
  125. data/spec/motion-support/core_ext/class/attribute_spec.rb +92 -0
  126. data/spec/motion-support/core_ext/date/acts_like_spec.rb +11 -0
  127. data/spec/motion-support/core_ext/date/calculation_spec.rb +186 -0
  128. data/spec/motion-support/core_ext/date/conversion_spec.rb +18 -0
  129. data/spec/motion-support/core_ext/date_and_time/calculation_spec.rb +336 -0
  130. data/spec/motion-support/core_ext/enumerable_spec.rb +130 -0
  131. data/spec/motion-support/core_ext/hash/deep_delete_if_spec.rb +19 -0
  132. data/spec/motion-support/core_ext/hash/deep_merge_spec.rb +32 -0
  133. data/spec/motion-support/core_ext/hash/except_spec.rb +43 -0
  134. data/spec/motion-support/core_ext/hash/key_spec.rb +236 -0
  135. data/spec/motion-support/core_ext/hash/reverse_merge_spec.rb +26 -0
  136. data/spec/motion-support/core_ext/hash/slice_spec.rb +61 -0
  137. data/spec/motion-support/core_ext/integer/inflection_spec.rb +23 -0
  138. data/spec/motion-support/core_ext/integer/multiple_spec.rb +19 -0
  139. data/spec/motion-support/core_ext/kernel/singleton_class_spec.rb +9 -0
  140. data/spec/motion-support/core_ext/metaclass_spec.rb +9 -0
  141. data/spec/motion-support/core_ext/module/aliasing_spec.rb +143 -0
  142. data/spec/motion-support/core_ext/module/anonymous_spec.rb +29 -0
  143. data/spec/motion-support/core_ext/module/attr_internal_spec.rb +104 -0
  144. data/spec/motion-support/core_ext/module/attribute_accessor_spec.rb +86 -0
  145. data/spec/motion-support/core_ext/module/delegation_spec.rb +136 -0
  146. data/spec/motion-support/core_ext/module/introspection_spec.rb +70 -0
  147. data/spec/motion-support/core_ext/module/reachable_spec.rb +61 -0
  148. data/spec/motion-support/core_ext/module/remove_method_spec.rb +25 -0
  149. data/spec/motion-support/core_ext/numeric/bytes_spec.rb +43 -0
  150. data/spec/motion-support/core_ext/numeric/conversions_spec.rb +40 -0
  151. data/spec/motion-support/core_ext/object/acts_like_spec.rb +21 -0
  152. data/spec/motion-support/core_ext/object/blank_spec.rb +54 -0
  153. data/spec/motion-support/core_ext/object/deep_dup_spec.rb +54 -0
  154. data/spec/motion-support/core_ext/object/duplicable_spec.rb +31 -0
  155. data/spec/motion-support/core_ext/object/inclusion_spec.rb +34 -0
  156. data/spec/motion-support/core_ext/object/instance_variable_spec.rb +19 -0
  157. data/spec/motion-support/core_ext/object/to_param_spec.rb +75 -0
  158. data/spec/motion-support/core_ext/object/to_query_spec.rb +37 -0
  159. data/spec/motion-support/core_ext/object/try_spec.rb +92 -0
  160. data/spec/motion-support/core_ext/range/include_range_spec.rb +31 -0
  161. data/spec/motion-support/core_ext/range/overlap_spec.rb +43 -0
  162. data/spec/motion-support/core_ext/regexp_spec.rb +7 -0
  163. data/spec/motion-support/core_ext/string/access_spec.rb +53 -0
  164. data/spec/motion-support/core_ext/string/behavior_spec.rb +7 -0
  165. data/spec/motion-support/core_ext/string/exclude_spec.rb +8 -0
  166. data/spec/motion-support/core_ext/string/filter_spec.rb +49 -0
  167. data/spec/motion-support/core_ext/string/indent_spec.rb +56 -0
  168. data/spec/motion-support/core_ext/string/inflection_spec.rb +142 -0
  169. data/spec/motion-support/core_ext/string/starts_end_with_spec.rb +14 -0
  170. data/spec/motion-support/core_ext/string/strip_spec.rb +34 -0
  171. data/spec/motion-support/core_ext/string_spec.rb +88 -0
  172. data/spec/motion-support/core_ext/time/acts_like_spec.rb +11 -0
  173. data/spec/motion-support/core_ext/time/calculation_spec.rb +201 -0
  174. data/spec/motion-support/core_ext/time/conversion_spec.rb +53 -0
  175. data/spec/motion-support/descendants_tracker_spec.rb +58 -0
  176. data/spec/motion-support/duration_spec.rb +107 -0
  177. data/spec/motion-support/hash_with_indifferent_access_spec.rb +605 -0
  178. data/spec/motion-support/inflector_spec.rb +504 -0
  179. data/spec/motion-support/ns_dictionary_spec.rb +89 -0
  180. data/spec/motion-support/ns_string_spec.rb +182 -0
  181. data/spec/motion-support/number_helper_spec.rb +55 -0
  182. metadata +352 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2bfe95adbe7cf15c915e6dcee0b40c3d5c8b9360
4
+ data.tar.gz: 47f34e480800bec09d1c0cebcede3491023e6081
5
+ SHA512:
6
+ metadata.gz: b311f86f4962cb664ad2acfeca1c9bade227c1e41affbbd972d54af70821d04337e170c692e42d1857e3709128dc75dbc4c4529afaee7d7d05828c8602bf47f2
7
+ data.tar.gz: 256cf0fa8c8e2bdde3c0c89d7eb6ee4914b1af6682cb44053f58a6066493f1d4f7b6817816b803656bf4ea064a4e77e65e8b87c88393f2c1a131d3aeb6d8c1a5
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ .repl_history
2
+ build
3
+ resources/*.nib
4
+ resources/*.momd
5
+ resources/*.storyboardc
6
+ *.gem
7
+ .bundle
8
+ Gemfile.lock
9
+ pkg/*
10
+ .DS_Store
11
+ doc/*
12
+ .dat*
13
+ .yardoc
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ motion/**/*.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in motion-support.gemspec
4
+ gemspec
data/HACKS.md ADDED
@@ -0,0 +1,7 @@
1
+ # Hacks to be removed ASAP
2
+
3
+ On every RubyMotion upgrade, check if the following things can be resolved/removed:
4
+
5
+ * Warning about automatic dependency detection (ADD). Currently, ADD does not work out of the box with MotionSupport. There are already a few suggested fixes, so we expect a fix to be released soon.
6
+ * `Object#__in_workaround`. If we define Object#in? directly, we get strange errors when running specs.
7
+ * `Date` class. There is a stub of a reimplementation of that class in MotionSupport. This should removed as soon as RubyMotion gets its own `Date` class (if ever). Otherwise, the implementation should be completed.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2005-2013 David Heinemeier Hansson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,359 @@
1
+ This is a fork of [motion-support](https://github.com/rubymotion/motion-support).
2
+
3
+ This works with MotionBlender to solve dependencies in spite of motion-require which is adopted by the original MotionSupport.
4
+
5
+ # MotionSupport
6
+
7
+ This is a port of the parts of ActiveSupport that make sense for RubyMotion.
8
+
9
+ To see what's there, generate the documentation with the `rdoc` command from the repository root, or look into the lib folder. Almost everything is tested.
10
+
11
+ # Usage
12
+
13
+ Install with
14
+
15
+ ```
16
+ gem install motion_blender-support
17
+ ```
18
+
19
+ or add to your `Gemfile`
20
+
21
+ ```ruby
22
+ gem 'motion_blender-support'
23
+ ```
24
+
25
+ # API docs
26
+
27
+ [Are here](http://www.rubydoc.info/github/rubymotion/motion-support/master).
28
+
29
+ # Partial loading
30
+
31
+ It is also possible to only use parts of this library. To do so, change your `Gemfile` so that it reads:
32
+
33
+ ```ruby
34
+ gem 'motion_blender-support', :require => false
35
+ ```
36
+
37
+ Then add a require statement as shown below to your `Rakefile`.
38
+
39
+ ## all
40
+
41
+ ```ruby
42
+ require 'motion_blender-support'
43
+ ```
44
+
45
+ Loads everything.
46
+
47
+ ## callbacks
48
+
49
+ ```ruby
50
+ require 'motion_blender-support/callbacks'
51
+ ```
52
+
53
+ Loads the `MotionSupport::Callbacks` module. It allows you to easily add Rails-style callbacks to any class.
54
+
55
+ ## concern
56
+
57
+ ```ruby
58
+ require 'motion_blender-support/concern'
59
+ ```
60
+
61
+ Loads the `MotionSupport::Concern` module. This simplifies separating classes into modules and managing module dependencies.
62
+
63
+ ## inflector
64
+
65
+ ```ruby
66
+ require 'motion_blender-support/inflector'
67
+ ```
68
+
69
+ Loads the `Inflector` module and extensions to the `String` class. See the "Inflector" app in the `examples/` folder for what the inflector can do.
70
+
71
+ Example usage include:
72
+
73
+ ```ruby
74
+ "app_delegate".camelize
75
+ => "AppDelegate"
76
+ "HomeController".constantize
77
+ => HomeController
78
+ "thing".pluralize
79
+ => "things"
80
+ "mice".singularize
81
+ => "mouse"
82
+ ```
83
+
84
+ ## core_ext
85
+
86
+ ```ruby
87
+ require 'motion_blender-support/core_ext'
88
+ ```
89
+
90
+ Loads all the extensions to core classes.
91
+
92
+ ## core_ext/array
93
+
94
+ ```ruby
95
+ require 'motion_blender-support/core_ext/array'
96
+ ```
97
+
98
+ Loads extensions to class `Array`. Example usage include
99
+
100
+ ```ruby
101
+ %w( a b c d ).from(2)
102
+ => ["c", "d"]
103
+ ['one', 'two', 'three'].to_sentence
104
+ => "one, two, and three"
105
+ [1, 2, 3, 4].in_groups_of(2)
106
+ => [[1, 2], [3, 4]]
107
+ ```
108
+
109
+ Extract options hash from variant args array
110
+
111
+ ```ruby
112
+ args = ['hello', 'world', { :foo => 'bar' }]
113
+ args.extract_options!
114
+ => { :foo => 'bar' }
115
+ ```
116
+
117
+ ## core_ext/class
118
+
119
+ ```ruby
120
+ require 'motion_blender-support/core_ext/class'
121
+ ```
122
+
123
+ Loads extensions to class `Class`.
124
+
125
+ ```ruby
126
+ class Foo
127
+ cattr_accessor :bar
128
+ class_attribute :foo
129
+ end
130
+ ```
131
+
132
+ ## core_ext/hash
133
+
134
+ ```ruby
135
+ require 'motion_blender-support/core_ext/hash'
136
+ ```
137
+
138
+ Loads extensions to class `Hash`, including class `HashWithIndifferentAccess`.
139
+
140
+ ```ruby
141
+ { 'foo' => 'bar', 'baz' => 'bam' }.symbolize_keys
142
+ => { :foo => 'bar', :baz => 'bam' }
143
+ { 'foo' => 'bar', 'baz' => 'bam' }.except('foo')
144
+ => { 'baz' => 'bam' }
145
+ { 'foo' => 'bar', 'baz' => 'bam' }.with_indifferent_access
146
+ => #<HashWithIndifferentAccess>
147
+ ```
148
+
149
+ ## core_ext/integer
150
+
151
+ ```ruby
152
+ require 'motion_blender-support/core_ext/integer'
153
+ ```
154
+
155
+ Loads extensions to class `Integer`.
156
+
157
+ ```ruby
158
+ 1.ordinalize
159
+ => "1st"
160
+ 3.ordinalize
161
+ => "3rd"
162
+ ```
163
+
164
+ ## core_ext/module
165
+
166
+ ```ruby
167
+ require 'motion_blender-support/core_ext/module'
168
+ ```
169
+
170
+ Loads extensions to class `Module`.
171
+
172
+ ```ruby
173
+ module Mod
174
+ mattr_accessor :foo, :bar
175
+ attr_internal :baz
176
+ delegate :boo, :to => :foo
177
+
178
+ remove_method :baz
179
+ end
180
+ ```
181
+
182
+ ## core_ext/numeric
183
+
184
+ ```ruby
185
+ require 'motion_blender-support/core_ext/numeric'
186
+ ```
187
+
188
+ Loads extensions to class `Numeric`.
189
+
190
+ ```ruby
191
+ 10.kilobytes
192
+ => 10240
193
+ 2.megabytes
194
+ => 2097152
195
+ 3.days
196
+ => 3
197
+ ```
198
+
199
+ ## core_ext/object
200
+
201
+ ```ruby
202
+ require 'motion_blender-support/core_ext/object'
203
+ ```
204
+
205
+ Loads extensions to class `Object`.
206
+
207
+ ```ruby
208
+ nil.blank?
209
+ => true
210
+ Object.new.blank?
211
+ => false
212
+ { "hello" => "world", "foo" => "bar" }.to_query
213
+ => "hello=world&foo=bar"
214
+ 1.duplicable?
215
+ => false
216
+ 1.try(:to_s)
217
+ => "1"
218
+ nil.try(:to_s)
219
+ => nil
220
+ ```
221
+
222
+ ## core_ext/range
223
+
224
+ ```ruby
225
+ require 'motion_blender-support/core_ext/range'
226
+ ```
227
+
228
+ Loads extensions to class `Range`.
229
+
230
+ ```ruby
231
+ (1..5).overlaps(3..9)
232
+ => true
233
+ (1..5).include?(2..3)
234
+ => true
235
+ ```
236
+
237
+ ## core_ext/string
238
+
239
+ ```ruby
240
+ require 'motion_blender-support/core_ext/string'
241
+ ```
242
+
243
+ Loads extensions to class `String`.
244
+
245
+ ```ruby
246
+ "ruby_motion".camelize
247
+ => "RubyMotion"
248
+ "User".pluralize
249
+ => "Users"
250
+ "mice".singularize
251
+ => "mouse"
252
+ "Foo::Bar".underscore
253
+ => "foo/bar"
254
+ "AppDelegate".underscore
255
+ => "app_delegate"
256
+ "UIView".constantize
257
+ => UIView
258
+ ```
259
+
260
+ ## core_ext/time
261
+
262
+ ```ruby
263
+ require 'motion_blender-support/core_ext/time'
264
+ ```
265
+
266
+ Loads extensions to class `Time`.
267
+
268
+ ```ruby
269
+ 1.week.ago
270
+ 17.days.from_now
271
+ Date.yesterday
272
+ Time.beginning_of_week
273
+ ```
274
+
275
+ # Differences to ActiveSupport
276
+
277
+ In general:
278
+
279
+ * All `I18n` stuff was removed. Maybe it will be readded later.
280
+ * No support for the `TimeWithZone` class (iOS apps don't need advanced time zone support)
281
+ * No support for the `DateTime` class
282
+ * All deprecated methods have been removed
283
+ * All `YAML` extensions were removed, since RubyMotion doesn't come with YAML support
284
+ * `Kernel#silence_warnings` and stream manipulation methods were removed
285
+ * Multibyte string handling methods have been removed
286
+ * All Rails-specific stuff was removed
287
+ * The dependency resolution code was removed. So was the dynamic code reloading code
288
+ * All marshalling code was removed
289
+ * All logging code was removed
290
+ * All extensions to `Test::Unit` were removed
291
+ * The `ActiveSupport` namespace is called `MotionSupport`
292
+
293
+ Specifically:
294
+
295
+ * `Array#third` .. `Array#fourty_two` were removed
296
+ * `Array#to_xml` is missing
297
+ * `Array#to_sentence` does not accept a `:locale` parameter
298
+ * `Class#subclasses` is missing. It depends on `ObjectSpace.each_object` which is missing in RubyMotion
299
+ * `Hash#extractable_options?` is missing
300
+ * `BigDecimal` conversions were removed
301
+ * `Time.current` an alias for `Time.now`
302
+ * `Date.current` an alias for `Date.today`
303
+ * `Date#to_time` does not accept a timezone form (`:local`, `:utc`)
304
+ * `Date#xmlschema` is missing
305
+ * `String#parameterize` is missing because it needs to transliterate the string, which is dependent on the locale
306
+ * `String#constantize` is very slow. Cache the result if you use it.
307
+ * `String#to_time`, `#to_date`, `#to_datetime` are missing because they depend on `Date#_parse`
308
+ * String inquiry methods are missing
309
+ * String multibyte methods are missing
310
+ * `String#html_safe` and `ERB` extensions are not needed in RubyMotion
311
+ * `Object#to_json` and subclasses are missing
312
+ * `Range#to_s(:db)` was removed
313
+ * The `rfc822` time format was removed, since it relies on time zone support.
314
+ * Extensions to `LoadError` and `NameError` were removed
315
+ * The `ThreadSafe` versions of `Hash` and `Array` are just aliases to the standard classes
316
+ * In `MotionSupport::Callbacks` it is not possible to give a string containing Ruby code as a conditions via `:if`, since RubyMotion doesn't support `eval`.
317
+ * In `MotionSupport::Callbacks`, if a proc is given as a condition to `:if`, the block must take the class instance as a parameter. `self` is not automatically set.
318
+ * In `MotionSupport::Callbacks#define_callbacks`, the `:terminator` argument must take a block of the form `lambda { |result| }` where `result` is the intermediate result from the callback methods.
319
+ * `NumberHelper` and numeric conversions only support phone numbers for now
320
+
321
+ Things to do / to decide:
322
+
323
+ * RubyMotion lacks a `Date` class. in `_stdlib` there is a stub of a Date class that makes the `Date` extensions work. This stub needs to be completed.
324
+ * Implement `Object#to_json`, probably best if implemented on top of Cocoa APIs
325
+ * Implement `Object#to_xml`
326
+ * Implement `Hash#from_xml`
327
+ * Do we need `Hash#extractable_options?`?
328
+ * Do we need `Class#superclass_delegating_accessor`?
329
+ * Implement all `InfiniteComparable` extensions
330
+ * Do we need `File#atomic_write` for thread-safe file writing?
331
+ * Do we need `Kernel#class_eval` (it delegates to `class_eval` on this' singleton class)?
332
+ * Do we need `Module#qualified_const_defined?`? What is that even for?
333
+ * Do we need `Module#synchronize`?
334
+ * Implement `Numeric` conversions, especially `NumberHelper`
335
+ * Do we need `Object#with_options`?
336
+ * Implement `String#to_time`, `String#to_date`. In the original ActiveSupport, they make use of the `Date#_parse` method (which seems like it's supposed to be private). Here, they should be implemented on top of Cocoa APIs
337
+ * Do we need `String#parameterize`? If so, we need to find a way to transliterate UTF-8 characters.
338
+ * Do we need the `StringInquirer`? It allows things like `Rails.env.development?` instead of `Rails.env == 'development'`
339
+ * Do we need multibyte string handling extensions? AFAIK, all strings in RubyMotion are UTF-8. Is that true?
340
+ * Do we need `Struct#to_h`?
341
+ * Implement extensions to class `Thread` if they make sense.
342
+ * Do we need the `Configurable` module?
343
+ * Do we need the `OrderedOptions` class?
344
+ * Some extensions have to be made available for Cocoa classes (`NSArray`, `NSDictionary` etc.), since we want to effectively handle return values from Objective-C methods (they return Cocoa classes). The way to do this is to write a conversion method from Cocoa class to Ruby class and delegate the extension methods in the Cocoa class to the conversion method. See `motion/core_ext/ns_string.rb` for an example.
345
+ * Go through documentation and remove or rewrite things not relevant to RubyMotion, especially examples mentioning Rails components
346
+
347
+ # Acknowledgements
348
+
349
+ ActiveSupport was originally written as part of Ruby on Rails by David Heinemeier Hansson. Over the years, countless contributors made many additions. They made this library possible.
350
+
351
+ # License
352
+
353
+ MotionSupport is released under the MIT license:
354
+
355
+ <http://www.opensource.org/licenses/MIT>
356
+
357
+ # Forking
358
+
359
+ Feel free to fork and submit pull requests!
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ $:.unshift("/Library/RubyMotion/lib")
3
+ require 'motion/project/template/ios'
4
+ require "bundler/gem_tasks"
5
+ Bundler.setup
6
+ Bundler.require
7
+
8
+ require 'motion-support'
9
+
10
+ Motion::Project::App.setup do |app|
11
+ # Use `rake config' to see complete project settings.
12
+ app.name = 'MotionSupport'
13
+ app.detect_dependencies = false
14
+ end
@@ -0,0 +1,5 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ true
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ .repl_history
2
+ build
3
+ tags
4
+ app/pixate_code.rb
5
+ resources/*.nib
6
+ resources/*.momd
7
+ resources/*.storyboardc
8
+ .DS_Store
9
+ nbproject
10
+ .redcar
11
+ #*#
12
+ *~
13
+ *.sw[po]
14
+ .eprj
15
+ .sass-cache
16
+ .idea
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'motion-require'
5
+ gem 'formotion'
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+ $:.unshift("/Library/RubyMotion/lib")
3
+ require 'motion/project'
4
+ require 'bundler'
5
+ Bundler.require
6
+
7
+ require '../../lib/motion-support/inflector'
8
+
9
+ Motion::Project::App.setup do |app|
10
+ # Use `rake config' to see complete project settings.
11
+ app.name = 'Inflector'
12
+ app.detect_dependencies = false
13
+ end
@@ -0,0 +1,8 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
4
+ @window.rootViewController = UINavigationController.alloc.initWithRootViewController(InflectorViewController.alloc.init)
5
+ @window.makeKeyAndVisible
6
+ true
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ MotionSupport::Inflector.inflections do |inflect|
2
+ inflect.acronym 'HTML'
3
+ inflect.acronym 'API'
4
+ inflect.acronym 'BSD'
5
+ end
@@ -0,0 +1,109 @@
1
+ class InflectorViewController < Formotion::FormController
2
+ def init
3
+ initWithForm(build_form)
4
+ self.title = "Inflector"
5
+ @form.on_submit do |form|
6
+ submit(form)
7
+ end
8
+ self
9
+ end
10
+
11
+ def submit(form)
12
+ data = form.render
13
+ original = String.new(data[:word])
14
+
15
+ update_fields(original)
16
+
17
+ form.row(:word).text_field.resignFirstResponder
18
+ end
19
+
20
+ def set_word(word)
21
+ @form.values = { :word => word }
22
+ update_fields(word)
23
+ end
24
+
25
+ def update_fields(original)
26
+ @form.values = {
27
+ :singular => original.singularize,
28
+ :plural => original.pluralize,
29
+ :camelized => original.camelize,
30
+ :lower_camelized => original.camelize(:lower),
31
+ :underscored => original.underscore,
32
+ :classified => original.classify,
33
+ :dasherized => original.dasherize,
34
+ :titleized => original.titleize,
35
+ :humanized => original.humanize
36
+ }
37
+ end
38
+
39
+ private
40
+ def build_form
41
+ @form ||= Formotion::Form.persist({
42
+ sections: [{
43
+ rows: [{
44
+ title: "Word",
45
+ key: :word,
46
+ type: :string,
47
+ placeholder: "Enter a word",
48
+ auto_correction: :no,
49
+ auto_capitalization: :none
50
+ }, {
51
+ title: "Select",
52
+ type: :button,
53
+ key: :select
54
+ }]
55
+ }, {
56
+ rows: [{
57
+ title: "Inflect",
58
+ type: :submit
59
+ }]
60
+ }, {
61
+ title: "Inflections",
62
+ rows: [{
63
+ title: "Singular",
64
+ key: :singular,
65
+ type: :static
66
+ }, {
67
+ title: "Plural",
68
+ key: :plural,
69
+ type: :static
70
+ }]
71
+ }, {
72
+ title: "Transformations",
73
+ rows: [{
74
+ title: "Camelized",
75
+ key: :camelized,
76
+ type: :static
77
+ }, {
78
+ title: "Lower-Camelized",
79
+ key: :lower_camelized,
80
+ type: :static
81
+ }, {
82
+ title: "Underscored",
83
+ key: :underscored,
84
+ type: :static
85
+ }, {
86
+ title: "Classified",
87
+ key: :classified,
88
+ type: :static
89
+ }, {
90
+ title: "Dasherized",
91
+ key: :dasherized,
92
+ type: :static
93
+ }, {
94
+ title: "Titleized",
95
+ key: :titleized,
96
+ type: :static
97
+ }, {
98
+ title: "Humanized",
99
+ key: :humanized,
100
+ type: :static
101
+ }]
102
+ }]
103
+ })
104
+ @form.row(:select).on_tap do
105
+ self.navigationController.pushViewController(WordsViewController.alloc.initWithParent(self), animated:true)
106
+ end
107
+ @form
108
+ end
109
+ end