Class: Pipely::Tasks::Graph
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Pipely::Tasks::Graph
- Includes:
- Rake::DSL
- Defined in:
- lib/pipely/tasks/graph.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
Pipeline definition instance.
-
#name ⇒ Object
Name of task.
-
#path ⇒ Object
Path to write graph images to.
-
#verbose ⇒ Object
Use verbose output.
Instance Method Summary collapse
-
#initialize(*args, &task_block) ⇒ Graph
constructor
A new instance of Graph.
- #run_task(verbose) ⇒ Object
- #setup_ivars(args) ⇒ Object
- #target_filename ⇒ Object
Constructor Details
#initialize(*args, &task_block) ⇒ Graph
Returns a new instance of Graph.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pipely/tasks/graph.rb', line 32 def initialize(*args, &task_block) setup_ivars(args) # create the `path` directory if it doesn't exist directory path namespace name do task :full => 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 task :open => :full do `open #{target_filename}` end end desc "Graphs the full pipeline definition using Graphviz" task name => "#{name}:full" end |
Instance Attribute Details
#definition ⇒ Object
Pipeline definition instance
23 24 25 |
# File 'lib/pipely/tasks/graph.rb', line 23 def definition @definition end |
#name ⇒ Object
Name of task.
default:
:graph
14 15 16 |
# File 'lib/pipely/tasks/graph.rb', line 14 def name @name end |
#path ⇒ Object
Path to write graph images to.
default:
"graphs"
20 21 22 |
# File 'lib/pipely/tasks/graph.rb', line 20 def path @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
30 31 32 |
# File 'lib/pipely/tasks/graph.rb', line 30 def verbose @verbose end |
Instance Method Details
#run_task(verbose) ⇒ Object
64 65 66 67 |
# File 'lib/pipely/tasks/graph.rb', line 64 def run_task(verbose) puts "Generating #{target_filename}" if verbose Pipely.draw(definition.to_json, target_filename) end |
#setup_ivars(args) ⇒ Object
58 59 60 61 62 |
# File 'lib/pipely/tasks/graph.rb', line 58 def setup_ivars(args) @name = args.shift || :graph @verbose = true @path = "graphs" end |
#target_filename ⇒ Object
69 70 71 |
# File 'lib/pipely/tasks/graph.rb', line 69 def target_filename "#{path}/#{definition.base_filename}.png" end |