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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1091af70dde8e2b640208f49633b3572ddf64e41c5063ec4541349a873829988
4
- data.tar.gz: aa450db53cfe1eacc076d32f35c78da9bb0bfe86ab014d73554127d9467db876
3
+ metadata.gz: 472d41138e7c8607cbc63dbff14db13079b6b824c342ec03661696c77f08f8f9
4
+ data.tar.gz: 291394e38307334eaedd49106b5c6c057331d972ccf4fa2619ce68904ca89a86
5
5
  SHA512:
6
- metadata.gz: 122b1ecaac183df2215020f86fdd9f534aed6f356e9bee3e0e53c281f88a6d0c519007aa9809f89c99cfbaeb2e563c712b597065373280160f655188c633749a
7
- data.tar.gz: 5c4e2a6f3832390138c1d6ea4d96ede15e8119fb85d67829da6801b81ff0c810d1e42c072bfcd647586b67c5482ec7209168015d0c97bc870326a5b6302916e2
6
+ metadata.gz: 2f7e4971cc16db4f139ae122a65fe19842bfd1e999362bfc57294e4fa2b41a3adbd228824e9126b13a13fc2499643dec07ad195e1d6050618137a54f12b34a48
7
+ data.tar.gz: 713ff0444661494cb22469f5f3535de7b20f89229ec82b5db07398654b6cd2622267db18a0d1841517f796a351bbc1d29800d79b53469009454532dba855b61e
@@ -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
@@ -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'].delete('heartRates')
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitFit
4
- VERSION = '0.17.1'
4
+ VERSION = '0.17.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-fit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax