You need automation ? Use Rake!

Publié par Nico Mar 26 juin 2007 10:18:00 GMT

For those who don’t know, Rake is a built language, similar in purpose to make and ant. It’s a specific domain language written in Ruby.

In this article I will introduce rake and describe some interesting tricks you can use to automate repetitive things you do everyday.

Theory

Rake has been developed by Jim Weirich and is based on Ruby, which means that you have full access to Ruby power inside Rake. Rake is not limited to what you know with tools like make or ant, it’s much more powerful and flexible.

Rake is all about dependencies. When you write a Rake script, you’re going to tell it that a given task depends on another one and so on. This way you can build a complete receipe to explain how to do things and in which order.

Because Rake is built on Ruby, you can do anything you want with your tasks :

  • manipulate files
  • compile your programs
  • cleanup your filesystem
  • generate skeletons
  • much much more

Let’s see what we can do!

Real World

First try: Adding a task and triggering it by default

task :default => [:say_hi]

desc "This is our first task"
task :say_hi do
  puts "Hey! I'm the first task you wrote!"
end

desc "Running test"
task :test do 
  require 'rake/runtest'
  Rake.run_tests 'tests/*.rb'
end

On the first line we’re telling rake that our default task—the one called if we use rake on the command-line) will be the task named say_hi. You can also call it by using rake say_hi.

Then we describe the task we’re going to write. This description will be printed if you use rake -T to know which tasks are available in your Rakefile.

Finally we’re defining a new task called say_hi using task keyword. What you put inside this task is just usual Ruby code.

Rake provides some facilities to manipulate files, create Gems and things like that. You should take a look at this API.

We’re using these facilities with the test task by loading a library distributed with Rake and calling one of its methods. For instance, we’re loading runtest library and running each test file available in ‘tests’ directory.

Linking tasks:

task :upload_files do
  # do the uploading
end

task :symlink => :upload_files do
  # create symlinks on the server-side
end

task :deploy => :symlink do
  # deploy the latest revision of your project
end

Now we have a bunch of tasks we can use. If we type rake deploy, it’s going to call the symlink task that depends on upload_files task. So rake will execute upload_file first, then symlink and deploy.

This is how you can link tasks and make sure that all required steps would be run before doing what you asked for.

Conclusion

If you begin to use Rake to automate your tasks, you’ll quickly realize that it is a powerful tool, easy to use . One of the most interesting thing is that Rake is built upon Ruby and that Ruby can run on any operating system. Of course, knowing Ruby will help you to master Rake but you can easily write simple tasks even if you’re a Ruby beginner.

Another thing is that Rake is not only for Ruby users. You can use it for anything like building C programs, cleaning your file-system, deploying, administrating your databases, ...

You should really give a try to Rake and if you do, let us know what you think about it and what you’re doing with it by leaving us a comment.

Publié sous  | Mots clés , ,  | 2 commentaires

Mise en ligne de Business on Rails

Publié par Nico Ven 15 juin 2007 08:51:00 GMT

Nous sommes heureux de vous présenter le premier annuaire francophone des sites et applications développés en Rails !

Notre objectif est de permettre à chacun de mettre en avant ses réalisations. Cet annuaire s’enrichira au fil des projets mis en ligne.

Résolument indépendant, Business on Rails concentrera le meilleur du Rails francophone pour donner de la visibilité à notre framework préféré auprès des décideurs et prescripteurs.

Nous pourrons aussi tenir à jour l’état de la production Rails de l’hexagone.

Vous aurez également accès à des interviews vidéos des décideurs qui expliqueront leurs choix et leurs retours d’expériences.

Bonne visite sur Business on Rails.

Publié sous  | Mots clés  | aucun commentaires

Réunion Ruby on Rails à Lille

Publié par Nico Jeu 14 juin 2007 15:25:00 GMT

Nous organisons, ce jeudi 28 juin à partir de 20H, une réunion autour de Ruby et Ruby on Rails.

Cette réunion est ouverte à tous et à toutes, développeurs confirmés, novices ou simples curieux.

