bubble-wrap 1.7.1 → 1.8.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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +1 -1
  4. data/GETTING_STARTED.md +1 -1
  5. data/Gemfile.lock +10 -10
  6. data/README.md +266 -122
  7. data/Rakefile +1 -1
  8. data/bubble-wrap.gemspec +7 -6
  9. data/lib/bubble-wrap.rb +0 -1
  10. data/lib/bubble-wrap/all.rb +13 -1
  11. data/lib/bubble-wrap/location.rb +1 -1
  12. data/lib/bubble-wrap/motion.rb +10 -0
  13. data/lib/bubble-wrap/rss_parser.rb +0 -1
  14. data/lib/bubble-wrap/test.rb +1 -0
  15. data/lib/bubble-wrap/version.rb +1 -1
  16. data/motion/core/device/ios/camera.rb +12 -1
  17. data/motion/core/ios/device.rb +7 -1
  18. data/motion/core/json.rb +1 -1
  19. data/motion/core/osx/app.rb +11 -1
  20. data/motion/core/time.rb +27 -4
  21. data/motion/location/location.rb +6 -2
  22. data/motion/mail/mail.rb +4 -0
  23. data/motion/media/player.rb +2 -1
  24. data/motion/motion/motion.rb +421 -0
  25. data/motion/reactor/deferrable.rb +29 -3
  26. data/motion/reactor/eventable.rb +3 -1
  27. data/motion/reactor/thread_aware_deferrable.rb +37 -0
  28. data/motion/rss_parser.rb +11 -21
  29. data/motion/sms/sms.rb +4 -0
  30. data/motion/ui/ui_alert_view.rb +3 -1
  31. data/motion/ui/ui_control_wrapper.rb +27 -0
  32. data/motion/ui/ui_view_wrapper.rb +1 -7
  33. data/motion/util/constants.rb +1 -1
  34. data/samples/alert/Gemfile +1 -0
  35. data/samples/alert/Gemfile.lock +16 -0
  36. data/samples/alert/Rakefile +1 -1
  37. data/samples/camera/Gemfile +2 -1
  38. data/samples/camera/Gemfile.lock +16 -0
  39. data/samples/camera/Rakefile +1 -1
  40. data/samples/gesture/Gemfile +2 -1
  41. data/samples/gesture/Gemfile.lock +9 -3
  42. data/samples/gesture/Rakefile +1 -1
  43. data/samples/location/Gemfile +3 -1
  44. data/samples/location/Gemfile.lock +18 -0
  45. data/samples/location/Rakefile +4 -2
  46. data/samples/location/app/controllers/{image_list_controller.rb → places_list_controller.rb} +0 -0
  47. data/samples/media/Gemfile +4 -0
  48. data/samples/media/Gemfile.lock +16 -0
  49. data/samples/media/Rakefile +1 -1
  50. data/samples/osx/Gemfile +3 -1
  51. data/samples/osx/Gemfile.lock +5 -1
  52. data/spec/lib/bubble-wrap/requirement_spec.rb +2 -2
  53. data/spec/motion/core/app_spec.rb +23 -0
  54. data/spec/motion/core/device/ios/camera_spec.rb +1 -1
  55. data/spec/motion/core/device/ios/device_spec.rb +6 -0
  56. data/spec/motion/core/ios/app_spec.rb +9 -24
  57. data/spec/motion/core/json_spec.rb +30 -10
  58. data/spec/motion/core/osx/app_spec.rb +2 -1
  59. data/spec/motion/core/time_spec.rb +34 -1
  60. data/spec/motion/location/location_spec.rb +6 -0
  61. data/spec/motion/mail/mail_spec.rb +20 -16
  62. data/spec/motion/motion/core_motion_spec.rb +231 -0
  63. data/spec/motion/reactor/deferrable_spec.rb +81 -0
  64. data/spec/motion/reactor/eventable_spec.rb +11 -0
  65. data/spec/motion/reactor/thread_aware_deferrable_spec.rb +85 -0
  66. data/spec/motion/rss_parser_spec.rb +11 -21
  67. data/spec/motion/sms/sms_spec.rb +11 -6
  68. data/spec/motion/ui/ui_alert_view_spec.rb +23 -0
  69. data/spec/motion/ui/ui_control_wrapper_spec.rb +24 -0
  70. metadata +58 -38
  71. data/lib/bubble-wrap/http.rb +0 -7
