views:

71

answers:

2

I'm working on something in ruby and trying to figure out if it can be turned into a gem. I can find documentation on how to make a gem and gem manuals, but I can't find anything that says, "here is what a gem can and cannot do."

Let's say I created some code, which of the following can a gem do? 1) Use rails conventions like views and routes* 2) Created and/or access tables in a database 3) Have its classes available as parent classes to new code the gem user may want 4) Have partials available for the gem user code to call 5) Expect fields in the environment file (i.e. ask the gem user to add a line to the environment file)

What are some of the other things a gem can or can't do?

*It looks like rails used plugins not gems but things have shifted a bit.

Thanks in advance.

+1  A: 

Gems is only tool (one of the many tools) to deploy some functionality.

It likes deb and rpm packages in linux systems. It likes setuptool and eggs in python. It likes MSI-packages in Windows-world.

I use gems to:

  • package my libraries - blocks of functionality, that can be used by other applications
  • package my applications - I use gem as one of methods of deployment my programs
demas
Can a gem do any of the 5 things I name above? What are the alternatives and which of those 5 can they do?
hershey
Yes, of course. Because gem is block of ANY functionality, but it will be a hack.
demas
A: 

I think a plugin (like engine) can do most of the things you've listed. A gem...maybe could if it hacked into the internals of rails so it could be associated.

rogerdpack
I looked at engine but it looks like it's for doing metaprogramming.
hershey