Class: Pipely::Tasks::UploadPipelineAsGem

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/pipely/tasks/upload_pipeline_as_gem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &task_block) ⇒ UploadPipelineAsGem

Returns a new instance of UploadPipelineAsGem.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 21

def initialize(*args, &task_block)
  setup_ivars(args)

  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

  Rake::Task["upload_steps"].enhance [name]
end

Instance Attribute Details

#bucket_nameObject

Returns the value of attribute bucket_name.



15
16
17
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 15

def bucket_name
  @bucket_name
end

#configObject

Returns the value of attribute config.



18
19
20
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 18

def config
  @config
end

#nameObject

Name of this rake task



13
14
15
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 13

def name
  @name
end

#s3_gems_pathObject

Returns the value of attribute s3_gems_path.



17
18
19
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 17

def s3_gems_path
  @s3_gems_path
end

#s3_steps_pathObject

Returns the value of attribute s3_steps_path.



16
17
18
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 16

def s3_steps_path
  @s3_steps_path
end

#templatesObject

Returns the value of attribute templates.



19
20
21
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 19

def templates
  @templates
end

Instance Method Details

#run_task(verbose) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 43

def run_task(verbose)
  s3_gem_paths = upload_gems
  context = build_bootstrap_context(s3_gem_paths)

  templates.each do |erb_file|
    upload_filename = File.basename(erb_file).sub( /\.erb$/, '' )

    # Exclude the pipeline.json
    if upload_filename == 'pipeline.json'
      next
    end

    template_erb = Erubis::Eruby.new( File.read(erb_file) )
    upload_to_s3( upload_filename, template_erb.result(context) )
  end
end

#setup_ivars(args) ⇒ Object



37
38
39
40
41
# File 'lib/pipely/tasks/upload_pipeline_as_gem.rb', line 37

def setup_ivars(args)
  @name = args.shift || 'deploy:upload_pipeline_as_gem'
  @verbose = true
  @templates = Dir.glob("templates/*.erb")
end