bubble-wrap 1.4.0 → 1.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/Gemfile.lock +1 -1
  4. data/README.md +22 -2
  5. data/bubble-wrap.gemspec +7 -7
  6. data/lib/bubble-wrap.rb +1 -1
  7. data/lib/bubble-wrap/core.rb +3 -3
  8. data/lib/bubble-wrap/ext.rb +0 -1
  9. data/lib/bubble-wrap/ext/motion_project_app.rb +4 -3
  10. data/lib/bubble-wrap/loader.rb +3 -3
  11. data/lib/bubble-wrap/media.rb +2 -0
  12. data/lib/bubble-wrap/requirement.rb +1 -1
  13. data/lib/bubble-wrap/version.rb +2 -2
  14. data/motion/core/device/ios/camera.rb +33 -3
  15. data/motion/core/device/ios/camera_wrapper.rb +10 -0
  16. data/motion/core/kvo.rb +18 -2
  17. data/motion/core/ns_notification_center.rb +1 -0
  18. data/motion/core/time.rb +5 -0
  19. data/motion/http/query.rb +15 -9
  20. data/motion/location/location.rb +3 -2
  21. data/motion/mail/mail.rb +2 -1
  22. data/motion/media/player.rb +10 -2
  23. data/motion/reactor.rb +2 -0
  24. data/motion/reactor/periodic_timer.rb +2 -1
  25. data/motion/shortcut.rb +8 -0
  26. data/motion/sms/sms.rb +2 -0
  27. data/motion/ui/ui_alert_view.rb +2 -0
  28. data/motion/ui/ui_bar_button_item.rb +12 -2
  29. data/motion/ui/ui_control_wrapper.rb +1 -0
  30. data/motion/ui/ui_view_wrapper.rb +5 -0
  31. data/samples/osx/Gemfile.lock +7 -3
  32. data/spec/motion/core/device/ios/camera_spec.rb +6 -0
  33. data/spec/motion/core/device/ios/camera_wrapper_spec.rb +51 -2
  34. data/spec/motion/core/kvo_spec.rb +27 -0
  35. data/spec/motion/core/ns_notification_center_spec.rb +3 -3
  36. data/spec/motion/core/time_spec.rb +13 -4
  37. data/spec/motion/core_spec.rb +0 -1
  38. data/spec/motion/http/query_spec.rb +5 -5
  39. data/spec/motion/http_spec.rb +1 -1
  40. data/spec/motion/location/location_spec.rb +2 -2
  41. data/spec/motion/mail/mail_spec.rb +1 -1
  42. data/spec/motion/media/player_spec.rb +34 -12
  43. data/spec/motion/ui/ui_bar_button_item_spec.rb +76 -0
  44. data/spec/motion/ui/ui_control_wrapper_spec.rb +38 -0
  45. data/spec/motion/ui/ui_view_wrapper_spec.rb +42 -0
  46. metadata +4 -6
  47. data/lib/bubble-wrap/ext/motion_project_config.rb +0 -34
@@ -44,7 +44,7 @@ describe "HTTP" do
44
44
  it "works with classic blocks as well" do
45
45
  [:get, :post, :put, :delete, :head, :patch].each do |method|
46
46
  called = false
47
- query = BubbleWrap::HTTP.send(method, @localhost_url, { action: 'not_valid' } ) do |response|
47
+ query = BubbleWrap::HTTP.send(method, @localhost_url, { action: 'not_valid' } ) do
48
48
  called = true
49
49
  end
50
50
  query.connectionDidFinishLoading(query.connection)
@@ -51,7 +51,7 @@ describe BubbleWrap::Location do
51
51
  end
52
52
 
53
53
  it "should set purpose using hash" do
54
- BW::Location.get(purpose: "test") do |result|
54
+ BW::Location.get(purpose: "test") do
55
55
  end
56
56
 
57
57
  location_manager.purpose.should == "test"
@@ -82,7 +82,7 @@ describe BubbleWrap::Location do
82
82
  end
83
83
 
84
84
  it "should use normal update functions" do
85
- BW::Location.get do |result|
85
+ BW::Location.get do
86
86
  end
87
87
 
88
88
  location_manager.instance_variable_get("@startUpdatingLocation").should == true
@@ -2,7 +2,7 @@
2
2
  class MailViewController < UIViewController
3
3
  attr_accessor :expectation
