From: Aredridel Date: 2005-03-26T09:46:57+09:00 Subject: Re: loading "plugins" On Sat, 26 Mar 2005 03:29:50 +0900, Hans Fugal wrote: > I am writing a log analyzer (hans.fugal.net/src/clog) that uses a sort > of plugin (I call them agents) which is basically a class that gets > instantiated and then called to do work. I want to include various > agents with the distribution. > > Where should the files end up? How should I discover the agents? > > The sysadmin will be able to specify a directory (or directories) that > contain his own agents, in addition to the included agents. I can scan > that directory for .rb files and load them. That part works. But I don't > want to make the sysadmin specify where the standard agents are in the > config file - that should be implied. "require 'clog/agents/*'" would > express what I want to do, although that isn't valid. I don't want to > hardcode a path to /usr/local/lib/site_ruby/whatever, either. > > Ultimately, the sysadmin should refer to the agents with a simple > one-word name, e.g. Postfix or Bogofilter. > The unix way would be to have /usr/share/yourapp/plugins/FooClass.rb be the FooClass plugin, and perhaps optionally also search a user's home directory, ~/.yourapp/plugins/FooClass.rb Simple, concise, understandable and scalable.