git-fit 0.7.9 → 0.8.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git-fit.rb +44 -42
  3. data/lib/git_fit/cli/export.rb +8 -6
  4. data/lib/git_fit/cli/geo_cli.rb +10 -8
  5. data/lib/git_fit/cli/gh_cli.rb +24 -22
  6. data/lib/git_fit/cli/import_cli.rb +40 -38
  7. data/lib/git_fit/cli/install_cli.rb +10 -8
  8. data/lib/git_fit/cli/sync.rb +9 -7
  9. data/lib/git_fit/cli.rb +29 -27
  10. data/lib/git_fit/config.rb +42 -28
  11. data/lib/git_fit/config_template.rb +2 -0
  12. data/lib/git_fit/db/activity.rb +2 -0
  13. data/lib/git_fit/db/cli.rb +11 -9
  14. data/lib/git_fit/db/connection.rb +8 -6
  15. data/lib/git_fit/db/rebuild.rb +5 -3
  16. data/lib/git_fit/export/defaults.rb +14 -12
  17. data/lib/git_fit/export/json.rb +5 -3
  18. data/lib/git_fit/export.rb +4 -2
  19. data/lib/git_fit/fit/decoder.rb +9 -7
  20. data/lib/git_fit/fit.rb +3 -1
  21. data/lib/git_fit/geo/amap_client.rb +15 -13
  22. data/lib/git_fit/geo/coord_transform.rb +2 -0
  23. data/lib/git_fit/geo/division_detector.rb +31 -26
  24. data/lib/git_fit/geo/nominatim_client.rb +14 -12
  25. data/lib/git_fit/geo/polyline.rb +4 -2
  26. data/lib/git_fit/geo/reverse_geocode.rb +11 -9
  27. data/lib/git_fit/geo.rb +8 -6
  28. data/lib/git_fit/import/apple_health.rb +84 -82
  29. data/lib/git_fit/import/local_file.rb +45 -42
  30. data/lib/git_fit/import.rb +4 -2
  31. data/lib/git_fit/install/actions.rb +15 -13
  32. data/lib/git_fit/parser/base.rb +12 -10
  33. data/lib/git_fit/parser/fit.rb +11 -9
  34. data/lib/git_fit/parser/gpx.rb +17 -15
  35. data/lib/git_fit/parser/tcx.rb +22 -20
  36. data/lib/git_fit/parser.rb +6 -4
  37. data/lib/git_fit/privacy/polyline_filter.rb +6 -4
  38. data/lib/git_fit/source/base.rb +25 -23
  39. data/lib/git_fit/source/tally.rb +9 -7
  40. data/lib/git_fit/source.rb +4 -2
  41. data/lib/git_fit/sport_mapper.rb +23 -21
  42. data/lib/git_fit/sync/base.rb +29 -27
  43. data/lib/git_fit/sync/garmin.rb +5 -3
  44. data/lib/git_fit/sync/garmin_base.rb +145 -143
  45. data/lib/git_fit/sync/garmin_base_di.rb +42 -40
  46. data/lib/git_fit/sync/garmin_cn.rb +8 -6
  47. data/lib/git_fit/sync/igpsport.rb +43 -41
  48. data/lib/git_fit/sync/keep.rb +98 -96
  49. data/lib/git_fit/sync/lorem.rb +31 -29
  50. data/lib/git_fit/sync/runner.rb +14 -11
  51. data/lib/git_fit/sync/strava.rb +61 -52
  52. data/lib/git_fit/sync/xingzhe.rb +52 -50
  53. data/lib/git_fit/sync/xoss.rb +68 -66
  54. data/lib/git_fit/timezone/resolver.rb +5 -3
  55. data/lib/git_fit/util/tally.rb +10 -8
  56. data/lib/git_fit/util.rb +2 -0
  57. data/lib/git_fit/version.rb +3 -1
  58. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b609e3146c751c1d1f0275272c827ad4c3eb42987459637bce681e04d310d217
4
- data.tar.gz: ce2f6508b97b28048a4c1927526a1f696b52b8c3e41cee1460f0ab2878fcf404
3
+ metadata.gz: fec2ac95bb7dbd444aef685e129221b5344838937449de995d6c1ef05315ed8a
4
+ data.tar.gz: 7cee0bbccf7ce0495f37f83bfa8e0c2b98f0c36009f43dea353b89d142d0ca00
5
5
  SHA512:
