Class: GitFit::Import::Tbulu

Inherits:
Source::Base show all
Defined in:
lib/git_fit/import/tbulu.rb

Constant Summary collapse

DEFAULT_IMPORT_DIR =
'data/import/2bulu'

Instance Attribute Summary

Attributes inherited from Source::Base

#progress_reported

Instance Method Summary collapse

Methods inherited from Source::Base

#build_progress_info

Constructor Details

#initialize(config:, db:, activity_filter: nil, privacy: nil, time_budget: nil) ⇒ Tbulu

Returns a new instance of Tbulu.



14
15
16
17
18
# File 'lib/git_fit/import/tbulu.rb', line 14

def initialize(config:, db:, activity_filter: nil, privacy: nil, time_budget: nil)
  super
  @import_dir = config['import_dir'] || DEFAULT_IMPORT_DIR
  @timezone_resolver = GitFit::Timezone::Resolver.new(config)
end

Instance Method Details

#authenticateObject



25
26
27
# File 'lib/git_fit/import/tbulu.rb', line 25

def authenticate
  true
end

#before_callObject



20
21
22
23
# File 'lib/git_fit/import/tbulu.rb', line 20

def before_call
  return false unless File.directory?(@import_dir)
  super
end

#callObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/git_fit/import/tbulu.rb', line 29

def call
  return 0 unless before_call

  files = scan_files
  total = 0
  files.each do |file_path|
    break if time_expired? && total.positive?
    r = process_one(file_path)
    total += 1 if r
    report_progress(total, files.size, File.basename(file_path)) if r
  end

  total
end

#pending_idsObject



44
45
46
# File 'lib/git_fit/import/tbulu.rb', line 44

def pending_ids
  []
end

#raw_dirObject



52
53
54
# File 'lib/git_fit/import/tbulu.rb', line 52

def raw_dir
  File.join('data', 'raw', '2bulu')
end

#source_labelObject



48
49
50
# File 'lib/git_fit/import/tbulu.rb', line 48

def source_label
  '2bulu'
end

#std_dirObject



56
57
58
# File 'lib/git_fit/import/tbulu.rb', line 56

def std_dir
  File.join('data', 'std', '2bulu')
end