$darkmode
Elektra 0.11.0
Plugin: ruby

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

Installation

See installation. The package is called libelektra5-ruby.

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

Known Issues