4
4
 
5
- def presentModalViewController(modal, animated: animated)
5
+ def presentViewController(modal, animated: animated, completion: completion)
6
6
  expectation.call modal, animated
7
7
  end
8
8
  end
@@ -29,6 +29,7 @@ describe BubbleWrap::Media::Player do
29
29
  end
30
30
  end
31
31
 
32
+ =begin
32
33
  describe ".play_modal" do
33
34
  before do
34
35
  @player = BW::Media::Player.new
@@ -40,11 +41,18 @@ describe BubbleWrap::Media::Player do
40
41
 
41
42
  @player.play_modal(@local_file)
42
43
 
43
- wait 1 do
44
+
45
+ EM.add_timer 2.0 do
46
+ resume
47
+ end
48
+ wait_max 5 do
44
49
  @controller.modalViewController.should.not == nil
50
+ EM.add_timer 4.0 do
51
+ resume
52
+ end
45
53
 
46
54
  @player.stop
47
- wait 1 do
55
+ wait_max 5 do
48
56
  @controller.modalViewController.should == nil
49
57
  @controller = nil
50
58
  @player = nil
@@ -53,25 +61,39 @@ describe BubbleWrap::Media::Player do
53
61
  end
54
62
 
55
63
  it "should present a modalViewController if controller given" do
56
- @controller = UIViewController.alloc.initWithNibName(nil, bundle:nil)
57
-
58
- # .presentMoviePlayerViewControllerAnimated detects whether or not
59
- # @controller.view is part of a hierarchy, I guess. if you remove this
60
- # then the test fails.
61
- App.window.rootViewController.view.addSubview(@controller.view)
64
+ parent = App.window.rootViewController
65
+ @controller = UINavigationController.alloc.init
66
+ parent.addChildViewController @controller
67
+ @controller.viewWillAppear(false)
68
+ parent.view.addSubview(@controller.view)
69
+ @controller.viewDidAppear(false)
62
70
 
63
- @player.play_modal(@local_file, controller: @controller)
71
+ @controller.didMoveToParentViewController(parent)
64
72
 
65
- wait 1 do
73
+ EM.add_timer 3.0 do
74
+ resume
75
+ end
76
+ wait_max 5 do
77
+ @player.play_modal(@local_file, controller: @controller)
66
78
  @controller.modalViewController.should.not == nil
79
+ EM.add_timer 2.0 do
80
+ @player.stop
81
+ end
82
+ EM.add_timer 4.0 do
83
+ resume
84
+ end
67
85
 
68
- @player.stop
69
- wait 1 do
86
+ wait_max 5 do
70
87
  @controller.modalViewController.should == nil
88
+ @controller.willMoveToParentViewController(nil)
89
+ @controller.viewWillDisappear(false)
90
+ @controller.removeFromParentViewController
91
+ @controller.viewDidDisappear(false)
71
92
  @controller = nil
72
93
  @player = nil
73
94
  end
74
95
  end
75
96
  end
76
97
  end
98
+ =end
77
99
  end
@@ -1,4 +1,30 @@
1
1
  describe BW::UIBarButtonItem do
2
+ class NavigationItemContainingBarButtonItem < UINavigationItem
3
+ def init_with_styled
4
+ initWithTitle('dummy')
5
+ subject = BW::UIBarButtonItem.styled(:plain, 'dummy') do
6
+ #Can be empty, but we need a block/proc here to potentially create a retain cycle
7
+ end
8
+ self.leftBarButtonItem = subject
9
+ self
10
+ end
11
+
12
+
13
+ def init_with_system
14
+ initWithTitle('dummy')
15
+ subject = BW::UIBarButtonItem.system(:save) do
16
+ #Can be empty, but we need a block/proc here to potentially create a retain cycle
17
+ end
18
+ self.leftBarButtonItem = subject
19
+ self
20
+ end
21
+
22
+ def dealloc
23
+ App.notification_center.post('NavigationItemContainingBarButtonItem dealloc', nil, {'tag'=>tag})
24
+ super
25
+ end
26
+ end
27
+
2
28
  describe ".styled" do
3
29
  describe "given an unknown style" do
4
30
  it "raises an exception" do
@@ -153,6 +179,31 @@ describe BW::UIBarButtonItem do
153
179
  @subject.action.should.equal(:call)
154
180
  end
155
181
  end
