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
# 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)
  RSpecTracer.logger.info "rspec-tracer remote_cache: restored cache from #{@cache_sha}"
end

#uploadObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/rspec_tracer/remote_cache/cache.rb', line 25

def upload
  @aws.upload_file(@repo.branch_ref, 'last_run.json')
  @aws.upload_dir(@repo.branch_ref, last_run_id)
  RSpecTracer.logger.info "rspec-tracer remote_cache: uploaded cache to #{@repo.branch_ref}"

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

  write_branch_refs(file_name)
  @aws.upload_branch_refs(@repo.branch_name, file_name)
end