[DRE-maint] Opinions on an addition to libacts-as-list-ruby

Gunnar Wolf gwolf at gwolf.org
Wed Oct 15 19:20:49 UTC 2008


Hi,

Still during Debconf, I filed an ITP for libacts-as-list-ruby. This
very handy and popular Rails plugin is -as most things Rails- thought
to be used from within Rails only, and only as a plugin, so it ships
with a very simple init.rb:

    $:.unshift "#{File.dirname(__FILE__)}/lib"
    require 'active_record/acts/list'
    ActiveRecord::Base.class_eval { include ActiveRecord::Acts::List }

In Rails, whatever code you have in vendor/plugins gets its init.rb
executed insta-magically upon the framework initialization. Now,
packaging this module will not put the init.rb in vendor/plugins (nor
anywhere in the system - I'm not shipping the file at all). After all,
this module can be used with any piece of code which uses
ActiveRecord. So, instead of this file I'm shipping
./usr/lib/ruby/1.8/acts_as_list.rb, which contains:

    require 'active_record/acts/list'
    begin
      require 'active_record'
    rescue LoadError
      require '/usr/share/rails/activerecord/lib/active_record'
    end
    ActiveRecord::Base.class_eval { include ActiveRecord::Acts::List }

The begin/rescue part is because it depends on either ActiveRecord or
Rails. And yes, it could even waive that (as many applications will
have the whole of rails stashed in vendor/), but I'm not _that_
forgiving. 

Now, why am I writing to the list? Because I am this way introducing a
slight change in the invocation - It will be needed to add a 
«require 'acts_as_list'» to code requiring this plugin, be it Rails
(of course, given we are not pluginizing) or otherwise.

I will try to push this idea upstream, and will of course document it
in README.Debian. Besides this, is there anything else I should look
out for? Anything you spectacularly bad with this idea?

Thanks,

-- 
Gunnar Wolf - gwolf at gwolf.org - (+52-55)5623-0154 / 1451-2244
PGP key 1024D/8BB527AF 2001-10-23
Fingerprint: 0C79 D2D1 2C4E 9CE4 5973  F800 D80E F35A 8BB5 27AF



More information about the Pkg-ruby-extras-maintainers mailing list