git-fit 0.17.1 → 0.17.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.
- checksums.yaml +4 -4
- data/lib/git_fit/source/keep.rb +9 -0
- data/lib/git_fit/sync/keep.rb +12 -3
- data/lib/git_fit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 472d41138e7c8607cbc63dbff14db13079b6b824c342ec03661696c77f08f8f9
|
|
4
|
+
data.tar.gz: 291394e38307334eaedd49106b5c6c057331d972ccf4fa2619ce68904ca89a86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f7e4971cc16db4f139ae122a65fe19842bfd1e999362bfc57294e4fa2b41a3adbd228824e9126b13a13fc2499643dec07ad195e1d6050618137a54f12b34a48
|
|
7
|
+
data.tar.gz: 713ff0444661494cb22469f5f3535de7b20f89229ec82b5db07398654b6cd2622267db18a0d1841517f796a351bbc1d29800d79b53469009454532dba855b61e
|
data/lib/git_fit/source/keep.rb
CHANGED
|
@@ -39,6 +39,15 @@ module GitFit
|
|
|
39
39
|
nil
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
def decode_step_data(step_data)
|
|
43
|
+
return nil unless step_data
|
|
44
|
+
raw = Base64.decode64(step_data)
|
|
45
|
+
decompressed = zlib_inflate(raw)
|
|
46
|
+
JSON.parse(decompressed)
|
|
47
|
+
rescue StandardError
|
|
48
|
+
nil
|
|
49
|
+
end
|
|
50
|
+
|
|
42
51
|
def aes_decrypt(data)
|
|
43
52
|
cipher = OpenSSL::Cipher.new('AES-128-CBC')
|
|
44
53
|
cipher.decrypt
|
data/lib/git_fit/sync/keep.rb
CHANGED
|
@@ -14,6 +14,8 @@ module GitFit
|
|
|
14
14
|
KEEP_TYPES = %w[running hiking cycling].freeze
|
|
15
15
|
KEEP_RAW_EXT = 'json'
|
|
16
16
|
|
|
17
|
+
STEP_ENCODED_FIELDS = %w[stepPoints stepFrequencies fullStepPoints].freeze
|
|
18
|
+
|
|
17
19
|
TYPE_MAP = {
|
|
18
20
|
'outdoorWalking' => 'walk',
|
|
19
21
|
'outdoorRunning' => 'run',
|
|
@@ -208,9 +210,16 @@ module GitFit
|
|
|
208
210
|
raw = run_data.dup
|
|
209
211
|
if raw['heartRate'].is_a?(Hash)
|
|
210
212
|
raw['heartRate'] = raw['heartRate'].dup
|
|
211
|
-
raw['heartRate'].
|
|
213
|
+
raw['heartRate']['heartRates'] = nil if raw['heartRate'].key?('heartRates')
|
|
214
|
+
end
|
|
215
|
+
raw['geoPoints'] = nil if raw.key?('geoPoints')
|
|
216
|
+
|
|
217
|
+
decoded_steps = {}
|
|
218
|
+
STEP_ENCODED_FIELDS.each do |field|
|
|
219
|
+
next unless raw.key?(field)
|
|
220
|
+
decoded_steps[field] = Source::Keep.decode_step_data(raw[field])
|
|
221
|
+
raw[field] = nil
|
|
212
222
|
end
|
|
213
|
-
raw.delete('geoPoints')
|
|
214
223
|
|
|
215
224
|
write_source_archive({
|
|
216
225
|
archiveVersion: 0,
|
|
@@ -219,7 +228,7 @@ module GitFit
|
|
|
219
228
|
raw: raw,
|
|
220
229
|
geoPoints: payload[:geo_points],
|
|
221
230
|
heartRates: payload[:hr_data],
|
|
222
|
-
}, keep_id)
|
|
231
|
+
}.merge(decoded_steps), keep_id)
|
|
223
232
|
|
|
224
233
|
wgs_points = Source::Keep.compute_wgs_points(payload, run_data)
|
|
225
234
|
write_standardized_json(wgs_points, payload, run_data, keep_id)
|
data/lib/git_fit/version.rb
CHANGED