bubble-wrap 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3cd8d9f0bebb81477fb04cb806c4e0313740981
4
- data.tar.gz: 0a17047861a5287be10ae1c36de0cc3e7f785d41
3
+ metadata.gz: c36af1404df9fe25d9bb32a34940b0877bf9eacd
4
+ data.tar.gz: c1d13206fbdff5651321d7ef362d7695ae8e2b7f
5
5
  SHA512:
6
- metadata.gz: 7f5a56f2fce145ababe84f93bc34f843cf7c88f8c334e7744e27f49af5e3fee3881acdde5ee0c28b315585655c2eaff22d4afbc1a6c70e3d4a3d527d5d492e07
7
- data.tar.gz: fc0742d02c49b7c2cfc4cee067bc50f8be7c6387a0fb2f88b8659e467d0f706601b37e0cd618e83a6388b859f6af1163cc340cdb315ff0539f31ede799cf2390
6
+ metadata.gz: 03a94c71a69d7d27c68a7713f53f78db2daf10fe90561c03839f851ba0c2e65a1397ea0fe407432d1f4fcae9c317fe7265a06862ed66bbe81246121aab2667ab
7
+ data.tar.gz: f37b7ffddccd80b6716ea18efbdd11e217c66a3a15261e439e3b82caa048bb9ab0e4dc4a277c6dd89a66a27ff0c868eb2e7d13564d4d9e34f3ba2eb89913155e
@@ -98,7 +98,7 @@ BW.require '/path/to/some/files/**/*.rb'
98
98
  ```
99
99
 
100
100
  For more information in using `BW.require` take a look at
101
- [the bubblewrap hacking guide](http://bubblewrap.io/hacking.html).
101
+ [the bubblewrap hacking guide](hacking.html).
102
102
 
103
103
  ## Go forth and conquer!
104
104
 
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bubble-wrap (1.6.0)
5
- bubble-wrap-http (= 1.6.0)
4
+ bubble-wrap (1.7.0)
5
+ bubble-wrap-http (= 1.7.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  bacon (1.1.0)
11
- bubble-wrap-http (1.6.0)
11
+ bubble-wrap-http (1.7.0)
12
12
  metaclass (0.0.1)
13
13
  mocha (0.11.4)
14
14
  metaclass (~> 0.0.1)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A collection of (tested) helpers and wrappers used to wrap Cocoa Touch and AppKit code and provide more Ruby like APIs.
4
4
 
5
- [BubbleWrap website](http://bubblewrap.io)
5
+ [BubbleWrap website](http://rubymotion.github.io/BubbleWrap/)
6
6
  [BubbleWrap mailing list](https://groups.google.com/forum/#!forum/bubblewrap)
7
7
 
8
8
  [![Code Climate](https://codeclimate.com/github/rubymotion/BubbleWrap.png)](https://codeclimate.com/github/rubymotion/BubbleWrap)
@@ -267,8 +267,22 @@ end
267
267
  BW::Device.camera.any.picture(media_types: [:movie, :image]) do |result|
268
268
  image_view = UIImageView.alloc.initWithImage(result[:original_image])
269
269
  end
270
+
271
+ # Lets the user edit the photo (with access to the edited and original photos)
272
+ BW::Device.camera.any.picture(allows_editing: true, media_types: [:image]) do |result|
273
+ edited_image_view = UIImageView.alloc.initWithImage(result[:edited_image])
274
+ original_image_view = UIImageView.alloc.initWithImage(result[:original_image])
275
+ end
270
276
  ```
271
277
 
278
+
279
+ Options include:
280
+
281
+ - `:allows_editing` - Boolean; whether a user can edit the photo/video before picking
282
+ - `:animated` - Boolean; whether to display the camera with an animation (default true)
283
+ - `:on_dismiss` - Lambda; called instead of the default dismissal logic
284
+ - `:media_types` - Array; containing any of `[:movie, :image]`
285
+
272
286
  ### JSON
273
287
 
274
288
  `BW::JSON` wraps `NSJSONSerialization` available in iOS5 and offers the same API as Ruby's JSON std lib. For apps building for iOS4, we suggest a different JSON alternative, like [AnyJSON](https://github.com/mattt/AnyJSON).