182
+
183
+ ###############################################################################################
184
+
185
+ describe "with BubbleWrap.use_weak_callbacks=true" do
186
+ it "removes cyclic references" do
187
+ observer = App.notification_center.observe('NavigationItemContainingBarButtonItem dealloc') do |obj|
188
+ if obj.userInfo['tag'] == 1
189
+ @weak_deallocated = true
190
+ elsif obj.userInfo['tag'] == 2
191
+ @strong_deallocated = true
192
+ end
193
+ end
194
+ autorelease_pool {
195
+ BubbleWrap.use_weak_callbacks = true
196
+ v1 = NavigationItemContainingBarButtonItem.alloc.init_with_styled
197
+ v1.tag = 1
198
+ BubbleWrap.use_weak_callbacks = false
199
+ v2 = NavigationItemContainingBarButtonItem.alloc.init_with_styled
200
+ v2.tag = 2
201
+ }
202
+ App.notification_center.unobserve(observer)
203
+ @weak_deallocated.should.equal true
204
+ @strong_deallocated.should.equal nil
205
+ end
206
+ end
156
207
  end
157
208
 
158
209
  #################################################################################################
@@ -222,6 +273,31 @@ describe BW::UIBarButtonItem do
222
273
  @subject.action.should.equal(nil)
223
274
  end
224
275
  end
276
+
277
+ ###############################################################################################
278
+
279
+ describe "with BubbleWrap.use_weak_callbacks=true" do
280
+ it "removes cyclic references" do
281
+ observer = App.notification_center.observe('NavigationItemContainingBarButtonItem dealloc') do |obj|
282
+ if obj.userInfo['tag'] == 1
283
+ @weak_deallocated = true
284
+ elsif obj.userInfo['tag'] == 2
285
+ @strong_deallocated = true
286
+ end
287
+ end
288
+ autorelease_pool {
289
+ BubbleWrap.use_weak_callbacks = true
290
+ v1 = NavigationItemContainingBarButtonItem.alloc.init_with_system
291
+ v1.tag = 1
292
+ BubbleWrap.use_weak_callbacks = false
293
+ v2 = NavigationItemContainingBarButtonItem.alloc.init_with_system
294
+ v2.tag = 2
295
+ }
296
+ App.notification_center.unobserve(observer)
297
+ @weak_deallocated.should.equal true
298
+ @strong_deallocated.should.equal nil
299
+ end
300
+ end
225
301
  end
226
302
 
227
303
  #################################################################################################
@@ -23,6 +23,44 @@ describe BW::UIControlWrapper do
23
23
  @touched.should.equal ['touched']
24
24
  end
25
25
 
26
+ it "BubbleWrap.use_weak_callbacks=true removes cyclic references" do
27
+ class ControlSuperView < UIView
28
+ def initWithFrame(frame)
29
+ super
30
+ subject = UIControl.alloc.init
31
+ subject.when(UIControlEventTouchUpInside) do
32
+ #Can be empty, but we need a block/proc here to potentially create a retain cycle
33
+ end
34
+ addSubview(subject)
35
+ self
36
+ end
37
+
38
+ def dealloc
39
+ App.notification_center.post('ControlSuperView dealloc', nil, {'tag'=>tag})
40
+ super
41
+ end
42
+ end
43
+
44
+ observer = App.notification_center.observe('ControlSuperView dealloc') do |obj|
45
+ if obj.userInfo['tag'] == 1
46
+ @weak_deallocated = true
47
+ elsif obj.userInfo['tag'] == 2
48
+ @strong_deallocated = true
49
+ end
50
+ end
51
+ autorelease_pool {
52
+ BubbleWrap.use_weak_callbacks = true
53
+ v1 = ControlSuperView.new
54
+ v1.tag = 1
55
+ BubbleWrap.use_weak_callbacks = false
56
+ v2 = ControlSuperView.new
57
+ v2.tag = 2
58
+ }
59
+ App.notification_center.unobserve(observer)
60
+ @weak_deallocated.should.equal true
61
+ @strong_deallocated.should.equal nil
62
+ end
63
+
26
64
  it "allows multiple targets for a given control event if specified" do
27
65
  @subject.when(UIControlEventTouchUpInside, append: true) do
28
66
  @touched << 'touched'
@@ -54,9 +54,51 @@ describe BW::UIViewWrapper do
54
54
  testMethod.call :whenPanned