Le thème principal de notre première soirée sera axé autour des méthodes agiles. Chaque participant pourra s’il le souhaite prendre 15 ou 20 minutes pour présenter un thème de son choix puis répondre aux éventuelles questions. Un vidéo projecteur sera à disposition.

Cette réunion aura lieu chez Digiport (euratechnologies, 165 avenue de Bretagne, 59044 Lille Cedex)

Si cette réunion rencontre un succès suffisant, nous aimerions la reconduire une fois par mois.

Si vous souhaitez venir, laissez nous un commentaire pour que nous puissions évaluer le nombre de personnes présentes.

Si vous avez des idées ou suggestions pour ces réunions, n’hésitez pas non plus à nous laisser un commentaire.

Publié sous  | Mots clés  | 10 commentaires

What's coming with Rails 2.0?

Publié par Nico Lun 11 juin 2007 14:32:00 GMT

During RailsConf ‘07, DHH talked about features that will be available in Rails 2.0.

Let’s review some of the most interesting ones :
  • Action Web Service is becoming a plugin and will not be bundled with Rails anymore. The prefered way to write WebServices is to use REST and Active Resource. Rails is an opiniated software and core team is trying to help REST becoming a standard way of implementing WebServices.
  • Breakpointer is back : you can now inspect an object in console while the application is running. So if you have a breakpoint in you app, you can watch your objects available to this point and then continue execution. Really handy to debug your app.
  • You can cache your Javascript and CSS files using cache => true. It will improve your HTTP perf by concatenating and gzipping your files together before sending them to the browser. So you’ll have only one connection rather that 5 if you have 5 .js files for instance.
  • Need more pref improvement ? Right, there’s something else: you will have access to asset hosts in you environment file. With this, you can specify that your static files are available on many host and access to load-balancing for free.
  • SQL Query Caching is in the place. All SQL queries are now cached ; if some data is outdated, Rails will know about it and will flush automatically.
  • Sexy migrations : the format used in migration files has changed. Rather than t.column :counter, :integer you can now use t.integer :counter. That’s the same for all other SQL types.
  • Config is now spread between many directory for clarity. You have multiple files for multiple sections
  • HTTP Authentication : there’s now a simple way to add HTTP authentication to an action. It can be useful for private RSS feeds or things like that.

This list isn’t exhaustive and Rails 2.0 will have some other great features. But now, you’ve got the idea, Rails Core Developer have focused on performance and this realease will be a gift for all Rails developers.

Publié sous  | Mots clés  | aucun commentaires

Animated commercial for Ruby on Rails

Publié par Nico Lun 11 juin 2007 14:03:00 GMT

Here is some fun about Ruby on Rails.

Take a look at Ruby on Rails, web development that doesn't hurt.

Publié sous  | Mots clés ,  | aucun commentaires

Interview with RailsEnvy

Publié par Nico Mar 05 juin 2007 08:12:00 GMT

We met RailsEnvy guys at RailsConf '07 and asked them to talk about their feelings and their business with Ruby on Rails.

For people who don't know, RailsEnvy is a famous blog talking about Rails. It's lead by Gregg Pollack (founder of Orlando Ruby Users Group) and Jason Seifer. They work together at Patched Software.

You should really take a look at their blog, they made pretty cool Ads for Rails!

Enjoy.

Download Flash player to see this video.

Publié sous  | Mots clés  | aucun commentaires

Introducing Apollo

Publié par Nico Ven 01 juin 2007 08:24:00 GMT

Kevin Hoyt, a platform evangelist at Adobe we met on a stand at the RailsConf '07, made us a small introduction to Apollo.

Apollo is a development tool that helps you to use Flash, Flex, HTML, JavaScript and Ajax to build and deploy rich Internet applications (RIAs) to the desktop using Flex and allowing the offline use of your Web applications.

Kevin doesn't explain how to use Apollo with Rails but you will be able to find examples on the web.

This video is about 20 minutes, enjoy!

Download Flash player to see this video.

Publié sous  | Mots clés , , ,  | aucun commentaires