Class: LambdaRubyBundler::CLI::CacheRunner

Inherits:
BaseRunner
  • Object
show all
Defined in:
lib/lambda_ruby_bundler/cli/cache_runner.rb

Overview

Runs the executor in Cache Mode.

Constant Summary collapse

MD5_EXTRACT_REGEX =
/build(?:dep)?-([a-f0-9]{32}).zip/.freeze

Instance Attribute Summary collapse

Attributes inherited from BaseRunner

#app_path, #root_path

Instance Method Summary collapse

Constructor Details

#initialize(root_path, app_path, cache_dir) ⇒ CacheRunner

Creates new instance of cache runner.

Parameters:

  • root_path (String)

    Path to the root of application (containing Gemfile.lock)

  • app_path (String)

    Path (relative to root_path) containing application code

  • cache_dir (String)

    Directory containing cached builds



19
20
21
22
# File 'lib/lambda_ruby_bundler/cli/cache_runner.rb', line 19

def initialize(root_path, app_path, cache_dir)
  super(root_path, app_path)
  @cache_dir = cache_dir
end

Instance Attribute Details

#cache_dirObject (readonly)

Returns the value of attribute cache_dir.



9
10
11
# File 'lib/lambda_ruby_bundler/cli/cache_runner.rb', line 9

def cache_dir
  @cache_dir
end

Instance Method Details

#runHash

Runs the executor, if necessary. Returns hash with two keys:

:application_bundle => path to the application code bundle
:dependency_layer => path to dependency bundle

Returns:

  • (Hash)

    Paths to the builds



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lambda_ruby_bundler/cli/cache_runner.rb', line 29

def run
  build_dependencies = !dependencies_builds.key?(dependencies_hash)
  build_application = !application_builds.key?(application_hash)

  if build_application || build_dependencies
    clear_cache
    bundle(build_dependencies)
  end

  paths
end