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.
22
23
24
25
26
27
28
|
# File 'lib/git_fit/import/local_file.rb', line 22
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
47
48
49
|
# File 'lib/git_fit/import/local_file.rb', line 47
def authenticate
true
end
|
#call ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/git_fit/import/local_file.rb', line 30
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
51
52
53
|
# File 'lib/git_fit/import/local_file.rb', line 51
def pending_ids
[]
end
|
#raw_dir_for(source) ⇒ Object
59
60
61
|
# File 'lib/git_fit/import/local_file.rb', line 59
def raw_dir_for(source)
File.join('data', 'raw', source)
end
|
#source_label ⇒ Object
55
56
57
|
# File 'lib/git_fit/import/local_file.rb', line 55
def source_label
'LocalFile'
end
|
#std_dir_for(source) ⇒ Object
63
64
65
|
# File 'lib/git_fit/import/local_file.rb', line 63
def std_dir_for(source)
File.join('data', 'std', source)
end
|