Ary Borenszweig
Ary is a software craftsman, he is our guru in all code-related problems. Always teaching how to develop the best code with simplicity in mind, he makes everything seem easy no matter how difficult, to the point that nothing seems impossible with him on the team. Very optimistic (sometimes too much), he has the ability to put any idea into code in almost no time.
February 22, 2010
String concatenation in ruby
I just found out the difference between += and << when used for a string.
irb(main):001:0> str = 'chan'
=> "chan"
irb(main):002:0> str.object_id
=> 69952758899780
irb(main):003:0> str += 'ged'
=> "changed"
irb(main):004:0> str.object_id
=> 69952758848800
irb(main):005:0> str << ', now not'
=> "changed, now not"
irb(main):006:0> str.object_id
=> 69952758848800
So I think that basically you should never use += for strings, unless you really want to hurt the garbage collector.
February 10, 2010
Ruby-Jump plugin for gedit
I searched the internet for a gedit plugin that would allow me to press a key and jump (navigate) to the file where a ruby class is defined. I couldn’t find one so I wrote one (I know about Geany but I couldn’t find that functionality there either).
Usage
If the file you are editing is located in a ruby on rails projects, this will work automatically. If not, you will need to have the FileBrowser plugin installed and activated. The file browser should be pointing to your project’s root path.
Pressing F3 will jump to the file of the name under the cursor. This uses ruby convention so if your cursor is over the word SomeClass the file some_class.rb will be opened. It also works for some plural forms, so pressing F3 over :my_messages will try to open my_message.rb.
Pressing F4 goes to the test file of the name under the cursor, or to the test file of the current document if no match was found for the previous search. So pressing F4 over SomeClass will open some_class_test.rb.
Download
ruby-jump_0.2.tar.gz – Extract the contents of the file in /home/youruser/.gnome2/gedit/plugins