Rake Venkat Subramaniam svenkat@cs.uh.edu 1 Automated Build Any - - PDF document

rake
SMART_READER_LITE
LIVE PREVIEW

Rake Venkat Subramaniam svenkat@cs.uh.edu 1 Automated Build Any - - PDF document

Rake Venkat Subramaniam svenkat@cs.uh.edu 1 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


slide-1
SLIDE 1

1

Venkat Subramaniam – svenkat@cs.uh.edu

Rake

2

Venkat Subramaniam – svenkat@cs.uh.edu

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
slide-2
SLIDE 2

3

Venkat Subramaniam – svenkat@cs.uh.edu

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

4

Venkat Subramaniam – svenkat@cs.uh.edu

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

slide-3
SLIDE 3

5

Venkat Subramaniam – svenkat@cs.uh.edu

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

6

Venkat Subramaniam – svenkat@cs.uh.edu

Let’s Give It a Try

slide-4
SLIDE 4

7

Venkat Subramaniam – svenkat@cs.uh.edu

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

8

Venkat Subramaniam – svenkat@cs.uh.edu

Rake Dry Run

  • Allows you to see what Rake will do
  • -- trace option will trace the task calls as

it executes

slide-5
SLIDE 5

9

Venkat Subramaniam – svenkat@cs.uh.edu

Rake prerequisites

  • You can find what the pre-requisite for

tasks are using the -P option

10

Venkat Subramaniam – svenkat@cs.uh.edu

Task and description

  • You can write a description for task and

check those out using –T option

slide-6
SLIDE 6

11

Venkat Subramaniam – svenkat@cs.uh.edu

Prerequisite Specification

  • You can specify when you define a task
  • You can also specify separately

12

Venkat Subramaniam – svenkat@cs.uh.edu

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

slide-7
SLIDE 7

13

Venkat Subramaniam – svenkat@cs.uh.edu

Using file

14

Venkat Subramaniam – svenkat@cs.uh.edu

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