6
- metadata.gz: d9686284cf445f18846ff8615fc1ba1bba8a0367bd817cf11af250956591bd2b063c37e2c7682f12b968b4e2345353db2e6d70a99cb6c3efd3247310e836cad5
7
- data.tar.gz: a230f480415c37954d46958241dc9901de4c1b36cdc3a038a0bac959d0c988c9b5a0fec5e25d854c2f8affd389c7b949654db2c222890c675a492e9323344ced
6
+ metadata.gz: 452fedbcc1e11299532c15c57df405fdf49d95e75a4185727aaab4684d6a1cf69630210b22b9c6f67e1d907083139375fd5de87f45da4b55e2ccd882a6378b0e
7
+ data.tar.gz: 3c0d2f2fce0b7d79f2c47b859754a8ef54b2df09577fe191939b516488b285527db46b59e10b55109fcc4550bf217c445271898dfe4ad95e12d2ad17f2ba41c7
data/lib/git-fit.rb CHANGED
@@ -1,6 +1,8 @@
1
- require "thor"
2
- require "yaml"
3
- require "fileutils"
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'yaml'
5
+ require 'fileutils'
4
6
 
5
7
  module GitFit
6
8
  SPORT_CATEGORIES = %w[run ride hike walk swim ski workout other].freeze
@@ -30,7 +32,7 @@ module GitFit
30
32
  summary_polyline: a[:summary_polyline],
31
33
  average_heartrate: a[:average_heartrate],
32
34
  average_speed: a[:average_speed],
33
- elevation_gain: a[:elevation_gain]
35
+ elevation_gain: a[:elevation_gain],
34
36
  }
35
37
  end
36
38
 
@@ -39,45 +41,45 @@ module GitFit
39
41
  hours = seconds / 3600
40
42
  minutes = (seconds % 3600) / 60
41
43
  secs = seconds % 60
42
- format("%d:%02d:%02d", hours, minutes, secs)
44
+ format('%d:%02d:%02d', hours, minutes, secs)
43
45
  end
44
46
  end
45
47
  end
46
48
 
47
- require_relative "git_fit/version"
48
- require_relative "git_fit/config"
49
- require_relative "git_fit/config_template"
50
- require_relative "git_fit/sport_mapper"
51
- require_relative "git_fit/geo"
52
- require_relative "git_fit/fit"
53
- require_relative "git_fit/parser"
54
- require_relative "git_fit/source"
55
- require_relative "git_fit/timezone/resolver"
56
- require_relative "git_fit/privacy/polyline_filter"
57
- require_relative "git_fit/import"
58
- require_relative "git_fit/sync/base"
59
- require_relative "git_fit/util"
60
- require_relative "git_fit/sync/lorem"
61
- require_relative "git_fit/sync/garmin_base"
62
- require_relative "git_fit/sync/garmin_base_di"
63
- require_relative "git_fit/sync/garmin"
64
- require_relative "git_fit/sync/garmin_cn"
65
- require_relative "git_fit/sync/strava"
66
- require_relative "git_fit/sync/keep"
67
- require_relative "git_fit/sync/igpsport"
68
- require_relative "git_fit/sync/xoss"
69
- require_relative "git_fit/sync/xingzhe"
70
- require_relative "git_fit/sync/runner"
71
- require_relative "git_fit/cli/sync"
72
- require_relative "git_fit/db/rebuild"
73
- require_relative "git_fit/db/connection"
74
- require_relative "git_fit/db/activity"
75
- require_relative "git_fit/export"
76
- require_relative "git_fit/db/cli"
77
- require_relative "git_fit/install/actions"
78
- require_relative "git_fit/cli/install_cli"
79
- require_relative "git_fit/cli/gh_cli"
80
- require_relative "git_fit/cli/export"
81
- require_relative "git_fit/cli/import_cli"
82
- require_relative "git_fit/cli/geo_cli"
83
- require_relative "git_fit/cli"
49
+ require_relative 'git_fit/version'
50
+ require_relative 'git_fit/config'
51
+ require_relative 'git_fit/config_template'
52
+ require_relative 'git_fit/sport_mapper'
53
+ require_relative 'git_fit/geo'
54
+ require_relative 'git_fit/fit'
55
+ require_relative 'git_fit/parser'
56
+ require_relative 'git_fit/source'
57
+ require_relative 'git_fit/timezone/resolver'
58
+ require_relative 'git_fit/privacy/polyline_filter'
59
+ require_relative 'git_fit/import'
60
+ require_relative 'git_fit/sync/base'
61
+ require_relative 'git_fit/util'
62
+ require_relative 'git_fit/sync/lorem'
63
+ require_relative 'git_fit/sync/garmin_base'
64
+ require_relative 'git_fit/sync/garmin_base_di'
65
+ require_relative 'git_fit/sync/garmin'
66
+ require_relative 'git_fit/sync/garmin_cn'
67
+ require_relative 'git_fit/sync/strava'
68
+ require_relative 'git_fit/sync/keep'
69
+ require_relative 'git_fit/sync/igpsport'
70
+ require_relative 'git_fit/sync/xoss'
71
+ require_relative 'git_fit/sync/xingzhe'
72
+ require_relative 'git_fit/sync/runner'
73
+ require_relative 'git_fit/cli/sync'
74
+ require_relative 'git_fit/db/rebuild'
75
+ require_relative 'git_fit/db/connection'
76
+ require_relative 'git_fit/db/activity'
77
+ require_relative 'git_fit/export'
78
+ require_relative 'git_fit/db/cli'
79
+ require_relative 'git_fit/install/actions'
80
+ require_relative 'git_fit/cli/install_cli'
81
+ require_relative 'git_fit/cli/gh_cli'
82
+ require_relative 'git_fit/cli/export'
83
+ require_relative 'git_fit/cli/import_cli'
84
+ require_relative 'git_fit/cli/geo_cli'
85
+ require_relative 'git_fit/cli'
@@ -1,10 +1,12 @@
1
- require "thor"
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
2
4
 
