locomotion 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -2
- data/app/app_delegate.rb +8 -4
- data/lib/locomotion/version.rb +1 -1
- data/motion/locomotion/delegate.rb +7 -1
- data/motion/locomotion/location.rb +38 -0
- data/motion/locomotion/watchman.rb +3 -2
- data/spec/integration_spec.rb +12 -0
- data/spec/locomotion/delegate_spec.rb +6 -1
- data/spec/locomotion/watchman_spec.rb +2 -2
- metadata +4 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25012d48eb0b25351374c35d3dd36775c47ba3ef
|
4
|
+
data.tar.gz: c9e483a9bdc6847023e50588bfc9d6dc666bd6fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b37cb7167f99eb7f43c4b0489384362d5fe4f2190013be3d4dd0ff2ee12a41f78f895a49ae5d33656bac78934278036860c287a2fb1abbf0afa6bd3832394736
|
7
|
+
data.tar.gz: f5a706cdb0e36c1b0ad6ec16cbba97dbf2bc6cf696793706941804b7c05e52d55a2e4271176d90245078f586d94ad2843ae7f55c5d4fd76769c832f866fc769c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
�}~�EּTuZ4�@�eH��.p>Ώ\ơ���爥 Y�UE�q�:<vԜ
|
1
|
+
����p�jf���5z�<����{�e� c�Q�D2��_C���g�)�xew�7~M�}��D�Tg��yY��ŦE���9]��%�ή����!�N�q(�� f|�E�
|
data/app/app_delegate.rb
CHANGED
@@ -8,10 +8,14 @@ class AppDelegate
|
|
8
8
|
@window.rootViewController = @controller
|
9
9
|
@window.makeKeyAndVisible
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
@label = UILabel.alloc.initWithFrame [ [10,10], [300,100] ]
|
12
|
+
@label.setAccessibilityLabel 'location'
|
13
|
+
@label.setText '...'
|
14
|
+
@controller.view.addSubview @label
|
15
|
+
|
16
|
+
Locomotion.watch purpose: 'Testing...' do |location|
|
17
|
+
@label.setText "#{location.latitude},#{location.longitude}"
|
18
|
+
end
|
15
19
|
|
16
20
|
true
|
17
21
|
end
|
data/lib/locomotion/version.rb
CHANGED
@@ -12,7 +12,9 @@ module Locomotion
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def locationManager manager, didUpdateLocations: locations
|
15
|
-
|
15
|
+
locations.each do |location|
|
16
|
+
@watchman.update location
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
def locationManager manager, didFailWithError: error
|
@@ -36,5 +38,9 @@ module Locomotion
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
41
|
+
def locationManager manager, didFinishDeferredUpdatesWithError: error
|
42
|
+
@watchman.error :deferred_fail
|
43
|
+
end
|
44
|
+
|
39
45
|
end
|
40
46
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Locomotion
|
2
|
+
class Location
|
3
|
+
|
4
|
+
def init(original)
|
5
|
+
@original = original
|
6
|
+
self
|
7
|
+
end
|
8
|
+
|
9
|
+
def latitude
|
10
|
+
@original.coordinate.latitude
|
11
|
+
end
|
12
|
+
|
13
|
+
def longitude
|
14
|
+
@original.coordinate.longitude
|
15
|
+
end
|
16
|
+
|
17
|
+
def speed
|
18
|
+
@original.speed
|
19
|
+
end
|
20
|
+
|
21
|
+
def heading
|
22
|
+
@original.course
|
23
|
+
end
|
24
|
+
|
25
|
+
def time
|
26
|
+
@original.timestamp
|
27
|
+
end
|
28
|
+
|
29
|
+
def accuracy
|
30
|
+
@original.horizontalAccuracy
|
31
|
+
end
|
32
|
+
|
33
|
+
def inspect
|
34
|
+
"<Location #{latitude} #{longitude} >"
|
35
|
+
end
|
36
|
+
alias :to_s :inspect
|
37
|
+
end
|
38
|
+
end
|
@@ -2,8 +2,9 @@ module Locomotion
|
|
2
2
|
class Watchman
|
3
3
|
|
4
4
|
def init location_manager = CLLocationManager
|
5
|
+
@delegate = Locomotion::Delegate.alloc.initWith(self)
|
5
6
|
@location_manager = location_manager.alloc.init
|
6
|
-
@location_manager.delegate =
|
7
|
+
@location_manager.delegate = @delegate
|
7
8
|
@location_manager.distanceFilter = KCLDistanceFilterNone
|
8
9
|
@location_manager.desiredAccuracy = KCLLocationAccuracyBest
|
9
10
|
self
|
@@ -32,7 +33,7 @@ module Locomotion
|
|
32
33
|
|
33
34
|
def update location
|
34
35
|
@listeners.each do |listener|
|
35
|
-
listener.call location
|
36
|
+
listener.call Location.alloc.init(location)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
describe 'integration into an app' do
|
2
|
+
extend Bacon::Functional::API
|
3
|
+
|
4
|
+
before do
|
5
|
+
self.window = UIApplication.sharedApplication.keyWindow
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'updates the location label' do
|
9
|
+
view('location').should.satisfy { |label| label.text =~ /-?\d+\.\d+,-?\d+\.\d+/ }
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -23,7 +23,7 @@ describe 'he who watches the watchman (the delegate)' do
|
|
23
23
|
|
24
24
|
it 'handles didUpdateLocations' do
|
25
25
|
@delegate.locationManager nil, didUpdateLocations: [1,2]
|
26
|
-
@watchman.locations.should.equal [2]
|
26
|
+
@watchman.locations.should.equal [1,2]
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'handles didFailWithError: KCLErrorDenied by notifying the watchman' do
|
@@ -66,4 +66,9 @@ describe 'he who watches the watchman (the delegate)' do
|
|
66
66
|
@delegate.locationManager nil, didChangeAuthorizationStatus: nil
|
67
67
|
@watchman.errors.should.equal nil
|
68
68
|
end
|
69
|
+
|
70
|
+
it 'handles failure of deferred updates' do
|
71
|
+
@delegate.locationManager nil, didFinishDeferredUpdatesWithError: 'an_error'
|
72
|
+
@watchman.errors.should.equal [:deferred_fail]
|
73
|
+
end
|
69
74
|
end
|
@@ -58,8 +58,8 @@ describe 'the watchman' do
|
|
58
58
|
|
59
59
|
it 'tells listeners on update' do
|
60
60
|
@watchman.listeners << proc { |location| @location = location }
|
61
|
-
@watchman.update
|
62
|
-
@location.should.
|
61
|
+
@watchman.update CLLocation.alloc.initWithLatitude 1, longitude: 1
|
62
|
+
@location.should.satisfy { |l| l.latitude == 1 && l.longitude == 1 }
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Rowe
|
@@ -77,7 +77,9 @@ files:
|
|
77
77
|
- locomotion.gemspec
|
78
78
|
- motion/locomotion.rb
|
79
79
|
- motion/locomotion/delegate.rb
|
80
|
+
- motion/locomotion/location.rb
|
80
81
|
- motion/locomotion/watchman.rb
|
82
|
+
- spec/integration_spec.rb
|
81
83
|
- spec/locomotion/delegate_spec.rb
|
82
84
|
- spec/locomotion/watchman_spec.rb
|
83
85
|
homepage: https://github.com/JonRowe/locomotion
|
@@ -106,5 +108,6 @@ specification_version: 4
|
|
106
108
|
summary: Geolocation library for RubyMotion
|
107
109
|
test_files:
|
108
110
|
- app/app_delegate.rb
|
111
|
+
- spec/integration_spec.rb
|
109
112
|
- spec/locomotion/delegate_spec.rb
|
110
113
|
- spec/locomotion/watchman_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|