Sirportly

Toggle Menu

Modules

Sirportly supports modules which allow extensions to the application to be easily inserted without needing to modify any of the files we provide. While this functionality is mostly beneficial to users of the Enterprise Edition, users of the hosted edition may still write modules and we will review them and consider them for inclusion in our cloud installation - if you do this, the modules must be able to benefit all users of the system rather than just your own account.

This documentation outlines how the modules system works and how you can use it within your own Sirportly installation. To begin with, all modules must be stored within modules directory in the root of your Sirportly installation. The filename should be the name of the module, with a .rb extension, for example if you were writing twitter integration you may call it twitter.rb. The name must correspond with the name of the module class you enter when developing the module.

In it's most basic form a module includes a name, a description, an author and code which should be executed when the application starts. All of these options must be included within the file as outlined below. On line 4, you should enter the class name for your module which must correspond with the filename, for example if the class name is Twitter the file name would be twitter.rb and if the class name is AwesomeStuff the filename would be awesome_stuff.rb.

module Sirportly
  module Modules
    module Custom
      class Twitter < Module

        module_name "Twitter"
        description "A description to define this module to Sirportly server admins"
        author "Your Name <joe@bloggs.com>"

        def self.loaded
          ## Any code in this method will be executed when the application is started.
        end

      end
    end
  end
end

Once you have created your module, in order for it to be loaded it must be configured in your configuration file. All modules which you wish to load must be listed in the config.modules.custom array, for example:

    config.plugins.custom = ['twitter', 'awesome_stuff']

In order to see a full list of all modules which have been included, you can execute the following bash code from the root of your installation path.

$ cd app
$ rake sirportly:modules

As soon as you start the application again, you will find that code you have entered in the self.loaded method is executed within the application startup process. This code will run for any Sirportly process including the web server, worker and cron processes.

If this was all modules could do they would be pretty boring things, so you'll need to look on the pages listed below for further information about how you to work with modules in a supported manner.