@@ -331,6 +345,8 @@ simple interface:
331
345
  # ['TF1', 'France 2', 'France 3']
332
346
  > App::Persistence['something__new'] # something previously never stored
333
347
  # nil
348
+ > App::Persistence.all
349
+ # {'all':'values', 'stored':'by', 'bubblewrap':'as a hash!'}
334
350
  ```
335
351
 
336
352
  ### Observers
@@ -389,7 +405,14 @@ iso8601 formatted string into a Time instance.
389
405
  Added interface for Ruby-like GPS and compass access:
390
406
 
391
407
  ```ruby
392
- BW::Location.get do |result|
408
+ > BW::Location.enabled? # Whether location services are enabled on the device
409
+ => true
410
+ > BW::Location.authorized? # If your app is authorized to use location services
411
+ => false
412
+ ```
413
+
414
+ ```ruby
415
+ BW::Location.get(purpose: 'We need to use your GPS because...') do |result|
393
416
  p "From Lat #{result[:from].latitude}, Long #{result[:from].longitude}"
394
417
  p "To Lat #{result[:to].latitude}, Long #{result[:to].longitude}"
395
418
  end
@@ -404,7 +427,27 @@ BW::Location.get_compass do |result|
404
427
  end
405
428
  ```
406
429
 
407
- Also available is `BW::Location.get_significant`, for monitoring significant location changes.
430
+ `BW::Location.get_significant` is also available, for monitoring significant location changes.
431
+
432
+ `BW::Location` also supports `get_once`-style methods, which will return the first result before ending the search:
433
+
434
+ ```ruby
435
+ BW::Location.get_once(desired_accuracy: :three_kilometers, ...) do |result|
436
+ if result.is_a?(CLLocation)
437
+ p result.coordinate.latitude
438
+ p result.coordinate.longitude
439
+ else
440
+ p "ERROR: #{result[:error]}"
441
+ end
442
+ end
443
+
444
+ BW::Location.get_compass_once do |heading|
445
+ p result[:magnetic_heading]
446
+ p result[:true_heading]
447
+ p result[:accuracy]
448
+ p result[:timestamp]
449
+ end
450
+ ```
408
451
 
409
452
  ## Media
410
453
 
@@ -428,7 +471,7 @@ Wrapper for showing an in-app mail composer view.
428
471
 
429
472
  ```ruby
430
473
  # Opens as a modal in the current UIViewController
431
- BW::Mail.compose {
474
+ BW::Mail.compose(
432
475
  delegate: self, # optional, defaults to rootViewController
433
476
  to: [ "tom@example.com" ],
434
477
  cc: [ "itchy@example.com", "scratchy@example.com" ],
@@ -437,7 +480,7 @@ BW::Mail.compose {
437
480
  subject: "My Subject",
438
481
  message: "This is my message. It isn't very long.",
439
482
  animated: false
440
- } do |result, error|
483
+ ) do |result, error|
441
484
  result.sent? # => boolean
442
485
  result.canceled? # => boolean
443
486
  result.saved? # => boolean
@@ -1029,4 +1072,3 @@ Do you have a suggestion for a specific wrapper? Feel free to open an
1029
1072
  issue/ticket and tell us about what you are after. If you have a
1030
1073
  wrapper/helper you are using and are thinking that others might enjoy,
1031
1074
  please send a pull request (with tests if possible).
1032
-
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ['mattaimonetti@gmail.com', 'francis@ignition.hk', 'james@sociable.co.nz', 'clay.allsopp@gmail.com', 'dylan@dylanmarkow.com', 'jan@dreimannzelt.de', 'mneorr@gmail.com']
7
7
  gem.description = 'RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull request.'
8
8
  gem.summary = 'RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull request.'
9
- gem.homepage = 'http://bubblewrap.io/'
9
+ gem.homepage = 'http://rubymotion.github.io/BubbleWrap/'
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|lib_spec|features)/})
@@ -2,6 +2,7 @@ require 'bubble-wrap/loader'
2
2
 
3
3
  BubbleWrap.require_ios("ui") do
4
4
  BubbleWrap.require('motion/util/constants.rb')
5
+ BubbleWrap.require('motion/ios/7/uiactivity_view_controller_constants.rb') if App.config.send(:deployment_target).to_f >= 7.0
5
6
  BubbleWrap.require('motion/ui/**/*.rb') do
6
7
  file('motion/ui/pollute.rb').depends_on %w(
7
8
  motion/ui/ui_control_wrapper.rb
@@ -1,4 +1,4 @@
1
1
  module BubbleWrap
2
- VERSION = '1.6.0' unless defined?(BubbleWrap::VERSION)
2
+ VERSION = '1.7.0' unless defined?(BubbleWrap::VERSION)
3
3
  MIN_MOTION_VERSION = '2.17'
4
4
  end
@@ -45,7 +45,7 @@ module BubbleWrap
45
45
  end
46
46
  alias_method "photo_library", "any"
47
47
  end
48
-
48
+
49
49
  def popover_from(view)
50
50
  @popover_in_view = view
51
51
  self
@@ -67,17 +67,18 @@ module BubbleWrap
67
67
  UIImagePickerController.isFlashAvailableForCameraDevice(camera_device)
68
68
  end
69
69
 
70
- # @param [Hash] options to open the UIImagePickerController with
70
+ # @param [Hash] options to open the UIImagePickerController with
71
71
  # the form {
72
72
  # source_type: :photo_library, :camera, or :saved_photos_album; default :photo_library
73
73
  # media_types: [] containing :image and/or :movie; default [:image]
74
74
  # allows_editing: true/false; default false
75
75
  # animated: true/false; default true
76
+ # on_dismiss: lambda; default nil
76
77
  # }
77
- #
78
+ #
78
79
  # @param [UIViewController] view controller from which to present the image picker;
79
80
  # if nil, uses the keyWindow's rootViewController.
80
- #
81
+ #
81
82
  # @block for callback. takes one argument.
82
83
  # - On error or cancelled, is called with a hash {error: BW::Camera::Error::<Type>}
83
84
  # - On success, is called with a hash with a possible set of keys
@@ -92,10 +93,13 @@ module BubbleWrap
92
93
  @callback = block
93
94
  @callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
94
95
 
95
- @options = options
96
- @options[:allows_editing] = false if not @options.has_key? :allows_editing
97
- @options[:animated] = true if not @options.has_key? :animated
98
- @options[:media_types] = [:image] if not @options.has_key? :media_types
96
+ @options = {
97
+ allows_editing: false,
98
+ animated: true,
99
+ on_dismiss: false,
100
+ media_types: [:image],
101
+ dismiss_completed: nil
102
+ }.merge(options)
99
103
 
100
104
  # If we're using Camera.any, by default use photo library
101
105
  if !@options.has_key?(:source_type) and self.location == :none
@@ -137,7 +141,7 @@ module BubbleWrap
137
141
 
138
142
  presenting_controller ||= App.window.rootViewController.presentedViewController # May be nil, but handles use case of container views
139
143
  presenting_controller ||= App.window.rootViewController
140
-
144
+
141
145
  # use popover for iPad (ignore on iPhone)
142
146
  if Device.ipad? and source_type==UIImagePickerControllerSourceTypePhotoLibrary and @popover_in_view
143
147
  @popover = UIPopoverController.alloc.initWithContentViewController(picker)
@@ -146,7 +150,7 @@ module BubbleWrap
146
150
  presenting_controller.presentViewController(self.picker, animated:@options[:animated], completion: lambda {})
147
151
  end
148
152
  end
149
-
153
+
150
154
  # iPad popover is dismissed
151
155
  def popoverControllerDidDismissPopover(popoverController)
152
156
  @popover = nil
@@ -194,7 +198,12 @@ module BubbleWrap
194
198
  end
195
199
 
196
200
  def dismiss
197
- self.picker.dismissViewControllerAnimated(@options[:animated], completion: lambda {})
201
+ if @options[:on_dismiss]
202
+ @options[:on_dismiss].call(self.picker)
203
+ return
204
+ end
205
+
206
+ self.picker.dismissViewControllerAnimated(@options[:animated], completion: @options[:dismiss_completed])
198
207
  end
199
208
 
200
209
  # @param [UIImagePickerControllerSourceType] source_type to check
@@ -43,6 +43,15 @@ module BubbleWrap
43
43
  def storage_key(key)
44
44
  "#{app_key}_#{key}"
45
45
  end
46
+
47
+ def all
48
+ hash = storage.dictionaryRepresentation.select{|k,v| k.start_with?(app_key) }
49
+ new_hash = {}
50
+ hash.each do |k,v|
51
+ new_hash[k.sub("#{app_key}_", '')] = v
52
+ end
53
+ new_hash
54
+ end
46
55
  end
47
56
 
48
57
  end
@@ -33,12 +33,27 @@ module BubbleWrap
33
33
  word
34
34
  end
35
35
 
36
- def to_url_encoded(encoding = NSUTF8StringEncoding)
37
- stringByAddingPercentEscapesUsingEncoding encoding
36
+ def to_url_encoded(encoding = nil, legacy = false)
37
+ if legacy
38
+ stringByAddingPercentEscapesUsingEncoding(encoding || NSUTF8StringEncoding)
39
+ else
40
+ encoding ||= KCFStringEncodingUTF8
41
+ encoding = CFStringConvertNSStringEncodingToEncoding(encoding) unless CFStringIsEncodingAvailable(encoding)
42
+ CFURLCreateStringByAddingPercentEscapes(nil, self, nil, "!*'();:@&=+$,/?%#[]", encoding)
43
+ end
38
44
  end
39
45
 
40
- def to_url_decoded(encoding = NSUTF8StringEncoding)
41
- stringByReplacingPercentEscapesUsingEncoding encoding
46
+ def to_url_decoded(encoding = nil, legacy = false)
47
+ if legacy
48
+ stringByReplacingPercentEscapesUsingEncoding(encoding || NSUTF8StringEncoding)
49
+ else
50
+ if encoding
51
+ encoding = CFStringConvertNSStringEncodingToEncoding(encoding) unless CFStringIsEncodingAvailable(encoding)
52
+ CFURLCreateStringByReplacingPercentEscapesUsingEncoding(nil, self, nil, encoding)
53
+ else
54
+ CFURLCreateStringByReplacingPercentEscapes(nil, self, nil)
55
+ end
56
+ end
42
57
  end
43
58
 
44
59
  def to_encoded_data(encoding = NSUTF8StringEncoding)
@@ -0,0 +1,10 @@
1
+ module BW
2
+ # iOS 7 ONLY Constants for UIActivityViewController
3
+ Constants.register(
4
+ UIActivityTypeAddToReadingList,
5
+ UIActivityTypePostToFlickr,
6
+ UIActivityTypePostToVimeo,
7
+ UIActivityTypePostToTencentWeibo,
8
+ UIActivityTypeAirDrop
9
+ )
10
+ end
@@ -51,13 +51,15 @@ module BubbleWrap
51
51
  def get(options = {}, &block)
52
52
  @callback = block
53
53
  @callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
54
- @options = options
54
+ @options = {
55
+ significant: false,
56
+ distance_filter: KCLDistanceFilterNone,
57
+ desired_accuracy: KCLLocationAccuracyBest,
58
+ retries: 5,
59
+ once: false
60
+ }.merge(options)
55
61
 
56
62
  @options[:significant] = false if @options[:significant].nil?
57
- @options[:distance_filter] ||= KCLDistanceFilterNone
58
- @options[:desired_accuracy] ||= KCLLocationAccuracyBest
59
- @options[:retries] ||= 5
60
- @options[:once] ||= false
61
63
  @retries = 0
62
64
 
63
65
  if not enabled?
@@ -81,6 +83,31 @@ module BubbleWrap
81
83
  get(options.merge(significant: true), &block)
82
84
  end
83
85
 
86
+ # Get the first returned location based on your options
87
+ # @param [Hash] options = {
88
+ # significant: true/false; whether to listen for significant location changes or
89
+ # all location changes (see Apple docs for info); default == false
90
+ # distance_filter: minimum change in distance to be updated about, in meters;
91
+ # default == uses KCLDistanceFilterNone,
92
+ # desired_accuracy: minimum accuracy for updates to arrive;
93
+ # any of :best_for_navigation, :best, :nearest_ten_meters,
94
+ # :hundred_meters, :kilometer, or :three_kilometers; default == :best
95
+ # purpose: string to display when the system asks user for location,
96
+ # retries: if location cant be found. how many errors do we retry; default == 5
97
+ # }
98
+ # @block for callback. takes one argument, `result`.
99
+ # - On error or cancelled, is called with a hash {error: BW::Location::Error::<Type>}
100
+ # - On success, it returns a CLLocation
101
+ #
102
+ #
103
+ # Example
104
+ # BW::Location.get_once(desired_accuracy: :three_kilometers, purpose: 'We need to use your GPS to show you how fun RM is') do |result|
105
+ # if result.is_a?(CLLocation)
106
+ # p "Lat #{result.latitude}, Long #{result.longitude}"
107
+ # else
108
+ # p "ERROR: #{result[:error]"
109
+ # end
110
+ # end
84
111
  def get_once(options = {}, &block)
85
112
  get(options.merge(once: true), &block)
86
113
  end
@@ -116,6 +143,11 @@ module BubbleWrap
116
143
  CLLocationManager.locationServicesEnabled
117
144
  end
118
145
 
146
+ # returns true/false whether services are enabled for the _app_
147
+ def authorized?
148
+ CLLocationManager.authorizationStatus == KCLAuthorizationStatusAuthorized
149
+ end
150
+
119
151
  def error(type)
120
152
  @callback && @callback.call({ error: type })
121
153
  @callback = nil
@@ -6,7 +6,7 @@ module BubbleWrap
6
6
  # Base method to create your in-app mail
7
7
  # ---------------------------------------
8
8
  # EX
9
- # BW::Mail.compose {
9
+ # BW::Mail.compose(
10
10
  # delegate: self, # optional, will use root view controller by default
11
11
  # to: [ "tom@example.com" ],
12
12
  # cc: [ "itchy@example.com", "scratchy@example.com" ],
@@ -15,36 +15,44 @@ module BubbleWrap
15
15
  # subject: "My Subject",
16
16
  # message: "This is my message. It isn't very long.",
17
17
  # animated: false
18
- # } do |result, error|
18
+ # ) do |result, error|
19
19
  # result.sent? # => boolean
20
20
  # result.canceled? # => boolean
21
21
  # result.saved? # => boolean
22
22
  # result.failed? # => boolean
23
23
  # error # => NSError
24
24
  # end
25
- def compose(options={}, &callback)
26
- @delegate = options[:delegate] || App.window.rootViewController
25
+ def compose(options = {}, &callback)
26
+ options = {
27
+ delegate: App.window.rootViewController,
28
+ animated: true,
29
+ html: false,
30
+ to: [],
31
+ cc: [],
32
+ bcc: [],
33
+ subject: 'Contact'
34
+ }.merge(options)
27
35
 
36
+ @delegate = options[:delegate]
37
+ @mailer_is_animated = options[:animated]
28
38
  @callback = callback
29
39
  @callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
30
-
40
+
31
41
  @mail_controller = create_mail_controller(options)
32
-
33
- @mailer_is_animated = options[:animated] == false ? false : true
42
+
34
43
  @delegate.presentViewController(@mail_controller, animated: @mailer_is_animated, completion: options[:completion])
35
44
  end
36
-
37
- def create_mail_controller(options={})
45
+
46
+ def create_mail_controller(options = {})
38
47
  mail_controller = MFMailComposeViewController.alloc.init
39
-
48
+
40
49
  mail_controller.mailComposeDelegate = self
41
50
  mail_controller.setToRecipients(Array(options[:to]))
42
51
  mail_controller.setCcRecipients(Array(options[:cc]))
43
52
  mail_controller.setBccRecipients(Array(options[:bcc]))
44
- mail_controller.setSubject(options[:subject] || "Contact")
45
- is_html = !!options[:html]
46
- mail_controller.setMessageBody(options[:message], isHTML: is_html)
47
-
53
+ mail_controller.setSubject(options[:subject])
54
+ mail_controller.setMessageBody(options[:message], isHTML: !!options[:html])
55
+
48
56
  mail_controller
49
57
  end
50
58
 
@@ -64,6 +64,10 @@ module BubbleWrap
64
64
  # self.view.addSubview media_player.view
65
65
  # end
66
66
  def play(content_url, options = {}, &block)
67
+ options = {
68
+ delay_play: false
69
+ }.merge(options)
70
+
67
71
  display_modal = !!options[:modal]
68
72
 
69
73
  klass = display_modal ? MPMoviePlayerViewController : MPMoviePlayerController
@@ -73,7 +77,6 @@ module BubbleWrap
73
77
 
74
78
  self.media_player.prepareToPlay if not display_modal
75
79
 
76
- options[:delay_play] = false if not options.has_key? :delay_play
77
80
  set_player_options(options)
78
81
 
79
82
  NSNotificationCenter.defaultCenter.observe MPMoviePlayerPlaybackDidFinishNotification do |notification|
@@ -144,4 +147,4 @@ module BubbleWrap
144
147
  end
145
148
  end
146
149
  end
147
- end
150
+ end
@@ -17,9 +17,9 @@ module BubbleWrap
17
17
  # result.canceled? # => boolean
18
18
  # result.failed? # => boolean
19
19
  # error # => NSError
20
- # }
21
-
22
- def compose(options={}, &callback)
20
+ # }
21
+
22
+ def compose(options = {}, &callback)
23
23
  @delegate = options[:delegate] || App.window.rootViewController
24
24
  @callback = callback
25
25
  @callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
@@ -28,12 +28,12 @@ module BubbleWrap
28
28
  @message_is_animated = options[:animated] == false ? false : true
29
29
  @delegate.presentModalViewController(@message_controller, animated: @message_is_animated)
30
30
  end
31
-
32
- def create_message_controller(options={})
31
+
32
+ def create_message_controller(options = {})
33
33
  message_controller = MFMessageComposeViewController.alloc.init
34
34
  message_controller.messageComposeDelegate = self
35
- message_controller.body = options[:message]
36
- message_controller.recipients = Array(options[:to])
35
+ message_controller.body = options[:message]
36
+ message_controller.recipients = Array(options[:to])
37
37
  message_controller
38
38
  end
39
39
 
@@ -41,11 +41,6 @@ module BW
41
41
  UIActivityTypePrint,
42
42
  UIActivityTypeCopyToPasteboard,
43
43
  UIActivityTypeAssignToContact,
44
- UIActivityTypeSaveToCameraRoll,
45
- UIActivityTypeAddToReadingList,
46
- UIActivityTypePostToFlickr,
47
- UIActivityTypePostToVimeo,
48
- UIActivityTypePostToTencentWeibo,
49
- UIActivityTypeAirDrop
44
+ UIActivityTypeSaveToCameraRoll
50
45
  )
