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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 180738dbb15f07ef04165d0a3dc899ac85294e17
4
- data.tar.gz: 9a92d1f757b4557bd03d8717386caa95419cc427
3
+ metadata.gz: 25012d48eb0b25351374c35d3dd36775c47ba3ef
4
+ data.tar.gz: c9e483a9bdc6847023e50588bfc9d6dc666bd6fa
5
5
  SHA512:
6
- metadata.gz: 5221aa2bf7100b699ddaf0231f9a4f20d204533f3d7272df269390944cc2ff90993f1151a8c5a04e51ff582d6c448dd5a0a78793597904c6ffabfc85d5eab901
7
- data.tar.gz: f5b6459b9d0a58f75e89660bef2f641a69c365b7fbb20a8ebb851888f2815e459fafc87a1243f74a67ab78dd2c005593a3276dadeea218870b6b4445d3bda89d
6
+ metadata.gz: b37cb7167f99eb7f43c4b0489384362d5fe4f2190013be3d4dd0ff2ee12a41f78f895a49ae5d33656bac78934278036860c287a2fb1abbf0afa6bd3832394736
7
+ data.tar.gz: f5a706cdb0e36c1b0ad6ec16cbba97dbf2bc6cf696793706941804b7c05e52d55a2e4271176d90245078f586d94ad2843ae7f55c5d4fd76769c832f866fc769c
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- X0)v}���Mr�O����8�5D�'��[�銱n̎K�<�#�Zӫ�z�wȷ{��y�����}�@g�XV��<\b ƚl��&N7�F��0#�\1MBڸ���PA>h���%��&������}�9M�)��ƒYmg���f�h�<xIx�*PeaS��߄��;? �a�
2
- �}~�EּTuZ4� @�eH��.p>Ώ\ơ���爥 Y�UE�q�:<vԜ
1
+ ����p�jf���5z�<����{�e� cQD2��_C���g�)xew7~M�}��DTg��yY��ŦE���9]��%�ή����!�N�q(�� f|�E
@@ -8,10 +8,14 @@ class AppDelegate
8
8
  @window.rootViewController = @controller
9
9
  @window.makeKeyAndVisible
10
10
 
11
- #@label = UILabel.alloc.initWithFrame [ [10,10], [300,100] ]
12
- #@label.setAccessibilityLabel 'username'
13
- #@label.setText '...'
14
- #@controller.view.addSubview @label
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
@@ -1,3 +1,3 @@
1
1
  module Locomotion
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -12,7 +12,9 @@ module Locomotion
12
12
  end
13
13
 
14
14
  def locationManager manager, didUpdateLocations: locations
15
- @watchman.update locations[-1]
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 = Locomotion::Delegate.alloc.initWith(self)
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 [1,1]
62
- @location.should.equal [1,1]
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.1
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