Class: GitFit::Import::LocalFile
Constant Summary
collapse
- IMPORT_DIRS =
{
"gpx" => "data/import/gpx",
"tcx" => "data/import/tcx",
"fit" => "data/import/fit"
}.freeze
- SUPPORTED_EXTENSIONS =
%w[.gpx .tcx .fit].freeze
- NS_TCX =
{ tcx: "http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2" }.freeze
Instance Attribute Summary
Attributes inherited from Source::Base
#progress_reported
Instance Method Summary
collapse
#before_call, #build_progress_info, #process_one
Constructor Details
#initialize(config:, db:, activity_filter: nil, privacy: nil, time_budget: nil, sources: nil, sport_override: nil) ⇒ LocalFile
Returns a new instance of LocalFile.
20
21
22
23
24
25
|
# File 'lib/git_fit/import/local_file.rb', line 20
def initialize(config:, db:, activity_filter: nil, privacy: nil, time_budget: nil, sources: nil, sport_override: nil)
super(config:, db:, activity_filter:, privacy:, time_budget:)
@sources = sources
@sport_override = sport_override
@timezone_resolver = GitFit::Timezone::Resolver.new(config)
end
|
Instance Method Details
#authenticate ⇒ Object
44
45
46
|
# File 'lib/git_fit/import/local_file.rb', line 44
def authenticate
true
end
|
#call ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/git_fit/import/local_file.rb', line 27
def call
return 0 unless authenticate
total_imported = 0
@sources.each do |source|
dir = IMPORT_DIRS[source]
next unless dir && File.directory?(dir)
files = Dir.glob(File.join(dir, "*"), File::FNM_CASEFOLD)
.select { |f| SUPPORTED_EXTENSIONS.include?(File.extname(f).downcase) && File.file?(f) }
total_imported += process_files(files, source)
end
total_imported
end
|
#pending_ids ⇒ Object
48
49
50
|
# File 'lib/git_fit/import/local_file.rb', line 48
def pending_ids
[]
end
|
#raw_dir_for(source) ⇒ Object
56
57
58
|
# File 'lib/git_fit/import/local_file.rb', line 56
def raw_dir_for(source)
File.join("data", "raw", source)
end
|
#source_label ⇒ Object
52
53
54
|
# File 'lib/git_fit/import/local_file.rb', line 52
def source_label
"LocalFile"
end
|
#std_dir_for(source) ⇒ Object
60
61
62
|
# File 'lib/git_fit/import/local_file.rb', line 60
def std_dir_for(source)
File.join("data", "std", source)
end
|