51
46
  end
@@ -1,6 +1,6 @@
1
1
  module BubbleWrap
2
2
  module UIControlWrapper
3
- def when(events, options={}, &block)
3
+ def when(events, options = {}, &block)
4
4
  @callback ||= {}
5
5
  @callback[events] ||= []
6
6
 
@@ -25,7 +25,7 @@ module BubbleWrap
25
25
  end
26
26
 
27
27
  def when_pressed(enableInteraction=true, &proc)
28
- add_gesture_recognizer_helper(UILongPressGestureRecognizer.alloc.initWithTarget(self, action:'handle_gesture:'), enableInteraction, proc)
28
+ add_gesture_recognizer_helper(UILongPressGestureRecognizer.alloc.initWithTarget(self, action:'handle_gesture_pressed_on_begin:'), enableInteraction, proc)
29
29
  end
30
30
 
31
31
  def self.deprecated_methods
@@ -45,6 +45,12 @@ module BubbleWrap
45
45
  @recognizers[recognizer].call(recognizer)
46
46
  end
47
47
 
48
+ def handle_gesture_pressed_on_begin(recognizer)
49
+ if recognizer.state==UIGestureRecognizerStateBegan
50
+ @recognizers[recognizer].call(recognizer)
51
+ end
52
+ end
53
+
48
54
  # Adds the recognizer and keeps a strong reference to the Proc object.
