bubble-wrap 1.7.0 → 1.7.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c36af1404df9fe25d9bb32a34940b0877bf9eacd
4
- data.tar.gz: c1d13206fbdff5651321d7ef362d7695ae8e2b7f
3
+ metadata.gz: faee2e15d6887fcd2cdb83c67b5cc2a62a421624
4
+ data.tar.gz: 2689f157cacaef27b81b313fff35803f78f8ea88
5
5
  SHA512:
6
- metadata.gz: 03a94c71a69d7d27c68a7713f53f78db2daf10fe90561c03839f851ba0c2e65a1397ea0fe407432d1f4fcae9c317fe7265a06862ed66bbe81246121aab2667ab
7
- data.tar.gz: f37b7ffddccd80b6716ea18efbdd11e217c66a3a15261e439e3b82caa048bb9ab0e4dc4a277c6dd89a66a27ff0c868eb2e7d13564d4d9e34f3ba2eb89913155e
6
+ metadata.gz: 9dcf5e4a7c790d9908499f9a0caafbfec344b264ff150741e2d86ad306f4b22ffe6335cdf552c1a6c2b4638b0e74771b705735b9315fbb54c3817c65d0cd8f3e
7
+ data.tar.gz: d1f7d8a3a0c0765c3da1ce7760b60ba2f55499b963e791c8df4ecec4d2587e3c3a6ee1dfb15a1c393efa557c7b1527b3079b5e8a74cc52b57be551d804327f12
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bubble-wrap (1.7.0)
5
- bubble-wrap-http (= 1.7.0)
4
+ bubble-wrap (1.7.1)
5
+ bubble-wrap-http (= 1.7.1)
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.7.0)
11
+ bubble-wrap-http (1.7.1)
12
12
  metaclass (0.0.1)
13
13
  mocha (0.11.4)
14
14
  metaclass (~> 0.0.1)
data/README.md CHANGED
@@ -26,7 +26,7 @@ require 'bubble-wrap'
26
26
  If you using Bundler:
27
27
 
28
28
  ```ruby
29
- gem "bubble-wrap", "~> 1.5.0"
29
+ gem "bubble-wrap", "~> 1.7.0"
30
30
  ```
31
31
 
32
32
  BubbleWrap is split into multiple modules so that you can easily choose which parts
data/bubble-wrap.gemspec CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/bubble-wrap/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ['Matt Aimonetti', 'Francis Chong', 'James Harton', 'Clay Allsopp', 'Dylan Markow', 'Jan Weinkauff', 'Marin Usalj']
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
- 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
- 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.'
7
+ gem.description = 'RubyMotion wrappers and helpers (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull request.'
8
+ gem.summary = 'RubyMotion wrappers and helpers (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull request.'
9
9
  gem.homepage = 'http://rubymotion.github.io/BubbleWrap/'
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
@@ -6,9 +6,7 @@ module BubbleWrap
6
6
  base.instance_eval do
7
7
  def setup_with_bubblewrap(*args, &block)
8
8
  bw_config = proc do |app|
9
- app.files = ::BubbleWrap::Requirement.files(app.files)
10
- app.files_dependencies ::BubbleWrap::Requirement.files_dependencies
11
- app.frameworks = ::BubbleWrap::Requirement.frameworks(app.frameworks)
9
+ ::BubbleWrap.before_config(app)
12
10
  block.call(app) unless block.nil?
13
11
  end
14
12
 
@@ -21,6 +19,20 @@ module BubbleWrap
21
19
 
22
20
  end
23
21
 
22
+ module Config
23
+ def config_with_bubblewrap
24
+ config_without_bubblewrap.tap do |c|
25
+ ::BubbleWrap.after_config(c)
26
+ end
27
+ end
28
+
29
+ def self.extended(base)
30
+ singleton_class = class << base; self; end
31
+ singleton_class.send :alias_method, :config_without_bubblewrap, :config
32
+ singleton_class.send :alias_method, :config, :config_with_bubblewrap
33
+ end
34
+ end
35
+
24
36
  module Platforms
25
37
  def osx?
26
38
  self.respond_to?(:template) && self.template == :osx
@@ -32,3 +44,5 @@ end
32
44
  Motion::Project::App.extend(BubbleWrap::Ext::BuildTask)
33
45
 
34
46
  Motion::Project::App.extend(BubbleWrap::Ext::Platforms)
47
+
48
+ Motion::Project::App.extend(BubbleWrap::Ext::Config)
@@ -39,6 +39,26 @@ unless defined?(BubbleWrap::LOADER_PRESENT)
39
39
  puts "bubble-wrap/#{requirement} requires OS X to use." if requirement
40
40
  end
41
41
  end
42
+
43
+ def before_config(app)
44
+ app.files = ::BubbleWrap::Requirement.files(app.files)
45
+ app.files_dependencies ::BubbleWrap::Requirement.files_dependencies
46
+ app.frameworks = ::BubbleWrap::Requirement.frameworks(app.frameworks)
47
+ end
48
+
49
+ def after_config(config)
50
+ BubbleWrap.require_ios do
51
+ ios7_files = 'motion/ios/7/uiactivity_view_controller_constants.rb'
52
+ if config.send(:deployment_target).to_f >= 7.0
53
+ ::BubbleWrap.require(ios7_files)
54
+ before_config(config)
55
+ else
56
+ config.files = config.files.reject {|s|
57
+ s.include?(ios7_files)
58
+ }
59
+ end
60
+ end
61
+ end
42
62
  end
43
63
 
44
64
  BW = BubbleWrap unless defined?(BW)
@@ -2,7 +2,6 @@ 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
6
5
  BubbleWrap.require('motion/ui/**/*.rb') do
