Class: BuildpackSupport::Rake::DependencyCacheTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/buildpack_support/rake/dependency_cache_task.rb

Overview

A task generator for tasks that download and cache buildpack dependencies

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&task_block) ⇒ DependencyCacheTask

Returns a new instance of DependencyCacheTask.



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/buildpack_support/rake/dependency_cache_task.rb', line 48

def initialize(&task_block)
  @verbose = true

  task_block.call(*[self].slice(0, task_block.arity)) if task_block
  abort 'build_dir must be configured' unless build_dir
  abort 'package_name must be configured' unless package_name
  abort 'staging_dir must be configured' unless staging_dir

  BuildpackSupport::Logging::LoggerFactory.instance.setup "#{build_dir}/"
  @cache = BuildpackSupport::Cache::DownloadCache.new(Pathname.new("#{staging_dir}/resources/cache"))

  create_cache_tasks package_name, verbose
end

Instance Attribute Details

#build_dirString

Returns the directory to caching log file into.

Returns:

  • (String)

    the directory to caching log file into



34
35
36
# File 'lib/buildpack_support/rake/dependency_cache_task.rb', line 34

def build_dir
  @build_dir
end

#package_nameString

Returns the name of the package.

Returns:

  • (String)

    the name of the package



38
39
40
# File 'lib/buildpack_support/rake/dependency_cache_task.rb', line 38

def package_name
  @package_name
end

#staging_dirString

Returns the directory to zip the contents of.

Returns:

  • (String)

    the directory to zip the contents of



42
43
44
# File 'lib/buildpack_support/rake/dependency_cache_task.rb', line 42

def staging_dir
  @staging_dir
end

#verboseBoolean

Returns the verbosity of the task. Defaults to false.

Returns:

  • (Boolean)

    the verbosity of the task. Defaults to false.



46
47
48
# File 'lib/buildpack_support/rake/dependency_cache_task.rb', line 46

def verbose
  @verbose
end

Instance Method Details

#run_task(target, verbose) ⇒ void

This method returns an undefined value.

Runs the task

Parameters:

  • target (String)

    the URI to cache

  • verbose (Boolean)

    whether to print messages to the console



67
68
69
70
# File 'lib/buildpack_support/rake/dependency_cache_task.rb', line 67

def run_task(target, verbose)
  rake_output_message "Caching #{target}" if verbose
  @cache.get(target) {}
end