motion_blender-support 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,101 @@
1
+ class WordsViewController < UITableViewController
2
+ WORDS = [
3
+ [
4
+ "Single words",
5
+ %w{
6
+ alias
7
+ axis
8
+ buffalo
9
+ bus
10
+ cat
11
+ child
12
+ cow
13
+ crisis
14
+ dog
15
+ house
16
+ man
17
+ matrix
18
+ mouse
19
+ move
20
+ octopus
21
+ ox
22
+ parenthesis
23
+ person
24
+ quiz
25
+ series
26
+ sex
27
+ vertex
28
+ zombie
29
+ }
30
+ ], [
31
+ "Uncountable words",
32
+ %w{
33
+ equipment
34
+ fish
35
+ information
36
+ jeans
37
+ money
38
+ police
39
+ rice
40
+ series
41
+ sheep
42
+ species
43
+ }
44
+ ], [
45
+ "Programming",
46
+ %w{
47
+ app_delegate
48
+ motion_support
49
+ motion_support/inflector
50
+ ruby_motion
51
+ }
52
+ ], [
53
+ "Acronyms",
54
+ %w{
55
+ free_bsd
56
+ html_api
57
+ html_tidy
58
+ ui_image
59
+ ui_table_view_controller
60
+ xml_http_request
61
+ }
62
+ ]
63
+ ]
64
+
65
+ def initWithParent(parent)
66
+ @parent = parent
67
+
68
+ self.title = "Select word"
69
+
70
+ self
71
+ end
72
+
73
+ def numberOfSectionsInTableView(tableView)
74
+ WORDS.size
75
+ end
76
+
77
+ def tableView(tableView, titleForHeaderInSection:section)
78
+ WORDS[section].first
79
+ end
80
+
81
+ def tableView(tableView, numberOfRowsInSection:section)
82
+ WORDS[section].last.size
83
+ end
84
+
85
+ def tableView(tableView, cellForRowAtIndexPath:indexPath)
86
+ fresh_cell.tap do |cell|
87
+ cell.textLabel.text = WORDS[indexPath.section].last[indexPath.row]
88
+ end
89
+ end
90
+
91
+ def tableView(tableView, didSelectRowAtIndexPath:indexPath)
92
+ @parent.set_word(WORDS[indexPath.section].last[indexPath.row])
93
+ navigationController.popViewControllerAnimated(true)
94
+ end
95
+
96
+ private
97
+ def fresh_cell
98
+ tableView.dequeueReusableCellWithIdentifier('Cell') ||
99
+ UITableViewCell.alloc.initWithStyle(UITableViewCellStyleSubtitle, reuseIdentifier:'Cell')
100
+ end
101
+ end
@@ -0,0 +1,9 @@
1
+ describe "Application 'Inflector'" do
2
+ before do
3
+ @app = UIApplication.sharedApplication
4
+ end
5
+
6
+ it "has one window" do
7
+ @app.windows.size.should == 1
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../motion/_stdlib/array'
5
+ require_relative '../../motion/concern'
6
+ require_relative '../../motion/descendants_tracker'
7
+ require_relative '../../motion/callbacks'
8
+ require_relative '../../motion/core_ext/kernel/singleton_class'
@@ -0,0 +1,4 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../motion/concern'
@@ -0,0 +1,10 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/core_ext/array'
5
+ require_relative '../../../motion/core_ext/array/wrap'
6
+ require_relative '../../../motion/core_ext/array/access'
7
+ require_relative '../../../motion/core_ext/array/conversions'
8
+ require_relative '../../../motion/core_ext/array/extract_options'
9
+ require_relative '../../../motion/core_ext/array/grouping'
10
+ require_relative '../../../motion/core_ext/array/prepend_and_append'
@@ -0,0 +1,5 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/core_ext/class/attribute'
5
+ require_relative '../../../motion/core_ext/class/attribute_accessors'
@@ -0,0 +1,13 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/core_ext/ns_dictionary'
5
+ require_relative '../../../motion/core_ext/hash/deep_merge'
6
+ require_relative '../../../motion/core_ext/hash/except'
7
+ require_relative '../../../motion/core_ext/hash/indifferent_access'
8
+ require_relative '../../../motion/core_ext/hash/keys'
9
+ require_relative '../../../motion/core_ext/hash/reverse_merge'
10
+ require_relative '../../../motion/core_ext/hash/slice'
11
+ require_relative '../../../motion/core_ext/hash/deep_delete_if'
12
+ require_relative '../../../motion/hash_with_indifferent_access'
13
+ require_relative '../../../motion/core_ext/module/delegation'
@@ -0,0 +1,6 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/core_ext/integer/multiple'
5
+ require_relative '../../../motion/core_ext/integer/inflections'
6
+ require_relative '../../../motion/core_ext/integer/time'
@@ -0,0 +1,11 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/core_ext/module/aliasing'
5
+ require_relative '../../../motion/core_ext/module/introspection'
6
+ require_relative '../../../motion/core_ext/module/anonymous'
7
+ require_relative '../../../motion/core_ext/module/reachable'
8
+ require_relative '../../../motion/core_ext/module/attribute_accessors'
9
+ require_relative '../../../motion/core_ext/module/attr_internal'
10
+ require_relative '../../../motion/core_ext/module/delegation'
11
+ require_relative '../../../motion/core_ext/module/remove_method'
@@ -0,0 +1,6 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/core_ext/numeric/bytes'
5
+ require_relative '../../../motion/core_ext/numeric/conversions'
6
+ require_relative '../../../motion/core_ext/numeric/time'
@@ -0,0 +1,12 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/_stdlib/cgi'
5
+ require_relative '../../../motion/core_ext/object/acts_like'
6
+ require_relative '../../../motion/core_ext/object/blank'
7
+ require_relative '../../../motion/core_ext/object/deep_dup'
8
+ require_relative '../../../motion/core_ext/object/duplicable'
9
+ require_relative '../../../motion/core_ext/object/try'
10
+ require_relative '../../../motion/core_ext/object/instance_variables'
11
+ require_relative '../../../motion/core_ext/object/to_param'
12
+ require_relative '../../../motion/core_ext/object/to_query'
@@ -0,0 +1,5 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/core_ext/range/include_range'
5
+ require_relative '../../../motion/core_ext/range/overlaps'
@@ -0,0 +1,13 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/core_ext/ns_string'
5
+ require_relative '../../../motion/core_ext/string/access'
6
+ require_relative '../../../motion/core_ext/string/behavior'
7
+ require_relative '../../../motion/core_ext/string/exclude'
8
+ require_relative '../../../motion/core_ext/string/filters'
9
+ require_relative '../../../motion/core_ext/string/indent'
10
+ require_relative '../../../motion/core_ext/string/starts_ends_with'
11
+ require_relative '../../../motion/core_ext/string/inflections'
12
+ require_relative '../../../motion/core_ext/string/strip'
13
+ require_relative '../../../motion/core_ext/module/delegation'
@@ -0,0 +1,16 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../../motion/_stdlib/date'
5
+ require_relative '../../../motion/_stdlib/time'
6
+ require_relative '../../../motion/core_ext/time/acts_like'
7
+ require_relative '../../../motion/core_ext/time/calculations'
8
+ require_relative '../../../motion/core_ext/time/conversions'
9
+ require_relative '../../../motion/core_ext/date/acts_like'
10
+ require_relative '../../../motion/core_ext/date/calculations'
11
+ require_relative '../../../motion/core_ext/date/conversions'
12
+ require_relative '../../../motion/core_ext/date_and_time/calculations'
13
+ require_relative '../../../motion/core_ext/integer/time'
14
+ require_relative '../../../motion/core_ext/numeric/time'
15
+ require_relative '../../../motion/core_ext/object/acts_like'
16
+ require_relative '../../../motion/duration'
@@ -0,0 +1,13 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative 'core_ext/array'
5
+ require_relative 'core_ext/class'
6
+ require_relative 'core_ext/hash'
7
+ require_relative 'core_ext/integer'
8
+ require_relative 'core_ext/module'
9
+ require_relative 'core_ext/numeric'
10
+ require_relative 'core_ext/object'
11
+ require_relative 'core_ext/range'
12
+ require_relative 'core_ext/string'
13
+ require_relative 'core_ext/time'
@@ -0,0 +1,8 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../../motion/inflector/inflections'
5
+ require_relative '../../motion/inflector/methods'
6
+ require_relative '../../motion/inflections'
7
+ require_relative '../../motion/core_ext/string/inflections'
8
+ require_relative '../../motion/core_ext/array/prepend_and_append'
@@ -0,0 +1,81 @@
1
+ require 'motion_blender'
2
+ MotionBlender.add __FILE__
3
+
4
+ require_relative '../motion/_stdlib/array'
5
+ require_relative '../motion/_stdlib/cgi'
6
+ require_relative '../motion/_stdlib/date'
7
+ require_relative '../motion/_stdlib/enumerable'
8
+ require_relative '../motion/_stdlib/time'
9
+ require_relative '../motion/callbacks'
10
+ require_relative '../motion/concern'
11
+ require_relative '../motion/core_ext/array'
12
+ require_relative '../motion/core_ext/array/access'
13
+ require_relative '../motion/core_ext/array/conversions'
14
+ require_relative '../motion/core_ext/array/extract_options'
15
+ require_relative '../motion/core_ext/array/grouping'
16
+ require_relative '../motion/core_ext/array/prepend_and_append'
17
+ require_relative '../motion/core_ext/array/wrap'
18
+ require_relative '../motion/core_ext/class/attribute'
19
+ require_relative '../motion/core_ext/class/attribute_accessors'
20
+ require_relative '../motion/core_ext/date/acts_like'
21
+ require_relative '../motion/core_ext/date/calculations'
22
+ require_relative '../motion/core_ext/date/conversions'
23
+ require_relative '../motion/core_ext/date_and_time/calculations'
24
+ require_relative '../motion/core_ext/enumerable'
25
+ require_relative '../motion/core_ext/hash/deep_delete_if'
26
+ require_relative '../motion/core_ext/hash/deep_merge'
27
+ require_relative '../motion/core_ext/hash/except'
28
+ require_relative '../motion/core_ext/hash/indifferent_access'
29
+ require_relative '../motion/core_ext/hash/keys'
30
+ require_relative '../motion/core_ext/hash/reverse_merge'
31
+ require_relative '../motion/core_ext/hash/slice'
32
+ require_relative '../motion/core_ext/integer/inflections'
33
+ require_relative '../motion/core_ext/integer/multiple'
34
+ require_relative '../motion/core_ext/integer/time'
35
+ require_relative '../motion/core_ext/kernel/singleton_class'
36
+ require_relative '../motion/core_ext/metaclass'
37
+ require_relative '../motion/core_ext/module/aliasing'
38
+ require_relative '../motion/core_ext/module/anonymous'
39
+ require_relative '../motion/core_ext/module/attr_internal'
40
+ require_relative '../motion/core_ext/module/attribute_accessors'
41
+ require_relative '../motion/core_ext/module/delegation'
42
+ require_relative '../motion/core_ext/module/introspection'
43
+ require_relative '../motion/core_ext/module/reachable'
44
+ require_relative '../motion/core_ext/module/remove_method'
45
+ require_relative '../motion/core_ext/ns_dictionary'
46
+ require_relative '../motion/core_ext/ns_string'
47
+ require_relative '../motion/core_ext/numeric/bytes'
48
+ require_relative '../motion/core_ext/numeric/conversions'
49
+ require_relative '../motion/core_ext/numeric/time'
50
+ require_relative '../motion/core_ext/object/acts_like'
51
+ require_relative '../motion/core_ext/object/blank'
52
+ require_relative '../motion/core_ext/object/deep_dup'
53
+ require_relative '../motion/core_ext/object/duplicable'
54
+ require_relative '../motion/core_ext/object/inclusion'
55
+ require_relative '../motion/core_ext/object/instance_variables'
56
+ require_relative '../motion/core_ext/object/to_param'
57
+ require_relative '../motion/core_ext/object/to_query'
58
+ require_relative '../motion/core_ext/object/try'
59
+ require_relative '../motion/core_ext/range/include_range'
60
+ require_relative '../motion/core_ext/range/overlaps'
61
+ require_relative '../motion/core_ext/regexp'
62
+ require_relative '../motion/core_ext/string/access'
63
+ require_relative '../motion/core_ext/string/behavior'
64
+ require_relative '../motion/core_ext/string/exclude'
65
+ require_relative '../motion/core_ext/string/filters'
66
+ require_relative '../motion/core_ext/string/indent'
67
+ require_relative '../motion/core_ext/string/inflections'
68
+ require_relative '../motion/core_ext/string/starts_ends_with'
69
+ require_relative '../motion/core_ext/string/strip'
70
+ require_relative '../motion/core_ext/time/acts_like'
71
+ require_relative '../motion/core_ext/time/calculations'
72
+ require_relative '../motion/core_ext/time/conversions'
73
+ require_relative '../motion/descendants_tracker'
74
+ require_relative '../motion/duration'
75
+ require_relative '../motion/hash_with_indifferent_access'
76
+ require_relative '../motion/inflections'
77
+ require_relative '../motion/inflector/inflections'
78
+ require_relative '../motion/inflector/methods'
79
+ require_relative '../motion/logger'
80
+ require_relative '../motion/number_helper'
81
+ require_relative '../motion/version'
@@ -0,0 +1,13 @@
1
+ class Array
2
+ def reverse_each
3
+ return to_enum(:reverse_each) unless block_given?
4
+
5
+ i = size - 1
6
+ while i >= 0
7
+ yield self[i]
8
+ i -= 1
9
+ end
10
+
11
+ self
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ # This is a very small part of the CGI class, borrowed from the Rubinius sources
2
+ class CGI
3
+ @@accept_charset="UTF-8" unless defined?(@@accept_charset)
4
+ # URL-encode a string.
5
+ # url_encoded_string = CGI::escape("'Stop!' said Fred")
6
+ # # => "%27Stop%21%27+said+Fred"
7
+ def CGI::escape(string)
8
+ string.gsub(/([^ a-zA-Z0-9_.-]+)/) do
9
+ '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
10
+ end.tr(' ', '+')
11
+ end
12
+
13
+ # URL-decode a string with encoding(optional).
14
+ # string = CGI::unescape("%27Stop%21%27+said+Fred")
15
+ # # => "'Stop!' said Fred"
16
+ def CGI::unescape(string,encoding=@@accept_charset)
17
+ str=string.tr('+', ' ').force_encoding(Encoding::ASCII_8BIT).gsub(/((?:%[0-9a-fA-F]{2})+)/) do
18
+ [$1.delete('%')].pack('H*')
19
+ end.force_encoding(encoding)
20
+ str.valid_encoding? ? str : str.force_encoding(string.encoding)
21
+ end
22
+ end
@@ -0,0 +1,81 @@
1
+ class Date
2
+ def self.gregorian_leap?(year)
3
+ if year % 400 == 0
4
+ true
5
+ elsif year % 100 == 0 then
6
+ false
7
+ elsif year % 4 == 0 then
8
+ true
9
+ else
10
+ false
11
+ end
12
+ end
13
+
14
+ def initialize(year = nil, month = nil, day = nil)
15
+ if year && month && day
16
+ @value = Time.utc(year, month, day)
17
+ else
18
+ @value = Time.now
19
+ end
20
+ end
21
+
22
+ def self.today
23
+ new
24
+ end
25
+
26
+ def to_s
27
+ "#{year}-#{month}-#{day}"
28
+ end
29
+
30
+ def ==(other)
31
+ year == other.year &&
32
+ month == other.month &&
33
+ day == other.day
34
+ end
35
+
36
+ def +(other)
37
+ val = @value + other * 3600 * 24
38
+ Date.new(val.year, val.month, val.day)
39
+ end
40
+
41
+ def -(other)
42
+ if other.is_a?(Date)
43
+ (@value - other.instance_variable_get(:@value)) / (3600 * 24)
44
+ elsif other.is_a?(Time)
45
+ (@value - other)
46
+ else
47
+ self + (-other)
48
+ end
49
+ end
50
+
51
+ def >>(months)
52
+ new_year = year + (self.month + months - 1) / 12
53
+ new_month = (self.month + months) % 12
54
+ new_month = new_month == 0 ? 12 : new_month
55
+ new_day = [day, Time.days_in_month(new_month, new_year)].min
56
+
57
+ Date.new(new_year, new_month, new_day)
58
+ end
59
+
60
+ def <<(months)
61
+ return self >> -months
62
+ end
63
+
64
+ [:year, :month, :day, :wday, :<, :<=, :>, :>=, :"<=>", :strftime].each do |method|
65
+ define_method method do |*args|
66
+ @value.send(method, *args)
67
+ end
68
+ end
69
+
70
+ def to_date
71
+ self
72
+ end
73
+
74
+ def to_time
75
+ @value
76
+ end
77
+
78
+ def succ
79
+ self + 1
80
+ end
81
+ end
@@ -0,0 +1,9 @@
1
+ module Enumerable
2
+ def reverse_each(&block)
3
+ return to_enum(:reverse_each) unless block_given?
4
+
5
+ # There is no other way then to convert to an array first... see 1.9's source.
6
+ to_a.reverse_each(&block)
7
+ self
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ class Time
2
+ def to_date
3
+ Date.new(year, month, day)
4
+ end
5
+
6
+ def to_time
7
+ self
8
+ end
9
+
10
+ def ==(other)
11
+ other &&
12
+ year == other.year &&
13
+ month == other.month &&
14
+ day == other.day &&
15
+ hour == other.hour &&
16
+ min == other.min &&
17
+ sec == other.sec
18
+ end
19
+ end