• Stars
    star
    604
  • Rank 74,189 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a ruby code dependency graph interactive visualizer

Rubrowser (Ruby Browser)

Gem Version Build Status

a visualizer for ruby code (rails or otherwise), it analyze your code and extract the modules definitions and used classes/modules and render all these information as a directed force graph using D3.

Note:

Starting from version 2.0.0 the project is no longer an http server, it generates one HTML file that is self-contained, data and script and html in one file, so you can generate it in your CI build and publish it as part of your documentation

this project is so small that the visualization looks like so

rubrowser visualization

the idea is that the project opens every .rb file and parse it with parser gem then list all modules and classes definitions, and all constants that are listed inside this module/class and link them together.

Here are some output examples

Gem Visualization
rack-1.6.4/lib rake
actioncable-5.0.0/lib acioncable
railties-5.0.0/lib railties

there are couple things you need to keep in mind:

  • if your file doesn't have a valid ruby syntax it won't be parsed and will print warning.
  • if you reference a class that is not defined in your project it won't be in the graph, we only display the graph of classes/modules you defined
  • it statically analyze the code so meta programming is out of question in here
  • rails associations are meta programming so forget it 😄

Installation

gem install rubrowser

Usage

Usage: rubrowser [options] [file] ...
    -o, --output=FILE                output file page, if not specified output will be written to stdout
    -l, --layout=FILE                layout file to apply on the resulting graph
    -s, --server=SERVER:PORT         rubrowser server for execution monitoring
    -T, --no-toolbox                 Don't display toolbox on the page
    -j, --json                       Do export data as JSON instead of HTML
    -v, --version                    Print Rubrowser version
    -h, --help                       Prints this help

if you run it without any options

rubrowser

it'll analyze the current directory and print out an HTML file, so you can write it to a file, and open it in your browser

rubrowser > output.html

Monitoring your application execution

Add rubrowser to your ruby project Gemfile

gem 'rubrowser'

Add the following code before your application runs, if it's a rails project this should be an initializer

Rubrowser::Monitor.run(path: Rails.root.to_s, port: 8080)

path is your code path, and port is the execution websocket server port, the server will open that port and announce any execution happens to the code inside your project directory.

now generate a rubrowser HTML output that connect to your server

rubrowser -slocalhost:8080 > output.html

Using a saved layout

When you move classes/modules in the graph to fix them in one place, then you refresh the page, you'll reset the graph again.

for that reason there is a button to download the current graph state as json file (fixed nodes positions), when you generate the graph again you can pass that file to rubrowser to embed it inside the output HTML file.

rubrowser -l layout.json

I recommend putting that file in your project and name it .rubrowser in that case it'll be easy to use it whenever you generate the graph.

rubrowser -l .rubrowser

So that in the future probably rubrowser can pick the file automatically, if you follow that naming, your project will be ready in that case.

Export data for use in external tools

rubrowser -j|jq '.'

Features

  • trace your execution in realtime on the graph
  • interactive graph, you can pull any node to fix it to some position
  • to release node double click on it
  • zoom and pan with mouse or touch pad
  • highlight node and all related nodes, it'll make it easier for you to see what depends and dependencies of certain class
  • highlight nodes by names or file path
  • ignore node by name, or file path
  • ignore nodes of certain type (modules/classes)
  • hide namespaces
  • hide relations
  • change graph appearance (collision radius)
  • stop animation immediately
  • fix all nodes in position or release all fixed nodes
  • Module/class circle size on the graph will be relative to module number of lines in your code
  • cyclical dependencies are marked in red
  • after you move nodes around, you can download the layout as a file, then provide it when generating the graph file again with -l file.json it will embed the layout in the file and the graph will have the same layout by default.

Why?

Because i didn't find a good visualization tool to make me understand ruby projects when I join a new one.

it's great when you want to get into an open source project and visualize the structure to know where to work and the relations between modules/classes.

More Repositories

1

dirtree

Visualizing files paths as an interactive tree, works nicely with gnu linux tools such as find, ls, or git ls-files
HTML
105
star
2

RubyScripts

Daily ruby scripts I create them for fun, watch it to get a daily script and learn a tip everyday
HTML
87
star
3

Codeigniter-Egypt

Another Codeigniter CMS, With some Love
PHP
77
star
4

xlog

📼 Personal knowledge management application. One binary HTTP server. works in any Markdown directory. autolinks pages, hashtags, auto preview images link, screenshare, screenshot, camera recording and audio recording embedded in the note. and fast search through the KB
Go
70
star
5

inbox

📮 WebRTC fast signaling HTTP server
Go
31
star
6

debugger

