Class: Pipely::Tasks::Definition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &task_block) ⇒ Definition

Returns a new instance of Definition.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pipely/tasks/definition.rb', line 32

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

  directory path

  desc "Graphs the full pipeline definition using Graphviz"
  task name => path 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

#definitionObject

Pipeline definition instance



23
24
25
# File 'lib/pipely/tasks/definition.rb', line 23

def definition
  @definition
end

#nameObject

Name of task.

default:

:definition


14
15
16
# File 'lib/pipely/tasks/definition.rb', line 14

def name
  @name
end

#pathObject

Path where rendered definitions are written.

default:

"definitions"


20
21
22
# File 'lib/pipely/tasks/definition.rb', line 20

def path
  @path
end

#verboseObject

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


30
31
32
# File 'lib/pipely/tasks/definition.rb', line 30

def verbose
  @verbose
end

Instance Method Details

#run_task(verbose) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/pipely/tasks/definition.rb', line 55

def run_task(verbose)
  puts "Generating #{target_filename}" if verbose

  File.open(target_filename, 'w') do |file|
    file.write(definition.to_json)
  end
end

#setup_ivars(args) ⇒ Object



49
50
51
52
53
# File 'lib/pipely/tasks/definition.rb', line 49

def setup_ivars(args)
  @name = args.shift || :definition
  @verbose = true
  @path = "definitions"
end

#target_filenameObject



63
64
65
# File 'lib/pipely/tasks/definition.rb', line 63

def target_filename
  "#{path}/#{definition.base_filename}.json"
end