3
5
  module GitFit
4
6
  class ExportCLI < Thor
5
- desc "json", "Export activities to JSON"
6
- option :output, type: :string, aliases: "-o", desc: "Output path"
7
- option :activity, type: :array, desc: "Filter by sport type", aliases: "--act"
7
+ desc 'json', 'Export activities to JSON'
8
+ option :output, type: :string, aliases: '-o', desc: 'Output path'
9
+ option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
8
10
  no_commands do
9
11
  def git_fit_config
10
12
  @git_fit_config ||= GitFit::Config.new(options[:config])
@@ -16,11 +18,11 @@ module GitFit
16
18
  conn = GitFit::DB::Connection.new(config.db_path)
17
19
  conn.migrate!
18
20
  db = conn.db
19
- path = options[:output] || config.export_config.dig("json", "path") || "site/activities.json"
21
+ path = options[:output] || config.export_config.dig('json', 'path') || 'site/activities.json'
20
22
  filter = options[:activity]&.map(&:strip)&.map(&:downcase)
21
23
  count = Export::JSON.new(db: db, output: path, activity_filter: filter).call
22
24
  say_status :done, "Exported #{count} activities to #{path}", :green
23
- rescue => e
25
+ rescue StandardError => e
24
26
  say_status :error, "JSON export failed: #{e.message}", :red
25
27
  end
26
28
  end
@@ -1,19 +1,21 @@
1
- require "thor"
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
2
4
 
3
5
  module GitFit
4
6
  class GeoCLI < Thor
5
- desc "detect", "Detect administrative divisions for activities with GPS data"
6
- option :limit, type: :numeric, aliases: "-l", desc: "Max activities to process"
7
- option :batch, type: :numeric, aliases: "-b", desc: "Batch size", default: 20
8
- option :strategy, type: :string, aliases: "-s", desc: "Strategy: proportional|start_end", default: "proportional"
9
- option :time, type: :numeric, aliases: "-t", desc: "Time budget in seconds"
7
+ desc 'detect', 'Detect administrative divisions for activities with GPS data'
8
+ option :limit, type: :numeric, aliases: '-l', desc: 'Max activities to process'
9
+ option :batch, type: :numeric, aliases: '-b', desc: 'Batch size', default: 20
10
+ option :strategy, type: :string, aliases: '-s', desc: 'Strategy: proportional|start_end', default: 'proportional'
11
+ option :time, type: :numeric, aliases: '-t', desc: 'Time budget in seconds'
10
12
  option :"dry-run", type: :boolean, desc: "Don't write to DB"
