Class: Pipely::Tasks::UploadSteps
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Pipely::Tasks::UploadSteps
- Includes:
- Rake::DSL
- Defined in:
- lib/pipely/tasks/upload_steps.rb
Instance Attribute Summary collapse
-
#local_path ⇒ Object
Local path to where the step files are.
-
#name ⇒ Object
Name of task.
-
#s3_bucket_name ⇒ Object
Name of S3 bucket to upload steps to.
-
#s3_path ⇒ Object
Path within S3 bucket to upload steps to.
-
#verbose ⇒ Object
Use verbose output.
Instance Method Summary collapse
-
#initialize(*args, &task_block) ⇒ UploadSteps
constructor
A new instance of UploadSteps.
- #run_task(verbose) ⇒ Object
- #setup_ivars(args) ⇒ Object
Constructor Details
#initialize(*args, &task_block) ⇒ UploadSteps
Returns a new instance of UploadSteps.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pipely/tasks/upload_steps.rb', line 35 def initialize(*args, &task_block) setup_ivars(args) unless ::Rake.application.last_comment desc "Upload Data Pipeline steps to S3" end task name, *args do |_, task_args| RakeFileUtils.send(:verbose, verbose) do if task_block task_block.call(*[self, task_args].slice(0, task_block.arity)) end run_task verbose end end end |
Instance Attribute Details
#local_path ⇒ Object
Local path to where the step files are.
default:
"steps"
20 21 22 |
# File 'lib/pipely/tasks/upload_steps.rb', line 20 def local_path @local_path end |
#name ⇒ Object
Name of task.
default:
:upload_steps
14 15 16 |
# File 'lib/pipely/tasks/upload_steps.rb', line 14 def name @name end |
#s3_bucket_name ⇒ Object
Name of S3 bucket to upload steps to.
23 24 25 |
# File 'lib/pipely/tasks/upload_steps.rb', line 23 def s3_bucket_name @s3_bucket_name end |
#s3_path ⇒ Object
Path within S3 bucket to upload steps to.
26 27 28 |
# File 'lib/pipely/tasks/upload_steps.rb', line 26 def s3_path @s3_path end |
#verbose ⇒ Object
Use verbose output. If this is set to true, the task will print the local and remote paths of each step file it uploads to S3.
default:
true
33 34 35 |
# File 'lib/pipely/tasks/upload_steps.rb', line 33 def verbose @verbose end |
Instance Method Details
#run_task(verbose) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/pipely/tasks/upload_steps.rb', line 59 def run_task(verbose) with_bucket do |directory| step_files.each do |file_name| dest = "#{s3_path}/#{File.basename(file_name)}" puts "uploading #{dest}" if verbose directory.files.create(key: dest, body: File.read(file_name)) end end end |
#setup_ivars(args) ⇒ Object
53 54 55 56 57 |
# File 'lib/pipely/tasks/upload_steps.rb', line 53 def setup_ivars(args) @name = args.shift || :upload_steps @verbose = true @local_path = "steps" end |