Class: BuildpackSupport::Rake::DisableRemoteDownloadsTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- BuildpackSupport::Rake::DisableRemoteDownloadsTask
- Defined in:
- lib/buildpack_support/rake/disable_remote_downloads_task.rb
Overview
A task generator for the task that disables remote downloads
Instance Attribute Summary collapse
-
#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) ⇒ DisableRemoteDownloadsTask
constructor
A new instance of DisableRemoteDownloadsTask.
-
#run_task(source, target, verbose) ⇒ void
Runs the task.
Constructor Details
#initialize(&task_block) ⇒ DisableRemoteDownloadsTask
Returns a new instance of DisableRemoteDownloadsTask.
38 39 40 41 42 43 44 45 46 |
# File 'lib/buildpack_support/rake/disable_remote_downloads_task.rb', line 38 def initialize(&task_block) @verbose = false task_block.call(*[self].slice(0, task_block.arity)) if task_block abort 'package_name must be configured' unless package_name abort 'staging_dir must be configured' unless staging_dir create_task package_name, staging_dir, verbose end |
Instance Attribute Details
#package_name ⇒ String
Returns the name of the package.
28 29 30 |
# File 'lib/buildpack_support/rake/disable_remote_downloads_task.rb', line 28 def package_name @package_name end |
#staging_dir ⇒ String
Returns the directory to zip the contents of.
32 33 34 |
# File 'lib/buildpack_support/rake/disable_remote_downloads_task.rb', line 32 def staging_dir @staging_dir end |
#verbose ⇒ Boolean
Returns the verbosity of the task. Defaults to true
.
36 37 38 |
# File 'lib/buildpack_support/rake/disable_remote_downloads_task.rb', line 36 def verbose @verbose end |
Instance Method Details
#run_task(source, target, verbose) ⇒ void
This method returns an undefined value.
Runs the task
54 55 56 57 58 59 60 61 62 |
# File 'lib/buildpack_support/rake/disable_remote_downloads_task.rb', line 54 def run_task(source, target, verbose) RakeFileUtils.verbose(verbose) do mkdir_p File.dirname target content = File.open(source, 'r') { |f| f.read.gsub(/enabled/, 'disabled') } File.open(target, 'w') { |f| f.write content } "Disabled remote downloads in #{target}" if verbose end end |