bubble-wrap 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -9
  3. data/CHANGELOG.md +21 -2
  4. data/Gemfile.lock +8 -5
  5. data/README.md +54 -3
  6. data/Rakefile +7 -1
  7. data/lib/bubble-wrap/camera.rb +1 -1
  8. data/lib/bubble-wrap/core.rb +1 -1
  9. data/lib/bubble-wrap/font.rb +1 -1
  10. data/lib/bubble-wrap/loader.rb +4 -4
  11. data/lib/bubble-wrap/media.rb +1 -1
  12. data/lib/bubble-wrap/motion.rb +7 -1
  13. data/lib/bubble-wrap/version.rb +2 -2
  14. data/motion/core/app.rb +4 -0
  15. data/motion/core/device/ios/camera_wrapper.rb +1 -1
  16. data/motion/core/device/ios/screen.rb +2 -2
  17. data/motion/core/device/osx/screen.rb +1 -1
  18. data/motion/core/device/screen.rb +1 -1
  19. data/motion/core/ios/device.rb +1 -1
  20. data/motion/core/ios/ns_index_path.rb +11 -0
  21. data/motion/core/json.rb +2 -2
  22. data/motion/core/kvo.rb +118 -55
  23. data/motion/core/ns_notification_center.rb +2 -2
  24. data/motion/core/ns_url_request.rb +2 -2
  25. data/motion/core/osx/device.rb +1 -1
  26. data/motion/core/string.rb +7 -7
  27. data/motion/font/font.rb +1 -1
  28. data/motion/ios/8/location_constants.rb +21 -0
  29. data/motion/location/location.rb +38 -18
  30. data/motion/mail/result.rb +1 -1
  31. data/motion/media/media.rb +1 -1
  32. data/motion/motion/accelerometer.rb +55 -0
  33. data/motion/motion/device_motion.rb +139 -0
  34. data/motion/motion/gyroscope.rb +55 -0
  35. data/motion/motion/magnetometer.rb +55 -0
  36. data/motion/motion/motion.rb +0 -288
  37. data/motion/reactor.rb +3 -3
  38. data/motion/reactor/deferrable.rb +32 -32
  39. data/motion/reactor/periodic_timer.rb +1 -1
  40. data/motion/reactor/queue.rb +6 -6
  41. data/motion/reactor/thread_aware_deferrable.rb +1 -1
  42. data/motion/reactor/timer.rb +1 -1
  43. data/motion/rss_parser.rb +6 -3
  44. data/motion/shortcut.rb +1 -1
  45. data/motion/sms/result.rb +1 -1
  46. data/motion/test_suite_delegate.rb +1 -1
  47. data/motion/ui/ui_activity_view_controller_wrapper.rb +6 -1
  48. data/motion/ui/ui_alert_view.rb +21 -1
  49. data/motion/util/deprecated.rb +1 -1
  50. data/samples/alert/Gemfile.lock +1 -1
  51. data/spec/lib/bubble-wrap/requirement_spec.rb +2 -2
  52. data/spec/lib/bubble-wrap_spec.rb +1 -1
  53. data/spec/lib/motion_stub.rb +1 -1
  54. data/spec/motion/core/app_spec.rb +6 -0
  55. data/spec/motion/core/device/osx/screen_spec.rb +1 -1
  56. data/spec/motion/core/ios/ns_index_path_spec.rb +20 -0
  57. data/spec/motion/core/kvo_spec.rb +171 -58
  58. data/spec/motion/core/ns_notification_center_spec.rb +3 -3
  59. data/spec/motion/core/string_spec.rb +16 -16
  60. data/spec/motion/core_spec.rb +3 -3
  61. data/spec/motion/font/font_spec.rb +1 -1
  62. data/spec/motion/location/location_spec.rb +61 -9
  63. data/spec/motion/mail/result_spec.rb +7 -7
  64. data/spec/motion/media/player_spec.rb +1 -1
  65. data/spec/motion/reactor/thread_aware_deferrable_spec.rb +3 -3
  66. data/spec/motion/sms/result_spec.rb +6 -6
  67. data/spec/motion/ui/ui_alert_view_spec.rb +59 -1
  68. data/spec/motion/util/deprecated_spec.rb +1 -1
  69. metadata +17 -4
  70. data/motion/ios/7/uiactivity_view_controller_constants.rb +0 -10
@@ -0,0 +1,55 @@
1
+ module BubbleWrap
2
+ module Motion
3
+ class Magnetometer < GenericMotionInterface
4
+
5
+ def start(options={}, &handler)
6
+ if options.key?(:interval)
7
+ @manager.magnetometerUpdateInterval = options[:interval]
8
+ end
9
+
10
+ if handler
11
+ queue = convert_queue(options[:queue])
12
+ @manager.startMagnetometerUpdatesToQueue(queue, withHandler: internal_handler(handler))
13
+ else
14
+ @manager.startMagnetometerUpdates
15
+ end
16
+
17
+ return self
18
+ end
19
+
20
+ private def handle_result(result_data, error, handler)
21
+ if result_data
22
+ result = {
23
+ data: result_data,
24
+ field: result_data.magneticField,
25
+ x: result_data.magneticField.x,
26
+ y: result_data.magneticField.y,
27
+ z: result_data.magneticField.z,
28
+ }
29
+ else
30
+ result = nil
31
+ end
32
+
33
+ handler.call(result, error)
34
+ end
35
+
36
+ def available?
37
+ @manager.magnetometerAvailable?
38
+ end
39
+
40
+ def active?
41
+ @manager.magnetometerActive?
42
+ end
43
+
44
+ def data
45
+ @manager.magnetometerData
46
+ end
47
+
48
+ def stop
49
+ @manager.stopMagnetometerUpdates
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+ end
@@ -129,293 +129,5 @@ module BubbleWrap
129
129
 
130
130
  end
131
131
 
132
- class Accelerometer < GenericMotionInterface
133
-
134
- def start(options={}, &handler)
135
- if options.key?(:interval)
136
- @manager.accelerometerUpdateInterval = options[:interval]
137
- end
138
-
139
- if handler
140
- queue = convert_queue(options[:queue])
141
- @manager.startAccelerometerUpdatesToQueue(queue, withHandler: internal_handler(handler))
142
- else
143
- @manager.startAccelerometerUpdates
144
- end
145
-
146
- return self
147
- end
148
-
149
- private def handle_result(result_data, error, handler)
150
- if result_data
151
- result = {
152
- data: result_data,
153
- acceleration: result_data.acceleration,
154
- x: result_data.acceleration.x,
155
- y: result_data.acceleration.y,
156
- z: result_data.acceleration.z,
157
- }
158
- else
159
- result = nil
160
- end
161
-
162
- handler.call(result, error)
163
- end
164
-
165
- def available?
166
- @manager.accelerometerAvailable?
167
- end
168
-
169
- def active?
170
- @manager.accelerometerActive?
171
- end
172
-
173
- def data
174
- @manager.accelerometerData
175
- end
176
-
177
- def stop
178
- @manager.stopAccelerometerUpdates
179
- end
180
-
181
- end
182
-
183
- class Gyroscope < GenericMotionInterface
184
-
185
- def start(options={}, &handler)
186
- if options.key?(:interval)
187
- @manager.gyroUpdateInterval = options[:interval]
188
- end
189
-
190
- if handler
191
- queue = convert_queue(options[:queue])
192
- @manager.startGyroUpdatesToQueue(queue, withHandler: internal_handler(handler))
193
- else
194
- @manager.startGyroUpdates
195
- end
196
-
197
- return self
198
- end
199
-
200
- private def handle_result(result_data, error, handler)
201
- if result_data
202
- result = {
203
- data: result_data,
204
- rotation: result_data.rotationRate,
205
- x: result_data.rotationRate.x,
206
- y: result_data.rotationRate.y,
207
- z: result_data.rotationRate.z,
208
- }
209
- else
210
- result = nil
211
- end
212
-
213
- handler.call(result, error)
214
- end
215
-
216
- def available?
217
- @manager.gyroAvailable?
218
- end
219
-
220
- def active?
221
- @manager.gyroActive?
222
- end
223
-
224
- def data
225
- @manager.gyroData
226
- end
227
-
228
- def stop
229
- @manager.stopGyroUpdates
230
- end
231
-
232
- end
233
-
234
- class Magnetometer < GenericMotionInterface
235
-
236
- def start(options={}, &handler)
237
- if options.key?(:interval)
238
- @manager.magnetometerUpdateInterval = options[:interval]
239
- end
240
-
241
- if handler
242
- queue = convert_queue(options[:queue])
243
- @manager.startMagnetometerUpdatesToQueue(queue, withHandler: internal_handler(handler))
244
- else
245
- @manager.startMagnetometerUpdates
246
- end
247
-
248
- return self
249
- end
250
-
251
- private def handle_result(result_data, error, handler)
252
- if result_data
253
- result = {
254
- data: result_data,
255
- field: result_data.magneticField,
256
- x: result_data.magneticField.x,
257
- y: result_data.magneticField.y,
258
- z: result_data.magneticField.z,
259
- }
260
- else
261
- result = nil
262
- end
263
-
264
- handler.call(result, error)
265
- end
266
-
267
- def available?
268
- @manager.magnetometerAvailable?
269
- end
270
-
271
- def active?
272
- @manager.magnetometerActive?
273
- end
274
-
275
- def data
276
- @manager.magnetometerData
277
- end
278
-
279
- def stop
280
- @manager.stopMagnetometerUpdates
281
- end
282
-
283
- end
284
-
285
- class DeviceMotion < GenericMotionInterface
286
-
287
- def start(options={}, &handler)
288
- if options.key?(:interval)
289
- @manager.deviceMotionUpdateInterval = options[:interval]
290
- end
291
-
292
- if options.key?(:reference)
293
- reference_frame = convert_reference_frame(options[:reference])
294
- else
295
- reference_frame = nil
296
- end
297
-
298
- if handler
299
- queue = convert_queue(options[:queue])
300
-
301
- if reference_frame
302
- @manager.startDeviceMotionUpdatesUsingReferenceFrame(reference_frame, toQueue: queue, withHandler: internal_handler(handler))
303
- else
304
- @manager.startDeviceMotionUpdatesToQueue(queue, withHandler: internal_handler(handler))
305
- end
306
- else
307
- if reference_frame
308
- @manager.startDeviceMotionUpdatesUsingReferenceFrame(reference_frame)
309
- else
310
- @manager.startDeviceMotionUpdates
311
- end
312
- end
313
-
314
- return self
315
- end
316
-
317
- private def handle_result(result_data, error, handler)
318
- if result_data
319
- result = {
320
- data: result_data,
321
- attitude: result_data.attitude,
322
- rotation: result_data.rotationRate,
323
- gravity: result_data.gravity,
324
- acceleration: result_data.userAcceleration,
325
- magnetic: result_data.magneticField,
326
- }
327
-
328
- if result_data.attitude
329
- result.merge!({
330
- roll: result_data.attitude.roll,
331
- pitch: result_data.attitude.pitch,
332
- yaw: result_data.attitude.yaw,
333
- matrix: result_data.attitude.rotationMatrix,
334
- quaternion: result_data.attitude.quaternion,
335
- })
336
- end
337
-
338
- if result_data.rotationRate
339
- result.merge!({
340
- rotation_x: result_data.rotationRate.x,
341
- rotation_y: result_data.rotationRate.y,
342
- rotation_z: result_data.rotationRate.z,
343
- })
344
- end
345
-
346
- if result_data.gravity
347
- result.merge!({
348
- gravity_x: result_data.gravity.x,
349
- gravity_y: result_data.gravity.y,
350
- gravity_z: result_data.gravity.z,
351
- })
352
- end
353
-
354
- if result_data.userAcceleration
355
- result.merge!({
356
- acceleration_x: result_data.userAcceleration.x,
357
- acceleration_y: result_data.userAcceleration.y,
358
- acceleration_z: result_data.userAcceleration.z,
359
- })
360
- end
361
-
362
- if result_data.magneticField
363
- case result_data.magneticField.accuracy
364
- when CMMagneticFieldCalibrationAccuracyLow
365
- accuracy = :low
366
- when CMMagneticFieldCalibrationAccuracyMedium
367
- accuracy = :medium
368
- when CMMagneticFieldCalibrationAccuracyHigh
369
- accuracy = :high
370
- end
371
-
372
- result.merge!({
373
- field: result_data.magneticField.field,
374
- magnetic_x: result_data.magneticField.field.x,
375
- magnetic_y: result_data.magneticField.field.y,
376
- magnetic_z: result_data.magneticField.field.z,
377
- magnetic_accuracy: accuracy,
378
- })
379
- end
380
- else
381
- result = nil
382
- end
383
-
384
- handler.call(result, error)
385
- end
386
-
387
- def convert_reference_frame(reference_frame)
388
- case reference_frame
389
- when :arbitrary_z
390
- CMAttitudeReferenceFrameXArbitraryZVertical
391
- when :corrected_z
392
- CMAttitudeReferenceFrameXArbitraryCorrectedZVertical
393
- when :magnetic_north
394
- CMAttitudeReferenceFrameXMagneticNorthZVertical
395
- when :true_north
396
- CMAttitudeReferenceFrameXTrueNorthZVertical
397
- else
398
- reference_frame
399
- end
400
- end
401
-
402
- def available?
403
- @manager.deviceMotionAvailable?
404
- end
405
-
406
- def active?
407
- @manager.deviceMotionActive?
408
- end
409
-
410
- def data
411
- @manager.deviceMotion
412
- end
413
-
414
- def stop
415
- @manager.stopDeviceMotionUpdates
416
- end
417
-
418
- end
419
-
420
132
  end
421
133
  end
data/motion/reactor.rb CHANGED
@@ -67,7 +67,7 @@ module BubbleWrap
67
67
  # parameter (the "operation") and schedule it for asynchronous execution
68
68
  # on a GCD concurrency queue. When the operation completes the result (if any)
69
69
  # is passed into the callback (if present).
70
- def defer(op=nil,cb=nil,&blk)
70
+ def defer(op=nil,cb=nil,&blk)
71
71
  schedule do
72
72
  result = (op||blk).call
73
73
  schedule(result, &cb) if cb
@@ -76,7 +76,7 @@ module BubbleWrap
76
76
 
77
77
  # A version of `defer` which schedules both the operator
78
78
  # and callback operations on the application's main thread.
79
- def defer_on_main(op=nil,cb=nil,&blk)
79
+ def defer_on_main(op=nil,cb=nil,&blk)
80
80
  schedule_on_main do
81
81
  result = (op||blk).call
82
82
  schedule_on_main(result, &cb) if cb
@@ -105,7 +105,7 @@ module BubbleWrap
105
105
  end
106
106
  ::Dispatch::Queue.main.async &cb
107
107
  end
108
-
108
+
109
109
  end
110
110
  end
111
111
 
@@ -7,13 +7,13 @@ module BubbleWrap
7
7
  # base.extend ::BubbleWrap::Reactor::Future
8
8
  # end
9
9
 
10
- # Specify a block to be executed if and when the Deferrable object
11
- # receives a status of :succeeded. See set_deferred_status for more
10
+ # Specify a block to be executed if and when the Deferrable object
11
+ # receives a status of :succeeded. See set_deferred_status for more
12
12
  # information.
13
- # Calling this method on a Deferrable object whose status is not yet
14
- # known will cause the callback block to be stored on an internal
15
- # list. If you call this method on a Deferrable whose status is
16
- # :succeeded, the block will be executed immediately, receiving
13
+ # Calling this method on a Deferrable object whose status is not yet
14
+ # known will cause the callback block to be stored on an internal
15
+ # list. If you call this method on a Deferrable whose status is
16
+ # :succeeded, the block will be executed immediately, receiving
17
17
  # the parameters given to the prior set_deferred_status call.
18
18
  def callback(&blk)
19
19
  return unless blk
@@ -35,8 +35,8 @@ module BubbleWrap
35
35
  end
36
36
  end
37
37
 
38
- # Specify a block to be executed if and when the Deferrable object
39
- # receives a status of :failed. See set_deferred_status for more
38
+ # Specify a block to be executed if and when the Deferrable object
39
+ # receives a status of :failed. See set_deferred_status for more
40
40
  # information.
41
41
  def errback(&blk)
42
42
  return unless blk
@@ -46,7 +46,7 @@ module BubbleWrap
46
46
  blk.call(*@deferred_args)
47
47
  elsif @deferred_status != :succeeded
48
48
  @errbacks ||= []
49
- @errbacks.unshift blk
49
+ @errbacks.unshift blk
50
50
  end
51
51
  end
52
52
 
@@ -81,31 +81,31 @@ module BubbleWrap
81
81
  end
82
82
  alias set_deferred_failure fail
83
83
 
84
- # Sets the “disposition” (status) of the Deferrable object. See also
85
- # the large set of sugarings for this method. Note that if you call
86
- # this method without arguments, no arguments will be passed to the
87
- # callback/errback. If the user has coded these with arguments,
88
- # then the user code will throw an argument exception. Implementors
89
- # of deferrable classes must document the arguments they will supply
84
+ # Sets the “disposition” (status) of the Deferrable object. See also
85
+ # the large set of sugarings for this method. Note that if you call
86
+ # this method without arguments, no arguments will be passed to the
87
+ # callback/errback. If the user has coded these with arguments,
88
+ # then the user code will throw an argument exception. Implementors
89
+ # of deferrable classes must document the arguments they will supply
90
90
  # to user callbacks.
91
- # OBSERVE SOMETHING VERY SPECIAL here: you may call this method even
92
- # on the INSIDE of a callback. This is very useful when a
93
- # previously-registered callback wants to change the parameters that
91
+ # OBSERVE SOMETHING VERY SPECIAL here: you may call this method even
92
+ # on the INSIDE of a callback. This is very useful when a
93
+ # previously-registered callback wants to change the parameters that
94
94
  # will be passed to subsequently-registered ones.
95
95
  # You may give either :succeeded or :failed as the status argument.
96
- # If you pass :succeeded, then all of the blocks passed to the object
97
- # using the callback method (if any) will be executed BEFORE the
98
- # set_deferred_status method returns. All of the blocks passed to the
96
+ # If you pass :succeeded, then all of the blocks passed to the object
97
+ # using the callback method (if any) will be executed BEFORE the
98
+ # set_deferred_status method returns. All of the blocks passed to the
99
99
  # object using errback will be discarded.
100
- # If you pass :failed, then all of the blocks passed to the object
101
- # using the errback method (if any) will be executed BEFORE the
102
- # set_deferred_status method returns. All of the blocks passed to the
100
+ # If you pass :failed, then all of the blocks passed to the object
101
+ # using the errback method (if any) will be executed BEFORE the
102
+ # set_deferred_status method returns. All of the blocks passed to the
103
103
  # object using # callback will be discarded.
104
- # If you pass any arguments to set_deferred_status in addition to the
105
- # status argument, they will be passed as arguments to any callbacks
106
- # or errbacks that are executed. It’s your responsibility to ensure
107
- # that the argument lists specified in your callbacks and errbacks match
108
- # the arguments given in calls to set_deferred_status, otherwise Ruby
104
+ # If you pass any arguments to set_deferred_status in addition to the
105
+ # status argument, they will be passed as arguments to any callbacks
106
+ # or errbacks that are executed. It’s your responsibility to ensure
107
+ # that the argument lists specified in your callbacks and errbacks match
108
+ # the arguments given in calls to set_deferred_status, otherwise Ruby
109
109
  # will raise an ArgumentError.
110
110
  def set_deferred_status(status, *args)
111
111
  cancel_timeout
@@ -137,9 +137,9 @@ module BubbleWrap
137
137
  end
138
138
  alias set_deferred_success succeed
139
139
 
140
- # Setting a timeout on a Deferrable causes it to go into the failed
141
- # state after the Timeout expires (passing no arguments to the object’s
142
- # errbacks). Setting the status at any time prior to a call to the
140
+ # Setting a timeout on a Deferrable causes it to go into the failed
141
+ # state after the Timeout expires (passing no arguments to the object’s
142
+ # errbacks). Setting the status at any time prior to a call to the
143
143
  # expiration of the timeout will cause the timer to be cancelled.
144
144
  def timeout(seconds)
145
145
  cancel_timeout