bubble-wrap 1.5.0 → 1.6.0.rc1
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 +4 -4
- data/.travis.yml +6 -1
- data/Gemfile.lock +3 -1
- data/README.md +98 -5
- data/Rakefile +1 -1
- data/bubble-wrap.gemspec +1 -0
- data/lib/bubble-wrap/all.rb +1 -1
- data/lib/bubble-wrap/http.rb +5 -5
- data/lib/bubble-wrap/network-indicator.rb +6 -0
- data/lib/bubble-wrap/ui.rb +1 -0
- data/lib/bubble-wrap/version.rb +1 -1
- data/motion/core.rb +3 -0
- data/motion/core/ios/app.rb +14 -2
- data/motion/core/string.rb +4 -0
- data/motion/location/location.rb +31 -1
- data/motion/network-indicator/network-indicator.rb +67 -0
- data/motion/reactor/eventable.rb +6 -4
- data/motion/ui/ui_activity_view_controller_wrapper.rb +51 -0
- data/motion/util/constants.rb +10 -5
- data/spec/motion/core/ios/app_spec.rb +27 -0
- data/spec/motion/core/string_spec.rb +13 -2
- data/spec/motion/location/location_spec.rb +65 -0
- data/spec/motion/network-indicator/network_indicator_spec.rb +112 -0
- data/spec/motion/reactor/eventable_spec.rb +54 -2
- data/spec/motion/ui/ui_activity_view_controller_wrapper_spec.rb +58 -0
- data/spec/motion/util/constants_spec.rb +6 -0
- metadata +29 -20
- data/motion/http.rb +0 -34
- data/motion/http/query.rb +0 -393
- data/motion/http/response.rb +0 -32
- data/spec/motion/http/query_spec.rb +0 -808
- data/spec/motion/http/response_spec.rb +0 -45
- data/spec/motion/http_spec.rb +0 -57
- data/travis.sh +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 601f1626c9a3a557c7120181febf1f2acf29ecd1
|
4
|
+
data.tar.gz: 53ea079e1921fe8d05d3ec03f98f4496d19d2040
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b95bf54c3049c7ba4e5bf97df0593195bd63588bc541beb40179f2ccac93eeb1fd33d99d0778facb8d7e20635775e21a32674509fd1bbbf51eb28b34513699d1
|
7
|
+
data.tar.gz: 1ba1653a02a10eca8ff65529afe6d6afc0946fc4b4dbce45545afef2728334aaad163f5fb59fbf8cd8b4e7ca9db083377ff143b510ea6181318b3f8d908388a4
|
data/.travis.yml
CHANGED
@@ -3,4 +3,9 @@ before_install:
|
|
3
3
|
- (ruby --version)
|
4
4
|
- mkdir -p ~/Library/RubyMotion/build
|
5
5
|
- sudo motion update
|
6
|
-
script:
|
6
|
+
script:
|
7
|
+
- bundle install
|
8
|
+
- bundle exec rake clean
|
9
|
+
- bundle exec rake spec
|
10
|
+
- bundle exec rake clean
|
11
|
+
- bundle exec rake spec osx=true
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bubble-wrap (1.
|
4
|
+
bubble-wrap (1.6.0.rc1)
|
5
|
+
bubble-wrap-http (= 1.6.0.rc1)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
bacon (1.1.0)
|
11
|
+
bubble-wrap-http (1.6.0.rc1)
|
10
12
|
metaclass (0.0.1)
|
11
13
|
mocha (0.11.4)
|
12
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.
|
29
|
+
gem "bubble-wrap", "~> 1.5.0"
|
30
30
|
```
|
31
31
|
|
32
32
|
BubbleWrap is split into multiple modules so that you can easily choose which parts
|
@@ -93,6 +93,12 @@ If you wish to only include the `SMS` wrapper:
|
|
93
93
|
require 'bubble-wrap/sms'
|
94
94
|
```
|
95
95
|
|
96
|
+
If you wish to only include the `NetworkIndicator` wrapper:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
require 'bubble-wrap/network-indicator'
|
100
|
+
```
|
101
|
+
|
96
102
|
If you want to include everything (ie kitchen sink mode) you can save time and do:
|
97
103
|
|
98
104
|
```ruby
|
@@ -146,6 +152,8 @@ BubbleWrap.rgb_color(23, 45, 12)
|
|
146
152
|
=> #<UICachedDeviceWhiteColor:0x8bb5be0>
|
147
153
|
'#FF8A19'.to_color
|
148
154
|
=> #<UIDeviceRGBColor:0x8d54110>
|
155
|
+
'#88FF8A19'.to_color # ARGB format
|
156
|
+
=> #<UIDeviceRGBColor:0xca0fe00>
|
149
157
|
```
|
150
158
|
|
151
159
|
Debug flag:
|
@@ -178,7 +186,10 @@ A module with useful methods related to the running application
|
|
178
186
|
> App.run_after(0.5) { p "It's #{Time.now}" }
|
179
187
|
# Runs the block after 0.5 seconds.
|
180
188
|
> App.open_url("http://matt.aimonetti.net")
|
181
|
-
|
189
|
+
> App.open_url("tel://123456789")
|
190
|
+
# Opens the url using the device's browser. Can also open custom URL schemas (accepts a string url or an instance of `NSURL`.)
|
191
|
+
> App.can_open_url("tel://")
|
192
|
+
# Returns whether the app can open a given URL resource.
|
182
193
|
> App::Persistence['channels'] # application specific persistence storage
|
183
194
|
# ['NBC', 'ABC', 'Fox', 'CBS', 'PBS']
|
184
195
|
> App::Persistence['channels'] = ['TF1', 'France 2', 'France 3']
|
@@ -375,7 +386,7 @@ iso8601 formatted string into a Time instance.
|
|
375
386
|
|
376
387
|
## Location
|
377
388
|
|
378
|
-
Added interface for Ruby-like GPS access:
|
389
|
+
Added interface for Ruby-like GPS and compass access:
|
379
390
|
|
380
391
|
```ruby
|
381
392
|
BW::Location.get do |result|
|
@@ -384,6 +395,15 @@ BW::Location.get do |result|
|
|
384
395
|
end
|
385
396
|
```
|
386
397
|
|
398
|
+
```ruby
|
399
|
+
BW::Location.get_compass do |result|
|
400
|
+
p result[:magnetic_heading] # Heading towards magnetic north
|
401
|
+
p result[:true_heading] # Heading towards true north
|
402
|
+
p result[:accuracy] # Potential error between magnetic and true heading
|
403
|
+
p result[:timestamp] # Timestamp of the heading calculation
|
404
|
+
end
|
405
|
+
```
|
406
|
+
|
387
407
|
Also available is `BW::Location.get_significant`, for monitoring significant location changes.
|
388
408
|
|
389
409
|
## Media
|
@@ -443,7 +463,36 @@ Wrapper for showing an in-app message (SMS) composer view.
|
|
443
463
|
result.canceled? # => boolean
|
444
464
|
result.failed? # => boolean
|
445
465
|
error # => NSError
|
446
|
-
}
|
466
|
+
}
|
467
|
+
```
|
468
|
+
|
469
|
+
## NetworkIndicator
|
470
|
+
|
471
|
+
Wrapper for showing and hiding the network indicator (the status bar spinner).
|
472
|
+
|
473
|
+
```ruby
|
474
|
+
BW::NetworkIndicator.show # starts the spinner
|
475
|
+
BW::NetworkIndicator.hide # stops it
|
476
|
+
|
477
|
+
# the nice thing is if you call 'show' multiple times, the 'hide' method will
|
478
|
+
# not have any effect until you've called it the same number of times.
|
479
|
+
BW::NetworkIndicator.show
|
480
|
+
# ...somewhere else
|
481
|
+
BW::NetworkIndicator.show
|
482
|
+
|
483
|
+
# ...down the line
|
484
|
+
BW::NetworkIndicator.hide
|
485
|
+
# indicator is still visible
|
486
|
+
|
487
|
+
BW::NetworkIndicator.hide
|
488
|
+
# NOW the indicator is hidden!
|
489
|
+
|
490
|
+
# If you *really* want to hide the indicator immediately, you can call `reset!`
|
491
|
+
# but this is in no way encouraged.
|
492
|
+
BW::NetworkIndicator.reset!
|
493
|
+
|
494
|
+
# and for completeness, a check to see if the indicator is visible
|
495
|
+
BW::NetworkIndicator.visible?
|
447
496
|
```
|
448
497
|
|
449
498
|
## UI
|
@@ -594,6 +643,50 @@ And the `.system` button types are:
|
|
594
643
|
:page_curl
|
595
644
|
```
|
596
645
|
|
646
|
+
### UIActivityViewController
|
647
|
+
|
648
|
+
`BW::UIActivityViewController` is a subclass of `UIActivityViewController` with an natural Ruby syntax.
|
649
|
+
|
650
|
+
You can initiate a `UIActivityViewController` with or without a completion handler block. For more information on `UIActivityViewController`s, see [Apple's documentation](https://developer.apple.com/library/ios/documentation/uikit/reference/UIActivityViewController_Class/Reference/Reference.html).
|
651
|
+
|
652
|
+
```ruby
|
653
|
+
# Without a completion handler
|
654
|
+
BW::UIActivityViewController.new(
|
655
|
+
items: "Some Text", # or ["Some Text", NSURL.URLWithString('http://www.rubymotion.com')] or a UIImage
|
656
|
+
animated: true, # Defaults to true
|
657
|
+
excluded: :add_to_reading_list # One item or an array
|
658
|
+
)
|
659
|
+
|
660
|
+
# With completion handler
|
661
|
+
BW::UIActivityViewController.new(
|
662
|
+
items: "Some Text",
|
663
|
+
animated: true,
|
664
|
+
excluded: [:add_to_reading_list, :print, :air_drop]
|
665
|
+
) do |activity_type, completed|
|
666
|
+
puts "completed with activity: #{activity_type} - finished?: #{completed}"
|
667
|
+
end
|
668
|
+
```
|
669
|
+
|
670
|
+
Built in activities that can be passed to the `excluded` option are defined as `UIActivity` class `UIActivityType` constants:
|
671
|
+
|
672
|
+
```ruby
|
673
|
+
:post_to_facebook
|
674
|
+
:post_to_twitter
|
675
|
+
:post_to_weibo
|
676
|
+
:message
|
677
|
+
:mail
|
678
|
+
:print
|
679
|
+
:copy_to_pasteboard
|
680
|
+
:assign_to_contact
|
681
|
+
:save_to_camera_roll
|
682
|
+
:add_to_reading_list
|
683
|
+
:post_to_flickr
|
684
|
+
:post_to_vimeo
|
685
|
+
:post_to_tencent_weibo
|
686
|
+
:air_drop
|
687
|
+
```
|
688
|
+
|
689
|
+
|
597
690
|
## HTTP
|
598
691
|
|
599
692
|
`BW::HTTP` wraps `NSURLRequest`, `NSURLConnection` and friends to provide Ruby developers with a more familiar and easier to use API.
|
@@ -677,7 +770,7 @@ class HttpClient
|
|
677
770
|
BW::HTTP.get(user_url(user_id)) do |response|
|
678
771
|
# ..
|
679
772
|
end
|
680
|
-
end
|
773
|
+
end
|
681
774
|
end
|
682
775
|
```
|
683
776
|
|
data/Rakefile
CHANGED
@@ -28,7 +28,7 @@ Motion::Project::App.setup do |app|
|
|
28
28
|
app.spec_files
|
29
29
|
if Motion::Project::App.osx?
|
30
30
|
app.spec_files -= Dir.glob("./spec/motion/**/ios/**.rb")
|
31
|
-
["font", "location", "media", "ui", "mail", "sms"].each do |package|
|
31
|
+
["font", "location", "media", "ui", "mail", "sms", "network-indicator"].each do |package|
|
32
32
|
app.spec_files -= Dir.glob("./spec/motion/#{package}/**/*.rb")
|
33
33
|
end
|
34
34
|
else
|
data/bubble-wrap.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
|
17
17
|
gem.extra_rdoc_files = gem.files.grep(%r{motion})
|
18
18
|
|
19
|
+
gem.add_dependency 'bubble-wrap-http', BubbleWrap::VERSION
|
19
20
|
gem.add_development_dependency 'mocha', '0.11.4'
|
20
21
|
gem.add_development_dependency 'mocha-on-bacon'
|
21
22
|
gem.add_development_dependency 'bacon'
|
data/lib/bubble-wrap/all.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
require File.expand_path('../loader', __FILE__)
|
2
|
-
['core', 'http', 'reactor', 'rss_parser', 'ui', 'location', 'media', 'font', 'mail','sms'].each { |sub|
|
2
|
+
['core', 'http', 'reactor', 'rss_parser', 'ui', 'location', 'media', 'font', 'mail','sms', 'network-indicator'].each { |sub|
|
3
3
|
require File.expand_path("../#{sub}", __FILE__)
|
4
4
|
}
|
data/lib/bubble-wrap/http.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'bubble-wrap/version' unless defined?(BubbleWrap::VERSION)
|
2
2
|
require 'bubble-wrap/loader'
|
3
|
-
|
4
|
-
|
5
|
-
BubbleWrap.
|
6
|
-
|
7
|
-
|
3
|
+
require 'bubble-wrap/network-indicator'
|
4
|
+
require 'bubble-wrap-http'
|
5
|
+
Motion::Project::App.warn "BubbleWrap::HTTP is deprecated and will be removed, see https://github.com/rubymotion/BubbleWrap/issues/308"
|
6
|
+
Motion::Project::App.warn "Switch to a different networking library soon - consider AFNetworking: http://afnetworking.com/"
|
7
|
+
Motion::Project::App.warn "You can use the 'bubble-wrap-http' gem if you need compatibility: https://github.com/rubymotion/BubbleWrap-HTTP"
|
data/lib/bubble-wrap/ui.rb
CHANGED
data/lib/bubble-wrap/version.rb
CHANGED
data/motion/core.rb
CHANGED
data/motion/core/ios/app.rb
CHANGED
@@ -3,9 +3,10 @@ module BubbleWrap
|
|
3
3
|
module_function
|
4
4
|
|
5
5
|
# Opens an url (string or instance of `NSURL`)
|
6
|
-
# in the device's web browser
|
6
|
+
# in the device's web browser or in the correspondent app for custom schemas
|
7
7
|
# Usage Example:
|
8
8
|
# App.open_url("http://matt.aimonetti.net")
|
9
|
+
# App.open_url("fb://profile")
|
9
10
|
def open_url(url)
|
10
11
|
unless url.is_a?(NSURL)
|
11
12
|
url = NSURL.URLWithString(url)
|
@@ -13,6 +14,17 @@ module BubbleWrap
|
|
13
14
|
UIApplication.sharedApplication.openURL(url)
|
14
15
|
end
|
15
16
|
|
17
|
+
# Returns whether an app can open a given URL resource (string or instance of `NSURL`)
|
18
|
+
# Useful to check if certain apps are installed before calling to their custom schemas.
|
19
|
+
# Usage Example:
|
20
|
+
# App.open_url("fb://profile") if App.can_open_url("fb://")
|
21
|
+
def can_open_url(url)
|
22
|
+
unless url.is_a?(NSURL)
|
23
|
+
url = NSURL.URLWithString(url)
|
24
|
+
end
|
25
|
+
UIApplication.sharedApplication.canOpenURL(url)
|
26
|
+
end
|
27
|
+
|
16
28
|
# Displays a UIAlertView.
|
17
29
|
#
|
18
30
|
# title - The title as a String.
|
@@ -80,4 +92,4 @@ module BubbleWrap
|
|
80
92
|
key_window || normal_windows.first
|
81
93
|
end
|
82
94
|
end
|
83
|
-
end
|
95
|
+
end
|
data/motion/core/string.rb
CHANGED
@@ -58,11 +58,15 @@ module BubbleWrap
|
|
58
58
|
colors = hex_color.scan(%r{[0-9A-Fa-f]}).map!{ |el| (el * 2).to_i(16) }
|
59
59
|
when 6
|
60
60
|
colors = hex_color.scan(%r<[0-9A-Fa-f]{2}>).map!{ |el| el.to_i(16) }
|
61
|
+
when 8
|
62
|
+
colors = hex_color.scan(%r<[0-9A-Fa-f]{2}>).map!{ |el| el.to_i(16) }
|
61
63
|
else
|
62
64
|
raise ArgumentError
|
63
65
|
end
|
64
66
|
if colors.size == 3
|
65
67
|
BubbleWrap.rgb_color(colors[0], colors[1], colors[2])
|
68
|
+
elsif colors.size == 4
|
69
|
+
BubbleWrap.rgba_color(colors[1], colors[2], colors[3], colors[0])
|
66
70
|
else
|
67
71
|
raise ArgumentError
|
68
72
|
end
|
data/motion/location/location.rb
CHANGED
@@ -70,6 +70,8 @@ module BubbleWrap
|
|
70
70
|
|
71
71
|
if @options[:significant]
|
72
72
|
self.location_manager.startMonitoringSignificantLocationChanges
|
73
|
+
elsif @options[:compass]
|
74
|
+
self.location_manager.startUpdatingHeading
|
73
75
|
else
|
74
76
|
self.location_manager.startUpdatingLocation
|
75
77
|
end
|
@@ -83,10 +85,21 @@ module BubbleWrap
|
|
83
85
|
get(options.merge(once: true), &block)
|
84
86
|
end
|
85
87
|
|
88
|
+
def get_compass(options = {}, &block)
|
89
|
+
get(options.merge(compass: true), &block)
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_compass_once(options = {}, &block)
|
93
|
+
get_compass(options.merge(once: true), &block)
|
94
|
+
end
|
95
|
+
|
86
96
|
# Stop getting locations
|
87
97
|
def stop
|
98
|
+
return unless @options
|
88
99
|
if @options[:significant]
|
89
100
|
self.location_manager.stopMonitoringSignificantLocationChanges
|
101
|
+
elsif @options[:compass]
|
102
|
+
self.location_manager.stopUpdatingHeading
|
90
103
|
else
|
91
104
|
self.location_manager.stopUpdatingLocation
|
92
105
|
end
|
@@ -121,6 +134,23 @@ module BubbleWrap
|
|
121
134
|
end
|
122
135
|
end
|
123
136
|
|
137
|
+
def locationManager(manager, didUpdateHeading:newHeading)
|
138
|
+
heading = {
|
139
|
+
magnetic_heading: newHeading.magneticHeading,
|
140
|
+
true_heading: newHeading.trueHeading,
|
141
|
+
accuracy: newHeading.headingAccuracy,
|
142
|
+
timestamp: newHeading.timestamp,
|
143
|
+
}
|
144
|
+
|
145
|
+
if @options[:once]
|
146
|
+
@callback && @callback.call(heading)
|
147
|
+
@callback = proc { |result| }
|
148
|
+
stop
|
149
|
+
else
|
150
|
+
@callback && @callback.call(heading)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
124
154
|
def locationManager(manager, didFailWithError:error)
|
125
155
|
if error.domain == KCLErrorDomain
|
126
156
|
case error.code
|
@@ -152,4 +182,4 @@ module BubbleWrap
|
|
152
182
|
end
|
153
183
|
end
|
154
184
|
end
|
155
|
-
::Location = BubbleWrap::Location unless defined?(::Location)
|
185
|
+
::Location = BubbleWrap::Location unless defined?(::Location)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module BubbleWrap
|
2
|
+
module NetworkIndicator
|
3
|
+
DELAY = 0.2
|
4
|
+
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def counter
|
8
|
+
@counter ||= 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
if Dispatch::Queue.current.to_s == 'com.apple.main-thread'
|
13
|
+
@counter = self.counter + 1
|
14
|
+
self.update_spinner
|
15
|
+
else
|
16
|
+
Dispatch::Queue.main.async do
|
17
|
+
self.show
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def hide
|
23
|
+
if Dispatch::Queue.current.to_s == 'com.apple.main-thread'
|
24
|
+
@counter = [self.counter - 1, 0].max
|
25
|
+
if self.counter == 0
|
26
|
+
if @hide_indicator_timer
|
27
|
+
@hide_indicator_timer.invalidate
|
28
|
+
end
|
29
|
+
@hide_indicator_timer = NSTimer.timerWithTimeInterval(DELAY - 0.01, target: self, selector: :update_spinner_timer, userInfo: nil, repeats: false)
|
30
|
+
NSRunLoop.mainRunLoop.addTimer(@hide_indicator_timer, forMode:NSRunLoopCommonModes)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
Dispatch::Queue.main.async do
|
34
|
+
self.hide
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_spinner_timer
|
40
|
+
update_spinner
|
41
|
+
end
|
42
|
+
|
43
|
+
def update_spinner
|
44
|
+
if Dispatch::Queue.current.to_s == 'com.apple.main-thread'
|
45
|
+
if @hide_indicator_timer
|
46
|
+
@hide_indicator_timer.invalidate
|
47
|
+
@hide_indicator_timer = nil
|
48
|
+
end
|
49
|
+
UIApplication.sharedApplication.networkActivityIndicatorVisible = (@counter > 0)
|
50
|
+
else
|
51
|
+
Dispatch::Queue.main.async do
|
52
|
+
self.update_spinner
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def visible?
|
58
|
+
UIApplication.sharedApplication.networkActivityIndicatorVisible?
|
59
|
+
end
|
60
|
+
|
61
|
+
def reset!
|
62
|
+
@counter = 0
|
63
|
+
self.update_spinner
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|