module Seafoam::Annotators

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

Public Class Methods

annotators() click to toggle source

Get a list of all annotators in the system.

# 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 = {}) click to toggle source

Apply all applicable annotators to a graph.

# 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