Ruby through rails part 5: Bundler Dsl

In this post, Sanjiv explains what happens under the hood when we do “bundle install”. While learning in detail about how are gems loaded, we learn a few useful Ruby tips and tricks and see some meta-programming at it’s pristine best!

narutosanjiv

Note: All path are relative to bundler gem path. For these blog, i am currently using ruby 2.1.2 and bundler 1.6.3.

While going through Bundler source code earlier, we have seen how bundler evaluates the Gemfile and creates function for each of keyword like gem, source and etc. Now we are going to see the implementation details of a few of these functions. Here is the `gem` function.

The `gem` function accepts one mandatory parameter – the name of the gem and other parameters is an array (called splat parameters). These can be any of :version, :git, :github, :platforms, :source or :group. The * operator (pronounced “star,” “unarray,” or, among the whimsically inclined, “splat”) does a kind of unwrapping of its operand into its components, those components being the elements of its array representation. This function first checks if gem name is provided as symbol and if it is, it throws an exception. The…

View original post 956 more words

Advertisements

About Gautam Rege

Rubyist, Entrepreneur and co-founder of Josh-Software - one of the leading Ruby development shops in India.
This entry was posted in General. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s