55
55
  end
56
56
 
57
+ describe '#when_screen_edge_panned' do
58
+ testMethod.call :when_screen_edge_panned
59
+ end
60
+
57
61
  describe '#when_pressed' do
58
62
  testMethod.call :when_pressed
59
63
  testMethod.call :whenPressed
60
64
  end
65
+
66
+ it "BubbleWrap.use_weak_callbacks=true removes cyclic references" do
67
+ class ViewSuperView < UIView
68
+ def initWithFrame(frame)
69
+ super
70
+ subject = UIView.alloc.init
71
+ subject.when_tapped do
72
+ #Can be empty, but we need a block/proc here to potentially create a retain cycle
73
+ end
74
+ addSubview(subject)
75
+ self
76
+ end
77
+
78
+ def dealloc
79
+ App.notification_center.post('ViewSuperView dealloc', nil, {'tag'=>tag})
80
+ super
81
+ end
82
+ end
83
+
84
+ observer = App.notification_center.observe('ViewSuperView dealloc') do |obj|
85
+ if obj.userInfo['tag'] == 1
86
+ @weak_deallocated = true
87
+ elsif obj.userInfo['tag'] == 2
88
+ @strong_deallocated = true
89
+ end
90
+ end
91
+ autorelease_pool {
92
+ BubbleWrap.use_weak_callbacks = true
93
+ v1 = ViewSuperView.new
94
+ v1.tag = 1
95
+ BubbleWrap.use_weak_callbacks = false
96
+ v2 = ViewSuperView.new
97
+ v2.tag = 2
98
+ }
99
+ App.notification_center.unobserve(observer)
100
+ @weak_deallocated.should.equal true
101
+ @strong_deallocated.should.equal nil
102
+ end
61
103
  end
62
104
  end
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.4.0
4
+ version: 1.5.0.rc1
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: 2013-10-06 00:00:00.000000000 Z
17
+ date: 2014-02-17 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: mocha
@@ -86,7 +86,6 @@ executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files:
88
88
  - lib/bubble-wrap/ext/motion_project_app.rb
89
- - lib/bubble-wrap/ext/motion_project_config.rb
90
89
  - motion/core.rb
91
90
  - motion/core/app.rb
92
91
  - motion/core/device.rb
@@ -199,7 +198,6 @@ files:
199
198
  - lib/bubble-wrap/core.rb
200
199
  - lib/bubble-wrap/ext.rb
201
200
  - lib/bubble-wrap/ext/motion_project_app.rb
202
- - lib/bubble-wrap/ext/motion_project_config.rb
203
201
  - lib/bubble-wrap/font.rb
204
202
  - lib/bubble-wrap/http.rb
205
203
  - lib/bubble-wrap/loader.rb
@@ -373,9 +371,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
373
371
  version: '0'
374
372
  required_rubygems_version: !ruby/object:Gem::Requirement
375
373
  requirements:
376
- - - '>='
374
+ - - '>'
377
375
  - !ruby/object:Gem::Version
378
- version: '0'
376
+ version: 1.3.1
379
377
  requirements: []
380
378
  rubyforge_project:
381
379
  rubygems_version: 2.0.3
@@ -1,34 +0,0 @@
1
- module BubbleWrap
2
- module Ext
3
- module ConfigTask
4
-
5
- def self.included(base)
6
- base.class_eval do
7
- alias_method :files_dependencies_without_bubblewrap, :files_dependencies
8
- alias_method :files_dependencies, :files_dependencies_with_bubblewrap
9
- end
10
- end
11
-
12
- def path_matching_expression
13
- /^\.?\//
14
- end
15
-
16
- def files_dependencies_with_bubblewrap(deps_hash)
17
- res_path = lambda do |x|
18
- path = path_matching_expression.match(x) ? x : File.join('.', x)
19
- unless @files.include?(path)
20
- Motion::Project::App.send(:fail, "Can't resolve dependency `#{x}' because #{path} is not in #{@files.inspect}")
21
- end
22
- path
23
- end
24
- deps_hash.each do |path, deps|
25
- deps = [deps] unless deps.is_a?(Array)
26
- @dependencies[res_path.call(path)] = deps.map(&res_path)
27
- end
28
- end
29
-
30
- end
31
- end
32
- end
33
-
34
- Motion::Project::Config.send(:include, BubbleWrap::Ext::ConfigTask)