motion-support 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.yardopts +1 -0
- data/HACKS.md +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +162 -63
- data/lib/motion-support/core_ext/string.rb +4 -1
- data/motion-support.gemspec +1 -1
- data/motion/core_ext/ns_string.rb +14 -0
- data/motion/core_ext/object/inclusion.rb +16 -0
- data/motion/hash_with_indifferent_access.rb +2 -0
- data/motion/version.rb +1 -1
- data/spec/motion-support/core_ext/object/inclusion_spec.rb +34 -0
- data/spec/motion-support/inflector_spec.rb +3 -3
- data/spec/motion-support/ns_string_spec.rb +182 -0
- metadata +14 -5
data/.gitignore
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
motion/**/*.rb
|
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
CHANGED
@@ -8,156 +8,249 @@ To see what's there, generate the documentation with the `rdoc` command from the
|
|
8
8
|
|
9
9
|
Install with
|
10
10
|
|
11
|
-
|
11
|
+
```
|
12
|
+
gem install motion-support
|
13
|
+
```
|
12
14
|
|
13
15
|
or add to your `Gemfile`
|
14
16
|
|
15
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'motion-support'
|
19
|
+
```
|
20
|
+
|
21
|
+
# API docs
|
22
|
+
|
23
|
+
[Are here](http://www.rubydoc.info/github/tkadauke/motion-support/master/frames).
|
16
24
|
|
17
25
|
# Partial loading
|
18
26
|
|
19
27
|
It is also possible to only use parts of this library. To do so, change your `Gemfile` so that it reads:
|
20
28
|
|
21
|
-
|
29
|
+
```ruby
|
30
|
+
gem 'motion-support', :require => false
|
31
|
+
```
|
22
32
|
|
23
33
|
Then add a require statement as shown below to your `Rakefile`.
|
24
34
|
|
25
35
|
## all
|
26
36
|
|
27
|
-
|
37
|
+
```ruby
|
38
|
+
require 'motion-support'
|
39
|
+
```
|
28
40
|
|
29
41
|
Loads everything.
|
30
42
|
|
31
43
|
## inflector
|
32
44
|
|
33
|
-
|
45
|
+
```ruby
|
46
|
+
require 'motion-support/inflector'
|
47
|
+
```
|
34
48
|
|
35
49
|
Loads the `Inflector` module and extensions to the `String` class. See the "Inflector" app in the `examples/` folder for what the inflector can do.
|
36
50
|
|
37
51
|
Example usage include:
|
38
52
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
53
|
+
```ruby
|
54
|
+
"app_delegate".camelize
|
55
|
+
=> "AppDelegate"
|
56
|
+
"HomeController".constantize
|
57
|
+
=> HomeController
|
58
|
+
"thing".pluralize
|
59
|
+
=> "things"
|
60
|
+
"mice".singularize
|
61
|
+
=> "mouse"
|
62
|
+
```
|
43
63
|
|
44
64
|
## core_ext
|
45
65
|
|
46
|
-
|
66
|
+
```ruby
|
67
|
+
require 'motion-support/core_ext'
|
68
|
+
```
|
47
69
|
|
48
70
|
Loads all the extensions to core classes.
|
49
71
|
|
50
72
|
## core_ext/array
|
51
73
|
|
52
|
-
|
74
|
+
```ruby
|
75
|
+
require 'motion-support/core_ext/array'
|
76
|
+
```
|
53
77
|
|
54
78
|
Loads extensions to class `Array`. Example usage include
|
55
79
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
80
|
+
```ruby
|
81
|
+
%w( a b c d ).from(2)
|
82
|
+
=> ["c", "d"]
|
83
|
+
['one', 'two', 'three'].to_sentence
|
84
|
+
=> "one, two, and three"
|
85
|
+
[1, 2, 3, 4].in_groups_of(2)
|
86
|
+
=> [[1, 2], [3, 4]]
|
87
|
+
```
|
88
|
+
|
89
|
+
Extract options hash from variant args array
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
args = ['hello', 'world', { :foo => 'bar' }]
|
93
|
+
args.extract_options!
|
94
|
+
=> { :foo => 'bar' }
|
95
|
+
```
|
60
96
|
|
61
97
|
## core_ext/class
|
62
98
|
|
63
|
-
|
99
|
+
```ruby
|
100
|
+
require 'motion-support/core_ext/class'
|
101
|
+
```
|
64
102
|
|
65
103
|
Loads extensions to class `Class`.
|
66
104
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
105
|
+
```ruby
|
106
|
+
class Foo
|
107
|
+
cattr_accessor :bar
|
108
|
+
class_attribute :foo
|
109
|
+
end
|
110
|
+
```
|
71
111
|
|
72
112
|
## core_ext/hash
|
73
113
|
|
74
|
-
|
114
|
+
```ruby
|
115
|
+
require 'motion-support/core_ext/hash'
|
116
|
+
```
|
75
117
|
|
76
118
|
Loads extensions to class `Hash`, including class `HashWithIndifferentAccess`.
|
77
119
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
120
|
+
```ruby
|
121
|
+
{ 'foo' => 'bar', 'baz' => 'bam' }.symbolize_keys
|
122
|
+
=> { :foo => 'bar', :baz => 'bam' }
|
123
|
+
{ 'foo' => 'bar', 'baz' => 'bam' }.except('foo')
|
124
|
+
=> { 'baz' => 'bam' }
|
125
|
+
{ 'foo' => 'bar', 'baz' => 'bam' }.with_indifferent_access
|
126
|
+
=> #<HashWithIndifferentAccess>
|
127
|
+
```
|
82
128
|
|
83
129
|
## core_ext/integer
|
84
130
|
|
85
|
-
|
131
|
+
```ruby
|
132
|
+
require 'motion-support/core_ext/integer'
|
133
|
+
```
|
86
134
|
|
87
135
|
Loads extensions to class `Integer`.
|
88
136
|
|
89
|
-
|
90
|
-
|
137
|
+
```ruby
|
138
|
+
1.ordinalize
|
139
|
+
=> "1st"
|
140
|
+
3.ordinalize
|
141
|
+
=> "3rd"
|
142
|
+
```
|
91
143
|
|
92
144
|
## core_ext/module
|
93
145
|
|
94
|
-
|
146
|
+
```ruby
|
147
|
+
require 'motion-support/core_ext/module'
|
148
|
+
```
|
95
149
|
|
96
150
|
Loads extensions to class `Module`.
|
97
151
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
152
|
+
```ruby
|
153
|
+
module Mod
|
154
|
+
mattr_accessor :foo, :bar
|
155
|
+
attr_internal :baz
|
156
|
+
delegate :boo, :to => :foo
|
157
|
+
|
158
|
+
remove_method :baz
|
159
|
+
end
|
160
|
+
```
|
105
161
|
|
106
162
|
## core_ext/numeric
|
107
163
|
|
108
|
-
|
164
|
+
```ruby
|
165
|
+
require 'motion-support/core_ext/numeric'
|
166
|
+
```
|
109
167
|
|
110
168
|
Loads extensions to class `Numeric`.
|
111
169
|
|
112
|
-
|
113
|
-
|
114
|
-
|
170
|
+
```ruby
|
171
|
+
10.kilobytes
|
172
|
+
=> 10240
|
173
|
+
2.megabytes
|
174
|
+
=> 2097152
|
175
|
+
3.days
|
176
|
+
=> 3
|
177
|
+
```
|
115
178
|
|
116
179
|
## core_ext/object
|
117
180
|
|
118
|
-
|
181
|
+
```ruby
|
182
|
+
require 'motion-support/core_ext/object'
|
183
|
+
```
|
119
184
|
|
120
185
|
Loads extensions to class `Object`.
|
121
186
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
187
|
+
```ruby
|
188
|
+
nil.blank?
|
189
|
+
=> true
|
190
|
+
Object.new.blank?
|
191
|
+
=> false
|
192
|
+
{ "hello" => "world", "foo" => "bar" }.to_query
|
193
|
+
=> "hello=world&foo=bar"
|
194
|
+
1.duplicable?
|
195
|
+
=> false
|
196
|
+
1.try(:to_s)
|
197
|
+
=> "1"
|
198
|
+
nil.try(:to_s)
|
199
|
+
=> nil
|
200
|
+
```
|
128
201
|
|
129
202
|
## core_ext/range
|
130
203
|
|
131
|
-
|
204
|
+
```ruby
|
205
|
+
require 'motion-support/core_ext/range'
|
206
|
+
```
|
132
207
|
|
133
208
|
Loads extensions to class `Range`.
|
134
209
|
|
135
|
-
|
136
|
-
|
210
|
+
```ruby
|
211
|
+
(1..5).overlaps(3..9)
|
212
|
+
=> true
|
213
|
+
(1..5).include?(2..3)
|
214
|
+
=> true
|
215
|
+
```
|
137
216
|
|
138
217
|
## core_ext/string
|
139
218
|
|
140
|
-
|
219
|
+
```ruby
|
220
|
+
require 'motion-support/core_ext/string'
|
221
|
+
```
|
141
222
|
|
142
223
|
Loads extensions to class `String`.
|
143
224
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
225
|
+
```ruby
|
226
|
+
"ruby_motion".camelize
|
227
|
+
=> "RubyMotion"
|
228
|
+
"User".pluralize
|
229
|
+
=> "Users"
|
230
|
+
"mice".singularize
|
231
|
+
=> "mouse"
|
232
|
+
"Foo::Bar".underscore
|
233
|
+
=> "foo/bar"
|
234
|
+
"AppDelegate".underscore
|
235
|
+
=> "app_delegate"
|
236
|
+
"UIView".constantize
|
237
|
+
=> UIView
|
238
|
+
```
|
150
239
|
|
151
240
|
## core_ext/time
|
152
241
|
|
153
|
-
|
242
|
+
```ruby
|
243
|
+
require 'motion-support/core_ext/time'
|
244
|
+
```
|
154
245
|
|
155
246
|
Loads extensions to class `Time`.
|
156
247
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
248
|
+
```ruby
|
249
|
+
1.week.ago
|
250
|
+
17.days.from_now
|
251
|
+
Date.yesterday
|
252
|
+
Time.beginning_of_week
|
253
|
+
```
|
161
254
|
|
162
255
|
# Differences to ActiveSupport
|
163
256
|
|
@@ -188,7 +281,6 @@ Specifically:
|
|
188
281
|
* `Date.current` an alias for `Date.today`
|
189
282
|
* `Date#to_time` does not accept a timezone form (`:local`, `:utc`)
|
190
283
|
* `Date#xmlschema` is missing
|
191
|
-
* `Object#in?` is missing. It is incompatible with Bacon, it will break specs.
|
192
284
|
* `String#parameterize` is missing because it needs to transliterate the string, which is dependent on the locale
|
193
285
|
* `String#constantize` is very slow. Cache the result if you use it.
|
194
286
|
* `String#to_time`, `#to_date`, `#to_datetime` are missing because they depend on `Date#_parse`
|
@@ -227,12 +319,19 @@ Things to do / to decide:
|
|
227
319
|
* Do we need the `Configurable` module?
|
228
320
|
* Do we need the `DescendantsTracker` module?
|
229
321
|
* Do we need the `OrderedOptions` class?
|
322
|
+
* 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.
|
230
323
|
* Go through documentation and remove or rewrite things not relevant to RubyMotion, especially examples mentioning Rails components
|
231
324
|
|
232
325
|
# Acknowledgements
|
233
326
|
|
234
327
|
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.
|
235
328
|
|
329
|
+
# License
|
330
|
+
|
331
|
+
MotionSupport is released under the MIT license:
|
332
|
+
|
333
|
+
<http://www.opensource.org/licenses/MIT>
|
334
|
+
|
236
335
|
# Forking
|
237
336
|
|
238
337
|
Feel free to fork and submit pull requests!
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'motion-require'
|
2
2
|
|
3
3
|
files = [
|
4
|
+
'core_ext/ns_string',
|
4
5
|
'core_ext/string/access',
|
5
6
|
'core_ext/string/behavior',
|
6
7
|
'core_ext/string/exclude',
|
@@ -8,7 +9,9 @@ files = [
|
|
8
9
|
'core_ext/string/indent',
|
9
10
|
'core_ext/string/starts_ends_with',
|
10
11
|
'core_ext/string/inflections',
|
11
|
-
'core_ext/string/strip'
|
12
|
+
'core_ext/string/strip',
|
13
|
+
|
14
|
+
'core_ext/module/delegation'
|
12
15
|
].map { |file| File.expand_path(File.join(File.dirname(__FILE__), "/../../../motion", "#{file}.rb")) }
|
13
16
|
|
14
17
|
Motion::Require.all(files)
|
data/motion-support.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.email = ["thomas.kadauke@googlemail.com"]
|
9
9
|
s.homepage = "https://github.com/tkadauke/motion-support"
|
10
10
|
s.summary = "Commonly useful extensions to the standard library for RubyMotion"
|
11
|
-
s.description = "Commonly useful extensions to the standard library for RubyMotion.
|
11
|
+
s.description = "Commonly useful extensions to the standard library for RubyMotion. Ported from ActiveSupport."
|
12
12
|
|
13
13
|
s.files = `git ls-files`.split($\)
|
14
14
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -0,0 +1,14 @@
|
|
1
|
+
motion_require "module/delegation"
|
2
|
+
|
3
|
+
class NSString
|
4
|
+
def to_s
|
5
|
+
String.new(self)
|
6
|
+
end
|
7
|
+
|
8
|
+
delegate :at, :blank?, :camelcase, :camelize, :classify, :constantize, :dasherize,
|
9
|
+
:deconstantize, :demodulize, :exclude?, :first, :foreign_key, :from, :humanize,
|
10
|
+
:indent, :indent!, :last, :parameterize, :pluralize, :safe_constantize,
|
11
|
+
:singularize, :squish, :squish!, :strip_heredoc, :tableize, :titlecase,
|
12
|
+
:titleize, :to, :truncate, :underscore,
|
13
|
+
:to => :to_s
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Object
|
2
|
+
# Returns true if this object is included in the argument(s). Argument must be
|
3
|
+
# any object which responds to +#include?+ or optionally, multiple arguments
|
4
|
+
# can be passed in. Usage:
|
5
|
+
#
|
6
|
+
# characters = ['Konata', 'Kagami', 'Tsukasa']
|
7
|
+
# 'Konata'.in?(characters) # => true
|
8
|
+
#
|
9
|
+
# This will throw an ArgumentError it doesn't respond to +#include?+.
|
10
|
+
def __in_workaround(args)
|
11
|
+
args.include?(self)
|
12
|
+
rescue NoMethodError
|
13
|
+
raise ArgumentError.new("The parameter passed to #in? must respond to #include?")
|
14
|
+
end
|
15
|
+
alias in? __in_workaround
|
16
|
+
end
|
data/motion/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
class LifeUniverseAndEverything
|
2
|
+
def include?(obj)
|
3
|
+
obj == 42
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
describe 'array' do
|
9
|
+
describe "in?" do
|
10
|
+
it "should support arrays" do
|
11
|
+
1.in?([1,2,3]).should == true
|
12
|
+
0.in?([1,2,3]).should == false
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should support hashes" do
|
16
|
+
:a.in?({a:1,b:2,c:3}).should == true
|
17
|
+
1.in?({a:1,b:2,c:3}).should == false
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should support ranges" do
|
21
|
+
1.in?(1..3).should == true
|
22
|
+
0.in?(1..3).should == false
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should support strings" do
|
26
|
+
'a'.in?("apple").should == true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should support anything that implements `include?`" do
|
30
|
+
42.in?(LifeUniverseAndEverything.new).should == true
|
31
|
+
0.in?(LifeUniverseAndEverything.new).should == false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -490,9 +490,9 @@ describe "Inflector" do
|
|
490
490
|
end
|
491
491
|
|
492
492
|
%w(plurals singulars uncountables humans acronyms).each do |scope|
|
493
|
-
|
494
|
-
|
495
|
-
|
493
|
+
it "should clear inflections with #{scope}" do
|
494
|
+
with_dup do
|
495
|
+
MotionSupport::Inflector.inflections do |inflect|
|
496
496
|
# clear the inflections
|
497
497
|
inflect.clear(scope)
|
498
498
|
inflect.send(scope).should == []
|
@@ -0,0 +1,182 @@
|
|
1
|
+
describe "NSString" do
|
2
|
+
before do
|
3
|
+
@string = NSString.stringWithString("ruby_motion")
|
4
|
+
end
|
5
|
+
|
6
|
+
describe "to_s" do
|
7
|
+
it "should convert NSDictionary to Hash" do
|
8
|
+
@string.to_s.class.should == String
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should preserve the value" do
|
12
|
+
@string.to_s.should == @string
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "at" do
|
17
|
+
it "should return character at NSString position" do
|
18
|
+
@string.at(0).should == 'r'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "blank?" do
|
23
|
+
it "should be true for empty NSString" do
|
24
|
+
NSString.stringWithString("").blank?.should == true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be false for non-empty NSString" do
|
28
|
+
@string.blank?.should == false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "camelize" do
|
33
|
+
it "should camelize NSString" do
|
34
|
+
@string.camelize.should == "RubyMotion"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "classify" do
|
39
|
+
it "should classify NSString" do
|
40
|
+
@string.classify.should == "RubyMotion"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "constantize" do
|
45
|
+
it "should constantize NSString" do
|
46
|
+
NSString.stringWithString("Object").constantize.should == Object
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "dasherize" do
|
51
|
+
it "should dasherize NSString" do
|
52
|
+
@string.dasherize.should == "ruby-motion"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "deconstantize" do
|
57
|
+
it "should deconstantize NSString" do
|
58
|
+
NSString.stringWithString("Ruby::Motion").deconstantize.should == "Ruby"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "demodulize" do
|
63
|
+
it "should demodulize NSString" do
|
64
|
+
NSString.stringWithString("Ruby::Motion").demodulize.should == "Motion"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "exclude?" do
|
69
|
+
it "should return true if NSString excludes substring" do
|
70
|
+
@string.exclude?("foo").should == true
|
71
|
+
@string.exclude?("ruby").should == false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "first" do
|
76
|
+
it "should return first character NSString" do
|
77
|
+
@string.first.should == "r"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "foreign_key" do
|
82
|
+
it "should return NSString" do
|
83
|
+
@string.foreign_key.should == "ruby_motion_id"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "from" do
|
88
|
+
it "should return substring of NSString starting at position" do
|
89
|
+
@string.from(5).should == "motion"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "humanize" do
|
94
|
+
it "should humanize NSString" do
|
95
|
+
@string.humanize.should == "Ruby motion"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "indent" do
|
100
|
+
it "should indent NSString" do
|
101
|
+
@string.indent(2).should == " ruby_motion"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "indent!" do
|
106
|
+
it "should indent NSString in place" do
|
107
|
+
@string.indent!(2).should == " ruby_motion"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "last" do
|
112
|
+
it "should return last character of NSString" do
|
113
|
+
@string.last.should == "n"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "pluralize" do
|
118
|
+
it "should pluralize NSString" do
|
119
|
+
NSString.stringWithString("thing").pluralize.should == "things"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "safe_constantize" do
|
124
|
+
it "should safe_constantize NSString" do
|
125
|
+
NSString.stringWithString("Object").safe_constantize.should == Object
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "singularize" do
|
130
|
+
it "should singularize NSString" do
|
131
|
+
NSString.stringWithString("things").singularize.should == "thing"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "squish" do
|
136
|
+
it "should squish NSString" do
|
137
|
+
NSString.stringWithString(" ruby\n motion").squish.should == "ruby motion"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "squish!" do
|
142
|
+
it "should squish NSString in place" do
|
143
|
+
NSString.stringWithString(" ruby\n motion").squish!.should == "ruby motion"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "strip_heredoc" do
|
148
|
+
it "should strip heredoc NSString" do
|
149
|
+
NSString.stringWithString(" ruby\n motion").strip_heredoc.should == "ruby\nmotion"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "tableize" do
|
154
|
+
it "should tableize NSString" do
|
155
|
+
@string.tableize.should == "ruby_motions"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "titleize" do
|
160
|
+
it "should titleize NSString" do
|
161
|
+
@string.titleize.should == "Ruby Motion"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "to" do
|
166
|
+
it "should return substring of NSString up to position" do
|
167
|
+
@string.to(3).should == "ruby"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe "truncate" do
|
172
|
+
it "should truncate NSString" do
|
173
|
+
@string.truncate(5).should == "ru..."
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "underscore" do
|
178
|
+
it "should underscore NSString" do
|
179
|
+
NSString.stringWithString("RubyMotion").underscore.should == "ruby_motion"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: motion-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thomas Kadauke
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-05-06 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: motion-require
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: *id002
|
37
|
-
description: Commonly useful extensions to the standard library for RubyMotion.
|
37
|
+
description: Commonly useful extensions to the standard library for RubyMotion. Ported from ActiveSupport.
|
38
38
|
email:
|
39
39
|
- thomas.kadauke@googlemail.com
|
40
40
|
executables: []
|
@@ -45,7 +45,10 @@ extra_rdoc_files: []
|
|
45
45
|
|
46
46
|
files:
|
47
47
|
- .gitignore
|
48
|
+
- .yardopts
|
48
49
|
- Gemfile
|
50
|
+
- HACKS.md
|
51
|
+
- MIT-LICENSE
|
49
52
|
- README.md
|
50
53
|
- Rakefile
|
51
54
|
- app/app_delegate.rb
|
@@ -108,6 +111,7 @@ files:
|
|
108
111
|
- motion/core_ext/module/reachable.rb
|
109
112
|
- motion/core_ext/module/remove_method.rb
|
110
113
|
- motion/core_ext/ns_dictionary.rb
|
114
|
+
- motion/core_ext/ns_string.rb
|
111
115
|
- motion/core_ext/numeric/bytes.rb
|
112
116
|
- motion/core_ext/numeric/conversions.rb
|
113
117
|
- motion/core_ext/numeric/time.rb
|
@@ -115,6 +119,7 @@ files:
|
|
115
119
|
- motion/core_ext/object/blank.rb
|
116
120
|
- motion/core_ext/object/deep_dup.rb
|
117
121
|
- motion/core_ext/object/duplicable.rb
|
122
|
+
- motion/core_ext/object/inclusion.rb
|
118
123
|
- motion/core_ext/object/instance_variables.rb
|
119
124
|
- motion/core_ext/object/to_param.rb
|
120
125
|
- motion/core_ext/object/to_query.rb
|
@@ -177,6 +182,7 @@ files:
|
|
177
182
|
- spec/motion-support/core_ext/object/blank_spec.rb
|
178
183
|
- spec/motion-support/core_ext/object/deep_dup_spec.rb
|
179
184
|
- spec/motion-support/core_ext/object/duplicable_spec.rb
|
185
|
+
- spec/motion-support/core_ext/object/inclusion_spec.rb
|
180
186
|
- spec/motion-support/core_ext/object/instance_variable_spec.rb
|
181
187
|
- spec/motion-support/core_ext/object/to_param_spec.rb
|
182
188
|
- spec/motion-support/core_ext/object/to_query_spec.rb
|
@@ -200,6 +206,7 @@ files:
|
|
200
206
|
- spec/motion-support/hash_with_indifferent_access_spec.rb
|
201
207
|
- spec/motion-support/inflector_spec.rb
|
202
208
|
- spec/motion-support/ns_dictionary_spec.rb
|
209
|
+
- spec/motion-support/ns_string_spec.rb
|
203
210
|
homepage: https://github.com/tkadauke/motion-support
|
204
211
|
licenses: []
|
205
212
|
|
@@ -213,7 +220,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
220
|
requirements:
|
214
221
|
- - ">="
|
215
222
|
- !ruby/object:Gem::Version
|
216
|
-
hash:
|
223
|
+
hash: 1040678399660585820
|
217
224
|
segments:
|
218
225
|
- 0
|
219
226
|
version: "0"
|
@@ -222,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
229
|
requirements:
|
223
230
|
- - ">="
|
224
231
|
- !ruby/object:Gem::Version
|
225
|
-
hash:
|
232
|
+
hash: 1040678399660585820
|
226
233
|
segments:
|
227
234
|
- 0
|
228
235
|
version: "0"
|
@@ -271,6 +278,7 @@ test_files:
|
|
271
278
|
- spec/motion-support/core_ext/object/blank_spec.rb
|
272
279
|
- spec/motion-support/core_ext/object/deep_dup_spec.rb
|
273
280
|
- spec/motion-support/core_ext/object/duplicable_spec.rb
|
281
|
+
- spec/motion-support/core_ext/object/inclusion_spec.rb
|
274
282
|
- spec/motion-support/core_ext/object/instance_variable_spec.rb
|
275
283
|
- spec/motion-support/core_ext/object/to_param_spec.rb
|
276
284
|
- spec/motion-support/core_ext/object/to_query_spec.rb
|
@@ -294,3 +302,4 @@ test_files:
|
|
294
302
|
- spec/motion-support/hash_with_indifferent_access_spec.rb
|
295
303
|
- spec/motion-support/inflector_spec.rb
|
296
304
|
- spec/motion-support/ns_dictionary_spec.rb
|
305
|
+
- spec/motion-support/ns_string_spec.rb
|