Forum: Rails-core (closed, excessive spam) Gems as plugins and rails/init.rb

Posted by Jacek Becela (Guest)
on 2008-05-28 13:37
(Received via mailing list)
Hello,

Why do we have to put "rails/init.rb" into a gem and not simply
"init.rb" in main dir of a gem to make it behave like a plugin? Are
there some special reasons for that?

It would be cool to have one codebase which can be packaged as a gem
or used as a classic plugin.

On the other hand, some say (and I agree) plugins will perish in favor
of gems - maybe we just should wait, or speed this process up by
converting plugins into gems and not allowing to use them in old way
by leaving only "rails/init.rb" and deleting "init.rb" from main dir?

Cheers,

Jacek
Posted by Chad Woolley (Guest)
on 2008-05-28 18:00
(Received via mailing list)
On Wed, May 28, 2008 at 4:36 AM, Jacek Becela <jacek.becela@gmail.com> 
wrote:
> Why do we have to put "rails/init.rb" into a gem and not simply
> "init.rb" in main dir of a gem to make it behave like a plugin? Are
> there some special reasons for that?

One reason would be to provide some namespacing of the init hook for
gems that work with multiple frameworks, or have a purpose outside the
context of Rails.

-- Chad
Posted by Chad Woolley (Guest)
on 2008-05-28 18:36
(Received via mailing list)
On Wed, May 28, 2008 at 4:36 AM, Jacek Becela <jacek.becela@gmail.com> 
wrote:
> Why do we have to put "rails/init.rb" into a gem and not simply
> "init.rb" in main dir of a gem to make it behave like a plugin? Are
> there some special reasons for that?

One reason would be to provide some namespacing of the init hook for
gems that work with multiple frameworks, or have a purpose outside the
context of Rails.

-- Chad
Posted by Jacek Becela (Guest)
on 2008-05-28 18:50
(Received via mailing list)
> One reason would be to provide some namespacing of the init hook for
> gems that work with multiple frameworks, or have a purpose outside the
> context of Rails.

Is init.rb in the main gem directory ever used by gems infrastucture?
I couldn't find any reference of that but I agree - it's more
aesthetic in rails dir and better in case of multiple frameworks.

My conclusion is to keep init.rb in both dirs: main and rails, and
make sure that only "rails/init.rb" is mentioned in gemspec, so the
generated gem will be as clean as possible.

--
Jacek
Posted by Chad Woolley (Guest)
on 2008-05-28 19:46
(Received via mailing list)
On Wed, May 28, 2008 at 9:50 AM, Jacek Becela <jacek.becela@gmail.com> 
wrote:
> My conclusion is to keep init.rb in both dirs: main and rails, and
> make sure that only "rails/init.rb" is mentioned in gemspec, so the
> generated gem will be as clean as possible.

Or make Rails look for it in either place in plugins, and only have it
in rails/init.rb for gems.  I thought this was already the case, but
maybe it was just discussed and not implemented yet.

-- Chad
Posted by Jacek Becela (Guest)
on 2008-05-28 22:22
(Received via mailing list)
> Or make Rails look for it in either place in plugins, and only have it
> in rails/init.rb for gems.  I thought this was already the case, but
> maybe it was just discussed and not implemented yet.

It's the case - it was not implemented, but I had a spare moment so I
created a patch:

http://rails.lighthouseapp.com/projects/8994/ticke...

You are most welcome to look at it and maybe +1 :)

--
Jacek
This topic is locked and can not be replied to.