git-fit 0.10.5 → 0.10.6
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.rb +1 -0
- data/lib/git_fit/dedup/trajectory.rb +2 -14
- data/lib/git_fit/export/gpx.rb +2 -2
- data/lib/git_fit/import/local_file.rb +3 -2
- data/lib/git_fit/std/resolver.rb +32 -0
- data/lib/git_fit/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 529a74a588a51b0b04ba1a0e15e629425dec93dd79986c6e6f45a0eda35d5914
|
|
4
|
+
data.tar.gz: 37a81d2e9285b8917c13b36eb343d3b97de27709cf1d71a094216c7a645b3168
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ecb103ba98d635affa43058a695811d061d8be767754e3012efb23aa3a7eb4a85b5ab6041c371da1371fab1afc31100f94f8cf77e11a21ec900b38be29a3dcf
|
|
7
|
+
data.tar.gz: 27610f67729cf037ac1a05772103abcc0899de47a484b929d4d62a4f34184c23921245c84f62ea308861ffa62c4e520e0d39223ecb8908e0c36966e0f6825d6c
|
data/lib/git-fit.rb
CHANGED
|
@@ -58,6 +58,7 @@ require_relative 'git_fit/timezone/resolver'
|
|
|
58
58
|
require_relative 'git_fit/privacy/polyline_filter'
|
|
59
59
|
require_relative 'git_fit/import'
|
|
60
60
|
require_relative 'git_fit/sync/base'
|
|
61
|
+
require_relative 'git_fit/std/resolver'
|
|
61
62
|
require_relative 'git_fit/util'
|
|
62
63
|
require_relative 'git_fit/sync/lorem'
|
|
63
64
|
require_relative 'git_fit/sync/garmin_base'
|
|
@@ -168,13 +168,8 @@ module GitFit
|
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
def load_std_points(run_id)
|
|
171
|
-
|
|
172
|
-
return nil unless
|
|
173
|
-
|
|
174
|
-
std_dir = File.join('data', 'std', source)
|
|
175
|
-
id = run_id.sub("#{source}_", '')
|
|
176
|
-
path = Dir.glob(File.join(std_dir, "#{id}.*")).first
|
|
177
|
-
return nil unless path && File.exist?(path)
|
|
171
|
+
path = GitFit::Std::Resolver.find(run_id)
|
|
172
|
+
return nil unless path
|
|
178
173
|
|
|
179
174
|
data = JSON.parse(File.read(path))
|
|
180
175
|
return data if data.is_a?(Array) && data.first.is_a?(Hash)
|
|
@@ -191,13 +186,6 @@ module GitFit
|
|
|
191
186
|
polyline
|
|
192
187
|
end
|
|
193
188
|
|
|
194
|
-
def source_from_run_id(run_id)
|
|
195
|
-
%w[garmin_cn garmin strava keep igpsport xoss xingzhe].each do |s|
|
|
196
|
-
return s if run_id.start_with?("#{s}_")
|
|
197
|
-
end
|
|
198
|
-
nil
|
|
199
|
-
end
|
|
200
|
-
|
|
201
189
|
def near(pt, candidates)
|
|
202
190
|
lat = pt['latitude'] || pt['positionLat'] || pt[:latitude] || pt[:positionLat]
|
|
203
191
|
lng = pt['longitude'] || pt['positionLong'] || pt[:longitude] || pt[:positionLong]
|
data/lib/git_fit/export/gpx.rb
CHANGED
|
@@ -79,8 +79,8 @@ module GitFit
|
|
|
79
79
|
def l2_points(activity)
|
|
80
80
|
return nil unless activity[:source]
|
|
81
81
|
|
|
82
|
-
path =
|
|
83
|
-
return nil unless
|
|
82
|
+
path = GitFit::Std::Resolver.find(activity[:run_id].to_s)
|
|
83
|
+
return nil unless path
|
|
84
84
|
|
|
85
85
|
records = ::JSON.parse(File.read(path))
|
|
86
86
|
return nil if records.empty?
|
|
@@ -124,8 +124,9 @@ module GitFit
|
|
|
124
124
|
h[:heart_rate] = pt[4] if pt[4]
|
|
125
125
|
h
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
natural_id = activity[:run_id].sub("#{source}_", '')
|
|
128
|
+
std_tmp = File.join(std_source_dir, ".#{natural_id}.json.tmp")
|
|
129
|
+
std_final = File.join(std_source_dir, "#{natural_id}.json")
|
|
129
130
|
File.write(std_tmp, JSON.generate(std_data))
|
|
130
131
|
File.rename(std_tmp, std_final)
|
|
131
132
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GitFit
|
|
4
|
+
module Std
|
|
5
|
+
module Resolver
|
|
6
|
+
# garmin_cn 必须排在 garmin 前面:"garmin_cn_7".start_with?("garmin_") == true
|
|
7
|
+
SOURCE_PREFIXES = %w[
|
|
8
|
+
garmin_cn garmin strava keep igpsport xoss xingzhe
|
|
9
|
+
apple_health gpx fit tcx
|
|
10
|
+
].freeze
|
|
11
|
+
|
|
12
|
+
# 从 run_id 解构出 [source, natural_id]
|
|
13
|
+
# natural_id = platform_id(sync)或内容哈希(local)
|
|
14
|
+
def self.decompose(run_id)
|
|
15
|
+
SOURCE_PREFIXES.each do |s|
|
|
16
|
+
prefix = "#{s}_"
|
|
17
|
+
return [s, run_id.sub(prefix, '')] if run_id.start_with?(prefix)
|
|
18
|
+
end
|
|
19
|
+
[nil, nil]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [String, nil] std 文件路径(相对 cwd),找不到返回 nil
|
|
23
|
+
def self.find(run_id)
|
|
24
|
+
source, natural_id = decompose(run_id)
|
|
25
|
+
return nil unless source
|
|
26
|
+
|
|
27
|
+
path = File.join('data', 'std', source, "#{natural_id}.json")
|
|
28
|
+
path if File.exist?(path)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/git_fit/version.rb
CHANGED
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.10.
|
|
4
|
+
version: 0.10.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lax
|
|
@@ -288,6 +288,7 @@ files:
|
|
|
288
288
|
- lib/git_fit/source/keep.rb
|
|
289
289
|
- lib/git_fit/source/tally.rb
|
|
290
290
|
- lib/git_fit/sport_mapper.rb
|
|
291
|
+
- lib/git_fit/std/resolver.rb
|
|
291
292
|
- lib/git_fit/strava_web/file_check.rb
|
|
292
293
|
- lib/git_fit/sync/base.rb
|
|
293
294
|
- lib/git_fit/sync/garmin.rb
|