49
55
  def add_gesture_recognizer_helper(recognizer, enableInteraction, proc)
50
56
  setUserInteractionEnabled true if enableInteraction && !isUserInteractionEnabled
@@ -1,4 +1,4 @@
1
- ## Location Demo
1
+ ## Camera Demo
2
2
 
3
- A bubble-wrap demo to show how to use location API.
3
+ A bubble-wrap demo to show how to use camera API.
4
4
 
@@ -66,6 +66,20 @@ describe BubbleWrap::Persistence do
66
66
  end
67
67
  end
68
68
 
69
+ describe "retrieving all objects" do
70
+ it 'can retrieve a dictionary of all objects' do
71
+ all = BubbleWrap::Persistence.all
72
+ all.is_a?(Hash).should == true
73
+
74
+ compare_to = {}
75
+ compare_to["anotherArbitraryNumber"] = 9001
76
+ compare_to["arbitraryNumber"] = 42
77
+ compare_to["arbitraryString"] = "test string"
78
+
79
+ all.should == compare_to
80
+ end
81
+ end
82
+
69
83
  describe "deleting object" do
70
84
  before do
71
85
  BubbleWrap::Persistence['arbitraryString'] = 'foobarbaz'
@@ -85,7 +99,7 @@ describe BubbleWrap::Persistence do
85
99
  def storage.synchronize; @sync_was_called = true; end
86
100
 
87
101
  BubbleWrap::Persistence.delete(:arbitraryString)
88
-
102
+
89
103
  storage.instance_variable_get(:@sync_was_called).should.equal true
90
104
  end
91
105
 
@@ -164,26 +164,49 @@ describe BubbleWrap::String do
164
164
  describe "encoding" do
165
165
 
166
166
  before do
167
- @raw_string = "hey ho let's {go}"
167
+ @raw_string = "hey ho let's {go} http://bubblewrap.io&rocks!"
168
168
  end
169
169
 
170
170
  it "to_url_encoded" do
171
- real_encoded = @raw_string.stringByAddingPercentEscapesUsingEncoding NSUTF8StringEncoding
171
+ real_encoded = CFURLCreateStringByAddingPercentEscapes(nil, @raw_string, nil, "!*'();:@&=+$,/?%#[]", KCFStringEncodingUTF8)
172
172
  @raw_string.to_url_encoded.should.equal real_encoded
173
173
  end
174
174
 
175
175
  it "handles other encodings" do
176
- utf16 = @raw_string.stringByAddingPercentEscapesUsingEncoding NSUTF16StringEncoding
176
+ utf16 = CFURLCreateStringByAddingPercentEscapes(nil, @raw_string, nil, "!*'();:@&=+$,/?%#[]", KCFStringEncodingUTF16)
177
+ @raw_string.to_url_encoded(KCFStringEncodingUTF16).should.equal utf16
178
+ end
179
+
180
+ it "automatically selects available encodings" do
181
+ encoding = if CFStringIsEncodingAvailable(NSUTF16StringEncoding)
182
+ NSUTF16StringEncoding
183
+ else
184
+ KCFStringEncodingUTF16
185
+ end
186
+
187
+ utf16 = CFURLCreateStringByAddingPercentEscapes(nil, @raw_string, nil, "!*'();:@&=+$,/?%#[]", encoding)
177
188
  @raw_string.to_url_encoded(NSUTF16StringEncoding).should.equal utf16
