bubble-wrap 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -9
- data/CHANGELOG.md +21 -2
- data/Gemfile.lock +8 -5
- data/README.md +54 -3
- data/Rakefile +7 -1
- data/lib/bubble-wrap/camera.rb +1 -1
- data/lib/bubble-wrap/core.rb +1 -1
- data/lib/bubble-wrap/font.rb +1 -1
- data/lib/bubble-wrap/loader.rb +4 -4
- data/lib/bubble-wrap/media.rb +1 -1
- data/lib/bubble-wrap/motion.rb +7 -1
- data/lib/bubble-wrap/version.rb +2 -2
- data/motion/core/app.rb +4 -0
- data/motion/core/device/ios/camera_wrapper.rb +1 -1
- data/motion/core/device/ios/screen.rb +2 -2
- data/motion/core/device/osx/screen.rb +1 -1
- data/motion/core/device/screen.rb +1 -1
- data/motion/core/ios/device.rb +1 -1
- data/motion/core/ios/ns_index_path.rb +11 -0
- data/motion/core/json.rb +2 -2
- data/motion/core/kvo.rb +118 -55
- data/motion/core/ns_notification_center.rb +2 -2
- data/motion/core/ns_url_request.rb +2 -2
- data/motion/core/osx/device.rb +1 -1
- data/motion/core/string.rb +7 -7
- data/motion/font/font.rb +1 -1
- data/motion/ios/8/location_constants.rb +21 -0
- data/motion/location/location.rb +38 -18
- data/motion/mail/result.rb +1 -1
- data/motion/media/media.rb +1 -1
- data/motion/motion/accelerometer.rb +55 -0
- data/motion/motion/device_motion.rb +139 -0
- data/motion/motion/gyroscope.rb +55 -0
- data/motion/motion/magnetometer.rb +55 -0
- data/motion/motion/motion.rb +0 -288
- data/motion/reactor.rb +3 -3
- data/motion/reactor/deferrable.rb +32 -32
- data/motion/reactor/periodic_timer.rb +1 -1
- data/motion/reactor/queue.rb +6 -6
- data/motion/reactor/thread_aware_deferrable.rb +1 -1
- data/motion/reactor/timer.rb +1 -1
- data/motion/rss_parser.rb +6 -3
- data/motion/shortcut.rb +1 -1
- data/motion/sms/result.rb +1 -1
- data/motion/test_suite_delegate.rb +1 -1
- data/motion/ui/ui_activity_view_controller_wrapper.rb +6 -1
- data/motion/ui/ui_alert_view.rb +21 -1
- data/motion/util/deprecated.rb +1 -1
- data/samples/alert/Gemfile.lock +1 -1
- data/spec/lib/bubble-wrap/requirement_spec.rb +2 -2
- data/spec/lib/bubble-wrap_spec.rb +1 -1
- data/spec/lib/motion_stub.rb +1 -1
- data/spec/motion/core/app_spec.rb +6 -0
- data/spec/motion/core/device/osx/screen_spec.rb +1 -1
- data/spec/motion/core/ios/ns_index_path_spec.rb +20 -0
- data/spec/motion/core/kvo_spec.rb +171 -58
- data/spec/motion/core/ns_notification_center_spec.rb +3 -3
- data/spec/motion/core/string_spec.rb +16 -16
- data/spec/motion/core_spec.rb +3 -3
- data/spec/motion/font/font_spec.rb +1 -1
- data/spec/motion/location/location_spec.rb +61 -9
- data/spec/motion/mail/result_spec.rb +7 -7
- data/spec/motion/media/player_spec.rb +1 -1
- data/spec/motion/reactor/thread_aware_deferrable_spec.rb +3 -3
- data/spec/motion/sms/result_spec.rb +6 -6
- data/spec/motion/ui/ui_alert_view_spec.rb +59 -1
- data/spec/motion/util/deprecated_spec.rb +1 -1
- metadata +17 -4
- data/motion/ios/7/uiactivity_view_controller_constants.rb +0 -10
@@ -4,7 +4,7 @@ describe "NSNotificationCenter" do
|
|
4
4
|
after do
|
5
5
|
@observer = nil
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
after do
|
9
9
|
BW::App.notification_center.unobserve(@observer) if @observer
|
10
10
|
end
|
@@ -23,13 +23,13 @@ describe "NSNotificationCenter" do
|
|
23
23
|
note.userInfo[:status].should == "ok"
|
24
24
|
end
|
25
25
|
|
26
|
-
lambda {
|
26
|
+
lambda {
|
27
27
|
BW::App.notification_center.post SampleNotification, Time.now, {:status => "ok"}
|
28
28
|
}.should.change { @notified }
|
29
29
|
end
|
30
30
|
|
31
31
|
it "remove observer" do
|
32
|
-
lambda {
|
32
|
+
lambda {
|
33
33
|
@observer = BW::App.notification_center.observe(SampleNotification) {}
|
34
34
|
BW::App.notification_center.unobserve(@observer)
|
35
35
|
}.should.not.change { BW::App.notification_center.observers.size }
|
@@ -40,7 +40,7 @@ describe BubbleWrap::String do
|
|
40
40
|
|
41
41
|
describe 'camelCase input' do
|
42
42
|
describe '.camelize(true)' do
|
43
|
-
it "upper cases the first character" do
|
43
|
+
it "upper cases the first character" do
|
44
44
|
'camelCase'.camelize(true).should == 'CamelCase'
|
45
45
|
end
|
46
46
|
end
|
@@ -113,19 +113,19 @@ describe BubbleWrap::String do
|
|
113
113
|
|
114
114
|
it "with 6 digits" do
|
115
115
|
@orange_color_from_hex= '#FF8A19'.to_color
|
116
|
-
@orange_color_from_hex.should == @orange_color
|
117
|
-
end
|
116
|
+
@orange_color_from_hex.should == @orange_color
|
117
|
+
end
|
118
118
|
|
119
|
-
it "with 3 digits" do
|
119
|
+
it "with 3 digits" do
|
120
120
|
@blue_color_from_hex = '#00F'.to_color
|
121
|
-
@blue_color_from_hex.should == @blue_color
|
122
|
-
end
|
121
|
+
@blue_color_from_hex.should == @blue_color
|
122
|
+
end
|
123
123
|
|
124
|
-
it "with no # sign" do
|
124
|
+
it "with no # sign" do
|
125
125
|
@orange_color_from_hex= 'FF8A19'.to_color
|
126
|
-
@orange_color_from_hex.should == @orange_color
|
127
|
-
end
|
128
|
-
end
|
126
|
+
@orange_color_from_hex.should == @orange_color
|
127
|
+
end
|
128
|
+
end
|
129
129
|
|
130
130
|
describe "a string with a color keyword (blue, red, lightText)" do
|
131
131
|
it "should return the corresponding color" do
|
@@ -150,16 +150,16 @@ describe BubbleWrap::String do
|
|
150
150
|
it "an invalid hex color" do
|
151
151
|
should.raise( ArgumentError ) {
|
152
152
|
'XXX'.to_color
|
153
|
-
}
|
153
|
+
}
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
156
|
it "a hex color with the wrong number of digits" do
|
157
157
|
should.raise( ArgumentError ) {
|
158
158
|
'FFFF'.to_color
|
159
|
-
}
|
159
|
+
}
|
160
160
|
end
|
161
|
-
|
162
|
-
end
|
161
|
+
|
162
|
+
end
|
163
163
|
|
164
164
|
describe "encoding" do
|
165
165
|
|
@@ -214,7 +214,7 @@ describe BubbleWrap::String do
|
|
214
214
|
utf8 = @raw_string.dataUsingEncoding NSUTF8StringEncoding
|
215
215
|
@raw_string.to_encoded_data.should.equal utf8
|
216
216
|
end
|
217
|
-
|
217
|
+
|
218
218
|
it "handles multiple encodings" do
|
219
219
|
utf16 = @raw_string.dataUsingEncoding NSUTF16StringEncoding
|
220
220
|
@raw_string.to_encoded_data(NSUTF16StringEncoding).should.equal utf16
|
data/spec/motion/core_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe 'BubbleWrap' do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "Localized string" do
|
54
|
-
|
54
|
+
|
55
55
|
it "loads the string from NSBundle" do
|
56
56
|
key = 'real_key'
|
57
57
|
value = 'Real Key'
|
@@ -66,11 +66,11 @@ describe 'BubbleWrap' do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
describe "uuid" do
|
71
71
|
|
72
72
|
it "always creates the new UUID" do
|
73
|
-
previous = BW.create_uuid
|
73
|
+
previous = BW.create_uuid
|
74
74
|
10.times do
|
75
75
|
uuid = BW.create_uuid
|
76
76
|
uuid.should.not.equal previous
|
@@ -93,11 +93,13 @@ describe BubbleWrap::Location do
|
|
93
93
|
CLLocationManager.authorize(KCLAuthorizationStatusAuthorized)
|
94
94
|
BW::Location.authorized?.should == true
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
# if Device.ios_version.to_f >= 8.0
|
97
|
+
# CLLocationManager.authorize(KCLAuthorizationStatusAuthorizedWhenInUse)
|
98
|
+
# BW::Location.authorized?.should == true
|
99
|
+
#
|
100
|
+
# CLLocationManager.authorize(KCLAuthorizationStatusAuthorizedAlways)
|
101
|
+
# BW::Location.authorized?.should == true
|
102
|
+
# end
|
101
103
|
end
|
102
104
|
|
103
105
|
it "should throw error if not enabled" do
|
@@ -147,7 +149,7 @@ describe BubbleWrap::Location do
|
|
147
149
|
result[:from].longitude.should == 49
|
148
150
|
end
|
149
151
|
|
150
|
-
BW::Location.locationManager(location_manager,
|
152
|
+
BW::Location.locationManager(location_manager, didUpdateLocations: [from, to])
|
151
153
|
end
|
152
154
|
end
|
153
155
|
|
@@ -163,11 +165,11 @@ describe BubbleWrap::Location do
|
|
163
165
|
@number_times += 1
|
164
166
|
end
|
165
167
|
|
166
|
-
BW::Location.locationManager(location_manager,
|
168
|
+
BW::Location.locationManager(location_manager, didUpdateLocations: [from, to])
|
167
169
|
|
168
170
|
to = CLLocation.alloc.initWithLatitude(0, longitude: 0)
|
169
171
|
from = CLLocation.alloc.initWithLatitude(0, longitude: 0)
|
170
|
-
BW::Location.locationManager(location_manager,
|
172
|
+
BW::Location.locationManager(location_manager, didUpdateLocations: [from, to])
|
171
173
|
@number_times.should == 1
|
172
174
|
end
|
173
175
|
end
|
@@ -233,8 +235,58 @@ describe BubbleWrap::Location do
|
|
233
235
|
result[:from].longitude.should == 49
|
234
236
|
end
|
235
237
|
|
236
|
-
BW::Location.locationManager(location_manager,
|
238
|
+
BW::Location.locationManager(location_manager, didUpdateLocations: [from, to])
|
239
|
+
end
|
240
|
+
|
241
|
+
it "should include previous locations" do
|
242
|
+
to = CLLocation.alloc.initWithLatitude(100, longitude: 50)
|
243
|
+
from = CLLocation.alloc.initWithLatitude(100, longitude: 49)
|
244
|
+
previous = CLLocation.alloc.initWithLatitude(100, longitude: 48)
|
245
|
+
|
246
|
+
BW::Location.get_significant do |result|
|
247
|
+
result[:to].longitude.should == 50
|
248
|
+
result[:from].longitude.should == 49
|
249
|
+
result[:previous].last.longitude.should == 48
|
250
|
+
end
|
251
|
+
|
252
|
+
BW::Location.locationManager(location_manager, didUpdateLocations: [previous, from, to])
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should preserve previous location when delegate method only returns current location" do
|
256
|
+
to = CLLocation.alloc.initWithLatitude(100, longitude: 49)
|
257
|
+
|
258
|
+
@number_times = 0
|
259
|
+
BW::Location.get_significant do |result|
|
260
|
+
if @number_times == 0
|
261
|
+
result[:to].longitude.should == 49
|
262
|
+
result[:from].should == nil
|
263
|
+
result[:previous].last.should == nil
|
264
|
+
else
|
265
|
+
result[:to].longitude.should == 50
|
266
|
+
result[:from].longitude.should == 49
|
267
|
+
result[:previous].last.should == nil
|
268
|
+
end
|
269
|
+
@number_times += 1
|
270
|
+
end
|
271
|
+
|
272
|
+
BW::Location.locationManager(location_manager, didUpdateLocations: [to])
|
273
|
+
|
274
|
+
to = CLLocation.alloc.initWithLatitude(100, longitude: 50)
|
275
|
+
BW::Location.locationManager(location_manager, didUpdateLocations: [to])
|
276
|
+
|
277
|
+
@number_times.should == 2
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe ".start" do
|
282
|
+
before do
|
283
|
+
reset
|
284
|
+
end
|
285
|
+
|
286
|
+
it "should not throw an error starting when the Location Manager has not been initialized" do
|
287
|
+
Proc.new { BW::Location.start }.should.not.raise Exception
|
237
288
|
end
|
289
|
+
|
238
290
|
end
|
239
291
|
|
240
292
|
describe ".stop" do
|
@@ -1,19 +1,19 @@
|
|
1
1
|
describe BW::Mail::Result do
|
2
|
-
|
2
|
+
|
3
3
|
before do
|
4
4
|
@subject = BW::Mail::Result.new(MFMailComposeResultCancelled, nil)
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
it "should set sent? when sent" do
|
8
8
|
@subject.result = MFMailComposeResultSent
|
9
9
|
@subject.should.be.sent
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should not set sent? when not sent" do
|
13
13
|
@subject.result = MFMailComposeResultCancelled
|
14
14
|
@subject.should.not.be.sent
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should set canceled? when canceled" do
|
18
18
|
@subject.result = MFMailComposeResultCancelled
|
19
19
|
@subject.should.be.canceled
|
@@ -23,7 +23,7 @@ describe BW::Mail::Result do
|
|
23
23
|
@subject.result = MFMailComposeResultSent
|
24
24
|
@subject.should.not.be.canceled
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
it "should set saved? when saved" do
|
28
28
|
@subject.result = MFMailComposeResultSaved
|
29
29
|
@subject.should.be.saved
|
@@ -33,7 +33,7 @@ describe BW::Mail::Result do
|
|
33
33
|
@subject.result = MFMailComposeResultFailed
|
34
34
|
@subject.should.not.be.saved
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should set failed? when failed" do
|
38
38
|
@subject.result = MFMailComposeResultFailed
|
39
39
|
@subject.should.be.failed
|
@@ -43,7 +43,7 @@ describe BW::Mail::Result do
|
|
43
43
|
@subject.result = MFMailComposeResultSent
|
44
44
|
@subject.should.not.be.failed
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "should set failed? when error" do
|
48
48
|
@subject.result = MFMailComposeResultCancelled
|
49
49
|
@subject.error = :errored
|
@@ -7,7 +7,7 @@ shared :queue_caching_deferrable_method do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "stores the queue, even if its not the main" do
|
10
|
-
@queue.async do
|
10
|
+
@queue.async do
|
11
11
|
@subject.send(@method, &@blk)
|
12
12
|
Dispatch::Queue.main.async { resume }
|
13
13
|
end
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
|
22
22
|
shared :queue_block_execution do
|
23
23
|
it "calls the block on the right thread, with deferred argument once the deferrable is finished" do
|
24
|
-
@queue.async do
|
24
|
+
@queue.async do
|
25
25
|
@subject.send(@block_method) do |*args|
|
26
26
|
Dispatch::Queue.current.to_s.should.equal @queue.to_s
|
27
27
|
args.should.equal [true]
|
@@ -34,7 +34,7 @@ shared :queue_block_execution do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "removes the queue from internal cache once the deferrable is finished" do
|
37
|
-
@subject.send(@block_method) do |*args|
|
37
|
+
@subject.send(@block_method) do |*args|
|
38
38
|
Dispatch::Queue.main.async { resume }
|
39
39
|
end
|
40
40
|
@subject.send(@status_method, true)
|
@@ -1,19 +1,19 @@
|
|
1
1
|
describe BW::SMS::Result do
|
2
|
-
|
2
|
+
|
3
3
|
before do
|
4
4
|
@subject = BW::SMS::Result.new(MessageComposeResultCancelled)
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
it "should set sent? when sent" do
|
8
8
|
@subject.result = MessageComposeResultSent
|
9
9
|
@subject.should.be.sent
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should not set sent? when not sent" do
|
13
13
|
@subject.result = MessageComposeResultFailed
|
14
14
|
@subject.should.not.be.sent
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should set canceled? when canceled" do
|
18
18
|
@subject.result = MessageComposeResultCancelled
|
19
19
|
@subject.should.be.canceled
|
@@ -23,8 +23,8 @@ describe BW::SMS::Result do
|
|
23
23
|
@subject.result = MessageComposeResultFailed
|
24
24
|
@subject.should.not.be.canceled
|
25
25
|
end
|
26
|
-
|
27
|
-
|
26
|
+
|
27
|
+
|
28
28
|
it "should set failed? when failed" do
|
29
29
|
@subject.result = MessageComposeResultFailed
|
30
30
|
@subject.should.be.failed
|
@@ -185,6 +185,8 @@ describe BW::UIAlertView do
|
|
185
185
|
:title => "title",
|
186
186
|
:message => "message",
|
187
187
|
:style => :plain_text_input,
|
188
|
+
:keyboard_type => UIKeyboardTypeURL,
|
189
|
+
:text => "text",
|
188
190
|
:placeholder => "placeholder",
|
189
191
|
:buttons => "button title",
|
190
192
|
:cancel_button_index => 0,
|
@@ -313,6 +315,7 @@ describe BW::UIAlertView do
|
|
313
315
|
:title => "title",
|
314
316
|
:message => "message",
|
315
317
|
:style => :plain_text_input,
|
318
|
+
:text => "text",
|
316
319
|
:placeholder => "placeholder",
|
317
320
|
:buttons => "button title",
|
318
321
|
:cancel_button_index => 0,
|
@@ -409,6 +412,14 @@ describe BW::UIAlertView do
|
|
409
412
|
@subject.plain_text_field.placeholder.should.be.nil
|
410
413
|
end
|
411
414
|
|
415
|
+
it "has no text" do
|
416
|
+
@subject.plain_text_field.text.should == ""
|
417
|
+
end
|
418
|
+
|
419
|
+
it "has the default keyboard type" do
|
420
|
+
@subject.plain_text_field.keyboardType.should == UIKeyboardTypeDefault
|
421
|
+
end
|
422
|
+
|
412
423
|
it "has no secure text field" do
|
413
424
|
@subject.secure_text_field.should.be.nil
|
414
425
|
end
|
@@ -426,7 +437,7 @@ describe BW::UIAlertView do
|
|
426
437
|
|
427
438
|
describe "given a text placeholder" do
|
428
439
|
before do
|
429
|
-
@options = {placeholder: "placeholder"}
|
440
|
+
@options = { placeholder: "placeholder" }
|
430
441
|
@subject = BW::UIAlertView.plain_text_input(@options)
|
431
442
|
end
|
432
443
|
|
@@ -436,6 +447,50 @@ describe BW::UIAlertView do
|
|
436
447
|
@subject.plain_text_field.placeholder.should == "placeholder"
|
437
448
|
end
|
438
449
|
end
|
450
|
+
|
451
|
+
###############################################################################################
|
452
|
+
|
453
|
+
describe "given text" do
|
454
|
+
before do
|
455
|
+
@options = { text: "text" }
|
456
|
+
@subject = BW::UIAlertView.plain_text_input(@options)
|
457
|
+
end
|
458
|
+
|
459
|
+
behaves_like "an instance with no options"
|
460
|
+
|
461
|
+
it "has the correct text" do
|
462
|
+
@subject.plain_text_field.text.should == "text"
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
###############################################################################################
|
467
|
+
|
468
|
+
describe "given a keyboard type" do
|
469
|
+
before do
|
470
|
+
@options = { keyboard_type: UIKeyboardTypeURL }
|
471
|
+
@subject = BW::UIAlertView.plain_text_input(@options)
|
472
|
+
end
|
473
|
+
|
474
|
+
behaves_like "an instance with no options"
|
475
|
+
|
476
|
+
it "has the correct keyboard type" do
|
477
|
+
@subject.plain_text_field.keyboardType.should == UIKeyboardTypeURL
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
describe "given a keyboard type as a symbol" do
|
482
|
+
before do
|
483
|
+
@options = { keyboard_type: :email_address }
|
484
|
+
@subject = BW::UIAlertView.plain_text_input(@options)
|
485
|
+
end
|
486
|
+
|
487
|
+
behaves_like "an instance with no options"
|
488
|
+
|
489
|
+
it "has the correct keyboard type" do
|
490
|
+
@subject.plain_text_field.keyboardType.should == UIKeyboardTypeEmailAddress
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
439
494
|
###############################################################################################
|
440
495
|
|
441
496
|
describe "given no options with a block" do
|
@@ -474,6 +529,7 @@ describe BW::UIAlertView do
|
|
474
529
|
:title => "title",
|
475
530
|
:message => "message",
|
476
531
|
:style => :default,
|
532
|
+
:text => "text",
|
477
533
|
:placeholder => "placeholder",
|
478
534
|
:buttons => "button title",
|
479
535
|
:cancel_button_index => 0,
|
@@ -617,6 +673,7 @@ describe BW::UIAlertView do
|
|
617
673
|
:title => "title",
|
618
674
|
:message => "message",
|
619
675
|
:style => :default,
|
676
|
+
:text => "text",
|
620
677
|
:placeholder => "placeholder",
|
621
678
|
:buttons => "button title",
|
622
679
|
:cancel_button_index => 0,
|
@@ -760,6 +817,7 @@ describe BW::UIAlertView do
|
|
760
817
|
:title => "title",
|
761
818
|
:message => "message",
|
762
819
|
:style => :default,
|
820
|
+
:text => "text",
|
763
821
|
:placeholder => "placeholder",
|
764
822
|
:buttons => "button title",
|
765
823
|
:cancel_button_index => 0,
|