Get input in Rake Tasks

This won’t work:

cvs_username = gets

to get it working you have to ask input from STDIN:

cvs_username = STDIN.gets

And this is a helper method:

def ask message
print message
STDIN.gets.chomp
end
# ...
cvs_username = ask('Please insert your CVS username')

Published in:  on November 7, 2008 at 2:47 pm Comments (2)

Sticker Dock

My Dock with thwe Sticker Icons!

My Dock with Sticker Icons!

Published in:  on August 27, 2008 at 4:48 pm Leave a Comment
Tags: , , , ,

How to declare top rake prerequisites from within a namespace

Here’s the problem

task :mytask do
  # ...
end

namespace :myscope do
  task :mytask => :mytask
end

This will end up with loop dependency error, so how we can call a top level task with the same name of one from our current scope?

The solution is not documented, i found it directly in the rake’s library code.

task :mytask do
  # ...
end

namespace :myscope do
  task :mytask => "rake:mytask"
end
Published in:  on May 28, 2008 at 12:48 pm Comments (1)

rails runner… with a relative path

Well, you know what ./script/runner is?

If so, you’ll know you can’t use it to build script without using an absolute path in the shebang line in your custom scripts:

> ./script/runner -h
Usage: ./script/runner [options] ('Some.ruby(code)' or a filename)
You can also use runner as a shebang line for your scripts like this:
#!/usr/bin/env /path/to/your/app/script/runner
...

 So here’s the solution! (here the script is saved in the script dir)

#!/usr/bin/env ruby
unless $0 =~ /runner/
  exec("#{File.dirname(__FILE__)}/runner #{__FILE__}")
  # "exec" exits the current processing, so this comment won't reached (thanks to Arthaey Angosii)
end
# Your great script goes here!

 Alternative:

#!/usr/bin/env ruby
$: << File.dirname(__FILE__)
ARGV[0] = __FILE__
load 'runner'
#your code here
Published in:  on January 23, 2008 at 10:43 am Comments (4)

build native ruby mysql on slackware 12

Here’s the magic option:

sudo gem install mysql  --include-dependencies -- --with-mysql-config=/usr/bin/mysql_config

UPDATE on other systems the following should work:

sudo gem install mysql  --include-dependencies -- --with-mysql-config=`which mysql_config`
Published in:  on November 14, 2007 at 4:09 pm Leave a Comment