Module: Seafoam::Annotators

Defined in:
lib/seafoam/annotators.rb,
lib/seafoam/annotators/graal.rb,
lib/seafoam/annotators/fallback.rb

Overview

Annotators are routines to read the graph and apply properties which tools, such as the render command, can use to show more understandable output.

Defined Under Namespace

Classes: FallbackAnnotator, GraalAnnotator

Class Method Summary collapse

Class Method Details

.annotatorsObject

Get a list of all annotators in the system.



21
22
23
24
25
26
27
28
29
30
# File 'lib/seafoam/annotators.rb', line 21

def self.annotators
  # Get all subclasses of Annotator.
  annotators = Annotator::SUBCLASSES.dup

  # We want the FallbackAnnotator to run last.
  annotators.delete FallbackAnnotator
  annotators.push FallbackAnnotator

  annotators
end

.apply(graph, options = {}) ⇒ Object

Apply all applicable annotators to a graph.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/seafoam/annotators.rb', line 6

def self.apply(graph, options = {})
  annotators.each do |annotator|
    next unless annotator.applies?(graph)

    # Record for information that the annotator annotated this graph.
    annotated_by = graph.props[:annotated_by] ||= []
    annotated_by.push annotator

    # Run the annotator.
    instance = annotator.new(options)
    instance.annotate graph
  end
end