motion-locman 0.2.1 → 0.2.2

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/locman/manager.rb +41 -26
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a471be877d5f63dc159d4157779aaa13ff44a2ca
4
- data.tar.gz: e67b3d70e0ccb082c173cdb7ea0970373bd0c407
3
+ metadata.gz: af0bf82467a15916079ca51b798fbcb64b7e06a3
4
+ data.tar.gz: 3593a8592a8283482837e52fd76830c59ddfbf8c
5
5
  SHA512:
6
- metadata.gz: 00ddf7e6bdcc0a8fdd7e4b45fa640e7023bebaa8692dc84d510c8e3980511b807404216a2ab85ea511c8a90d886679890c0ec5bc354da07f59f543803b0e2a0d
7
- data.tar.gz: c1d42908dfc8753137d0a93ddb67150517befda8b054e981fbacb90bab292e50e6cd5bb0908b1ee0aedb289d5c892d08aad0fd656b636f5c5ad0e698cf1bf41b
6
+ metadata.gz: 154a8c729e25fd5189b04520202cba127c9a9fd4a1c00bf9ba205c3459c63395f42a5d2eafa723ba1f036c8998051f4890b9be3017dc868f4a335fd069bac2aa
7
+ data.tar.gz: bc937de27c597ea5329a2fe52510c096c0940bb62cb61c6a06ad373902988aa5faf6ff28e6eb414fd03f8ebb7758b223379a406d635bcc972eb682a6f439a977
@@ -7,6 +7,9 @@ module Locman
7
7
  # @return [Integer] The minimum horizontal distance threshold for on_update event.
8
8
  attr_accessor :distance_filter
9
9
 
10
+ # @return [Boolean] Set whether location should be updated in the background or not.
11
+ attr_accessor :background
12
+
10
13
  # @return [Proc] Proc function that will be called when there is a new location retrieval.
11
14
  attr_accessor :on_update
12
15
 
@@ -56,9 +59,46 @@ module Locman
56
59
  # @param accuracy [Symbol] Desired accuracy of the location data.
57
60
  def accuracy=(accuracy)
58
61
  fail(ArgumentError, "Invalid accuracy: #{accuracy}") if ACCURACY_MAP[accuracy].nil?
62
+ manager.desiredAccuracy = ACCURACY_MAP[accuracy]
59
63
  @accuracy = accuracy
60
64
  end
61
65
 
66
+ def distance_filter=(distance_filter)
67
+ fail(ArgumentError, "Distance filter should be integer") unless distance_filter.is_a?(Integer)
68
+ manager.distanceFilter = distance_filter
69
+ @distance_filter = distance_filter
70
+ end
71
+
72
+ # Sets whether location should be updated on the background or not.
73
+ def background=(background)
74
+ if !background.is_a?(TrueClass) || !background.is_a?(FalseClass)
75
+ fail(ArgumentError, "Background should be boolean")
76
+ end
77
+
78
+ manager.allowsBackgroundLocationUpdates = background
79
+ @background = background
80
+ end
81
+
82
+ def after_authorize=(after_authorize)
83
+ fail(ArgumentError, "Must provide proc") unless after_authorize.is_a?(Proc)
84
+ @after_authorize = after_authorize
85
+ end
86
+
87
+ def on_update=(on_update)
88
+ fail(ArgumentError, "Must provide proc") unless on_update.is_a?(Proc)
89
+ @on_update = on_update
90
+ end
91
+
92
+ def on_error=(on_error)
93
+ fail(ArgumentError, "Must provide proc") unless on_error.is_a?(Proc)
94
+ @on_error = on_error
95
+ end
96
+
97
+ def on_visit=(on_visit)
98
+ fail(ArgumentError, "Must provide proc") unless on_visit.is_a?(Proc)
99
+ @on_visit = on_visit
100
+ end
101
+
62
102
  def authorize!
63
103
  return true unless CLLocationManager.authorizationStatus == KCLAuthorizationStatusNotDetermined
64
104
  manager.requestAlwaysAuthorization
@@ -76,21 +116,11 @@ module Locman
76
116
  nil
77
117
  end
78
118
 
79
- def after_authorize=(after_authorize)
80
- fail(ArgumentError, "Must provide proc") unless after_authorize.is_a?(Proc)
81
- @after_authorize = after_authorize
82
- end
83
-
84
- def start!(params = {})
85
- params[:background] ||= false
86
-
119
+ def start!
87
120
  if CLLocationManager.authorizationStatus != KCLAuthorizationStatusAuthorized
88
121
  fail(Exception, "Location permission is not authorized by user")
89
122
  end
90
123
 
91
- manager.desiredAccuracy = ACCURACY_MAP[@accuracy]
92
- manager.distanceFilter = @distance_filter
93
- manager.allowsBackgroundLocationUpdates = true if params[:background]
94
124
  manager.startUpdatingLocation
95
125
  end
96
126
 
@@ -114,21 +144,6 @@ module Locman
114
144
  manager.stopMonitoringSignificantLocationChanges
115
145
  end
116
146
 
117
- def on_update=(on_update)
118
- fail(ArgumentError, "Must provide proc") unless on_update.is_a?(Proc)
119
- @on_update = on_update
120
- end
121
-
122
- def on_error=(on_error)
123
- fail(ArgumentError, "Must provide proc") unless on_error.is_a?(Proc)
124
- @on_error = on_error
125
- end
126
-
127
- def on_visit=(on_visit)
128
- fail(ArgumentError, "Must provide proc") unless on_visit.is_a?(Proc)
129
- @on_visit = on_visit
130
- end
131
-
132
147
  # Delegates
133
148
 
134
149
  def locationManager(manager, didChangeAuthorizationStatus: status)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-locman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minku Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake