background preloader

Tutorials

Facebook Twitter

Rake Tutorial. If you’re developing with Rails you’ve probably encountered rake once or twice.

Rake Tutorial

This blog post aims to walk you through where rake came from and an introduction on how to use it effectively in your Rails apps. A Little Bit of History Rake is the project of Jim Weirich. It’s a build tool. For a good laugh and an even more in depth history check out the "rational.rdoc" from the Rake documentation. What’s the need for an automated build system at all? Historically, developers used build automation to call compilers and linkers from inside a build script versus attempting to make the compiler calls from the command line. It’s about Dependencies This may be a bit of a stretch to say but build tools are about dependencies.

What we’re saying here is that the file named “hello.tmp” depends on the directory "tmp". If you were to look at the "hello.tmp" file you would see the phrase "Hello". Now if you were to run it twice you would see something like this: Running Other Tasks Namespaces Refactoring. Rake Tutorial. Rake is a build tool written in Ruby, similar to make, Ant and Phing.

Rake Tutorial

There is a major difference between Rake and the others, though. Unlike the rest of the tools, Rake does not provide an external DSL (like XML build file in Ant). Instead, all the task are written in pure Ruby. Therefore you gain full flexibility and can take advantage of some nice Ruby features. What Are The Build Tools? If you've ever tried to install software from source in the Linux or Unix system, there is a high probability that you have already had contact with make.

My eBook: “Memoirs of a Software Team Leader” Read more » Second and third lines are simply make program invocations. Make also allows to spare time. Build tools can be used not only for source code compilation, but that was infact the task they were created for. Difference Between Rake and Other Build Tools As I have already mentioned, there is one major difference between Rake and other build tools.

Install Rake First Rake Task Expressing Dependencies. Getting Started - { Received via EMail: I have just started using the excellent Rake tool (thanks, Jim!)

Getting Started - {

And I am at a bit of a loss on how to proceed. I am attempting to create unit test for some C++ code I am creating, […] Several people recently have made similar comments, they really like rake, but have had trouble getting started. Although the Rake documentation is fairly complete, it really does assume you are familiar with other build tools such as ant and make. To adderess this lack, I’m going to post several Rake tutorial articles that will take you through some of the basics. Here’s the first one! The Problem We will start with a very simple build problem, the type of problem that make (and now rake) were desiged to deal with. Suppose I am a C programmer and I have a simple C program consisting of the following files. main.c #include "greet.h" int main() { greet ("World"); return 0; } greet.h extern void greet(const char * who); greet.c (Yes, it really is the old standard "Hello, World" program.