@@ -19,7 +19,7 @@ module BubbleWrap
19
19
  return unless blk
20
20
  @deferred_status ||= :unknown
21
21
  if @deferred_status == :succeeded
22
- blk.call(*@deferred_args)
22
+ execute_block(&blk)
23
23
  elsif @deferred_status != :failed
24
24
  @callbacks ||= []
25
25
  @callbacks.unshift blk
@@ -42,6 +42,7 @@ module BubbleWrap
42
42
  return unless blk
43
43
  @deferred_status ||= :unknown
44
44
  if @deferred_status == :failed
45
+ execute_block(&blk)
45
46
  blk.call(*@deferred_args)
46
47
  elsif @deferred_status != :succeeded
47
48
  @errbacks ||= []
@@ -49,6 +50,31 @@ module BubbleWrap
49
50
  end
50
51
  end
51
52
 
53
+ def execute_block(&blk)
54
+ return unless blk
55
+ blk.call(*@deferred_args)
56
+ end
57
+
58
+ def delegate(delegate)
59
+ callback_delegate(delegate)
60
+ errback_delegate(delegate)
61
+ self
62
+ end
63
+
64
+ def errback_delegate(delegate)
65
+ errback do |*args|
66
+ delegate.fail *args
67
+ end
68
+ self
69
+ end
70
+
71
+ def callback_delegate(delegate)
72
+ callback do |*args|
73
+ delegate.succeed *args
74
+ end
75
+ self
76
+ end
77
+
52
78
  # Sugar for set_deferred_status(:failed, …)
53
79
  def fail(*args)
54
80
  set_deferred_status :failed, *args
@@ -91,14 +117,14 @@ module BubbleWrap
91
117
  when :succeeded
92
118
  if @callbacks
93
119
  while cb = @callbacks.pop
94
- cb.call(*@deferred_args)
120
+ execute_block(&cb)
95
121
  end
96
122
  end
97
123
  @errbacks.clear if @errbacks
98
124
  when :failed
99
125
  if @errbacks
100
126
  while eb = @errbacks.pop
101
- eb.call(*@deferred_args)
127
+ execute_block(&eb)
102
128
  end
103
129
  end
104
130
  @callbacks.clear if @callbacks
@@ -18,8 +18,10 @@ module BubbleWrap
18
18
  events = _events_for_key(event)
19
19
  if method
20
20
  events.delete_if { |m| m.receiver == method.receiver and m.name == method.name }
21
- else
21
+ elsif blk
22
22
  events.delete_if { |b| b == blk }
23
+ else
24
+ __events__[event] = Array.new
23
25
  end
24
26
  blk
25
27
  end
@@ -0,0 +1,37 @@
1
+ module BubbleWrap
2
+ module Reactor
3
+ class ThreadAwareDeferrable < DefaultDeferrable
4
+ include ::BubbleWrap::Reactor::Deferrable
5
+
6
+
7
+ # need to store the the queue in callback / errback
8
+ def callback(&blk)
9
+ return unless blk
10
+ cache_block_queue(&blk)
11
+ super(&blk)
12
+ end
13
+
14
+ def errback(&blk)
15
+ return unless blk
16
+ cache_block_queue(&blk)
17
+ super(&blk)
18
+ end
19
+
20
+ def execute_block(&blk)
21
+ return unless blk
22
+ queue = @queue_cache.delete(blk.object_id)
23
+ return unless queue
24
+ queue.async do
25
+ blk.call(*@deferred_args)
26
+ end
27
+ end
28
+
29
+ def cache_block_queue(&blk)
30
+ return unless blk
31
+ @queue_cache ||= {}
32
+ @queue_cache[blk.object_id] = Dispatch::Queue.current
33
+ end
34
+ end
35
+ end
36
+ end
37
+
data/motion/rss_parser.rb CHANGED
@@ -50,9 +50,11 @@ module BubbleWrap
50
50
  if data
51
51
  data_to_parse = input.respond_to?(:to_data) ? input.to_data : input
52
52
  @source = data_to_parse
53
+ @source_type = :data
53
54
  else