7
6
  file('motion/ui/pollute.rb').depends_on %w(
8
7
  motion/ui/ui_control_wrapper.rb
@@ -1,4 +1,4 @@
1
1
  module BubbleWrap
2
- VERSION = '1.7.0' unless defined?(BubbleWrap::VERSION)
2
+ VERSION = '1.7.1' unless defined?(BubbleWrap::VERSION)
3
3
  MIN_MOTION_VERSION = '2.17'
4
4
  end
data/motion/core/kvo.rb CHANGED
@@ -53,7 +53,7 @@ module BubbleWrap
53
53
  @targets.each do |target, key_paths|
54
54
  key_paths.each_key do |key_path|
55
55
  target.removeObserver(self, forKeyPath:key_path)
56
- end
56
+ end
57
57
  end
58
58
  remove_all_observer_blocks
59
59
  end
@@ -81,6 +81,9 @@ module BubbleWrap
81
81
 
82
82
  key_paths = @targets[target]
83
83
  key_paths.delete(key_path.to_s) if !key_paths.nil?
84
+ if key_paths.nil? || key_paths.length == 0
85
+ @targets.delete(target)
86
+ end
84
87
  end
85
88
 
86
89
  def remove_all_observer_blocks
@@ -28,6 +28,8 @@ module BubbleWrap
28
28
  module_function
29
29
  # Start getting locations
30
30
  # @param [Hash] options = {
31
+ # authorization_type: :always/:when_in_use to trigger the type of authorization you want
32
+ # default == uses :always
31
33
  # significant: true/false; whether to listen for significant location changes or
32
34
  # all location changes (see Apple docs for info); default == false
33
35
  # distance_filter: minimum change in distance to be updated about, in meters;
@@ -37,6 +39,7 @@ module BubbleWrap
37
39
  # :hundred_meters, :kilometer, or :three_kilometers; default == :best
38
40
  # purpose: string to display when the system asks user for location,
39
41
  # retries: if location cant be found. how many errors do we retry; default == 5
42
+ # calibration: if the OS should display the heading calibration to the user; default == false
40
43
  # }
41
44
  # @block for callback. takes one argument, `result`.
42
45
  # - On error or cancelled, is called with a hash {error: BW::Location::Error::<Type>}
@@ -52,11 +55,13 @@ module BubbleWrap
52
55
  @callback = block
53
56
  @callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
54
57
  @options = {
58
+ authorization_type: :always,
55
59
  significant: false,
56
60
  distance_filter: KCLDistanceFilterNone,
57
61
  desired_accuracy: KCLLocationAccuracyBest,
58
62
  retries: 5,
59
- once: false
63
+ once: false,
64
+ calibration: false
60
65
  }.merge(options)
61
66
 
62
67
  @options[:significant] = false if @options[:significant].nil?
@@ -66,6 +71,13 @@ module BubbleWrap
66
71
  error(Error::DISABLED) and return
67
72
  end
68
73
 
74
+ self.location_manager
75
+
76
+ if self.location_manager.respondsToSelector('requestAlwaysAuthorization')
77
+ @options[:authorization_type] == :always ? self.location_manager.requestAlwaysAuthorization : self.location_manager.requestWhenInUseAuthorization
78
+ end
79
+
80
+
69
81
  self.location_manager.distanceFilter = @options[:distance_filter]
70
82
  self.location_manager.desiredAccuracy = Constants.get("KCLLocationAccuracy", @options[:desired_accuracy])
71
83
  self.location_manager.purpose = @options[:purpose] if @options[:purpose]
@@ -212,6 +224,10 @@ module BubbleWrap
212
224
  error(Error::PERMISSION_DENIED)
213
225
  end
214
226
  end
227
+
228
+ def locationManagerShouldDisplayHeadingCalibration(manager)
229
+ @options[:calibration] ? @options[:calibration] : false
230
+ end
215
231
  end
216
232
  end
217
233
  ::Location = BubbleWrap::Location unless defined?(::Location)
@@ -7,21 +7,26 @@ module BubbleWrap
7
7
  # and be passed the arguments that are passed to
8
8
  # `trigger`.
9
9
  def on(event, method = nil, &blk)
10
+ events = _events_for_key(event)
10
11
  method_or_block = method ? method : blk
11
- __events__[event].push method_or_block
12
+ events.push method_or_block
12
13
  end
13
14
 
14
15
  # When `event` is triggered, do not call the given
15
16
  # block any more
16
17
  def off(event, method = nil, &blk)
17
- method_or_block = method ? method : blk
18
- __events__[event].delete_if { |b| b == method_or_block }
18
+ events = _events_for_key(event)
19
+ if method
20
+ events.delete_if { |m| m.receiver == method.receiver and m.name == method.name }
21
+ else
22
+ events.delete_if { |b| b == blk }
23
+ end
19
24
  blk
20
25
  end
21
26
 
22
27
  # Trigger an event
23
28
  def trigger(event, *args)
24
- blks = __events__[event].clone
29
+ blks = _events_for_key(event).clone
25
30
  blks.map do |blk|
26
31
  blk.call(*args)
27
32
  end
@@ -30,7 +35,11 @@ module BubbleWrap
30
35
  private
31
36
 
32
37
  def __events__
33
- @__events__ ||= Hash.new { |h,k| h[k] = [] }
38
+ @__events__ ||= Hash.new
39
+ end
40
+
41
+ def _events_for_key(event)
42
+ __events__[event] ||= Array.new
34
43
  end
35
44
  end
36
45
  end
@@ -100,7 +100,7 @@ describe BubbleWrap::KVO do
100
100
  @example.send(:remove_observer_block, nil, "key_path")
101
101
  @example.send(:registered?, target, "key_path").should == true
102
102
  end
103
-
103
+
104
104
  it "should not remove an observer block if the key path is not present" do
105
105
  target = Object.new
106
106
  block = lambda { |old_value, new_value| }
@@ -108,7 +108,7 @@ describe BubbleWrap::KVO do
108
108
  @example.send(:remove_observer_block, target, nil)
109
109
  @example.send(:registered?, target, "key_path").should == true
110
110
  end
111
-
111
+
112
112
  it "should remove only one observer block" do
113
113
  target = Object.new
114
114
  block = lambda { |old_value, new_value| }
@@ -118,9 +118,9 @@ describe BubbleWrap::KVO do
118
118
  @example.send(:registered?, target, "key_path1").should == false
119
119
  @example.send(:registered?, target, "key_path2").should == true
120
120
  end
121
-
121
+
122
122
  # remove all
123
-
123
+
124
124
  it "should remove all observer blocks" do
125
125
  target = Object.new
126
126
  block = lambda { |old_value, new_value| }
@@ -128,21 +128,38 @@ describe BubbleWrap::KVO do
128
128
  @example.send(:add_observer_block, target, "key_path2", &block)
129
129
  @example.send(:remove_all_observer_blocks)
130
130
  @example.send(:registered?, target, "key_path1").should == false
131
- @example.send(:registered?, target, "key_path2").should == false
131
+ @example.send(:registered?, target, "key_path2").should == false
132
+ end
133
+
134
+ it "should remove target from targets if no observers remain" do
135
+ target = Object.new
136
+ block = lambda { |old_value, new_value| }
137
+ @example.send(:add_observer_block, target, "key_path", &block)
138
+ @example.send(:remove_observer_block, target, "key_path")
139
+ @example.instance_variable_get(:@targets).length.should == 0
140
+ end
141
+
142
+ it "should not remove target from targets if observers remain" do
143
+ target = Object.new
144
+ block = lambda { |old_value, new_value| }
145
+ @example.send(:add_observer_block, target, "key_path1", &block)
146
+ @example.send(:add_observer_block, target, "key_path2", &block)
147
+ @example.send(:remove_observer_block, target, "key_path1")
148
+ @example.instance_variable_get(:@targets).length.should > 0
132
149
  end
133
-
150
+
134
151
  end
135
-
152
+
136
153
  describe "API" do
137
154
  before do
138
155
  @example = KvoExample.new
139
156
  end
140
-
157
+
141
158
  after do
142
159
  @example.unobserve_all
143
160
  @example = nil
144
161
  end
145
-
162
+
146
163
  # observe
147
164
 
148
165
  it "should observe a key path" do
@@ -152,11 +169,11 @@ describe BubbleWrap::KVO do
152
169
  old_value.should == "Foo"
153
170
  new_value.should == "Bar"
154
171
  end
155
-
172
+
156
173
  @example.set_text "Bar"
157
174
  observed.should == true
158
175
  end
159
-
176
+
160
177
  it "should observe a key path with more than one block" do
161
178
  observed_one = false
162
179
  observed_two = false
@@ -170,22 +187,22 @@ describe BubbleWrap::KVO do
170
187
  @example.observe_label do |old_value, new_value|
171
188
  observed_three = true
172
189
  end
173
-
190
+
174
191
  @example.set_text "Bar"
175
192
  observed_one.should == true
176
193
  observed_two.should == true
177
194
  observed_three.should == true
178
195
  end
179
-
196
+
180
197
  # unobserve
181
-
198
+
182
199
  it "should unobserve a key path" do
183
200
  observed = false
184
201
  @example.observe_label do |old_value, new_value|
185
202
  observed = true
186
203
  end
187
204
  @example.unobserve_label
188
-
205
+
189
206
  @example.set_text "Bar"
190
207
  observed.should == false
191
208
  end
@@ -199,7 +216,7 @@ describe BubbleWrap::KVO do
199
216
  old_value.should == 1
200
217
  new_value.should == 2
201
218
  end
202
-
219
+
203
220
  @example.age = 2
204
221
  observed.should == true
205
222
  end
@@ -210,13 +227,13 @@ describe BubbleWrap::KVO do
210
227
  observed = true
211
228
  end
212
229
  @example.unobserve :age
213
-
230
+
214
231
  @example.age = 2
215
232
  observed.should == false
216
233
  end
217
-
234
+
218
235
  end
219
-
236
+
220
237
  =begin
221
238
  it "should be able to observe a collection" do
222
239
  observed = false
@@ -224,9 +241,9 @@ describe BubbleWrap::KVO do
224
241
  puts "#{collection} #{old_value} #{new_value} #{indexes}"
225
242
  observed = true
226
243
  end
227
-
244
+
228
245
  @example.items << "Dragonfruit"
229
- observed.should == true
246
+ observed.should == true
230
247
  end
231
248
  =end
232
249
 
@@ -69,7 +69,7 @@ describe 'BubbleWrap' do
69
69
 
70
70
  describe "uuid" do
71
71
 
72
- it "creates always the new UUID" do
72
+ it "always creates the new UUID" do
73
73
  previous = BW.create_uuid
74
74
  10.times do
75
75
  uuid = BW.create_uuid
@@ -176,6 +176,7 @@ describe BubbleWrap::Location do
176
176
  end
177
177
 
178
178
  location_manager.instance_variable_get("@startUpdatingHeading").should == true
179
+ BW::Location.locationManagerShouldDisplayHeadingCalibration(location_manager).should == false
179
180
  end
180
181
 
181
182
  it "should have correct heading when succeeding" do
@@ -196,6 +197,13 @@ describe BubbleWrap::Location do
196
197
 
197
198
  BW::Location.locationManager(location_manager, didUpdateHeading: heading)
198
199
  end
200
+
201
+ it "should show the calibration screen when needed" do
202
+ BW::Location.get_compass(calibration: true) do |result|
203
+ end
204
+
205
+ BW::Location.locationManagerShouldDisplayHeadingCalibration(location_manager).should == true
206
+ end
199
207
  end
200
208
 
201
209
  describe ".get_significant" do
@@ -48,6 +48,21 @@ describe BubbleWrap::Reactor::Eventable do
48
48
  events[:foo].member?(proof).should == false
49
49
  end
50
50
 
51
+ it 'unregisters method events after kvo' do
52
+ observing_object = Class.new do
53
+ include BubbleWrap::KVO
54
+ end.new
55
+
56
+ @subject.on(:foo, @subject.method(:description))
57
+ block = lambda { |old_value, new_value| }
58
+ observing_object.observe(@subject, :cool_variable, &block)
59
+ @subject.off(:foo, @subject.method(:description))
60
+
61
+ events = @subject.instance_variable_get(:@__events__)
62
+ events[:foo].length.should == 0
63
+ observing_object.unobserve_all
64
+ end
65
+
51
66
  it 'calls other event procs when a proc unregisters itself' do
52
67
  @proxy.proof = 0
53
68
  proof1 = proc do |r|
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.7.0
4
+ version: 1.7.1
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-07-11 00:00:00.000000000 Z
17
+ date: 2014-08-29 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.7.0
25
+ version: 1.7.1
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.7.0
32
+ version: 1.7.1
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: mocha
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -86,8 +86,8 @@ dependencies:
86
86
  - - '>='
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
- description: RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more
90
- Ruby like, one API at a time. Fork away and send your pull request.
89
+ description: RubyMotion wrappers and helpers (Ruby for iOS and OS X) - Making Cocoa
90
+ APIs more Ruby like, one API at a time. Fork away and send your pull request.
91
91
  email:
92
92
  - mattaimonetti@gmail.com
93
93
  - francis@ignition.hk
@@ -395,8 +395,8 @@ rubyforge_project:
395
395
  rubygems_version: 2.0.3
396
396
  signing_key:
397
397
  specification_version: 4
398
- summary: RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more Ruby
399
- like, one API at a time. Fork away and send your pull request.
398
+ summary: RubyMotion wrappers and helpers (Ruby for iOS and OS X) - Making Cocoa APIs
399
+ more Ruby like, one API at a time. Fork away and send your pull request.
400
400
  test_files:
401
401
  - spec/lib/bubble-wrap/ext/motion_project_app_spec.rb
402
402
  - spec/lib/bubble-wrap/ext/motion_project_config_spec.rb