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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3e935c4e4949dfd80ef84c659f9f64a727d9c1d3aab7c2b6303d6571f42156b
4
- data.tar.gz: 771f645e5ae8a369c89237d3df03c00b06d5887f5331e7cfec306af0c57f8eb6
3
+ metadata.gz: def93fbb1103170a99f7a1a346e419c92bb147a1a6671a1a485248229a3b6178
4
+ data.tar.gz: e56db533020db64602a5b62a2d05b2d42f8e2115d0212425594136506668aac5
5
5
  SHA512:
6
- metadata.gz: 926a648129246714657066e5d7a21b9663682af63516a98d21646e9c58167b4c962150697a8d1d9e14068c834d1d010f9d3696628f8edae9b6ee8f2c614d36cc
7
- data.tar.gz: 7bebd70ae9b51e18fc97278f7e691466ea5ca4aec07594c83bc7ca2c9ff913f85566dcf9b98b6013a279a3c2927216fd60ad82d860d8185b8fb133a873fbc5fe
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
@@ -33,6 +33,7 @@ module GitFit
33
33
  average_heartrate: a[:average_heartrate],
34
34
  average_speed: a[:average_speed],
35
35
  elevation_gain: a[:elevation_gain],
36
+ elevation_loss: a[:elevation_loss],
36
37
  }
37
38
  end
38
39
 
@@ -178,7 +178,7 @@ module GitFit
178
178
  end
179
179
 
180
180
  def config_path
181
- File.expand_path(@options[:config] || 'config/config.yml')
181
+ File.expand_path(@options[:config] || GitFit::Config.default_path)
182
182
  end
183
183
 
184
184
  def garmin_cfg
@@ -149,7 +149,7 @@ module GitFit
149
149
  private
150
150
 
151
151
  def config_path
152
- File.expand_path(@options[:config] || 'config/config.yml')
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"># config/config.yml
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"
@@ -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 (config/config.yml):
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>"
@@ -62,7 +62,7 @@ module GitFit
62
62
  puts ''
63
63
  puts 'Local config:'
64
64
  puts " #{source}:"
65
- puts ' secret: (已自动写入 config/config.yml)'
65
+ puts " secret: (已自动写入 #{GitFit::Config.default_path})"
66
66
  end
67
67
  else
68
68
  say_status :error, 'Authentication failed', :red
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] || 'config/config.yml'
129
+ path = options[:output] || GitFit::Config.default_path
130
130
  FileUtils.mkdir_p(File.dirname(path))
131
131
 
132
132
  if File.exist?(path)
@@ -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
- load_file(DEFAULT_PATH) if !path && File.exist?(DEFAULT_PATH)
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,
@@ -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 source dedup_group_id
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)
@@ -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