11
13
  def detect
12
14
  config = GitFit::Config.new
13
15
  conn = GitFit::DB::Connection.new(config.db_path)
14
16
  conn.migrate!
15
17
  db = conn.db
16
- amap_key = ENV["AMAP_API_KEY"] || config.sync_config("amap")["api_key"]
18
+ amap_key = ENV['AMAP_API_KEY'] || config.sync_config('amap')['api_key']
17
19
  detector = GitFit::Geo::DivisionDetector.new(
18
20
  db: db,
19
21
  amap_key: amap_key,
@@ -24,7 +26,7 @@ module GitFit
24
26
  dry_run: options[:"dry-run"],
25
27
  )
26
28
  detector.run
27
- rescue => e
29
+ rescue StandardError => e
28
30
  say_status :error, "Geo detection failed: #{e.message}", :red
29
31
  end
30
32
  end
@@ -1,16 +1,18 @@
1
- require "thor"
2
- require "open3"
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'open3'
3
5
 
4
6
  module GitFit
5
7
  module GhHelpers
6
8
  def detect_repo(url = nil)
7
9
  url ||= `git remote get-url origin`.chomp
8
- url.sub(%r{.*github\.com[:/]}, "").sub(/\.git$/, "")
10
+ url.sub(%r{.*github\.com[:/]}, '').sub(/\.git$/, '')
9
11
  end
10
12
 
11
13
  def gh(*args)
12
14
  repo = options[:repo] || detect_repo
13
- out, err, st = Open3.capture3("gh", *args.map(&:to_s), "-R", repo)
15
+ out, err, st = Open3.capture3('gh', *args.map(&:to_s), '-R', repo)
14
16
  raise "gh: #{err.strip}" unless st.success?
15
17
  out
16
18
  end
@@ -19,50 +21,50 @@ module GitFit
19
21
  class GhSecretCLI < Thor
20
22
  include GhHelpers
21
23
 
22
- class_option :repo, type: :string, desc: "GitHub repo (owner/repo)"
24
+ class_option :repo, type: :string, desc: 'GitHub repo (owner/repo)'
23
25
 
24
- desc "list", "List secrets"
26
+ desc 'list', 'List secrets'
25
27
  def list
26
- puts gh("secret", "list")
28
+ puts gh('secret', 'list')
27
29
  end
28
30
 
29
- desc "set KEY", "Set a secret (reads value from stdin or prompt)"
31
+ desc 'set KEY', 'Set a secret (reads value from stdin or prompt)'
30
32
  def set(key)
31
- puts gh("secret", "set", key)
33
+ puts gh('secret', 'set', key)
32
34
  end
33
35
 
34
- desc "delete KEY", "Delete a secret"
36
+ desc 'delete KEY', 'Delete a secret'
35
37
  def delete(key)
36
- puts gh("secret", "delete", key)
38
+ puts gh('secret', 'delete', key)
37
39
  end
38
40
  end
39
41
 
40
42
  class GhConfigCLI < Thor
41
43
  include GhHelpers
42
44
 
43
- class_option :repo, type: :string, desc: "GitHub repo (owner/repo)"
45
+ class_option :repo, type: :string, desc: 'GitHub repo (owner/repo)'
44
46
 
45
- desc "list", "List variables"
47
+ desc 'list', 'List variables'
46
48
  def list
47
- puts gh("variable", "list")
49
+ puts gh('variable', 'list')
48
50
  end
49
51
 
50
- desc "set KEY VALUE", "Set a variable"
52
+ desc 'set KEY VALUE', 'Set a variable'
51
53
  def set(key, value)
52
- puts gh("variable", "set", key, "--body", value)
54
+ puts gh('variable', 'set', key, '--body', value)
53
55
  end
54
56
 
55
- desc "get KEY", "Get a variable value"
57
+ desc 'get KEY', 'Get a variable value'
56
58
  def get(key)
57
- puts gh("variable", "get", key)
59
+ puts gh('variable', 'get', key)
58
60
  end
59
61
  end
60
62
 
61
63
  class GhCLI < Thor
62
- desc "secret SUBCOMMAND", "Manage GitHub Secrets"
63
- subcommand "secret", GhSecretCLI
64
+ desc 'secret SUBCOMMAND', 'Manage GitHub Secrets'
65
+ subcommand 'secret', GhSecretCLI
64
66
 
