git-fit 0.13.0 → 0.13.1

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: 982b74047f07432a6d3383f54f53b9d585d459465140d7a35fd52dbc23589372
4
+ data.tar.gz: a8ee0897607fdf8b1f6951e4f601d423f15dcfdbdcbed4b928be8d04ffc4d893
5
5
  SHA512:
6
- metadata.gz: 926a648129246714657066e5d7a21b9663682af63516a98d21646e9c58167b4c962150697a8d1d9e14068c834d1d010f9d3696628f8edae9b6ee8f2c614d36cc
7
- data.tar.gz: 7bebd70ae9b51e18fc97278f7e691466ea5ca4aec07594c83bc7ca2c9ff913f85566dcf9b98b6013a279a3c2927216fd60ad82d860d8185b8fb133a873fbc5fe
6
+ metadata.gz: 1fc55f0b434a310a583ff62c39c27927ed2f82c65c1f6f5e646a6b605b85f559cdf01177d7fe9dbcd35b98e2b5d3cda7456b4adb1f4a3427b59d6a22c7d64dc8
7
+ data.tar.gz: 99cde1f2fac8ab122f76405686e04da91a93c404bc41667b8368371bf8c23724deba5adf669aa4cb569d451b3403e0fabd3a009b06cabd63651b6c76e90daeb5
@@ -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"
@@ -16,7 +16,7 @@ module GitFit
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
@@ -199,7 +199,7 @@ module GitFit
199
199
  end
200
200
 
201
201
  def save_secret_to_config
202
- path = @config['config_path'] || 'config/config.yml'
202
+ path = @config['config_path'] || GitFit::Config.default_path
203
203
  return unless File.exist?(path)
204
204
 
205
205
  cfg = YAML.safe_load(File.read(path)) || {}
@@ -477,7 +477,7 @@ module GitFit
477
477
  end
478
478
 
479
479
  def reauth_hint
480
- "Re-auth: set sync.#{source_prefix}.secret in config/config.yml"
480
+ "Re-auth: set sync.#{source_prefix}.secret in #{GitFit::Config.default_path}"
481
481
  end
482
482
 
483
483
  def build_attrs(detail, activity_id, type, polyline = nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitFit
4
- VERSION = '0.13.0'
4
+ VERSION = '0.13.1'
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.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lax