class Pipely::Tasks::UploadSteps

Attributes

local_path[RW]

Local path to where the step files are.

default:

"steps"
name[RW]

Name of task.

default:

:upload_steps
s3_bucket_name[RW]

Name of S3 bucket to upload steps to.

s3_path[RW]

Path within S3 bucket to upload steps to.

verbose[RW]

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

Public Class Methods

new(*args, &task_block) click to toggle source
# File lib/pipely/tasks/upload_steps.rb, line 34
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

Public Instance Methods

run_task(verbose) click to toggle source
# File lib/pipely/tasks/upload_steps.rb, line 58
def run_task(verbose)
  with_bucket do |bucket|
    s3_uploader = Pipely::Deploy::S3Uploader.new(bucket, s3_path)
    s3_uploader.upload(step_files)
  end
end
setup_ivars(args) click to toggle source
# File lib/pipely/tasks/upload_steps.rb, line 52
def setup_ivars(args)
  @name = args.shift || :upload_steps
  @verbose = true
  @local_path = "steps"
end

Private Instance Methods

step_files() click to toggle source
# File lib/pipely/tasks/upload_steps.rb, line 78
def step_files
  FileList.new(File.join(local_path, "**", "*")).reject { |fname|
    File.directory?( fname )
  }
end
with_bucket() { |bucket| ... } click to toggle source
# File lib/pipely/tasks/upload_steps.rb, line 67
def with_bucket
  s3 = Aws::S3::Resource.new
  bucket = s3.bucket(s3_bucket_name)

  if bucket.exists?
    yield(bucket)
  else
    raise "Couldn't find S3 bucket '#{s3_bucket_name}'"
  end
end