Class: ControllersDiagram

Inherits:
AppDiagram show all
Defined in:
lib/railroad/controllers_diagram.rb

Overview

RailRoad controllers diagram

Instance Method Summary collapse

Methods inherited from AppDiagram

#print

Constructor Details

#initialize(options) ⇒ ControllersDiagram

Returns a new instance of ControllersDiagram.



12
13
14
15
16
# File 'lib/railroad/controllers_diagram.rb', line 12

def initialize(options)
  #options.exclude.map! {|e| "app/controllers/" + e}
  super options
  @graph.diagram_type = 'Controllers'
end

Instance Method Details

#generateObject

Process controller files



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/railroad/controllers_diagram.rb', line 19

def generate
  STDERR.print "Generating controllers diagram\n" if @options.verbose

  files = Dir.glob("app/controllers/**/*_controller.rb") - @options.exclude
  files << 'app/controllers/application.rb'
  files.each do |f|
    class_name = extract_class_name(f)
    # ApplicationController's file is 'application.rb'
    class_name += 'Controller' if class_name == 'Application'
    process_class class_name.constantize
  end 
end