Ruby Screenshot of the Week #26: Ruby 1.9 Changes - hashes and case statements


Ruby 1.9 has been released. It's a "development" version meaning that you wouldn't want to use it in production, but now is a good time to learn the new ways of doing things such that migrating to Ruby 2.0 will be easier.



Via Ruby Inside, I read
James Edward Gray's recent blog entry
detailing the work he did to update his library to 1.9 - and a number of people leaving comments are also pointing out language changes.



One such change mentioned is case/when statements not allowing colon as a separator. (I don't see this in Ruby Changes Wiki - does anyone have a source for this?). Seems like a a good candidate for a Ruby quickfix:






There are a couple of available fixes:






The first one is just replacing the colon with a then:






The second fix is instead putting the statement on a separate indented line:






Another language change I found in Sam Ruby's post is that you cannot write hashes as lists anymore. Here's a quickfix for that - first the code, this is from webrick's httpstatus class:





The quickfix is attached to the first list entry in the hash:






And previewing the fix shows the following proposed edit:






As usual, the NetBeans Ruby forums can be accessed via Nabble here and Gmane newsreaders here (other feedback channels here).

Comments:

Ruby 1.8.5 would output "warning: colon will be obsoleted; use semicolon" if it came across one of these cases with warnings enabled, so this has been in the plans for a while. Surprisingly, 1.8.6 seems to have removed the warning.

"Replace : with ;" would be my preferred quickfix for this, although I'm sure many would disagree.

Posted by scott on January 05, 2008 at 02:56 PM PST #

Hi Tor,
may be it would be better to activate Preview or Disable option by invoking right arrow key and then selecting one of the options? if netbeans hind api could do this :-)

Posted by Denis on January 06, 2008 at 07:09 AM PST #

hi Tor! The Haml plugin remains to be broken for last versions

Posted by ruby.freeman on January 07, 2008 at 09:50 AM PST #

Hi Scott, thanks - I just checked in a fix (build #6103) which includes a third fix options for this hint which uses a semicolon as you suggested.

Hi Denis, yes, I agree - the problem is as you suspected in the editor infrastructure, but I was just meeting with some of those developers today who are visiting the area and they also want something like that so we'll try to address it soon.

Hi Freeman, thanks, I'll let Dylan know. Last I heard he was rewriting the HAML support from scratch which should make the features must more powerful, similar to the RHTML support.

Posted by Tor Norbye on January 10, 2008 at 02:37 PM PST #

Is reformatting in ruby going to be fixed?

Posted by aph on January 16, 2008 at 03:30 AM PST #

Hi Tor! I've updated HAML module from http://mediacast.sun.com/users/%7Etor/media/org-netbeans-modules-haml.nbm/details
now it works, great!
but old small bug is still there - if I change some fonts for haml - it changes their view to defaults in few second after the page is opened.

Posted by ruby.freeman on January 17, 2008 at 10:59 AM PST #

I would like to learn Java Programming for free online with Microsystems. If you have any information or any other advice, please help me. Thanks!

Posted by Yared Mekasha on January 18, 2008 at 05:08 AM PST #

Hi aph,
By "Is Reformatting in Ruby going to be fixed", are you referring to Ruby files (where I'm not aware of any problems), or problems in ERB/RHTML files? There are several known problems there which will be addressed soon.

Freeman, glad to hear HAML is working for you again.

Yared, sorry, that's a pretty vague question, but go to java.sun.com, I'm sure there are a lot of learning resources there.

Posted by Tor Norbye on January 18, 2008 at 10:11 AM PST #

Hi Aph,
FYI - I just checked in a fix for formatting in ERB/RHTML files (see build 6315 or later, and issue
http://www.netbeans.org/issues/show_bug.cgi?id=125006
)

Posted by Tor Norbye on January 24, 2008 at 05:11 PM PST #

Post a Comment:
Comments are closed for this entry.
About

Tor Norbye

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today