Easy UML from your rails app
If you're a programmer, chances are you're not a big fan of making software diagrams. Writing code is much more fun!
Of course, if you remain agile you can do a whole project by yourself. But say you are using rails in a professional environment? Sooner or later, you're going to want to show someone a global overview of how your app is structured.
In my opinion, diagrams are good to reach agreement on the design of software.
It should be easy to maintain,
it shouldn't all be written in advance, and
it definetly shouldn't be a product in and of itself.
Since we're lazy ruby programmers, why not turn the waterfall upside down and generate diagrams from our code?
Go and get Railroad. Its needs Graphviz to work. You can get railroad as a gem and graphviz is hopefully in your package manager.
After getting those, just try it out on your current project!
Generate a model diagram from your app including non-ActiveRecord models and inheritance.
$ railroad -M -a -i | dot -Tpng > doc/models.png
Generate a controller diagram.
$ railroad -C | neato -Tpng > doc/controllers.png
Check out the railroad site for more info, code examples and some sample output. The output actually looks pretty neat. Here's what it generates for Typo.
Backgroundrb is pretty cool stuff
For my employer I'm developing a rails app that needs to do a lot of RPC calls in the background. It's not really putting strain on our servers, but that sort of stuff will always take longer than you want it to. At first I just wanted PHP-style output buffering. However that doesn't scale too well with rails setups being the way they are.
To improve stability and reliability, we need to seperate it from the rails environment copmletely.
Enter Backgroundrb.
Backgroundrb lets you do some heavy lifting in the background. It's basically a separate server that allows you to run worker threads.
Now you might ask: "How does this fit into rails?". Well, it goes a little something like this...
The worker (put this in /lib/workers)
class ExampleWorker < BackgrounDRb::Worker::RailsBase
def do_work(args)
results[:some_string] = "I'm robust!"
end
end
ExampleWorker.registerRequest for heavy lifting coming in:
def background_action
session[:job_key] = MiddleMan.new_worker(:class => :example_worker, :args => {:arg => params[:some_arg]})
endResponse going out (this could be used in an AJAX calback action):
def callback
@result = MiddleMan.worker(session[:job_key]).results[:some_string]
end
It's so simple I couldn't have thought it up!
You can name your worker jobs by passing :job_key in the :args hash.
Let me speculate that this will become a widely used plugin as rails is receiving more and more commercial adoption. Who knows, it might even get merged into rails core! It definetly blows PHP's output buffering out of the water!










