git-fit 0.24.0 → 0.24.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: 2be1dd5148fb72d95b76d20b31193422edbb0e8be620062a6d2c34d04f577aa0
4
- data.tar.gz: 2192297d4bce4c23cdd8f9420f9f21e37caa1c562fec5eb2f6abd1235fa7977e
3
+ metadata.gz: 03ca873b9ed2085415130819f206c4a374c481be9c4d4437fce418447e2bbe75
4
+ data.tar.gz: 891b392511c8d64435d62568b47ff51d9420e39503a7c05055892a9e83f40771
5
5
  SHA512:
6
- metadata.gz: f9156265923a164e1dd88e46d924c7d607a13027dfdcbb5c8206ae768d58f8c27c3ac09e462840c3968eb1cd152f473f0eb4462d484319ab349ec1d9e1573ead
7
- data.tar.gz: 998b8597afbea703c34761105394e64c3d8c76f75f4109e55a3a43c6b73073a75711d95a2876ab03a1cbff1c2606cc2cb6067d39b775ab049a71087bea9ed830
6
+ metadata.gz: 2b063e4faa22be8c5d25b511caa38d5bf39b7b7f1dad21f6299ed66799ea9b09d8a68709ee758c47ac6c85f8ccd57d70cd58ad80118a51d6ab81784f28e6f012
7
+ data.tar.gz: a25c1d3a2fb1d9f25a5bc24c280c02a8e9217ba81d27b876faaefb4576c3576bfa1a33ee56384b82252b3a74cd42360b3e041627253995b69f2511fbc9e8adcd
@@ -98,7 +98,7 @@ module GitFit
98
98
  data = parse_json(resp)
99
99
  return false unless resp.code.to_i == 200 && data.is_a?(Hash) && data['data'].is_a?(Hash)
100
100
 
101
- write_source_archive(data, pending[:id])
101
+ write_source_archive(data['data'], pending[:id])
102
102
  upsert_from_detail(pending[:id], data['data'])
103
103
  end
104
104
 
@@ -154,7 +154,7 @@ module GitFit
154
154
 
155
155
  def load_raw_activity(id)
156
156
  data = JSON.parse(File.read(raw_path(id)))
157
- detail = data['data']
157
+ detail = data['data'] || data
158
158
  return false unless detail.is_a?(Hash)
159
159
 
160
160
  upsert_from_detail(id, detail)
@@ -165,7 +165,7 @@ module GitFit
165
165
  return false unless attrs
166
166
 
167
167
  points = attrs.delete(:standard_points)
168
- write_std(points, log_id)
168
+ write_std(points, log_id) unless points.empty?
169
169
  upsert_activity(attrs)
170
170
  attrs
171
171
  end
@@ -177,7 +177,6 @@ module GitFit
177
177
  return nil unless start_time && moving_time.positive?
178
178
 
179
179
  points = standard_points(detail['points'])
180
- return nil if points.empty?
181
180
 
182
181
  hr_values = heart_rate_values(detail['heart_rate'])
183
182
  cadence_values = cadence_values(detail)
@@ -210,7 +209,15 @@ module GitFit
210
209
  end
211
210
 
212
211
  def point_attributes(points)
213
- return { summary_polyline: nil } if points.empty?
212
+ if points.empty?
213
+ return {
214
+ summary_polyline: nil,
215
+ elevation_gain: nil,
216
+ elevation_loss: nil,
217
+ elevation_min: nil,
218
+ elevation_max: nil,
219
+ }
220
+ end
214
221
 
215
222
  alts = points.filter_map { |point| numeric(point[:altitude]) }
216
223
  {
@@ -54,8 +54,10 @@ module GitFit
54
54
  return true if credentials_present?
55
55
  return false unless @interactive_auth
56
56
 
57
- @phone ||= prompt('Joyrun phone number: ')
58
- @sms_code ||= prompt('Joyrun SMS code: ')
57
+ @phone = prompt('Joyrun phone number: ') if @phone.empty?
58
+ @sms_code = prompt('Joyrun SMS code: ') if @sms_code.empty?
59
+ raise AuthError, 'Joyrun phone and SMS code are required' if @phone.empty? || @sms_code.empty?
60
+
59
61
  login_with_sms(@phone, @sms_code)
60
62
  end
61
63
 
@@ -105,7 +107,7 @@ module GitFit
105
107
  raise SyncError, sid_error_message unless sid_valid?(resp, data)
106
108
  return false unless data.is_a?(Hash) && data['runrecord'].is_a?(Hash)
107
109
 
108
- write_source_archive(data, pending[:id])
110
+ write_source_archive(data['runrecord'], pending[:id])
109
111
  upsert_from_detail(data['runrecord'])
110
112
  end
111
113
 
@@ -158,7 +160,7 @@ module GitFit
158
160
 
159
161
  def load_raw_activity(id)
160
162
  data = JSON.parse(File.read(raw_path(id)))
161
- record = data['runrecord']
163
+ record = data['runrecord'] || data
162
164
  return false unless record.is_a?(Hash)
163
165
 
164
166
  upsert_from_detail(record)
@@ -315,8 +317,12 @@ module GitFit
315
317
  end
316
318
 
317
319
  def prompt(label)
318
- warn label
319
- $stdin.gets.to_s.strip
320
+ $stderr.print(label)
321
+ $stderr.flush
322
+ input = $stdin.gets
323
+ raise AuthError, 'Joyrun auth requires phone and SMS code on stdin' if input.nil?
324
+
325
+ input.strip
320
326
  end
321
327
 
322
328
  def present_string(value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitFit
4
- VERSION = '0.24.0'
4
+ VERSION = '0.24.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.24.0
4
+ version: 0.24.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax