git-fit 0.26.3 → 0.26.4

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: 2448b68c76af16677f97ce1d0dbc2393509841c3470af63f94e0c8e233a7dae0
4
- data.tar.gz: 1221a4adfe3ec1ae49325f9f1bb7c1897135fb6244a6f3d9ccdcbb5675889e8f
3
+ metadata.gz: 3cea1445cb1e525a1be8c8b814b7b3f69a27aac4e4e42411b5eb993227fef373
4
+ data.tar.gz: f672f8bfbded7feb9484dc8a214b945338c1a7c3136c1e80f539afe66bb1db0e
5
5
  SHA512:
6
- metadata.gz: 3d38b68ce8d2b7e042c88766b9dbdc4aa73b993038464c48037502f0ee1926f68107d70f5dd081dd4b62e3c5570984a43fa9fcb86731ba282793c97efa886818
7
- data.tar.gz: 3e9831435d92c93bb1c64833e3c3e363c3bb02418c7747b60670a055d23e193414c6fcead02559cbfed141da8ff7f05c82f161466d35443922531269454a7a22
6
+ metadata.gz: e051bd7d24a99544a65b6f537bfb5483980cc399a1977310383f5f3a6ed8c4381bfe3a6811b0de3dc359571f9128b093379b4cc8d4ad923b8252190c7a738fce
7
+ data.tar.gz: 493fa21dffeb7d8aed1039e3aad0eaee0c3a4c4774129fbedf4293962923fcd456715b900b21dd64e1eee8e9167660bddffc968bb99aa0d8628c637215ed4a14
@@ -160,6 +160,21 @@ module GitFit
160
160
  self.class.source_prefix
161
161
  end
162
162
 
163
+ # device_info messages → label of the recording device. Lookup order:
164
+ # GARMIN_PRODUCT_SUPPLEMENT (full display name) → garminProduct token
165
+ # ("Garmin Edge 540") → "Garmin <pk>" fallback (workouts#38/#59)
166
+ def self.device_label(infos)
167
+ info = infos.find { |d| d['deviceIndex'] == 'creator' } || infos.first
168
+ return nil unless info
169
+
170
+ supplement = GARMIN_PRODUCT_SUPPLEMENT[info['product']]
171
+ return supplement if supplement
172
+
173
+ return nil unless info['garminProduct']
174
+
175
+ format_garmin_device(info['garminProduct'])
176
+ end
177
+
163
178
  def self.format_garmin_device(token)
164
179
  # garminProduct token (e.g. "edge540") or unresolved numeric pk →
165
180
  # human label ("Garmin Edge 540" / "Garmin 3307")
@@ -690,6 +705,11 @@ module GitFit
690
705
  # Garmin FIT garminProduct token prefix → display prefix (unlisted → capitalize)
691
706
  GARMIN_DEVICE_PREFIXES = { 'fr' => 'Forerunner', 'hrm' => 'HRM' }.freeze
692
707
 
708
+ # Product pk → full display name for co-branded hardware missing from the
709
+ # bundled garminProduct profile; no "Garmin " prefix (Cannondale wheel
710
+ # sensor is Garmin-made but Cannondale-branded, workouts#59)
711
+ GARMIN_PRODUCT_SUPPLEMENT = { 3307 => 'Cannondale Wheel Sensor' }.freeze
712
+
693
713
  def raw_path(platform_id)
694
714
  File.join(raw_dir, platform_id, 'activity.fit')
695
715
  end
@@ -774,18 +794,14 @@ module GitFit
774
794
  false
775
795
  end
776
796
 
777
- # FIT device_info creator message "Garmin Edge 540"-style device label;
778
- # product ids missing from the bundled profile fall back to "Garmin <pk>"
779
- # (workouts#38 — Connect deviceTypePk has no public lookup table)
797
+ # FIT device_info → recording-device label (via self.class.device_label);
798
+ # product ids missing everywhere fall back to "Garmin <pk>" (workouts#38
799
+ # — Connect deviceTypePk has no public lookup table)
780
800
  def extract_device(activity_id)
781
801
  fit_path = raw_path(activity_id)
782
802
  return nil unless File.exist?(fit_path)
783
803
 
784
- infos = FIT::Decoder.device_info(fit_path)
785
- info = infos.find { |d| d['deviceIndex'] == 'creator' } || infos.first
786
- return nil unless info && info['garminProduct']
787
-
788
- self.class.format_garmin_device(info['garminProduct'])
804
+ self.class.device_label(FIT::Decoder.device_info(fit_path))
789
805
  rescue StandardError => e
790
806
  warn "Garmin: device_info decode failed for #{activity_id}: #{e.message}"
791
807
  nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitFit
4
- VERSION = '0.26.3'
4
+ VERSION = '0.26.4'
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.26.3
4
+ version: 0.26.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax