Class: BuildpackSupport::Rake::BuildpackStageTask

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

Overview

A task generator for the tasks that copy files to the staging directory

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&task_block) ⇒ BuildpackStageTask

Creates an instance



44
45
46
47
48
49
50
51
52
53
# File 'lib/buildpack_support/rake/buildpack_stage_task.rb', line 44

def initialize(&task_block)
  @verbose = false

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

  create_copy_tasks files, package_name, staging_dir, verbose
end

Instance Attribute Details

#filesArray<String>

Returns the files to copy to the staging_dir.

Returns:

  • (Array<String>)

    the files to copy to the staging_dir



29
30
31
# File 'lib/buildpack_support/rake/buildpack_stage_task.rb', line 29

def files
  @files
end

#package_nameString

Returns the name of the package.

Returns:

  • (String)

    the name of the package



33
34
35
# File 'lib/buildpack_support/rake/buildpack_stage_task.rb', line 33

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



37
38
39
# File 'lib/buildpack_support/rake/buildpack_stage_task.rb', line 37

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.



41
42
43
# File 'lib/buildpack_support/rake/buildpack_stage_task.rb', line 41

def verbose
  @verbose
end

Instance Method Details

#run_task(source, target, verbose) ⇒ void

This method returns an undefined value.

Runs the task

Parameters:

  • source (String)

    the file to copy

  • target (String)

    where to copy the file to

  • verbose (Boolean)

    whether to print messages to the console



61
62
63
64
65
66
# File 'lib/buildpack_support/rake/buildpack_stage_task.rb', line 61

def run_task(source, target, verbose)
  RakeFileUtils.verbose(verbose) do
    mkdir_p File.dirname(target)
    cp source, target
  end
end