Widgets

TBD

Applications

Ruby on Rails applications allow plugins to extend the Sonar webapp with a complete MVC stack : controllers, helpers, models and views. Contrary to widgets, it does not require to declare a Java component. Ruby sources just have to be stored in the plugin directory : /src/main/resources/org/sonar/ror/<plugin key>. This directory must also contain an empty file named init.rb.

Development Mode

The development mode reloads Ruby changes on the fly. It allows to edit code and to directly interact with the application. Only the changes on the files that exist during server startup are supported. Adding a new file requires to restart the server.

To enable the development mode on an application :

Install Sonar

Install the plugin by copying the initial JAR file to /extensions/plugins

Edit the file war/sonar-server/WEB-INF/web.xml and set the context-params rails.env to development and jruby.max.runtimes to 3.

Edit the file war/sonar-server/WEB-INF/config/environment.rb and set the absolute path to your ruby application by replacing the property config.plugin_paths :

Start server

Static Files

Plugins can provide static files like images, CSS or JS files. They have to be copied in src/main/resources/static and then can by accessible from the public URL :

The URL can be generated from widgets or applications with the Ruby helper function :

Note that the plugin key is logged during the maven build :

Icon

Static files are not deployed on the fly when the development mode is enabled. The plugin has to be built and re-installed after changes.