65
- desc "config SUBCOMMAND", "Manage GitHub Variables"
66
- subcommand "config", GhConfigCLI
67
+ desc 'config SUBCOMMAND', 'Manage GitHub Variables'
68
+ subcommand 'config', GhConfigCLI
67
69
  end
68
70
  end
@@ -1,16 +1,18 @@
1
- require "thor"
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
2
4
 
3
5
  module GitFit
4
6
  class ImportCLI < Thor
5
7
  FILE_SOURCES = %w[gpx fit tcx].freeze
6
8
 
7
- desc "all", "Import from all sources (gpx, fit, tcx)"
8
- option :source, type: :string, aliases: "-s",
9
- desc: "Import source(s) — comma-separated (default: gpx,fit,tcx)"
10
- option :activity, type: :array, desc: "Filter by sport type", aliases: "--act"
11
- option :sport, type: :string, desc: "Override sport_category for GPX files"
9
+ desc 'all', 'Import from all sources (gpx, fit, tcx)'
10
+ option :source, type: :string, aliases: '-s',
11
+ desc: 'Import source(s) — comma-separated (default: gpx,fit,tcx)'
12
+ option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
13
+ option :sport, type: :string, desc: 'Override sport_category for GPX files'
12
14
  def all
13
- sources = (options[:source] || "gpx,fit,tcx").split(",").map(&:strip).map(&:downcase)
15
+ sources = (options[:source] || 'gpx,fit,tcx').split(',').map(&:strip).map(&:downcase)
14
16
  unknown = sources.reject { |s| FILE_SOURCES.include?(s) }
15
17
  unless unknown.empty?
16
18
  say_status :error, "Unknown source(s): #{unknown.join(', ')}. Supported: gpx, fit, tcx", :red
@@ -22,7 +24,7 @@ module GitFit
22
24
  conn.migrate!
23
25
  db = conn.db
24
26
  filter = options[:activity]&.map(&:strip)&.map(&:downcase)
25
- time_budget = config.dig("sync", "time_budget")
27
+ time_budget = config.dig('sync', 'time_budget')
26
28
  sport_override = options[:sport]
27
29
 
28
30
  total = 0
@@ -37,12 +39,12 @@ module GitFit
37
39
  count = adapter.call
38
40
  say_status :done, "#{source}: #{count} activities", :green
39
41
  total += count
40
- rescue => e
42
+ rescue StandardError => e
41
43
  say_status :error, "#{source}: #{e.message}", :red
42
44
  end
43
45
 
44
46
  if total.zero?
45
- say_status :warn, "0 activities imported", :yellow
47
+ say_status :warn, '0 activities imported', :yellow
46
48
  else
47
49
  say_status :done, "Total: #{total} activities", :green
48
50
  end
@@ -50,113 +52,113 @@ module GitFit
50
52
 
51
53
  default_command :all
52
54
 
53
- desc "gpx", "Import GPX files from data/import/gpx/"
54
- option :activity, type: :array, desc: "Filter by sport type", aliases: "--act"
55
- option :sport, type: :string, desc: "Override sport_category for GPX files"
55
+ desc 'gpx', 'Import GPX files from data/import/gpx/'
56
+ option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
57
+ option :sport, type: :string, desc: 'Override sport_category for GPX files'
56
58
  def gpx
57
59
  config = GitFit::Config.new
58
60
  conn = GitFit::DB::Connection.new(config.db_path)
59
61
  conn.migrate!
60
62
  db = conn.db
61
63
  filter = options[:activity]&.map(&:strip)&.map(&:downcase)
62
- time_budget = config.dig("sync", "time_budget")
64
+ time_budget = config.dig('sync', 'time_budget')
63
65
  sport_override = options[:sport]
64
66
 
65
- say_status :import, "gpx", :green
67
+ say_status :import, 'gpx', :green
66
68
  adapter = GitFit::Import::LocalFile.new(
67
69
  config: {}, db:, activity_filter: filter,
68
70
  time_budget: time_budget,
69
- sources: ["gpx"],
71
+ sources: ['gpx'],
70
72
  sport_override: sport_override
71
73
  )
72
74
 
73
75
  begin
74
76
  count = adapter.call
75
77
  if count == 0