178
189
  end
179
190
 
180
191
  it "to_url_decoded" do
181
192
  encoded_string = "hey%20ho%20let's%20%7Bgo%7D"
182
- real_decoded = encoded_string.stringByReplacingPercentEscapesUsingEncoding NSUTF8StringEncoding
183
-
193
+ real_decoded = CFURLCreateStringByReplacingPercentEscapes(nil, encoded_string, nil)
184
194
  encoded_string.to_url_decoded.should.equal real_decoded
185
195
  end
186
196
 
197
+ it "to_url_decoded with encoding" do
198
+ real_encoded = @raw_string.to_url_encoded(KCFStringEncodingUTF16)
199
+ real_decoded = CFURLCreateStringByReplacingPercentEscapes(nil, real_encoded, nil, KCFStringEncodingUTF16)
200
+ real_encoded.to_url_decoded.should.equal real_decoded
201
+ end
202
+
203
+ it "should not contain disallowed characters" do
204
+ encoded_string = @raw_string.to_url_encoded
205
+ encoded_string.should.not.match(/\//)
206
+ encoded_string.should.not.match(/:/)
207
+ encoded_string.should.not.match(/!/)
208
+ encoded_string.should.not.match(/&/)
209
+ end
187
210
 
188
211
  describe "dataUsingEncoding" do
189
212
 
@@ -16,11 +16,20 @@ class CLLocationManager
16
16
  @enabled = enable
17
17
  end
18
18
 
19
+ def self.authorize(authorize)
20
+ @authorized = authorize
21
+ end
22
+
19
23
  def self.locationServicesEnabled
20
24
  return true if @enabled.nil?
21
25
  @enabled
22
26
  end
23
27
 
28
+ def self.authorizationStatus
29
+ return KCLAuthorizationStatusNotDetermined if @authorized.nil?
30
+ @authorized
31
+ end
32
+
24
33
  def startUpdatingLocation
25
34
  @startUpdatingLocation = true
26
35
  end
@@ -69,6 +78,22 @@ describe BubbleWrap::Location do
69
78
  location_manager.purpose.should == "test"
70
79
  end
71
80
 
81
+ it "should return false when not available" do
82
+ CLLocationManager.authorize(KCLAuthorizationStatusNotDetermined)
83
+ BW::Location.authorized?.should == false
84
+
85
+ CLLocationManager.authorize(KCLAuthorizationStatusRestricted)
86
+ BW::Location.authorized?.should == false
87
+
88
+ CLLocationManager.authorize(KCLAuthorizationStatusDenied)
89
+ BW::Location.authorized?.should == false
90
+ end
91
+
92
+ it "should return true when available" do
93
+ CLLocationManager.authorize(KCLAuthorizationStatusAuthorized)
94
+ BW::Location.authorized?.should == true
95
+ end
96
+
72
97
  it "should throw error if not enabled" do
73
98
  CLLocationManager.enable(false)
74
99
 
@@ -51,7 +51,7 @@ describe "RSSParser" do
51
51
  # To avoid interfering the http_spec's mocking, we only want to override HTTP.get if it's
52
52
  # for the RSSParser spec.
53
53
  alias_method :original_get, :get
54
- def get(url, options={}, &block)
54
+ def get(url, options = {}, &block)
55
55
  if url == 'https://raw.github.com/gist/2952427/9f1522cbe5d77a72c7c96c4fdb4b77bd58d7681e/atom.xml'
56
56
  string = File.read(File.join(App.resources_path, 'atom.xml'))
57
57
  yield BW::HTTP::Response.new(body: string.to_data, status_code: 200)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bubble-wrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Aimonetti
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2014-04-27 00:00:00.000000000 Z
17
+ date: 2014-07-11 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: bubble-wrap-http
@@ -22,14 +22,14 @@ dependencies:
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 1.6.0
25
+ version: 1.7.0
26
26
  type: :runtime
27
27
  prerelease: false
28
28
  version_requirements: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 1.6.0
32
+ version: 1.7.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: mocha
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +123,7 @@ extra_rdoc_files:
123
123
  - motion/core/string.rb
124
124
  - motion/core/time.rb
125
125
  - motion/font/font.rb
126
+ - motion/ios/7/uiactivity_view_controller_constants.rb
126
127
  - motion/location/location.rb
127
128
  - motion/location/pollute.rb
128
129
  - motion/mail/mail.rb
@@ -250,6 +251,7 @@ files:
250
251
  - motion/core/string.rb
251
252
  - motion/core/time.rb
252
253
  - motion/font/font.rb
254
+ - motion/ios/7/uiactivity_view_controller_constants.rb
253
255
  - motion/location/location.rb
254
256
  - motion/location/pollute.rb
255
257
  - motion/mail/mail.rb
@@ -371,7 +373,7 @@ files:
371
373
  - spec/motion/ui/ui_view_wrapper_spec.rb
372
374
  - spec/motion/util/constants_spec.rb
373
375
  - spec/motion/util/deprecated_spec.rb
374
- homepage: http://bubblewrap.io/
376
+ homepage: http://rubymotion.github.io/BubbleWrap/
375
377
  licenses: []
376
378
  metadata: {}
377
379
  post_install_message: