
\begin{DoxyItemize}
\item infos = Information about R\+U\+BY plugin is in keys below
\item infos/author = Bernhard Denner \href{mailto:bernhard.denner@gmail.com}{\tt bernhard.\+denner@gmail.\+com}
\item infos/licence = B\+SD
\item infos/needs =
\item infos/provides = storage
\item infos/placements = getstorage setstorage
\item infos/recommends =
\item infos/status = maintained reviewed tested nodep configurable preview memleak experimental
\item infos/description = Ruby plugin bridge, implement Elektra plugins with Ruby
\end{DoxyItemize}

This plugin is an Elektra to Ruby bridge and makes is possible to implement Elektra plugins with Ruby. This plugin requires the {\ttfamily swig\+\_\+ruby} binding.

\subsection*{Configuration Options}

The plugin has the following configuration options\+:


\begin{DoxyItemize}
\item {\ttfamily script}\+: path to the Ruby plugin to use (mandatory)
\end{DoxyItemize}

\subsection*{Usage}

Mount a configuration file using this plugin, which specifying the concrete Ruby Elektra plugin\+:


\begin{DoxyCode}
kdb mount /.ssh/authorized\_keys user/ssh/authorized\_keys ruby script=<path to elektra
source>/src/plugins/ruby/ruby/ssh\_authorized\_keys.rb
kdb ls user/ssh/authorized\_keys
\end{DoxyCode}


\subsection*{Implementing Ruby Plugins}

The following example illustrates how to implement a Elektra plugin with Ruby\+:


\begin{DoxyCode}
require 'kdb'

# call the static function 'define' to define a new Plugin. This
# function expects one argument and a block, which implements the plugin
Kdb::Plugin.define :somename do

  # this is automatically defined
  #@plugin\_name = "somename"


  # 'Open' method, called during Elektra plugin initialization
  # parameter:
  #  - errorKey: Kdb::Key, add error information if required
  # returns:
  #  - nil or 0: no error
  #  - -1      : error during initialization
  def open(errorKey)

    # generally it is save to simply throw an exception. This has the same
    # semantic as returning -1
  end

  # the close method is currently not supported, since this will crash the
  # Ruby-VM if this method should be called during the VM.finalization !!!
  #def close(errorKey)
  #
  #end


  # 'check\_conf' method, called before this plugin is used for mounting to check
  # if the supplied config is valid. Missing or invalid config settings can be
  # 'corrected' or added.
  # Parameter:
  #  - errorKey: Kdb::Key, to add error information
  #  - config: Kdb::KeySet, holds all plugin configuration setting
  # returns:
  #  - nil or 1 : success and the plugin configuration was NOT changed
  #  -        0 : the plugin configuration was changed and is now OK
  #  -       -1 : the configuration is NOT OK
  def check\_conf(errorKey, config)

  end


  # 'get' method, is called during a get cycle, to query all keys
  #
  # Parameter:
  #  - returned : Kdb::KeySet, already holding keys to be manipulated or to be
  #               filled by a storage plugin. All added keys have to have the same
  #               key name prefix as given by parentKey.
  #  - parentKey: Kdb::Key, defining the current Elektra path. The value of this key
  #               holds the configuration file name to read from
  # Returns:
  #  - nil or 1 : on success
  #  -        0 : OK but nothing was to do
  #  -       -1 : failure
  def get(returned, parentKey)

  end


  # 'set' method, is called when writing a configuration file
  #
  # Parameter:
  #  - returned : Kdb::KeySet, holding all keys which should be written to the
  #               config file.
  #  - parentKey: Kdb::Key, defining the current Elektra path. The value of this key
  #               holds the configuration file name to write to
  # Returns:
  #  - nil or 1 : on success
  #           0 : on success with no changed keys in database
  #          -1 : failure
  def set(returned, parentKey)

  end


  # 'error' method, is called when some plugin had a problem during a write cycle
  #
  # Parameter:
  #  - returned : Kdb::KeySet, holding all keys which should be written to the
  #               config file.
  #  - parentKey: Kdb::Key, defining the current Elektra path. The value of this key
  #               holds the configuration file name to write to
  # Returns:
  #  - nil or 1 : on success
  #           0 : on success with no action
  #          -1 : failure
  def set(returned, parentKey)

  end

end
\end{DoxyCode}


\subsection*{Known Issues}


\begin{DoxyItemize}
\item The plugin might cause a S\+I\+G\+S\+E\+GV crash on application shutdown. This is a result of missing Ruby\+VM de initialization, which is silently ignored as we can\textquotesingle{}t determine if the Ruby VM is still needed or not (libelektra might be used by an Ruby application).
\item The plugin does not work correctly with Ruby version managers like {\ttfamily rbenv} or {\ttfamily rvm} and is intended to be used with the Ruby ecosystem installed in system context.
\item Automated test cases are missing 
\end{DoxyItemize}