I’m building a new version of a Facebook app called Lovers. You can find the Lovers source code on GitHub. I’m also building a custom gem for Facebook alongside it. I want the changes that I make to this custom Facebook gem to immediately go into effect for Lovers.
What’s the correct way to organize its directory structure? Currently, it looks like so:
|- config.ru
|- features
|- support
|- env.rb
|- lib
|- lovers
|= lovers.rb
|- vendor
| - facebook
| - lib
|- modules/classes here
I added ./vendor/facebook/lib to the $LOAD_PATH from config.ru & env.rb. That’s working, but should I be using an init.rb file to do this? What’s the best practice?
You could put your gem in
vendor/facebook, and use Bundler as Simone Carletti suggested, but instead of pulling your gem from rubygems, you could use the:pathoption, to tell bundler where to load your gem from.Using that you could even move the gem out of your project’s tree while developing them side by side.
Your
Gemfilewould contain something like:There are a couple other problems with this.
In order for you to use Bundler to manage your gem, your gem needs a
.gemspecfile. The gemspec specifies your gem’s information, things like version and dependencies. Check out the docs on it.There is already a gem named facebook, so you might want to think about a different name for your gem.