76
- say_status :warn, "gpx: 0 activities (already imported or none found)", :yellow
78
+ say_status :warn, 'gpx: 0 activities (already imported or none found)', :yellow
77
79
  else
78
80
  say_status :done, "gpx: #{count} activities", :green
79
81
  end
80
82
  count
81
- rescue => e
83
+ rescue StandardError => e
82
84
  say_status :error, "gpx: #{e.message}", :red
83
85
  0
84
86
  end
85
87
  end
86
88
 
87
- desc "tcx", "Import TCX files from data/import/tcx/"
88
- option :activity, type: :array, desc: "Filter by sport type", aliases: "--act"
89
+ desc 'tcx', 'Import TCX files from data/import/tcx/'
90
+ option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
89
91
  def tcx
90
92
  config = GitFit::Config.new
91
93
  conn = GitFit::DB::Connection.new(config.db_path)
92
94
  conn.migrate!
93
95
  db = conn.db
94
96
  filter = options[:activity]&.map(&:strip)&.map(&:downcase)
95
- time_budget = config.dig("sync", "time_budget")
97
+ time_budget = config.dig('sync', 'time_budget')
96
98
 
97
- say_status :import, "tcx", :green
99
+ say_status :import, 'tcx', :green
98
100
  adapter = GitFit::Import::LocalFile.new(
99
101
  config: {}, db:, activity_filter: filter,
100
102
  time_budget: time_budget,
101
- sources: ["tcx"]
103
+ sources: ['tcx']
102
104
  )
103
105
 
104
106
  begin
105
107
  count = adapter.call
106
108
  if count == 0
107
- say_status :warn, "tcx: 0 activities (already imported or none found)", :yellow
109
+ say_status :warn, 'tcx: 0 activities (already imported or none found)', :yellow
108
110
  else
109
111
  say_status :done, "tcx: #{count} activities", :green
110
112
  end
111
113
  count
112
- rescue => e
114
+ rescue StandardError => e
113
115
  say_status :error, "tcx: #{e.message}", :red
114
116
  0
115
117
  end
116
118
  end
117
119
 
118
- desc "fit", "Import FIT files from data/import/fit/"
119
- option :activity, type: :array, desc: "Filter by sport type", aliases: "--act"
120
+ desc 'fit', 'Import FIT files from data/import/fit/'
121
+ option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
120
122
  def fit
121
123
  config = GitFit::Config.new
122
124
  conn = GitFit::DB::Connection.new(config.db_path)
123
125
  conn.migrate!
124
126
  db = conn.db
125
127
  filter = options[:activity]&.map(&:strip)&.map(&:downcase)
126
- time_budget = config.dig("sync", "time_budget")
128
+ time_budget = config.dig('sync', 'time_budget')
127
129
 
128
- say_status :import, "fit", :green
130
+ say_status :import, 'fit', :green
129
131
  adapter = GitFit::Import::LocalFile.new(
130
132
  config: {}, db:, activity_filter: filter,
131
133
  time_budget: time_budget,
132
- sources: ["fit"]
134
+ sources: ['fit']
133
135
  )
134
136
 
135
137
  begin
136
138
  count = adapter.call
137
139
  if count == 0
138
- say_status :warn, "fit: 0 activities (already imported or none found)", :yellow
140
+ say_status :warn, 'fit: 0 activities (already imported or none found)', :yellow
139
141
  else
140
142
  say_status :done, "fit: #{count} activities", :green
141
143
  end
142
144
  count
143
- rescue => e
145
+ rescue StandardError => e
144
146
  say_status :error, "fit: #{e.message}", :red
145
147
  0
146
148
  end
147
149
  end
148
150
 
149
- desc "apple_health", "Import from Apple Health export.zip"
150
- option :activity, type: :array, desc: "Filter by sport type", aliases: "--act"
151
+ desc 'apple_health', 'Import from Apple Health export.zip'
152
+ option :activity, type: :array, desc: 'Filter by sport type', aliases: '--act'
151
153
  def apple_health
152
154
  config = GitFit::Config.new
153
155
  conn = GitFit::DB::Connection.new(config.db_path)
154
156
  conn.migrate!
155
157
  db = conn.db
156
158
  filter = options[:activity]&.map(&:strip)&.map(&:downcase)
157
- time_budget = config.dig("sync", "time_budget")
159
+ time_budget = config.dig('sync', 'time_budget')
158
160
 
