motion_blender-support 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.yardopts +1 -0
- data/Gemfile +4 -0
- data/HACKS.md +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +359 -0
- data/Rakefile +14 -0
- data/app/app_delegate.rb +5 -0
- data/examples/Inflector/.gitignore +16 -0
- data/examples/Inflector/Gemfile +5 -0
- data/examples/Inflector/Rakefile +13 -0
- data/examples/Inflector/app/app_delegate.rb +8 -0
- data/examples/Inflector/app/inflections.rb +5 -0
- data/examples/Inflector/app/inflector_view_controller.rb +109 -0
- data/examples/Inflector/app/words_view_controller.rb +101 -0
- data/examples/Inflector/resources/Default-568h@2x.png +0 -0
- data/examples/Inflector/spec/main_spec.rb +9 -0
- data/lib/motion-support/callbacks.rb +8 -0
- data/lib/motion-support/concern.rb +4 -0
- data/lib/motion-support/core_ext/array.rb +10 -0
- data/lib/motion-support/core_ext/class.rb +5 -0
- data/lib/motion-support/core_ext/hash.rb +13 -0
- data/lib/motion-support/core_ext/integer.rb +6 -0
- data/lib/motion-support/core_ext/module.rb +11 -0
- data/lib/motion-support/core_ext/numeric.rb +6 -0
- data/lib/motion-support/core_ext/object.rb +12 -0
- data/lib/motion-support/core_ext/range.rb +5 -0
- data/lib/motion-support/core_ext/string.rb +13 -0
- data/lib/motion-support/core_ext/time.rb +16 -0
- data/lib/motion-support/core_ext.rb +13 -0
- data/lib/motion-support/inflector.rb +8 -0
- data/lib/motion-support.rb +81 -0
- data/motion/_stdlib/array.rb +13 -0
- data/motion/_stdlib/cgi.rb +22 -0
- data/motion/_stdlib/date.rb +81 -0
- data/motion/_stdlib/enumerable.rb +9 -0
- data/motion/_stdlib/time.rb +19 -0
- data/motion/callbacks.rb +511 -0
- data/motion/concern.rb +122 -0
- data/motion/core_ext/array/access.rb +28 -0
- data/motion/core_ext/array/conversions.rb +86 -0
- data/motion/core_ext/array/extract_options.rb +11 -0
- data/motion/core_ext/array/grouping.rb +99 -0
- data/motion/core_ext/array/prepend_and_append.rb +7 -0
- data/motion/core_ext/array/wrap.rb +45 -0
- data/motion/core_ext/array.rb +19 -0
- data/motion/core_ext/class/attribute.rb +119 -0
- data/motion/core_ext/class/attribute_accessors.rb +168 -0
- data/motion/core_ext/date/acts_like.rb +8 -0
- data/motion/core_ext/date/calculations.rb +117 -0
- data/motion/core_ext/date/conversions.rb +56 -0
- data/motion/core_ext/date_and_time/calculations.rb +232 -0
- data/motion/core_ext/enumerable.rb +90 -0
- data/motion/core_ext/hash/deep_delete_if.rb +23 -0
- data/motion/core_ext/hash/deep_merge.rb +27 -0
- data/motion/core_ext/hash/except.rb +15 -0
- data/motion/core_ext/hash/indifferent_access.rb +19 -0
- data/motion/core_ext/hash/keys.rb +150 -0
- data/motion/core_ext/hash/reverse_merge.rb +22 -0
- data/motion/core_ext/hash/slice.rb +40 -0
- data/motion/core_ext/integer/inflections.rb +27 -0
- data/motion/core_ext/integer/multiple.rb +10 -0
- data/motion/core_ext/integer/time.rb +41 -0
- data/motion/core_ext/kernel/singleton_class.rb +6 -0
- data/motion/core_ext/metaclass.rb +8 -0
- data/motion/core_ext/module/aliasing.rb +69 -0
- data/motion/core_ext/module/anonymous.rb +19 -0
- data/motion/core_ext/module/attr_internal.rb +38 -0
- data/motion/core_ext/module/attribute_accessors.rb +64 -0
- data/motion/core_ext/module/delegation.rb +175 -0
- data/motion/core_ext/module/introspection.rb +60 -0
- data/motion/core_ext/module/reachable.rb +5 -0
- data/motion/core_ext/module/remove_method.rb +12 -0
- data/motion/core_ext/ns_dictionary.rb +14 -0
- data/motion/core_ext/ns_string.rb +14 -0
- data/motion/core_ext/numeric/bytes.rb +44 -0
- data/motion/core_ext/numeric/conversions.rb +49 -0
- data/motion/core_ext/numeric/time.rb +75 -0
- data/motion/core_ext/object/acts_like.rb +10 -0
- data/motion/core_ext/object/blank.rb +105 -0
- data/motion/core_ext/object/deep_dup.rb +44 -0
- data/motion/core_ext/object/duplicable.rb +87 -0
- data/motion/core_ext/object/inclusion.rb +15 -0
- data/motion/core_ext/object/instance_variables.rb +28 -0
- data/motion/core_ext/object/to_param.rb +58 -0
- data/motion/core_ext/object/to_query.rb +26 -0
- data/motion/core_ext/object/try.rb +78 -0
- data/motion/core_ext/range/include_range.rb +23 -0
- data/motion/core_ext/range/overlaps.rb +8 -0
- data/motion/core_ext/regexp.rb +5 -0
- data/motion/core_ext/string/access.rb +104 -0
- data/motion/core_ext/string/behavior.rb +6 -0
- data/motion/core_ext/string/exclude.rb +11 -0
- data/motion/core_ext/string/filters.rb +55 -0
- data/motion/core_ext/string/indent.rb +43 -0
- data/motion/core_ext/string/inflections.rb +178 -0
- data/motion/core_ext/string/starts_ends_with.rb +4 -0
- data/motion/core_ext/string/strip.rb +24 -0
- data/motion/core_ext/time/acts_like.rb +8 -0
- data/motion/core_ext/time/calculations.rb +215 -0
- data/motion/core_ext/time/conversions.rb +52 -0
- data/motion/descendants_tracker.rb +50 -0
- data/motion/duration.rb +104 -0
- data/motion/hash_with_indifferent_access.rb +253 -0
- data/motion/inflections.rb +67 -0
- data/motion/inflector/inflections.rb +203 -0
- data/motion/inflector/methods.rb +321 -0
- data/motion/logger.rb +47 -0
- data/motion/number_helper.rb +54 -0
- data/motion/version.rb +3 -0
- data/motion_blender-support.gemspec +21 -0
- data/spec/motion-support/_helpers/constantize_test_cases.rb +75 -0
- data/spec/motion-support/_helpers/inflector_test_cases.rb +270 -0
- data/spec/motion-support/callback_spec.rb +702 -0
- data/spec/motion-support/concern_spec.rb +93 -0
- data/spec/motion-support/core_ext/array/access_spec.rb +29 -0
- data/spec/motion-support/core_ext/array/conversion_spec.rb +60 -0
- data/spec/motion-support/core_ext/array/extract_options_spec.rb +15 -0
- data/spec/motion-support/core_ext/array/grouping_spec.rb +85 -0
- data/spec/motion-support/core_ext/array/prepend_and_append_spec.rb +25 -0
- data/spec/motion-support/core_ext/array/wrap_spec.rb +19 -0
- data/spec/motion-support/core_ext/array_spec.rb +16 -0
- data/spec/motion-support/core_ext/class/attribute_accessor_spec.rb +127 -0
- data/spec/motion-support/core_ext/class/attribute_spec.rb +92 -0
- data/spec/motion-support/core_ext/date/acts_like_spec.rb +11 -0
- data/spec/motion-support/core_ext/date/calculation_spec.rb +186 -0
- data/spec/motion-support/core_ext/date/conversion_spec.rb +18 -0
- data/spec/motion-support/core_ext/date_and_time/calculation_spec.rb +336 -0
- data/spec/motion-support/core_ext/enumerable_spec.rb +130 -0
- data/spec/motion-support/core_ext/hash/deep_delete_if_spec.rb +19 -0
- data/spec/motion-support/core_ext/hash/deep_merge_spec.rb +32 -0
- data/spec/motion-support/core_ext/hash/except_spec.rb +43 -0
- data/spec/motion-support/core_ext/hash/key_spec.rb +236 -0
- data/spec/motion-support/core_ext/hash/reverse_merge_spec.rb +26 -0
- data/spec/motion-support/core_ext/hash/slice_spec.rb +61 -0
- data/spec/motion-support/core_ext/integer/inflection_spec.rb +23 -0
- data/spec/motion-support/core_ext/integer/multiple_spec.rb +19 -0
- data/spec/motion-support/core_ext/kernel/singleton_class_spec.rb +9 -0
- data/spec/motion-support/core_ext/metaclass_spec.rb +9 -0
- data/spec/motion-support/core_ext/module/aliasing_spec.rb +143 -0
- data/spec/motion-support/core_ext/module/anonymous_spec.rb +29 -0
- data/spec/motion-support/core_ext/module/attr_internal_spec.rb +104 -0
- data/spec/motion-support/core_ext/module/attribute_accessor_spec.rb +86 -0
- data/spec/motion-support/core_ext/module/delegation_spec.rb +136 -0
- data/spec/motion-support/core_ext/module/introspection_spec.rb +70 -0
- data/spec/motion-support/core_ext/module/reachable_spec.rb +61 -0
- data/spec/motion-support/core_ext/module/remove_method_spec.rb +25 -0
- data/spec/motion-support/core_ext/numeric/bytes_spec.rb +43 -0
- data/spec/motion-support/core_ext/numeric/conversions_spec.rb +40 -0
- data/spec/motion-support/core_ext/object/acts_like_spec.rb +21 -0
- data/spec/motion-support/core_ext/object/blank_spec.rb +54 -0
- data/spec/motion-support/core_ext/object/deep_dup_spec.rb +54 -0
- data/spec/motion-support/core_ext/object/duplicable_spec.rb +31 -0
- data/spec/motion-support/core_ext/object/inclusion_spec.rb +34 -0
- data/spec/motion-support/core_ext/object/instance_variable_spec.rb +19 -0
- data/spec/motion-support/core_ext/object/to_param_spec.rb +75 -0
- data/spec/motion-support/core_ext/object/to_query_spec.rb +37 -0
- data/spec/motion-support/core_ext/object/try_spec.rb +92 -0
- data/spec/motion-support/core_ext/range/include_range_spec.rb +31 -0
- data/spec/motion-support/core_ext/range/overlap_spec.rb +43 -0
- data/spec/motion-support/core_ext/regexp_spec.rb +7 -0
- data/spec/motion-support/core_ext/string/access_spec.rb +53 -0
- data/spec/motion-support/core_ext/string/behavior_spec.rb +7 -0
- data/spec/motion-support/core_ext/string/exclude_spec.rb +8 -0
- data/spec/motion-support/core_ext/string/filter_spec.rb +49 -0
- data/spec/motion-support/core_ext/string/indent_spec.rb +56 -0
- data/spec/motion-support/core_ext/string/inflection_spec.rb +142 -0
- data/spec/motion-support/core_ext/string/starts_end_with_spec.rb +14 -0
- data/spec/motion-support/core_ext/string/strip_spec.rb +34 -0
- data/spec/motion-support/core_ext/string_spec.rb +88 -0
- data/spec/motion-support/core_ext/time/acts_like_spec.rb +11 -0
- data/spec/motion-support/core_ext/time/calculation_spec.rb +201 -0
- data/spec/motion-support/core_ext/time/conversion_spec.rb +53 -0
- data/spec/motion-support/descendants_tracker_spec.rb +58 -0
- data/spec/motion-support/duration_spec.rb +107 -0
- data/spec/motion-support/hash_with_indifferent_access_spec.rb +605 -0
- data/spec/motion-support/inflector_spec.rb +504 -0
- data/spec/motion-support/ns_dictionary_spec.rb +89 -0
- data/spec/motion-support/ns_string_spec.rb +182 -0
- data/spec/motion-support/number_helper_spec.rb +55 -0
- 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
|
Binary file
|
@@ -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,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,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,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,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,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,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,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
|