Professional Web Applications Themes

Plugin-API - Ruby

Hi, -- On Thu, Nov 20, 2003, Christian Kruse wrote: > Hi there, > > I'm writing an application in Ruby which should be easy to extend. One > should be able to write a plugin for this application and should be able > to load it with an entry in the config file, e.g. > > [snip] > What's the "ruby way" to do this? > > Greetings, > CK > Maybe you can have a look at the rbot source code ([url]http://www.linuxbrit.co.uk[/url]) which has a quite good system of plugin auto discovery (and reload too) HTH, -- Pierre ...

  1. #1

    Default Re: Plugin-API

    Hi, --

    On Thu, Nov 20, 2003, Christian Kruse wrote:
    > Hi there,
    >
    > I'm writing an application in Ruby which should be easy to extend. One
    > should be able to write a plugin for this application and should be able
    > to load it with an entry in the config file, e.g.
    >
    > [snip]
    > What's the "ruby way" to do this?
    >
    > Greetings,
    > CK
    >
    Maybe you can have a look at the rbot source code
    ([url]http://www.linuxbrit.co.uk[/url]) which has a quite good system of plugin
    auto discovery (and reload too)

    HTH,
    --
    Pierre Baillet
    It is a good viewpoint to see the world as a dream. When you have something
    like a nightmare, you will wake up and tell yourself that it was only a dream.
    It is said that the world we live in is not a bit different from this.
    Ghost Dog - The Way of the Samouraï


    Pierre Baillet Guest

  2. #2

    Default Plugin-API

    Hi there,

    I'm writing an application in Ruby which should be easy to extend. One
    should be able to write a plugin for this application and should be able
    to load it with an entry in the config file, e.g.

    Load ContentFilter

    Perl I would use eval statements like

    eval "use $modname";
    die $ if $;

    to load the plugin. In Perl the plugin would look like the following:

    push {$main::Plugins->{state}},new Module;

    package Module;

    sub new() {
    }
    ....

    1;

    What's the "ruby way" to do this?

    Greetings,
    CK

    Christian Kruse Guest

  3. #3

    Default Re: Plugin-API


    "Christian Kruse" <ckrusedefunced.de> schrieb im Newsbeitrag
    news:8mgipb.a13.lnnews.defunced.de...
    > Hi there,
    >
    > I'm writing an application in Ruby which should be easy to extend. One
    > should be able to write a plugin for this application and should be able
    > to load it with an entry in the config file, e.g.
    >
    > Load ContentFilter
    >
    > Perl I would use eval statements like
    >
    > eval "use $modname";
    > die $ if $;
    >
    > to load the plugin. In Perl the plugin would look like the following:
    >
    > push {$main::Plugins->{state}},new Module;
    >
    > package Module;
    >
    > sub new() {
    > }
    > ....
    >
    > 1;
    >
    > What's the "ruby way" to do this?
    Assuming the config file is evaluated as ruby code you can do:

    15:33:28 [temp]: for file in PluginBase.rb SomePlugin.rb config.rb
    application.rb ; do echo "---- $file ----" ; cat "$file" ; done
    ---- PluginBase.rb ----
    class PluginBase
    end

    ---- SomePlugin.rb ----
    require 'PluginBase'

    class PluginClass < PluginBase
    # functionality
    end

    $plugin_registry << PluginClass
    ---- config.rb ----
    require 'SomePlugin'

    ---- application.rb ----
    # other classes

    $plugin_registry = []

    eval File.readlines("config.rb").join

    p $plugin_registry

    15:33:36 [temp]:


    As easy as that...

    robert

    Robert Klemme Guest

  4. #4

    Default Re: Plugin-API

    il Thu, 20 Nov 2003 14:47:52 +0100, Christian Kruse
    <ckrusedefunced.de> ha scritto::


    you may find this thread useful:
    [url]http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/48648[/url]
    gabriele renzi Guest

  5. #5

    Default Re: Plugin-API

    On Thu, Nov 20, 2003, Christian Kruse wrote:
    > Hi there,
    >
    > I'm writing an application in Ruby which should be easy to extend. One
    > should be able to write a plugin for this application and should be able
    > to load it with an entry in the config file, e.g.
    >
    > [snip]
    > What's the "ruby way" to do this?
    >
    > Greetings,
    > CK
    You might want to look at the plugin system used by FreeRIDE which is called
    FreeBASE and has been packaged as a separate download. See:

    [url]http://freeride.rubyforge.org/wiki/wiki.pl?FreeBASE[/url]

    The FreeRIDE IDE is completely (100%) implemented as a set of plugins, with
    the exception of FreeBASE, which is the plugin manager. It has sophisticated
    facilities for specifying dependencies between plugins (which affects the
    load order of plugins) and includes a high-performance messaging engine (the
    databus) that allows plugins to communicate with each other while minimizing
    coupling.

    However, if your plugin needs are very simple, this might be overkill.

    Curt


    Curt Hibbs Guest

  6. #6

    Default Re: Plugin-API

    Hoi,
    > [...]
    Thank you very much for your help.

    Greetings,
    CK

    Christian Kruse Guest

Similar Threads

  1. Opera Plugin - Like IE Plugin
    By Sectas in forum Macromedia Contribute General Discussion
    Replies: 1
    Last Post: April 7th, 09:54 AM
  2. Replies: 3
    Last Post: May 18th, 07:31 AM
  3. Plugin's
    By iukini in forum Adobe Illustrator Windows
    Replies: 8
    Last Post: May 6th, 03:21 PM
  4. Replies: 0
    Last Post: January 16th, 06:22 PM
  5. Ann : New plugin
    By Roberto in forum FileMaker
    Replies: 0
    Last Post: October 10th, 09:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139