159
- say_status :import, "apple_health", :green
161
+ say_status :import, 'apple_health', :green
160
162
  adapter = GitFit::Import::AppleHealth.new(
161
163
  config: {}, db:, activity_filter: filter,
162
164
  time_budget: time_budget
@@ -165,12 +167,12 @@ module GitFit
165
167
  begin
166
168
  count = adapter.call
167
169
  if count == 0
168
- say_status :warn, "apple_health: 0 activities (already imported or none found)", :yellow
170
+ say_status :warn, 'apple_health: 0 activities (already imported or none found)', :yellow
169
171
  else
170
172
  say_status :done, "apple_health: #{count} activities", :green
171
173
  end
172
174
  count
173
- rescue => e
175
+ rescue StandardError => e
174
176
  say_status :error, "apple_health: #{e.message}", :red
175
177
  0
176
178
  end
@@ -1,19 +1,21 @@
1
- require "thor"
2
- require "fileutils"
3
- require "yaml"
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'fileutils'
5
+ require 'yaml'
4
6
 
5
7
  module GitFit
6
8
  class InstallCLI < Thor
7
- desc "actions [family]", "Install GitHub Actions (default: all families)"
8
- option :check, type: :boolean, desc: "Check on-disk files against templates, exit non-zero on mismatch"
9
- option :"dry-run", type: :boolean, desc: "Render templates and print without writing"
9
+ desc 'actions [family]', 'Install GitHub Actions (default: all families)'
10
+ option :check, type: :boolean, desc: 'Check on-disk files against templates, exit non-zero on mismatch'
11
+ option :"dry-run", type: :boolean, desc: 'Render templates and print without writing'
10
12
  def actions(family = nil)
11
13
  check = options[:check]
12
14
  dry_run = options[:"dry-run"]
13
15
 
14
16
  if check && dry_run
15
- say "Error: --check and --dry-run are mutually exclusive", :red
16
- raise Thor::Error, "Cannot use --check and --dry-run together"
17
+ say 'Error: --check and --dry-run are mutually exclusive', :red
18
+ raise Thor::Error, 'Cannot use --check and --dry-run together'
17
19
  end
18
20
 
19
21
  results = GitFit::Install::Actions.install(family, check: check, dry_run: dry_run)
@@ -1,19 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GitFit
2
4
  module Cli
3
5
  module Sync
4
6
  def sync
5
7
  db = connect_db
6
8
  source = options[:source]
7
- filter = options[:activity]&.flat_map { |v| v.split(",") }&.map(&:strip)&.map(&:downcase)
9
+ filter = options[:activity]&.flat_map { |v| v.split(',') }&.map(&:strip)&.map(&:downcase)
8
10
  privacy = GitFit::Privacy::PolylineFilter.new(config: git_fit_config.privacy_config)
9
11
 
10
12
  sources = if source
11
13
  [source]
12
14
  else
13
- configured = (git_fit_config["sync"] || {}).select { |_k, v| v.is_a?(Hash) }.keys
15
+ configured = (git_fit_config['sync'] || {}).select { |_k, v| v.is_a?(Hash) }.keys
14
16
  builtin = GitFit::Sync::Base.adapters
15
17
  .map { |c| c.config_key }
16
- if ENV["GIT_FIT_ENVIRONMENT"] == "testing"
18
+ if ENV['GIT_FIT_ENVIRONMENT'] == 'testing'
17
19
  builtin += GitFit::Sync::Base.test_adapters
18
20
  .map { |c| c.config_key }
19
21
  end
@@ -26,12 +28,12 @@ module GitFit
26
28
  config: git_fit_config,
27
29
  activity_filter: filter,
28
30
  privacy: privacy,
29
- num_workers: git_fit_config.dig("sync", "workers") || 3,
30
- time_budget: git_fit_config.dig("sync", "time_budget"),
31
- total_timeout: git_fit_config.dig("sync", "total_timeout")
31
+ num_workers: git_fit_config.dig('sync', 'workers') || 3,
32
+ time_budget: git_fit_config.dig('sync', 'time_budget'),
33
+ total_timeout: git_fit_config.dig('sync', 'total_timeout')
32
34
  )
33
35
  runner.run
34
- rescue => e
36
+ rescue StandardError => e
35
37
  say_status :error, e.message, :red
36
38
  end
37
39
  end