Imaginemos un mundo libre

La paz interior comienza en el momento en el que decides no permitir, que ninguna persona o evento, tome el control de tus emociones.

Archive for May 2008


leave a comment »

Rake is a Ruby program that builds other Ruby programs.  Each time you execute rake, it knows how to build those programs by reading a file called Rakefile which has a set of tasks.  Those tasks allows us to do some project needs in a very easy and efficient way.

When you generate a rails project you automatically get a Rakefile and it is located in the root of your project.

You can see all rake tasks and their descriptions by running a simple command in your main directory:

rake –tasks

And this should be shown:

 rake backgroundrb:remove # Remove backgroundrb from your rails ...
 rake backgroundrb:restart # Restart backgroundrb server (default...
 rake backgroundrb:setup # Setup backgroundrb in your rails app...
 rake backgroundrb:start # Start backgroundrb server (default v...
 rake backgroundrb:stop # Stop backgroundrb server (default va...
 rake db:abort_if_pending_migrations # Raises an error if there are pending...
 rake db:charset # Retrieves the charset for the curren...
 rake db:collation # Retrieves the collation for the curr...
 rake db:create # Create the database defined in confi...
 rake db:create:all # Create all the local databases defin...
 rake db:drop # Drops the database for the current R...
 rake db:drop:all # Drops all the local databases define...
 rake db:fixtures:identify # Search for a fixture given a LABEL o...
 rake db:fixtures:load # Load fixtures into the current envir...
 rake db:migrate # Migrate the database through scripts...
 rake db:migrate:redo # Rollbacks the database one migration...
 rake db:migrate:reset # Resets your database using your migr...
 rake db:reset # Drops and recreates the database fro...
 rake db:rollback # Rolls the schema back to the previou...
 rake db:schema:dump # Create a db/schema.rb file that can ...
 rake db:schema:load # Load a schema.rb file into the database
 rake db:sessions:clear # Clear the sessions table
 rake db:sessions:create # Creates a sessions migration for use...
 rake db:structure:dump # Dump the database structure to a SQL...
 rake db:test:clone # Recreate the test database from the ...
 rake db:test:clone_structure # Recreate the test databases from the...
 rake db:test:prepare # Prepare the test database and load t...
 rake db:test:purge # Empty the test database
 rake db:version # Retrieves the current schema version...
 rake doc:app # Build the app HTML Files
 rake doc:clobber_app # Remove rdoc products
 rake doc:clobber_plugins # Remove plugin documentation
 rake doc:clobber_rails # Remove rdoc products
 rake doc:plugins # Generate documentation for all insta...
 rake doc:rails # Build the rails HTML Files
 rake doc:reapp # Force a rebuild of the RDOC files
 rake doc:rerails # Force a rebuild of the RDOC files
 rake log:clear # Truncates all *.log files in log/ to...
 rake notes # Enumerate all annotations
 rake notes:fixme # Enumerate all FIXME annotations
 rake notes:optimize # Enumerate all OPTIMIZE annotations
 rake notes:todo # Enumerate all TODO annotations
 rake rails:freeze:edge # Lock to latest Edge Rails or a speci...
 rake rails:freeze:gems # Lock this application to the current...
 rake rails:unfreeze # Unlock this application from freeze ...
 rake rails:update # Update both configs, scripts and pub...
 rake rails:update:configs # Update config/boot.rb from your curr...
 rake rails:update:javascripts # Update your javascripts from your cu...
 rake rails:update:scripts # Add new scripts to the application s...
 rake remove_simple_captcha_files # Remove unuseful captcha images and s...
 rake routes # Print out all defined routes in matc...
 rake secret # Generate a crytographically secure s...
 rake solr:destroy_index # Remove Solr index
 rake solr:start # Starts Solr.
 rake solr:stop # Stops Solr.
 rake stats # Report code statistics (KLOCs, etc) ...
 rake test # Test all units and functionals
 rake test:functionals # Run tests for functionalsdb:test:pre...
 rake test:integration # Run tests for integrationdb:test:pre...
 rake test:plugins # Run tests for pluginsenvironment / R...
 rake test:recent # Run tests for recentdb:test:prepare ...
 rake test:uncommitted # Run tests for uncommitteddb:test:pre...
 rake test:units # Run tests for unitsdb:test:prepare /...
 rake tmp:cache:clear # Clears all files and directories in ...
 rake tmp:clear # Clear session, cache, and socket fil...
 rake tmp:create # Creates tmp directories for sessions...
 rake tmp:pids:clear # Clears all files in tmp/pids
 rake tmp:sessions:clear # Clears all files in tmp/sessions
 rake tmp:sockets:clear # Clears all files in tmp/sockets
 rake uml:schema # Generate an XMI db/schema.xml file d...

Those rake tasks will be used many times when developing your rails application.
For example, there is an interesting task rake stats which generates detailed statistics about your application code and provides a dashboard of information.  This is what I get:

| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
| Controllers          |  6080 |  5241 |      54 |     369 |   6 |    12 |
| Helpers              |   552 |   501 |       0 |      25 |   0 |    18 |
| Models               |  3855 |  3274 |     157 |     326 |   2 |     8 |
| Libraries            |  3068 |  2806 |      18 |      71 |   3 |    37 |
| APIs                 |     9 |     9 |       1 |       0 |   0 |     0 |
| Components           |     0 |     0 |       0 |       0 |   0 |     0 |
| Integration tests    |     0 |     0 |       0 |       0 |   0 |     0 |
| Functional tests     |  1261 |   942 |      97 |     200 |   2 |     2 |
| Unit tests           |  1246 |   884 |     117 |     129 |   1 |     4 |
| Total                | 16071 | 13657 |     444 |    1120 |   2 |    10 |
Code LOC: 11831     Test LOC: 1826     Code to Test Ratio: 1:0.2

There are many other rake commands very useful for rails development.

Thanks for your visit to the blog. You can follow me on Twitter:


Written by Ronny Yabar

May 30, 2008 at 10:13 pm

Posted in Ruby on Rails

Tagged with , ,

En busca de Hackers – Documental

leave a comment »

En busca de Hackers, es un documental emitido por elegantMob de España, el cual muestra una seria de entrevistas y formas de vida, de distintos hackers esparcidos por el país.

Claramente, se trata de romper esos prejuicios, insertados en la sociedad, acerca de lo que es un Hacker y mostrar realmente, lo que significa este estilo de vida y forma de pensar. Vean y analizen ustedes mismos.


Written by Ronny Yabar

May 27, 2008 at 10:16 am

Summer of Code started

leave a comment »

Hey. Today Summer of Code started and I feel pretty well at this point.

I had a good chat with my mentor David Shettler (Leader software developer of the OSVDB team). I consider him a complete professional and better mentor because of his support, humility and his advices.

I remember perfectly the first words he told me today: “Oh Ronny. Fun starts today”.

We discuss many things , mainly about the current OSVDB database schema wich is really big. This let me get a better understanding of the project and making an initial design of my work and use cases.

I got subversion access and I am now looking the source code and running this great software project (OSVDB 2.0). This is a real web application written in ruby on rails used to manage vulnerabilities and all the osvdb website. It is just amazing.

I really enjoyed this day and think this will be a great experience for me and other summer of coders. I am going to inform of my work progress in the OSVDB gsoc 2008 wiki.

Good luck to everyone. Enjoy the summer.

Written by Ronny Yabar

May 26, 2008 at 1:05 am

Hpricot installation problem

with 4 comments

Hpricot is a fast,  flexible HTML parser written in C. Hpricot can be handy for reading broken XML files,  since many of the same techniques can be used. If a quote is missing Hpricot will try to figure it out.

I was really having problems to install hpricot,  the newest version is 0.6.  Whenever I executed:

$ sudo gem install hpricot
Select which gem to install for your platform (arm-linux)
1. hpricot 0.6 (mswin32)
2. hpricot 0.6 (jruby)
3. hpricot 0.6 (ruby)
4. hpricot 0.5 (ruby)
5. hpricot 0.5 (mswin32)
6. Skip this gem
7. Cancel installation
> 3

I received the following message:

Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

I Typed this to see what is going on:

ruby extconf.rb install hpricot

and the error continue

extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1

Gem files will remain installed in /var/lib/gems/1.8/gems/hpricot-0.6 for inspection. Results logged to /var/lib/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/gem_make.out

Googling for a while,  I found a good solution in the hpricot project wiki.  The main problem is that I had ruby 1.8 and 1.9 installed. Ruby 1.8.5 was the version I was using, but I didn’t have development libraries installed.  So, gem couldn’t install correctly hpricot.

You can check your version for ruby, rails, gem and everything else by typing -m after the program name.

$ ruby -v
ruby 1.8.5 (2006-08-25) [i486-linux]
$ gem -v

The solution: There is a file we need,  called mkmf.rb. It has connection with ruby libraries,  so let’s search it.

$ auto-apt search mkmf.rb
usr/lib/ruby/1.9/mkmf.rb        devel/ruby1.9-dev

As you can see, we don't have it in ruby1.8 directory, so let us install ruby1.8 development libraries.

$ sudo apt-get install ruby1.8-dev

and now, we have the mkmf.rb in ruby1.8

$ auto-apt search mkmf.rb
usr/lib/ruby/1.9/mkmf.rb        devel/ruby1.9-dev
usr/lib/ruby/1.8/mkmf.rb        devel/ruby1.8-dev

There is no documentation in the wiki,  but I assume that you have to install another gem called mechanize which is  an hpricot  dependency.

$ sudo gem install mechanize
Install required dependency hpricot? [Yn]
Select which gem to install for your platform (arm-linux)
1. hpricot 0.6 (mswin32)
2. hpricot 0.6 (jruby)
3. hpricot 0.6 (ruby)
4. hpricot 0.6 (jruby)
5. hpricot 0.6 (ruby)
6. hpricot 0.6 (mswin32)
7. Skip this gem
8. Cancel installation
> 3
Building native extensions.  This could take a while...
Successfully installed mechanize-0.6.9
Successfully installed hpricot-0.6
Installing ri documentation for mechanize-0.6.9...
Installing ri documentation for hpricot-0.6...
Installing RDoc documentation for mechanize-0.6.9...
Installing RDoc documentation for hpricot-0.6...

Finally, you will get hpricot successfully installed and now you can use this great gem.

Thanks for your visit to the blog. You can follow me on Twitter:

Written by Ronny Yabar

May 5, 2008 at 9:36 pm

Posted in Ruby on Rails

Tagged with ,