Monday, March 5, 2007

NetBeans+Ruby Demos

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


Roman has created two excellent demos of the new NetBeans + Ruby support. The first one shows Rails support, the second gets into editing. Let me me point out that until now, my focus has been on editing - so the Rails support is very preliminary. The interesting features are in the editing area, but as the Rails demo shows, if you're building a Rails application you should be able to get your work done. (There is an open bug pertaining to process management - launched Ruby processes aren't always killed by the IDE, so keep an eye on your process list for older processes. Yes, it will be fixed!)



Here's a quick hint, since it's not really obvious from the IDE: Use Shift F6 early and often. It "runs" the current file. For a unit test, that will run the tests. In a Rails app, it will open the browser on the "relevant" URL. For example, if you're editing a controller, or a view, or a helper, it will show the associated view.



I recently added a new feature to the editor you can play with: Smart Selection. Press Ctrl-Shift-Up/Down (on the Mac, Command-Shift up/down). It will select progressively larger code blocks based on the parse tree. Within a comment, it first selects the line, then the whole comment block.



Finally, I just integrated a Ruby Gem Manager (available from the Tools menu). This lets you easily see which Ruby gems you have installed, and more importantly upgrade them or install new ones. This assumes there is a gem command next to your Ruby interpreter, which is the case for the bundled JRuby, but maybe not if you're configured NetBeans to run with whatever you have installed in /usr/.



Here's a screenshot of the initial screen - my locally installed gems:






Here's what you get when you click on Install New:






Actually, if you just press Install New you see a much larger list - all available gems. You can filter down the list by typing in the Filter field - regular expressions are okay. Here I've typed rails to see any gems that have "rails" in the name or description.



I'm writing this from San Francisco international airport - I'm waiting for my flight out to Denver for the
Posse Roundup 2007. It's going to be a fantastic week - technical talks, skiing, and of course I'm excited to see the unveiling of Josh Marinacci and Robert Cooper's project.
With all the attention around the Ruby work this week it's bad timing to go off the grid, but at least I can leave by pointing out that this is an open source project, all the code is available and if there's a fatal bug in there, somebody can find it and fix it! Have a great week - I know I will.



P.S. I've seen lots of blog entries around the NetBeans Ruby support lately - thank you all for trying it out and writing about it. I found
this Ruby IDE comparison particularly
interesting.


11 comments:

  1. Cool, nice looking Gem manager!
    Do you happen to know the best way to add Markaby (.mab) extensions as ruby source file types? I've tried through the advanced options editor but NullPointerExceptions seem to be thrown.
    Other than that I haven't had too many problems using the nightly builds, the progress of it is coming along nicely. I will be fully switching over once it hits a stable release.

    ReplyDelete
  2. Fantastic job -- looking forward to debugging in M8.
    Some small problems:
    1) how to add new gems (running in Ubuntu 6.1) and need root mode?
    2) how to generate "processor" for activemessaging?
    Can you change the combobox to allow the user to add new items to the generate combobox? (Had same problem in RADRails).
    As a Newbie, your HELP is awesome and significantly shortens the learning curve.

    ReplyDelete
  3. awesome.
    I fund one problem.
    when typing
    puts "#{some_var}"
    Netbeans does no longer do anything after I typed
    "{".
    still Netbeans is my new IDE of choice for Ruby and when it will have refactoring sometime it will be a real killer

    ReplyDelete
  4. Hi Tor,
    The ruby module is great, I can't believe how quickly you're putting this stuff together. Can I echo Chris' comment about the generate dialogue. Having made a bold leap into the world of resources I miss seeing the scaffold_resource generator. Do you know if anyone is working on syntax and formatting for .yml files at the moment?

    ReplyDelete
  5. Hi Tor,
    I have really enjoyed playing around with the Ruby module that you have been writing. At the moment I'm looking into the support that is available for Rails development. Have you added support yet for issuing a `rake migrate` command? Also, would you have an idea why the JRuby's IRB implementation does not recognize the `rake` command?

    ReplyDelete
  6. Karl-Koenig KoenigssonMarch 11, 2007 at 11:43 PM

    This is great indeed! What I really like is the integration of all things Ruby and Rails in a context, rather than in a file tree. The Gem support is just the thing to make an IDE truly Integrated.
    Still, one thing is beyond me: how do I add a gem that is not online? The Hobo gem is of particular interest to me and I have yet to see how I can add this.
    Furthermore, the Hobo gem provides a couple of new generators that it would be splendid if it was possible to add to the IDE as well. It sort of looses all meaning if one can not run the generators, you see... :-)

    ReplyDelete
  7. I have been using Java for 10 years and Ruby for a month. Answering my own question I posted earlier - I figured out that you can not run Rake from IRB, but do you have plans to expose both the Ruby Console and the Rake command from within Netbeans?
    Currently, I'm using the combination of Netbeans and Instant Rails to do Rails development. Instant Rails is used to run both Rake and the Ruby console, while I use Netbeans for all the other development related tasks.

    ReplyDelete
  8. Hi Tor,
    When you use Instant Rails, there is a menu option called "Open Ruby Console Window". The Ruby Console is just a shell (BASH) window open to the directory of the current Rails project.
    The term `Ruby Console` might be something that the Instant Rails developers came up with. The `Ruby Console` will be unnecessary once Rake and the Rails Console become available within Netbeans.

    ReplyDelete
  9. Tor: Cool, thanks! Is there anywhere to grab the latest Ruby modules aside from the update center?

    ReplyDelete
  10. Tor: Nevermind, tracked it down. :)

    ReplyDelete
  11. Ruby+Netbeans is amazing.
    But when I typed a dot "." the code completion doesn't work.
    do I must use the "CTRL+SPACE" for code completion?

    ReplyDelete