Module: GitFit::Std::Resolver
- Defined in:
- lib/git_fit/std/resolver.rb
Constant Summary collapse
- SOURCE_PREFIXES =
garmin_cn 必须排在 garmin 前面:"garmin_cn_7".start_with?("garmin_") == true
%w[ garmin_cn garmin strava keep igpsport xoss xingzhe apple_health gpx fit tcx ].freeze
Class Method Summary collapse
-
.decompose(run_id) ⇒ Object
从 run_id 解构出 [source, natural_id] natural_id = platform_id(sync)或内容哈希(local).
-
.find(run_id) ⇒ String?
Std 文件路径(相对 cwd),找不到返回 nil.
Class Method Details
.decompose(run_id) ⇒ Object
从 run_id 解构出 [source, natural_id] natural_id = platform_id(sync)或内容哈希(local)
14 15 16 17 18 19 20 |
# File 'lib/git_fit/std/resolver.rb', line 14 def self.decompose(run_id) SOURCE_PREFIXES.each do |s| prefix = "#{s}_" return [s, run_id.sub(prefix, '')] if run_id.start_with?(prefix) end [nil, nil] end |
.find(run_id) ⇒ String?
Returns std 文件路径(相对 cwd),找不到返回 nil.
23 24 25 26 27 28 29 |
# File 'lib/git_fit/std/resolver.rb', line 23 def self.find(run_id) source, natural_id = decompose(run_id) return nil unless source path = File.join('data', 'std', source, "#{natural_id}.json") path if File.exist?(path) end |