git-fit 0.13.0 → 0.14.0
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/db/migrations/003_add_elevation_fields.rb +19 -0
- data/lib/git-fit.rb +1 -0
- data/lib/git_fit/auth/garmin.rb +1 -1
- data/lib/git_fit/auth/strava.rb +2 -2
- data/lib/git_fit/cli/strava.rb +2 -2
- data/lib/git_fit/cli/sync.rb +1 -1
- data/lib/git_fit/cli.rb +1 -1
- data/lib/git_fit/config.rb +8 -2
- data/lib/git_fit/dedup/field_elector.rb +4 -0
- data/lib/git_fit/export/csv.rb +2 -1
- data/lib/git_fit/export/json.rb +6 -1
- data/lib/git_fit/fit/decoder.js +1 -1
- data/lib/git_fit/fit/decoder.rb +6 -0
- data/lib/git_fit/import/apple_health.rb +36 -7
- data/lib/git_fit/import/tbulu.rb +2 -2
- data/lib/git_fit/parser/base.rb +26 -0
- data/lib/git_fit/parser/fit.rb +15 -2
- data/lib/git_fit/parser/gpx.rb +3 -0
- data/lib/git_fit/parser/tbulu.rb +8 -2
- data/lib/git_fit/parser/tcx.rb +6 -1
- data/lib/git_fit/sync/garmin_base.rb +6 -2
- data/lib/git_fit/sync/igpsport.rb +28 -2
- data/lib/git_fit/sync/keep.rb +24 -0
- data/lib/git_fit/sync/lorem.rb +12 -4
- data/lib/git_fit/sync/strava.rb +15 -2
- data/lib/git_fit/sync/xingzhe.rb +1 -0
- data/lib/git_fit/sync/xoss.rb +23 -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: def93fbb1103170a99f7a1a346e419c92bb147a1a6671a1a485248229a3b6178
|
|
4
|
+
data.tar.gz: e56db533020db64602a5b62a2d05b2d42f8e2115d0212425594136506668aac5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 844d55ba27a60361019e1ee0a26d37d378f777ba4cdcf5b9c6d7140da99f713e0d722d4171446a8a9b846d683145437e56681a3af56a3e1521c96c39446064d0
|
|
7
|
+
data.tar.gz: ea001dd780c5eb8134c7f0eefed75c917b05b7e63d99cf395a60f7241becde2041617821b4f319142c9e22ce534f568eaeaaab6e70b8fac04143375c582e2b06
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Sequel.migration do
|
|
2
|
+
up do
|
|
3
|
+
alter_table(:activities) do
|
|
4
|
+
add_column :elevation_loss, Float
|
|
5
|
+
add_column :elevation_min, Float
|
|
6
|
+
add_column :elevation_max, Float
|
|
7
|
+
add_column :steps, Integer
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
down do
|
|
12
|
+
alter_table(:activities) do
|
|
13
|
+
drop_column :steps
|
|
14
|
+
drop_column :elevation_max
|
|
15
|
+
drop_column :elevation_min
|
|
16
|
+
drop_column :elevation_loss
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/git-fit.rb
CHANGED
data/lib/git_fit/auth/garmin.rb
CHANGED
data/lib/git_fit/auth/strava.rb
CHANGED
|
@@ -149,7 +149,7 @@ module GitFit
|
|
|
149
149
|
private
|
|
150
150
|
|
|
151
151
|
def config_path
|
|
152
|
-
File.expand_path(@options[:config] ||
|
|
152
|
+
File.expand_path(@options[:config] || GitFit::Config.default_path)
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
def load_fresh_config
|
|
@@ -182,7 +182,7 @@ module GitFit
|
|
|
182
182
|
<li>填写 Application Name、Website(任意)、Authorization Callback Domain = <code>localhost</code></li>
|
|
183
183
|
<li>复制 Client ID 和 Client Secret</li></ol>
|
|
184
184
|
<p style="color:#aaa;font-size:0.85rem">配置后<b>刷新此页面</b>即可开始授权(无需重启)</p>
|
|
185
|
-
<div class="box">#
|
|
185
|
+
<div class="box"># #{GitFit::Config.default_path}
|
|
186
186
|
strava:
|
|
187
187
|
client_id: "your_client_id"
|
|
188
188
|
client_secret: "your_client_secret"
|
data/lib/git_fit/cli/strava.rb
CHANGED
|
@@ -10,13 +10,13 @@ module GitFit
|
|
|
10
10
|
class StravaCLI < Thor
|
|
11
11
|
VALID_FORMATS = %w[original tcx gpx].freeze
|
|
12
12
|
|
|
13
|
-
TOKEN_HELP = <<~HELP
|
|
13
|
+
TOKEN_HELP = <<~HELP.freeze
|
|
14
14
|
Token expired or invalid — generate a fresh one:
|
|
15
15
|
1. Open https://www.strava.com/login and sign in (email + OTP)
|
|
16
16
|
2. F12 → Application → Cookies → https://www.strava.com
|
|
17
17
|
3. Copy the Value of strava_remember_token
|
|
18
18
|
4. Configure it:
|
|
19
|
-
Local (
|
|
19
|
+
Local (#{GitFit::Config.default_path}):
|
|
20
20
|
sync.strava.web_auth.jwt: "<JWT>"
|
|
21
21
|
Env:
|
|
22
22
|
export GIT_FIT_STRAVA_WEB_AUTH_JWT="<JWT>"
|
data/lib/git_fit/cli/sync.rb
CHANGED
data/lib/git_fit/cli.rb
CHANGED
|
@@ -126,7 +126,7 @@ module GitFit
|
|
|
126
126
|
desc 'init', 'Generate config.yml'
|
|
127
127
|
option :output, type: :string, desc: 'Output path', aliases: '-o'
|
|
128
128
|
def init
|
|
129
|
-
path = options[:output] ||
|
|
129
|
+
path = options[:output] || GitFit::Config.default_path
|
|
130
130
|
FileUtils.mkdir_p(File.dirname(path))
|
|
131
131
|
|
|
132
132
|
if File.exist?(path)
|
data/lib/git_fit/config.rb
CHANGED
|
@@ -29,13 +29,19 @@ module GitFit
|
|
|
29
29
|
},
|
|
30
30
|
}.freeze
|
|
31
31
|
|
|
32
|
-
DEFAULT_PATH = 'config/config.yml'
|
|
33
32
|
KNOWN_TOP_KEYS = %w[database sync export privacy system].freeze
|
|
34
33
|
|
|
34
|
+
# Default config file path: GIT_FIT_CONFIG_PATH env override, else root config.yml.
|
|
35
|
+
def self.default_path
|
|
36
|
+
env = ENV['GIT_FIT_CONFIG_PATH'].to_s.strip
|
|
37
|
+
env.empty? ? 'config.yml' : env
|
|
38
|
+
end
|
|
39
|
+
|
|
35
40
|
def initialize(path = nil)
|
|
36
41
|
@data = deep_dup(DEFAULTS)
|
|
37
42
|
load_file(path) if path
|
|
38
|
-
|
|
43
|
+
default = self.class.default_path
|
|
44
|
+
load_file(default) if !path && File.exist?(default)
|
|
39
45
|
load_env
|
|
40
46
|
validate!
|
|
41
47
|
end
|
|
@@ -17,6 +17,10 @@ module GitFit
|
|
|
17
17
|
max_cadence: :non_null,
|
|
18
18
|
summary_polyline: :best_polyline,
|
|
19
19
|
elevation_gain: :median,
|
|
20
|
+
elevation_loss: :median,
|
|
21
|
+
elevation_min: :min,
|
|
22
|
+
elevation_max: :max,
|
|
23
|
+
steps: :median,
|
|
20
24
|
calories: :median,
|
|
21
25
|
average_temperature: :non_null,
|
|
22
26
|
average_speed: :computed,
|
data/lib/git_fit/export/csv.rb
CHANGED
|
@@ -11,7 +11,8 @@ module GitFit
|
|
|
11
11
|
location_country summary_polyline
|
|
12
12
|
average_heartrate max_heartrate average_cadence max_cadence
|
|
13
13
|
average_power max_power calories average_temperature
|
|
14
|
-
average_speed elevation_gain
|
|
14
|
+
average_speed elevation_gain elevation_loss elevation_min elevation_max
|
|
15
|
+
steps source dedup_group_id
|
|
15
16
|
].freeze
|
|
16
17
|
|
|
17
18
|
def initialize(db:, output:, activity_filter: nil)
|
data/lib/git_fit/export/json.rb
CHANGED
|
@@ -80,6 +80,10 @@ module GitFit
|
|
|
80
80
|
average_temperature: a[:average_temperature],
|
|
81
81
|
average_speed: a[:average_speed],
|
|
82
82
|
elevation_gain: a[:elevation_gain],
|
|
83
|
+
elevation_loss: a[:elevation_loss],
|
|
84
|
+
elevation_min: a[:elevation_min],
|
|
85
|
+
elevation_max: a[:elevation_max],
|
|
86
|
+
steps: a[:steps],
|
|
83
87
|
source: a[:source],
|
|
84
88
|
}
|
|
85
89
|
if a[:divisions]
|
|
@@ -103,7 +107,8 @@ module GitFit
|
|
|
103
107
|
result
|
|
104
108
|
else
|
|
105
109
|
composite = members.first&.slice(:run_id, :distance, :moving_time, :elapsed_time,
|
|
106
|
-
:average_heartrate, :max_heartrate, :elevation_gain,
|
|
110
|
+
:average_heartrate, :max_heartrate, :elevation_gain, :elevation_loss,
|
|
111
|
+
:elevation_min, :elevation_max, :steps,
|
|
107
112
|
:average_speed, :average_cadence, :max_cadence) || {}
|
|
108
113
|
composite[:summary_polyline] = pick_best_polyline(group_activities)
|
|
109
114
|
composite
|