class DataMapper::Visualizer::Rake::GraphVizTask

Constants

DIAGRAMS

The types of GraphViz diagrams.

FORMATS

The image formats for GraphViz diagrams.

Attributes

diagrams[R]

The types of diagrams to generate.

formats[R]

The formats of the diagrams to generate.

Public Class Methods

new(options={},&block) click to toggle source

Creates a new ‘dm:doc:graphviz` task.

@param [Hash] options

Additional options.

@option options [Boolean] :relational

Specifies whether to generate a relational diagram.

@option options [Boolean] :schema

Specifies whether to generate a schema diagram.

@option options [Boolean] :png

Specifies whether to generate a PNG image.

@option options [Boolean] :svg

Specifies whether to generate a SVG image.

@yield [task]

The given block will be passed the newly created task.

@yieldparam [GraphVizTask] task

The new GraphViz task.

@see GraphViz.new

Calls superclass method
# File lib/dm-visualizer/rake/graphviz_task.rb, line 49
def initialize(options={},&block)
  extract_options = lambda { |keys|
    if keys.any? { |key| options[key] }
      keys.select { |key| options.delete(key) }
    else
      keys
    end
  }

  @diagrams = extract_options[DIAGRAMS]
  @formats  = extract_options[FORMATS]

  super(options,&block)
end

Public Instance Methods

define() click to toggle source

Defines the ‘dm:doc:graphviz` namespace.

Calls superclass method
# File lib/dm-visualizer/rake/graphviz_task.rb, line 67
def define
  super do
    namespace(:graphviz) do
      @diagrams.each do |type|
        namespace(type) do
          @formats.each do |format|
            desc "Generates a #{format.to_s.upcase} GraphViz #{type} diagram of the DataMapper Models"
            task(format) do
              GraphViz.new(@options.merge(
                :naming => type,
                :file   => "doc/#{type}_diagram",
                :format => format
              )).visualize!
            end
          end
        end

        task(type => @formats.map { |format| "#{type}:#{format}" })
      end
    end

    task(:graphviz => @diagrams.map { |type| "graphviz:#{type}" })
  end
end