Class: AppDiagram

Inherits:
Object
  • Object
show all
Defined in:
lib/railroad/app_diagram.rb

Overview

Root class for RailRoad diagrams

Direct Known Subclasses

AasmDiagram, ControllersDiagram, ModelsDiagram

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ AppDiagram

Returns a new instance of AppDiagram.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/railroad/app_diagram.rb', line 10

def initialize(options)
  @options = options
  @graph = DiagramGraph.new
  @graph.show_label = @options.label

  STDERR.print "Loading application environment\n" if @options.verbose
  load_environment

  STDERR.print "Loading application classes\n" if @options.verbose
  load_classes
end

Instance Method Details

Print diagram



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/railroad/app_diagram.rb', line 23

def print
  if @options.output
    old_stdout = STDOUT.dup
    begin
      STDOUT.reopen(@options.output)
    rescue
      STDERR.print "Error: Cannot write diagram to #{@options.output}\n\n"
      exit 2
    end
  end
  
  if @options.xmi 
      STDERR.print "Generating XMI diagram\n" if @options.verbose
  	STDOUT.print @graph.to_xmi
  else
      STDERR.print "Generating DOT graph\n" if @options.verbose
      STDOUT.print @graph.to_dot 
  end

  if @options.output
    STDOUT.reopen(old_stdout)
  end
end