Lambdas Recursivos
why I love Ruby
bookmark_files = lambda do |file| if file.is_bookmarked? my_bookmarks << file elsif file.got_children? file.children.each &bookmark_files end end
February 17, 2011 | En Ruby | No hay comentarios
why I love Ruby
bookmark_files = lambda do |file| if file.is_bookmarked? my_bookmarks << file elsif file.got_children? file.children.each &bookmark_files end end
El formato por defecto del logger de Rails si bien da mucha informacion es algo feo. Para mejorarlo pueden pegar esta modificacion en el archivo environment.rb. El siguiente format_message muestra los logs con colores segun el level y un timestamp
class Logger
NUMBER_TO_COLOR_MAP = {'DEBUG'=>'0;37', 'INFO'=>'32', 'WARN'=>'33', 'ERROR'=>'31', 'FATAL'=>'31', 'UNKNOWN'=>'37'}
def format_message(level, time, progname, msg)
color = NUMBER_TO_COLOR_MAP[level]
"#{time.to_s(:db)} \e[#{color}m#{level.center(7)}\e[0m -- #{msg}\n"
end
end$ sudo gem install rvm $ rvm-install
despues de esto seguir las instrucciones en pantalla para finalizar la instalacion de rvm.
$ rvm install 1.9.1
$ rvm use 1.9.1 $ ruby -v ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin10.3.2]
Entradas y comentarios feeds. 14 queries. 0.260 seconds.