54
55
  url = input.is_a?(NSURL) ? input : NSURL.alloc.initWithString(input)
55
56
  @source = url
57
+ @source_type = :url
56
58
  end
57
59
  self.state = :initializes
58
60
  self
@@ -75,12 +77,15 @@ module BubbleWrap
75
77
  def parse(&block)
76
78
  @block = block
77
79
 
78
- fetch_source_data do |data|
79
- @parser = NSXMLParser.alloc.initWithData(data)
80
- @parser.shouldProcessNamespaces = true
81
- @parser.delegate ||= self
82
- @parser.parse
80
+ if @source_type == :url
81
+ @parser = NSXMLParser.alloc.initWithContentsOfURL(@source)
82
+ else
83
+ @parser = NSXMLParser.alloc.initWithData(@source)
83
84
  end
85
+
86
+ @parser.shouldProcessNamespaces = true
87
+ @parser.delegate ||= self
88
+ @parser.parse
84
89
  end
85
90
 
86
91
  # Delegate getting called when parsing starts
@@ -129,7 +134,7 @@ module BubbleWrap
129
134
  # If a block was set, it will be called on each parsed items
130
135
  def parserDidEndDocument(parser)
131
136
  puts "done parsing" if debug
132
- self.state = :is_done
137
+ self.state = :is_done unless self.state == :errors
133
138
  end
134
139
 
135
140
  def parserError
@@ -140,20 +145,5 @@ module BubbleWrap
140
145
  # parser:validationErrorOccurred:
141
146
  # parser:foundCDATA:
142
147
 
143
- protected
144
-
145
- def fetch_source_data(&blk)
146
- if @source.is_a?(NSURL)
147
- HTTP.get(@source.absoluteString) do |response|
148
- if response.ok?
149
- blk.call(response.body)
150
- else
151
- parser(parser, parseErrorOccurred:"HTTP request failed (#{response})")
152
- end
153
- end
154
- else
155
- yield @source
156
- end
157
- end
158
148
  end
159
149
  end
data/motion/sms/sms.rb CHANGED
@@ -37,6 +37,10 @@ module BubbleWrap
37
37
  message_controller
38
38
  end
39
39
 
40
+ def can_send_sms?
41
+ !!MFMessageComposeViewController.canSendText
42
+ end
43
+
40
44
  # Event when the MFMessageComposeViewController is closed
41
45
  # -------------------------------------------------------------
42
46
  # the callback is fired if it was present in the constructor
@@ -49,7 +49,9 @@ module BW
49
49
  options = {buttons: ["Cancel", "OK"],
50
50
  cancel_button_index: 0}.merge!(options)
51
51
  options[:style] = :plain_text_input
52
- new(options, &block)
52
+ new(options, &block).tap do |view|
53
+ view.textFieldAtIndex(0).placeholder = options[:placeholder] if options[:placeholder]
54
+ end
53
55
  end
54
56
 
55
57
  def secure_text_input(options = {}, &block)
@@ -1,6 +1,8 @@
1
1
  module BubbleWrap
2
2
  module UIControlWrapper
3
3
  def when(events, options = {}, &block)
4
+ events = BW::Constants.get("UIControlEvent", events)
5
+
4
6
  @callback ||= {}
5
7
  @callback[events] ||= []
6
8
 
@@ -14,4 +16,29 @@ module BubbleWrap
14
16
  addTarget(@callback[events].last, action:'call', forControlEvents: events)
15
17
  end
16
18
  end
19
+
20
+ Constants.register(
21
+ UIControlEventTouchDown,
22
+ UIControlEventTouchDownRepeat,
23
+ UIControlEventTouchDragInside,
24
+ UIControlEventTouchDragOutside,
25
+ UIControlEventTouchDragEnter,
26
+ UIControlEventTouchDragExit,
27
+ UIControlEventTouchUpInside,
28
+ UIControlEventTouchUpOutside,
29
+ UIControlEventTouchCancel,
30
+
31
+ UIControlEventValueChanged,
32
+
33
+ UIControlEventEditingDidBegin,
34
+ UIControlEventEditingChanged,
35
+ UIControlEventEditingDidEnd,
36
+ UIControlEventEditingDidEndOnExit,
37
+
38
+ UIControlEventAllTouchEvents,
39
+ UIControlEventAllEditingEvents,
40
+ # UIControlEventApplicationReserved,
41
+ # UIControlEventSystemReserved,
42
+ UIControlEventAllEvents
43
+ )
17
44
  end
