Class: RailsForge::Graph
- Inherits:
-
Object
- Object
- RailsForge::Graph
- Defined in:
- lib/railsforge/graph.rb
Overview
Graph class generates visual dependency graphs
Defined Under Namespace
Classes: GraphError
Instance Method Summary collapse
-
#generate ⇒ String
Generate dependency graph.
-
#initialize(base_path = nil) ⇒ Graph
constructor
Initialize the graph generator.
Constructor Details
#initialize(base_path = nil) ⇒ Graph
Initialize the graph generator
10 11 12 13 14 15 16 |
# File 'lib/railsforge/graph.rb', line 10 def initialize(base_path = nil) @base_path = base_path || find_rails_app_path raise GraphError, "Not in a Rails application directory" unless @base_path @output_dir = File.join(@base_path, "tmp", "railsforge") @relationships = [] end |
Instance Method Details
#generate ⇒ String
Generate dependency graph
20 21 22 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/railsforge/graph.rb', line 20 def generate puts "Analyzing Rails app structure..." puts "" # Collect relationships analyze_controllers analyze_services analyze_queries analyze_models analyze_jobs # Create output directory FileUtils.mkdir_p(@output_dir) # Generate DOT file dot_file = generate_dot_file # Generate SVG if Graphviz is available svg_file = generate_svg(dot_file) puts "Dependency graph generated!" puts " DOT: #{dot_file}" puts " SVG: #{svg_file}" if svg_file { dot: dot_file, svg: svg_file } end |