Class: Pipely::Component
- Inherits:
-
Object
- Object
- Pipely::Component
- Defined in:
- lib/pipely/component.rb
Overview
Represents a Component within a Data Pipeline Definition amzn.to/16lbBKx
Constant Summary collapse
- REFERENCE_KEYS =
[ 'dependsOn', 'input', 'output', 'runsOn', 'schedule', 'onFail', 'onSuccess', 'dataFormat', 'precondition', ]
- STATE_COLORS =
{ 'FINISHED' => 'deepskyblue1', 'RUNNING' => 'chartreuse', 'WAITING_ON_DEPENDENCIES' => 'gray', 'WAITING_FOR_RUNNER' => 'bisque4', 'FAILED' => 'orangered', }
Instance Method Summary collapse
- #coerce_references ⇒ Object
- #dependencies(scope = nil) ⇒ Object
- #graphviz_options ⇒ Object
-
#initialize(args) ⇒ Component
constructor
A new instance of Component.
- #to_json(options = {}, depth = 0) ⇒ Object
Constructor Details
#initialize(args) ⇒ Component
48 49 50 51 52 |
# File 'lib/pipely/component.rb', line 48 def initialize(args) @original_args = args.clone super coerce_references end |
Instance Method Details
#coerce_references ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/pipely/component.rb', line 54 def coerce_references REFERENCE_KEYS.each do |key| value = send(key) unless value.is_a?(ReferenceList) send("#{key}=", ReferenceList.new(value)) end end end |
#dependencies(scope = nil) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/pipely/component.rb', line 73 def dependencies(scope=nil) deps = dependsOn.build_dependencies('dependsOn') + precondition.build_dependencies('precondition') + input.build_dependencies('input') + output.build_dependencies('output') if :all == scope deps += runsOn.build_dependencies(:runsOn) deps += schedule.build_dependencies(:schedule) deps += onFail.build_dependencies(:onFail) deps += onSuccess.build_dependencies(:onSuccess) deps += dataFormat.build_dependencies(:dataFormat) end deps end |
#graphviz_options ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/pipely/component.rb', line 63 def { :shape => 'record', :label => "{#{label}}", :color => color || 'black', :fillcolor => STATE_COLORS[execution_state] || 'white', :style => 'filled', } end |
#to_json(options = {}, depth = 0) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/pipely/component.rb', line 90 def to_json(={}, depth=0) h = @original_args REFERENCE_KEYS.each do |key| value = send(key) if value.present? h[key] = value else h.delete(key) end end h.to_json() end |