bubble-wrap 1.7.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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
 
5
5
  $:.unshift("../../lib")
6
6
  require 'bubble-wrap/media'
data/samples/osx/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'bubble-wrap', :path => "../../" # '~> 1.3.0'
3
+ gem "rake"
4
+ gem 'bubble-wrap', :path => "../../"
5
+ gem 'bubble-wrap-http'
@@ -1,14 +1,18 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- bubble-wrap (1.4.0)
4
+ bubble-wrap (1.7.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ bubble-wrap-http (1.7.1)
10
+ rake (10.4.2)
9
11
 
10
12
  PLATFORMS
11
13
  ruby
12
14
 
13
15
  DEPENDENCIES
14
16
  bubble-wrap!
17
+ bubble-wrap-http
18
+ rake
@@ -38,9 +38,9 @@ describe BubbleWrap::Requirement do
38
38
 
39
39
  it 'can depend on another file' do
40
40
  @subject.scan(@root_path, 'motion/*.rb') do
41
- file('motion/http.rb').depends_on('motion/core.rb')
41
+ file('motion/motion.rb').depends_on('motion/constants.rb')
42
42
  end
43
- @subject.file('motion/http.rb').file_dependencies.should.include @subject.file('motion/core.rb')
43
+ @subject.file('motion/motion.rb').file_dependencies.should.include @subject.file('motion/constants.rb')
44
44
  end
45
45
 
46
46
  it 'can use a framework' do
@@ -74,6 +74,29 @@ describe BubbleWrap::App do
74
74
 
75
75
  end
76
76
 
77
+ describe ".open_url" do
78
+
79
+ it "uses NSURL or converts NSString in NSURL and opens it" do
80
+ if Kernel.const_defined?(:UIApplication)
81
+ application = UIApplication.sharedApplication
82
+ else
83
+ application = NSWorkspace.sharedWorkspace
84
+ end
85
+ def application.url; @url end
86
+ def application.openURL(url); @url = url end
87
+
88
+ url = NSURL.URLWithString('http://localhost')
89
+ App.open_url(url)
90
+ application.url.should.equal url
91
+
92
+ url = 'http://localhost'
93
+ App.open_url(url)
94
+ application.url.class.should.equal NSURL
95
+ application.url.description.should.equal url
96
+ end
97
+
98
+ end
99
+
77
100
  describe ".environment" do
78
101
 
79
102
  it 'returns current application environment' do
@@ -93,7 +93,7 @@ describe BubbleWrap::Device::Camera do
93
93
  camera.imagePickerController(camera.instance_variable_get("@picker"), didFinishPickingMediaWithInfo: info)
94
94
  image_view.nil?.should == false
95
95
  end
96
-
96
+
97
97
  it 'should set popover' do
98
98
  uiview = UIView.alloc
99
99
  camera = BW::Device.camera.photo_library.popover_from(uiview)
@@ -65,6 +65,12 @@ describe "iOS" do
65
65
  end
66
66
  end
67
67
 
68
+ describe '.vendor_identifier' do
69
+ it 'returns a value' do
70
+ BW::Device.vendor_identifier.should.not == nil
71
+ end
72
+ end
73
+
68
74
  describe '.orientation' do
69
75
  it 'delegates to BubbleWrap::Screen.orientation' do
70
76
  BW::Device.orientation.should == BW::Device::Screen.orientation
@@ -148,9 +148,15 @@ describe BubbleWrap::App do
148
148
  end
149
149
 
150
150
  describe '.window' do
151
- it 'returns UIApplication.sharedApplication.keyWindow' do
152
- App.window.should == UIApplication.sharedApplication.keyWindow
153
- end
151
+ # iOS 8 Makes the return of UIApplication.sharedApplication.keyWindow.class
152
+ # extremely volitile, especially when an alert view is shown.
153
+ # Removing this test for now.
154
+ #
155
+ # TODO - Fix this test so that it works consistently.
156
+ #
157
+ # it 'returns UIApplication.sharedApplication.keyWindow' do
158
+ # App.window.class.should == UIApplication.sharedApplication.keyWindow.class
159
+ # end
154
160
 
155
161
  describe 'with UIActionSheet' do
156
162
 
@@ -159,10 +165,8 @@ describe BubbleWrap::App do
159
165
  action_sheet.cancelButtonIndex = (action_sheet.addButtonWithTitle("Cancel"))
160
166
 
161
167
  old_window = App.window
162
- window_count = App.windows.count
163
168
  action_sheet.showInView(App.window)
164
169
  wait 1 do
165
- UIApplication.sharedApplication.windows.count.should > window_count
166
170
  App.window.should == old_window
167
171
 
168
172
  action_sheet.dismissWithClickedButtonIndex(action_sheet.cancelButtonIndex, animated: false)
@@ -187,25 +191,6 @@ describe BubbleWrap::App do
187
191
 
188
192
  end
189
193
 
190
- describe ".open_url" do
191
-
192
- it "uses NSURL or converts NSString in NSURL and opens it" do
193
- application = UIApplication.sharedApplication
194
- def application.url; @url end
195
- def application.openURL(url); @url = url end
196
-
197
- url = NSURL.URLWithString('http://localhost')
198
- App.open_url(url)
199
- application.url.should.equal url
200
-
201
- url = 'http://localhost'
202
- App.open_url(url)
203
- application.url.class.should.equal NSURL
204
- application.url.description.should.equal url
205
- end
206
-
207
- end
208
-
209
194
  describe ".can_open_url" do
210
195
 
211
196
  it "uses NSURL or converts NSString in NSURL and opens it" do
@@ -27,7 +27,7 @@ EOS
27
27
  end
28
28
 
29
29
  describe "parsing a basic JSON string without block" do
30
-
30
+
31
31
  before do
32
32
  @parsed = BubbleWrap::JSON.parse(@json_string)
33
33
  end
@@ -60,10 +60,17 @@ EOS
60
60
  obj.size.should == 3
61
61
  end
62
62
 
63
+ it "should parse String generated from NSData" do
64
+ #A contrived example to produce NSString(s) created from NSData instances
65
+ text = NSString.alloc.initWithData(@json_string.to_data, encoding:NSUTF8StringEncoding)
66
+ parsed = BW::JSON.parse(text)
67
+ parsed['login'].should == 'mattetti'
68
+ end
69
+
63
70
  end
64
71
 
65
72
  describe "parsing a basic JSON string with block" do
66
-
73
+
67
74
  before do
68
75
  BubbleWrap::JSON.parse(@json_string) do |parsed|
69
76
  @parsed = parsed
@@ -95,11 +102,11 @@ EOS
95
102
  describe "generating a JSON string from an object" do
96
103
 
97
104
  before do
98
- @obj = { foo: 'bar',
99
- 'bar' => 'baz',
100
- baz: 123,
101
- foobar: [1,2,3],
102
- foobaz: {'a' => 1, 'b' => 2}
105
+ @obj = { foo: 'bar',
106
+ 'bar' => 'baz',
107
+ baz: 123,
108
+ foobar: [1,2,3],
109
+ foobaz: {'a' => 1, 'b' => 2}
103
110
  }
104
111
  end
105
112
 
@@ -112,21 +119,34 @@ EOS
112
119
  it "should encode and decode and object losslessly" do
113
120
  json = BubbleWrap::JSON.generate(@obj)
114
121
  obj = BubbleWrap::JSON.parse(json)
115
-
122
+
116
123
  obj["foo"].should == 'bar'
117
124
  obj["bar"].should == 'baz'
118
125
  obj["baz"].should == 123
119
- obj["foobar"].should == [1,2,3]
126
+ obj["foobar"].should == [1,2,3]
120
127
  obj["foobaz"].should == {"a" => 1, "b" => 2}
121
128
 
122
129
  # TODO Find out why following line cause runtime error
123
130
  # obj.keys.sort.should == @obj.keys.sort
124
131
  # obj.values.sort.should == @obj.values.sort
125
- obj.keys.sort { |a, b| a.to_s <=> b.to_s }.should == @obj.keys.sort { |a, b| a.to_s <=> b.to_s }
132
+ obj.keys.sort { |a, b| a.to_s <=> b.to_s }.should == @obj.keys.sort { |a, b| a.to_s <=> b.to_s }
126
133
  obj.values.sort { |a, b| a.to_s <=> b.to_s }.should == @obj.values.sort { |a, b| a.to_s <=> b.to_s }
127
134
  end
128
135
 
129
136
  end
130
137
 
138
+ describe "rescuing from parser errors" do
139
+ it "should rescue from invalid data" do
140
+ begin
141
+ BubbleWrap::JSON.parse("{")
142
+ success = true
143
+ rescue BubbleWrap::JSON::ParserError
144
+ failure = true
145
+ end
146
+ success.should == nil
147
+ failure.should == true
148
+ end
149
+ end
150
+
131
151
  end
132
152
 
@@ -1,5 +1,6 @@
1
1
  describe BubbleWrap::App do
2
2
  describe "OS X" do
3
+
3
4
  describe '.delegate' do
4
5
  it 'returns a TestSuiteDelegate' do
5
6
  App.delegate.should == NSApplication.sharedApplication.delegate
@@ -12,4 +13,4 @@ describe BubbleWrap::App do
12
13
  end
13
14
  end
14
15
  end
15
- end
16
+ end
@@ -1,7 +1,7 @@
1
1
  describe "Time" do
2
2
 
3
3
  describe "Caching the date formatter" do
4
-
4
+
5
5
  it "should reuse the created formatter" do
6
6
  100.times do
7
7
  Time.iso8601("2011-04-11T13:22:21Z")
@@ -13,18 +13,44 @@ describe "Time" do
13
13
 
14
14
  end
15
15
 
16
+ describe "auto-parsing of different iso8601 formats" do
17
+ before do
18
+ @time = '1981-12-23T19:41:32-400'
19
+ @time_zulu = '1981-12-23T19:41:32Z'
20
+ @time_fractional_seconds = '1981-12-23T19:41:32.324-400'
21
+ @time_fractional_seconds_zulu = '1981-12-23T19:41:32.324Z'
22
+ end
23
+
24
+ it "should parse a normal iso8601 time" do
25
+ Time.iso8601(@time).instance_of?(Time).should == true
26
+ end
27
+
28
+ it "should parse an iso8601 time with zulu timezone" do
29
+ Time.iso8601(@time_zulu).instance_of?(Time).should == true
30
+ end
31
+
32
+ it "should parse an iso8601 time with fractional time" do
33
+ Time.iso8601(@time_fractional_seconds).instance_of?(Time).should == true
34
+ end
35
+
36
+ it "should parse an iso8601 time with fractional time and zulu timezone" do
37
+ Time.iso8601(@time_fractional_seconds_zulu).instance_of?(Time).should == true
38
+ end
39
+ end
16
40
 
17
41
  describe "parsing an iso8601 formatted time to a Time object" do
18
42
  before do
19
43
  @time = Time.iso8601("2012-#{Time.now.month}-#{Time.now.day}T19:41:32Z")
20
44
  @time_with_timezone = Time.iso8601_with_timezone("1987-08-10T06:00:00+02:00")
21
45
  @time_with_fractional_seconds = Time.iso8601_with_fractional_seconds("2012-#{Time.now.month}-#{Time.now.day}T19:41:32.123Z")
46
+ @time_with_fractional_seconds_and_timezone = Time.iso8601_with_fractional_seconds_and_timesone("2012-#{Time.now.month}-#{Time.now.day}T19:41:32.123+02:00")
22
47
  end
23
48
 
24
49
  it "should be a time" do
25
50
  @time.instance_of?(Time).should == true
26
51
  @time_with_timezone.instance_of?(Time).should == true
27
52
  @time_with_fractional_seconds.instance_of?(Time).should == true
53
+ @time_with_fractional_seconds_and_timezone.instance_of?(Time).should == true
28
54
  end
29
55
 
30
56
  # Crashes Buggy RubyMotion 1.18
@@ -33,42 +59,49 @@ describe "Time" do
33
59
  @time.zone.should == local_zone
34
60
  @time_with_timezone.zone == local_zone
35
61
  @time_with_fractional_seconds.zone.should == local_zone
62
+ @time_with_fractional_seconds_and_timezone.zone.should == local_zone
36
63
  end
37
64
 
38
65
  it "should have a valid year" do
39
66
  @time.utc.year.should == 2012
40
67
  @time_with_timezone.utc.year.should == 1987
41
68
  @time_with_fractional_seconds.utc.year.should == 2012
69
+ @time_with_fractional_seconds_and_timezone.utc.year.should == 2012
42
70
  end
43
71
 
44
72
  it "should have a valid month" do
45
73
  @time.utc.month.should == Time.now.month
46
74
  @time_with_timezone.utc.month.should == 8
47
75
  @time_with_fractional_seconds.utc.month.should == Time.now.month
76
+ @time_with_fractional_seconds_and_timezone.utc.month.should == Time.now.month
48
77
  end
49
78
 
50
79
  it "should have a valid day" do
51
80
  @time.utc.day.should == Time.now.day
52
81
  @time_with_timezone.utc.day.should == 10
53
82
  @time_with_fractional_seconds.utc.day.should == Time.now.day
83
+ @time_with_fractional_seconds_and_timezone.utc.day.should == Time.now.day
54
84
  end
55
85
 
56
86
  it "should have a valid hour" do
57
87
  @time.utc.hour.should == 19
58
88
  @time_with_timezone.utc.hour.should == 4
59
89
  @time_with_fractional_seconds.utc.hour.should == 19
90
+ @time_with_fractional_seconds_and_timezone.utc.hour.should == 17
60
91
  end
61
92
 
62
93
  it "should have a valid minute" do
63
94
  @time.utc.min.should == 41
64
95
  @time_with_timezone.utc.min.should == 0
65
96
  @time_with_fractional_seconds.utc.min.should == 41
97
+ @time_with_fractional_seconds_and_timezone.utc.min.should == 41
66
98
  end
67
99
 
68
100
  it "should have a valid second" do
69
101
  @time.utc.sec.should == 32
70
102
  @time_with_timezone.utc.sec.should == 0
71
103
  @time_with_fractional_seconds.utc.sec.should == 32
104
+ @time_with_fractional_seconds_and_timezone.utc.sec.should == 32
72
105
  end
73
106
  end
74
107
 
@@ -92,6 +92,12 @@ describe BubbleWrap::Location do
92
92
  it "should return true when available" do
93
93
  CLLocationManager.authorize(KCLAuthorizationStatusAuthorized)
94
94
  BW::Location.authorized?.should == true
95
+
96
+ CLLocationManager.authorize(KCLAuthorizationStatusAuthorizedWhenInUse)
97
+ BW::Location.authorized?.should == true
98
+
99
+ CLLocationManager.authorize(KCLAuthorizationStatusAuthorizedAlways)
100
+ BW::Location.authorized?.should == true
95
101
  end
96
102
 
97
103
  it "should throw error if not enabled" do
@@ -1,7 +1,7 @@
1
1
  # Mocking the presentViewController
2
2
  class MailViewController < UIViewController
3
3
  attr_accessor :expectation
4
-
4
+
5
5
  def presentViewController(modal, animated: animated, completion: completion)
6
6
  expectation.call modal, animated
7
7
  end
@@ -13,23 +13,23 @@ end
13
13
  # but it's testable.
14
14
  class MFMailComposeViewController
15
15
  attr_accessor :toRecipients, :ccRecipients, :bccRecipients, :subject, :message, :html
16
-
16
+
17
17
  def setToRecipients(r)
18
18
  self.toRecipients = r
19
19
  end
20
-
20
+
21
21
  def setCcRecipients(r)
22
22
  self.ccRecipients = r
23
23
  end
24
-
24
+
25
25
  def setBccRecipients(r)
26
26
  self.bccRecipients = r
27
27
  end
28
-
28
+
29
29
  def setSubject(r)
30
30
  self.subject = r
31
31
  end
32
-
32
+
33
33
  def setMessageBody(message, isHTML: html)
34
34
  self.message = message
35
35
  self.html = html
@@ -51,21 +51,25 @@ describe BW::Mail do
51
51
  animated: false
52
52
  }
53
53
  end
54
-
54
+
55
+ it "should determine if the device can send mail or not" do
56
+ [true, false].include? BW::Mail.can_send_mail?.should == true
57
+ end
58
+
55
59
  it "should open the mail controller in a modal" do
56
60
  @view_controller.expectation = lambda { |mail_controller, animated|
57
61
  mail_controller.should.be.kind_of(MFMailComposeViewController)
58
62
  }
59
-
63
+
60
64
  BubbleWrap::Mail.compose @standard_mail_options
61
65
  end
62
-
66
+
63
67
  it "should create a mail controller with the right to: address set" do
64
68
  @view_controller.expectation = lambda { |mail_controller, animated|
65
69
  mail_controller.toRecipients.should.be.kind_of(Array)
66
70
  mail_controller.toRecipients.should == @standard_mail_options[:to]
67
71
  }
68
-
72
+
69
73
  BubbleWrap::Mail.compose @standard_mail_options
70
74
  end
71
75
 
@@ -74,7 +78,7 @@ describe BW::Mail do
74
78
  mail_controller.ccRecipients.should.be.kind_of(Array)
75
79
  mail_controller.ccRecipients.should == @standard_mail_options[:cc]
76
80
  }
