Elektra  0.8.23
Plugin: ruby

This plugin is an Elektra to Ruby bridge and makes is possible to implement Elektra plugins with Ruby. This plugin requires the swig_ruby binding.

Configuration Options

The plugin has the following configuration options:

Usage

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

1 kdb mount /.ssh/authorized_keys user/ssh/authorized_keys ruby script=<path to elektra
2 source>/src/plugins/ruby/ruby/ssh_authorized_keys.rb
3 kdb ls user/ssh/authorized_keys

Implementing Ruby Plugins

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

1 require 'kdb'
2 
3 # call the static function 'define' to define a new Plugin. This
4 # function expects one argument and a block, which implements the plugin
5 Kdb::Plugin.define :somename do
6 
7  # this is automatically defined
8  #@plugin_name = "somename"
9 
10 
11  # 'Open' method, called during Elektra plugin initialization
12  # parameter:
13  # - errorKey: Kdb::Key, add error information if required
14  # returns:
15  # - nil or 0: no error
16  # - -1 : error during initialization
17  def open(errorKey)
18 
19  # generally it is save to simply throw an exception. This has the same
20  # semantic as returning -1
21  end
22 
23  # the close method is currently not supported, since this will crash the
24  # Ruby-VM if this method should be called during the VM.finalization !!!
25  #def close(errorKey)
26  #
27  #end
28 
29 
30  # 'check_conf' method, called before this plugin is used for mounting to check
31  # if the supplied config is valid. Missing or invalid config settings can be
32  # 'corrected' or added.
33  # Parameter:
34  # - errorKey: Kdb::Key, to add error information
35  # - config: Kdb::KeySet, holds all plugin configuration setting
36  # returns:
37  # - nil or 1 : success and the plugin configuration was NOT changed
38  # - 0 : the plugin configuration was changed and is now OK
39  # - -1 : the configuration is NOT OK
40  def check_conf(errorKey, config)
41 
42  end
43 
44 
45  # 'get' method, is called during a get cycle, to query all keys
46  #
47  # Parameter:
48  # - returned : Kdb::KeySet, already holding keys to be manipulated or to be
49  # filled by a storage plugin. All added keys have to have the same
50  # key name prefix as given by parentKey.
51  # - parentKey: Kdb::Key, defining the current Elektra path. The value of this key
52  # holds the configuration file name to read from
53  # Returns:
54  # - nil or 1 : on success
55  # - 0 : OK but nothing was to do
56  # - -1 : failure
57  def get(returned, parentKey)
58 
59  end
60 
61 
62  # 'set' method, is called when writing a configuration file
63  #
64  # Parameter:
65  # - returned : Kdb::KeySet, holding all keys which should be written to the
66  # config file.
67  # - parentKey: Kdb::Key, defining the current Elektra path. The value of this key
68  # holds the configuration file name to write to
69  # Returns:
70  # - nil or 1 : on success
71  # 0 : on success with no changed keys in database
72  # -1 : failure
73  def set(returned, parentKey)
74 
75  end
76 
77 
78  # 'error' method, is called when some plugin had a problem during a write cycle
79  #
80  # Parameter:
81  # - returned : Kdb::KeySet, holding all keys which should be written to the
82  # config file.
83  # - parentKey: Kdb::Key, defining the current Elektra path. The value of this key
84  # holds the configuration file name to write to
85  # Returns:
86  # - nil or 1 : on success
87  # 0 : on success with no action
88  # -1 : failure
89  def set(returned, parentKey)
90 
91  end
92 
93 end

Known Issues