@@ -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_pressed_on_begin:'), enableInteraction, proc)
28
+ add_gesture_recognizer_helper(UILongPressGestureRecognizer.alloc.initWithTarget(self, action:'handle_gesture:'), enableInteraction, proc)
29
29
  end
30
30
 
31
31
  def self.deprecated_methods
@@ -45,12 +45,6 @@ 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
-
54
48
  # Adds the recognizer and keeps a strong reference to the Proc object.
55
49
  def add_gesture_recognizer_helper(recognizer, enableInteraction, proc)
56
50
  setUserInteractionEnabled true if enableInteraction && !isUserInteractionEnabled
@@ -3,7 +3,7 @@ module BubbleWrap
3
3
  module Constants
4
4
  module_function
5
5
 
6
- # Looks like RubyMotiononly adds UIKit constants
6
+ # Looks like RubyMotion only adds UIKit constants
7
7
  # at compile time. If you don't use these
8
8
  # directly in your code, they don't get added
9
9
  # to Kernel and Constants.get crashes.
@@ -1,3 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ gem "rake"
3
4
  gem "bubble-wrap", :path => "../../"
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ bubble-wrap (1.7.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bubble-wrap!
16
+ rake
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  $:.unshift("/Library/RubyMotion/lib")
3
- require 'motion/project'
3
+ require 'motion/project/template/ios'
4
4
  require 'bundler'
5
5
  Bundler.require
6
6
 
@@ -1,3 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'bubble-wrap', '~> 1.1.0'
3
+ gem "rake"
4
+ gem "bubble-wrap", :path => "../../"
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ bubble-wrap (1.7.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bubble-wrap!
16
+ rake
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  $:.unshift("/Library/RubyMotion/lib")
3
- require 'motion/project'
3
+ require 'motion/project/template/ios'
4
4
  require 'bubble-wrap/core'
5
5
  require 'bubble-wrap/camera'
6
6
 
@@ -1,4 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'bubble-wrap', '~> 1.1.0'
3
+ gem 'rake'
4
+ gem "bubble-wrap", :path => "../../"
4
5
  gem 'motion-dryer'
@@ -1,12 +1,18 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ bubble-wrap (1.7.1)
5
+
1
6
  GEM
2
- remote: http://rubygems.org/
7
+ remote: https://rubygems.org/
3
8
  specs:
4
- bubble-wrap (1.1.1)
5
9
  motion-dryer (0.0.1)
10
+ rake (10.4.2)
6
11
 
7
12
  PLATFORMS
8
13
  ruby
9
14
 
10
15
  DEPENDENCIES
11
- bubble-wrap (~> 1.1.0)
16
+ bubble-wrap!
12
17
  motion-dryer
18
+ rake
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  $:.unshift("/Library/RubyMotion/lib")
3
- require 'motion/project'
3
+ require 'motion/project/template/ios'
4
4
  require 'bundler'
5
5
  Bundler.require :default
6
6
 
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'bubble-wrap', '~> 1.1.0'
3
+ gem 'rake'
4
+ gem "bubble-wrap", :path => "../../"
5
+ gem 'bubble-wrap-http'
@@ -0,0 +1,18 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ bubble-wrap (1.7.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ bubble-wrap-http (1.7.1)
10
+ rake (10.4.2)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bubble-wrap!
17
+ bubble-wrap-http
18
+ rake
@@ -1,10 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  $:.unshift("/Library/RubyMotion/lib")
3
- require 'motion/project'
3
+ require 'motion/project/template/ios'
4
4
  require 'bubble-wrap/location'
5
- require 'bubble-wrap/http'
6
5
  require 'bubble-wrap/core'
7
6
 
7
+ require 'bundler'
8
+ Bundler.require
9
+
8
10
  Motion::Project::App.setup do |app|
9
11
  app.name = 'location'
10
12
  end
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rake"
4
+ gem "bubble-wrap", :path => "../../"
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ bubble-wrap (1.7.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bubble-wrap!
16
+ rake