Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the <appname>.rb file in /lib typically used for in a Ruby project?

Tags:

ruby

structure

In reference to this question: Ideal ruby project structure I noticed that appname.rb is in lib, and is top level.

I was reading through a little of the Rake source code on Github, and I noticed their project structure is pretty much the same. They have a top level 'rake.rb' file in /lib, but I'm not sure what it's there for.

In The Pickaxe (Programming Ruby 1.9), they show an example of structuring a small project, with pretty much the same directory structure above, but there is no mention of the usage of a top level .rb in /lib.

So, my question is: What exactly is this thing typically used for in a Ruby project?

Sorry if this is a stupid question, I'm sure it is, but I'm relatively new to Ruby. I don't know that much Ruby-foo right now. ;)

Thanks.

like image 715
Rayne Avatar asked Oct 14 '09 17:10

Rayne


1 Answers

Usually (and certainly in the example of rake) the appname.rb file is a shortcut to require a lot of other files. If you take a look at that file in the Rake project on GitHub, most of what it does is require files in the lib/rake directory and include modules as necessary. That file is what lets you require 'rake' without having to know what individual files rake needs.

like image 131
Emily Avatar answered Nov 15 '22 06:11

Emily