Golang Debugger Graphical user interface for Go programming language. Based on Delve debugger
Go
30
star
7

rubyfunctions

Like Rubygems.org but for Ruby functions
Ruby
27
star
8

Sema-lang

لغة برمجة عربية بديلة للغة CSS لتنسيق صفحات الإنترنت
JavaScript
26
star
9

askwiki

Ask Wikipedia is a ruby gem for querying wikipedia in any language from within your ruby or rails application, and also could be used from commandline directly.
Ruby
22
star
10

retro

Retrospective board for teams, minimal and clean
HTML
21
star
11

restreamer

A personal restreamer nginx server to stream to multiple sources
Dockerfile
19
star
12

capistrano-decompose

Capistrano plugin to deploy your application inside docker containers with docker compose
Ruby
15
star
13

devtools

A set of simple tools every developer needs, collected in one application.
CSS
15
star
14

library

My physical books library
Go
13
star
15

go-server

Go server project template. Small set of functions and minimal dependencies. I wouldn't call it a framework. Just clone it and start your project no strings attached
Go
10
star
16

Gamra

a fireworks alternative application, made using python, wxwidgets. for linux and windows
Python
9
star
17

who-is-the-ceo-now-me

Software House Simulator
JavaScript
9
star
18

recorder

Record your screen and download it as a video file
HTML
9
star
19

AI

A repo that will hold my AI related experiments
Dockerfile
8
star
20

Sefa-lang

صفة هى لغة برمجة عربية بديلة للغة XHTML مبنية على لغة XML و يتم ترجمتها عن طريق XSL و مدعومة من قبل جميع المتصفحات على جميع المنصات
XSLT
8
star
21

amun

A minimal CLI text editor, built on Ruby, looking for Emacs as it's father and idol.
Ruby
7
star
22

mindmap

A very specific and opinionated web framework to traverse a graph data structure
Ruby
6
star
23

gitmq

GitMQ: Git message queue
Ruby
6
star
24

lsgh

List github user repository and pull requests in directory structure format
Ruby
6
star
25

emad-elsaid.github.io

My personal Blog
HTML
6
star
26

notifications.el

A notifications panel for spacemacs, that works with org mode and evil mode
Emacs Lisp
6
star
27

hydra

𓆚 C implementation of the famous Emacs Hydra package to be used in terminal. Groups commands and assign each command a key binding
C
5
star
28

types

Go Package provides a generic data types similar to that of Ruby
Go
5
star
29

timer

a stopwatch timer for rubik's cube speed solvers
JavaScript
5
star
30

codeye

Code insights, statistics of your code, history, contributions and contributors, graphs and more.
Go
5
star
31

estimate

An Estimation board for teams, non-persistent. simple and fast.
HTML
4
star
32

CS3D499-Plugin

C++
4
star
33

rails-templates

Rails templates I use to bootstrap projects
Ruby
4
star
34

portableBrowser

this is a light weight browser using Mozilla XULrunner you can use it to view any web page,
JavaScript
4
star
35

live

List of youtube live channels videos
Go
4
star
36

emacs-rss-mode

Emacs RSS reader mode
Emacs Lisp
3
star
37

Colosseum-plugin

C++
3
star
38

snake

Snake game in C++
C++
3
star
39

Github-PHP-Wiki

make your github wiki available outside github
PHP
3
star
40

Todo

a simple todo application with ExtJs, PHP, Ajax .. for education purposes
JavaScript
3
star
41

offlinerss

Download RSS entries offline to your machine
Go
3
star
42

sheet2chart

Google sheets to google chart converter
HTML
3
star
43

noty

A bookmarks and snippets manager
Ruby
2
star
44

gosed

Go stream editor
Go
2
star
45

jenkins-docker-compose

A setup to run jenkins with docker compose
Dockerfile
2
star
46

command_tree

Builds trees of commands for the terminal, each node is either a group of commands or the command itself, every node is associated with a character to access it.
Ruby
2
star
47

Bounce-Game

bounce game, a ball that jumps and evade sticks get coins and so.
C++
2
star
48

presentations

Presentations
HTML
2
star
49

home

Home server setup
Shell
1
star
50

QA

Arabic Questions answering application depends on Google Search ,simple LNP and classification algorithms.
Java
1
star
51

touch-mouse

Move mouse using your smartphone.
Ruby
1
star
52

fb2jekyll

import facebook posts to jekyll blog
Ruby
1
star
53

Airpad

Airpad mouse control application with camera
1
star
54

jumping-blocks

a jumping blocks toy with javascript, jquery, intended for enjoy purpose, if you like it forke and develop a little
JavaScript
1
star