The Caboteria / Tech Web / TechNotes > ProgrammingNotes / RubyNotes (27 Nov 2015, TobyCabot)
Citrus is a fun parser generator for Ruby. It lets you mix small bits of Ruby code in with your parser grammar. http://mjijackson.com/citrus/

Invoking a method with an ampersand-parameter: http://blog.jayfields.com/2007/01/ruby-invoking-method-with.html

Github's style guide: https://github.com/styleguide/ruby

http://madebydna.com/all/code/2011/06/24/eigenclasses-demystified.html - metaprogramming basics
https://www.youtube.com/watch?v=by5fFOBhtPQ - object model intro
http://www.reactive.io/tips/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/

RVM

RVM is a nice tool that manages multiple installations of Ruby, JRuby, gems, etc. It's very useful if you're working on both Ruby and JRuby projects. http://rvm.beginrescueend.com/
Since RVM compiles each version of ruby locally you need to make sure that you've installed the -dev packages for the features that you want. Readline, for example: libreadline-dev on debian. http://rubyforge.org/tracker/index.php?func=detail&aid=23925&group_id=1900&atid=7436

When you install RVM, run rvm requirements and install everything it recommends. You'll probably also need libpq-dev (postgresql) and libcurl-dev (curl).

Debian - when I used RVM on Debian for the first time, I had to use RVM to install copies of zlib and openssl in RVM's tree. For some reason configure couldn't see the Debian's versions.
http://rvm.beginrescueend.com/packages/openssl/
http://rvm.beginrescueend.com/packages/zlib/

Debugging

http://bashdb.sourceforge.net/ruby-debug.html - ruby debugger user's guide
http://rubyforge.org/projects/ruby-debug/ - ruby debugger project page

You want to run Debugger.start as soon as you can (preferably at the top level) so the debugger can capture the full stack frame.

Tips on debugging memory leaks: http://blog.skylight.io/hunting-for-leaks-in-ruby/

Rails Development

https://github.com/rails/rails/issues - this is the "official" Rails bug tracking system. The Rails "trac" and "lighthouse" sites appear to be obsolete although they have powerful Google-fu

Run a single unit test:

$ ruby -I"lib:test" test/test_filename.rb -n test_launch_should_create_a_response_set
The "test_" prefix and underscores need to be added, so this invocation would match a method named "launch should create a response set".

Performance

http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126

Security

http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/ - 13 Security Gotchas You Should Know About

Testing

I prefer minitest to rspec. https://www.youtube.com/watch?v=ojd1G4gOMdk is a good explanation of the relative complexity of the two packages.

Edit | Attach | Print version | History: r18 < r17 < r16 < r15 < r14 | Backlinks | Raw View | Raw edit | More topic actions
Copyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback