Upload
eugene-henderson
View
212
Download
0
Embed Size (px)
Citation preview
1Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Rake
2Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Automated Build• Any non-trivial project needs facility to
automate builds– Routine common tasks that need to be
carried out several times a day
• Not very efficient to do manually and also error prone
• Rake is the make utility for Rails
3Venkat Subramaniam – [email protected] Subramaniam – [email protected]
What does a make file have?• Typically a make file has
– Commands or tasks
– Dependency between the tasks
– A way to specify which tasks to execute (selectively or all)
– Tasks only execute if necessary
4Venkat Subramaniam – [email protected] Subramaniam – [email protected]
make vs. ant• Even though similar quite some
differences
• ant is task based– You specify tasks and instructions to execute
• make allows file type based specification– You can say that a type of file needs to be
built based on another type of file– make will check for timestamp of these files
and decide if it should be built
5Venkat Subramaniam – [email protected] Subramaniam – [email protected]
What’s special about Rake?• Ant for Java (NAnt for .NET) uses xml• Jim Weirich’s Rake uses ruby!• Makes it easier to write – you are not
switching languages – feels natural• If you know Ruby, you simply read it and
you get it!• Rake is a internal Domain Specific
Language which uses the Ruby syntax• Rake is very easy to extend – write Ruby
code
6Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Let’s Give It a Try
7Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Rake Conventions• Rake uses rakefile.rb by default when you
type rake
• => is used for dependency/pre-requisites
• :default is the task that will be executed, err, by default
8Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Rake Dry Run• Allows you to see what Rake will do
• -- trace option will trace the task calls as it executes
9Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Rake prerequisites• You can find what the pre-requisite for
tasks are using the -P option
10Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Task and description• You can write a description for task and
check those out using –T option
11Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Prerequisite Specification• You can specify when you define a task• You can also specify separately
12Venkat Subramaniam – [email protected] Subramaniam – [email protected]
file tasks• In addition to tasks like we saw so far,
you can define file tasks
• File tasks (like good old make) specify the input output file and pre-requisite input file
• Checks time stamp of output file and if it is earlier than input file, task is executed
13Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Using file
14Venkat Subramaniam – [email protected] Subramaniam – [email protected]
Rake and Rails• Rails make great use of Rake
• Allows you to run different tasks– Tests– Cloning database– …
• One way to learn rake is to study the rake files in Rails