77
-
81
+
78
82
  BubbleWrap::Mail.compose @standard_mail_options
79
83
  end
80
84
 
@@ -83,7 +87,7 @@ describe BW::Mail do
83
87
  mail_controller.bccRecipients.should.be.kind_of(Array)
84
88
  mail_controller.bccRecipients.should == @standard_mail_options[:bcc]
85
89
  }
86
-
90
+
87
91
  BubbleWrap::Mail.compose @standard_mail_options
88
92
  end
89
93
 
@@ -92,7 +96,7 @@ describe BW::Mail do
92
96
  mail_controller.subject.should.be.kind_of(String)
93
97
  mail_controller.subject.should == @standard_mail_options[:subject]
94
98
  }
95
-
99
+
96
100
  BubbleWrap::Mail.compose @standard_mail_options
97
101
  end
98
102
 
@@ -101,7 +105,7 @@ describe BW::Mail do
101
105
  mail_controller.message.should.be.kind_of(String)
102
106
  mail_controller.message.should == @standard_mail_options[:message]
103
107
  }
104
-
108
+
105
109
  BubbleWrap::Mail.compose @standard_mail_options
106
110
  end
107
111
 
@@ -109,7 +113,7 @@ describe BW::Mail do
109
113
  @view_controller.expectation = lambda { |mail_controller, animated|
110
114
  mail_controller.html.should == @standard_mail_options[:html]
111
115
  }
112
-
116
+
113
117
  BubbleWrap::Mail.compose @standard_mail_options
114
118
  end
115
119
 
@@ -117,7 +121,7 @@ describe BW::Mail do
117
121
  @view_controller.expectation = lambda { |mail_controller, animated|
118
122
  animated.should.be.false
119
123
  }
120
-
124
+
121
125
  BubbleWrap::Mail.compose @standard_mail_options
122
126
  end
123
127