Dicas de Ruby e/ou Rails
Executando um script em ruby
Para se executar um script em ruby, podemos fazer:
bundle exec rails runner "eval(File.read 'arquivo.rb')"
Analisando logs de ambientes
gem install request-log-analyzer
request-log-analyzer -f rails3 --output html --file report.html production.log
Referências:
- Get S3 request statistics in four simple steps - Jayway
- Teaser check failed · Issue #181 · wvanbergen/request-log-analyzer · GitHub
Running Rspec tests automatically
With the use of the guard-rspec gem and the help of this StackOverflow question we configured the use of guard, to watch for modifications to our files and run rspec when something changes.
To use guard, simply run bundle exec guard inside the container, in the /app directory, and be happy!
Discovering the version of a gem while debugging
puts Gem.loaded_specs["activesupport"].version
Help from rubygems - How do you check the Gem Version in Ruby at Runtime? - Stack Overflow