Class: Pipely::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/pipely/definition.rb

Overview

Pipely’s representation of a Pipeline Definition for AWS Data Pipeline amzn.to/1bpW8Ru

Constant Summary collapse

NON_GRAPH_COMPONENT_TYPES =

Showing all component types leads to an unwieldy graph. TODO: make this list configurable.

[
  'Schedule',
  'SnsAlarm',
  'Ec2Resource',
  'EmrCluster',
  'CSV',
  nil,
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(components) ⇒ Definition

Returns a new instance of Definition.



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

def initialize(components)
  @components = components
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



33
34
35
# File 'lib/pipely/definition.rb', line 33

def components
  @components
end

Class Method Details

.parse(content) ⇒ Object



22
23
24
25
26
27
# File 'lib/pipely/definition.rb', line 22

def self.parse(content)
  objects = JSON.parse(content)['objects']
  components = objects.map{|obj| Component.new(obj)}

  new(components)
end

Instance Method Details

#apply_component_attributes(component_attributes) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/pipely/definition.rb', line 45

def apply_component_attributes(component_attributes)
  self.components.each do |component|
    if attributes = component_attributes[component.id]
      component.attributes = attributes
    end
  end
end

#components_for_graphObject



35
36
37
38
39
# File 'lib/pipely/definition.rb', line 35

def components_for_graph
  components.reject { |component|
    NON_GRAPH_COMPONENT_TYPES.include?(component['type'])
  }
end

#to_jsonObject



41
42
43
# File 'lib/pipely/definition.rb', line 41

def to_json
  { :objects => components }.to_json
end