Class: RSpecTracer::RemoteCache::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_tracer/remote_cache/cache.rb

Defined Under Namespace

Classes: CacheError

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



12
13
14
15
# File 'lib/rspec_tracer/remote_cache/cache.rb', line 12

def initialize
  @aws = RSpecTracer::RemoteCache::Aws.new
  @repo = RSpecTracer::RemoteCache::Repo.new(@aws)
end

Instance Method Details

#downloadObject



17
18
19
20
21
22
23
24
25
# File 'lib/rspec_tracer/remote_cache/cache.rb', line 17

def download
  return unless cache_ref?

  @aws.download_file(@cache_sha, 'last_run.json')
  @aws.download_dir(@cache_sha, last_run_id)
rescue StandardError => e
  puts "Error: #{e.message}"
  puts e.backtrace.first(5).join("\n")
end

#uploadObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rspec_tracer/remote_cache/cache.rb', line 27

def upload
  @aws.upload_file(@repo.branch_ref, 'last_run.json')
  @aws.upload_dir(@repo.branch_ref, last_run_id)

  file_name = File.join(RSpecTracer.cache_path, 'branch_refs.json')

  write_branch_refs(file_name)
  @aws.upload_branch_refs(@repo.branch_name, file_name)
rescue StandardError => e
  puts "Error: #{e.message}"
  puts e.backtrace.first(5).join("\n")
end