Class: BuildpackSupport::Rake::WriteVersionFileTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- BuildpackSupport::Rake::WriteVersionFileTask
- Defined in:
- lib/buildpack_support/rake/write_version_file_task.rb
Overview
A task generator for the task that creates version file.
Instance Attribute Summary collapse
-
#buildpack_version ⇒ BuildpackSupport::BuildpackVersion
The version of the buildpack.
-
#package_name ⇒ String
The name of the package.
-
#staging_dir ⇒ String
The directory to zip the contents of.
-
#verbose ⇒ Boolean
The verbosity of the task.
Instance Method Summary collapse
-
#initialize(&task_block) ⇒ WriteVersionFileTask
constructor
Creates an instance.
-
#run_task(name, buildpack_version, verbose) ⇒ void
Runs the task.
Constructor Details
#initialize(&task_block) ⇒ WriteVersionFileTask
Creates an instance
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/buildpack_support/rake/write_version_file_task.rb', line 44 def initialize(&task_block) @verbose = false task_block.call(*[self].slice(0, task_block.arity)) if task_block abort 'buildpack_version must be configured' unless buildpack_version abort 'package_name must be configured' unless package_name abort 'staging_dir must be configured' unless staging_dir create_task buildpack_version, package_name, staging_dir, verbose end |
Instance Attribute Details
#buildpack_version ⇒ BuildpackSupport::BuildpackVersion
Returns the version of the buildpack.
29 30 31 |
# File 'lib/buildpack_support/rake/write_version_file_task.rb', line 29 def buildpack_version @buildpack_version end |
#package_name ⇒ String
Returns the name of the package.
33 34 35 |
# File 'lib/buildpack_support/rake/write_version_file_task.rb', line 33 def package_name @package_name end |
#staging_dir ⇒ String
Returns the directory to zip the contents of.
37 38 39 |
# File 'lib/buildpack_support/rake/write_version_file_task.rb', line 37 def staging_dir @staging_dir end |
#verbose ⇒ Boolean
Returns the verbosity of the task. Defaults to false
.
41 42 43 |
# File 'lib/buildpack_support/rake/write_version_file_task.rb', line 41 def verbose @verbose end |
Instance Method Details
#run_task(name, buildpack_version, verbose) ⇒ void
This method returns an undefined value.
Runs the task
61 62 63 64 65 |
# File 'lib/buildpack_support/rake/write_version_file_task.rb', line 61 def run_task(name, buildpack_version, verbose) RakeFileUtils.verbose(verbose) { mkdir_p File.dirname(name) } File.open(name, 'w') { |f| f.write(buildpack_version.to_hash.to_yaml) } "Wrote buildpack version to #{name}" if verbose end |