Open simply whatever non-NetBeans Ruby (on Rails) project in NetBeans

Subtitle: Poor man's, but effective and simple solution

This is a tip (or trick) for how to quickly open any project (Rails or non-Rails one) without any NetBeans metadata in NetBeans. E.g. from RubyForge, Kenai, GitHub, ... or just your local one. In short, all you need is to run nb_ruby_project command (which is Ruby few-liner (excluding NetBeans metadata)) and press C-S-1 in NetBeans.

nb_ruby_project is downloadable/viewable on pastie or here.

You need just change the two lines in the script to point to your netbeans executable and optionally to your userdir if you are using non-default one (e.g. --userdir option during start-up).

NB_BIN = '/path/to/netbeans/bin/netbeans'
# NB_USER_DIR = '/path/to/optional/userdir'

You might also start-up NetBeans before using the script (but not necessary)

$ nb_ruby_project 
Usage: nb_ruby_project <ruby_project_dir> [--rails]

For example see the following two-step (checking out and opening in NetBeans) terminal session for how to open RubyGems project from RubyForge:

$ svn co svn://rubyforge.org/var/svn/rubygems/trunk rubygems
$ nb_ruby_project rubygems

Project: rubygems (non-Rails)

Will create following files (NetBeans metadata) in:
  /space/ruby/sources/rubygems/nbproject/project.xml
  /space/ruby/sources/rubygems/nbproject/project.properties

Press "y<Enter>" to agree: y
Mentioned NetBeans metadata created

Opening 'Rakefile' in NetBeans...

Now the project's Rakefile should be opened in the running NetBeans session (or new NetBeans instance is started). Just press there C-S-1 (Menu | Navigate | Select in Projects) and press <Enter> to confirm the dialog as shown on the image below.

Open RubyGems in NetBeans

After the project is opened you might want to set different Ruby platform, add more sources and/or roots, rename the project, etc.

This is just workaround for the issue 126410 which should enable to do this from NetBeans directly. But I'm using the script very often for RubyForge-alike sites in the meantime, so sharing.... It might be enhanced with bunch of small features, like asking for source roots, being Ruby-independent, etc. But it's just a temporary workaround... hopefully not for too long.

Note that you can open all the gems you have installed on your machine, see your $GEM_HOME/gems directory. You might also use the script from CLI to quickly open projects already containing NetBeans metadata (metadata creation will be just detected and skipped) during browsing your harddisk.

Comments:

[Trackback]

Posted by informednetworker.com on November 24, 2008 at 01:03 AM PST #

I'm trying to open the redmine source in netbeans, and this helped, but it would be nice if the project was opened as a rails app and not as a ruby app. How would I go about doing this?

Posted by Jori Hardman on August 25, 2009 at 07:49 AM PDT #

You might use --rails switch. E.g.:

nb_ruby_project instiki --rails

Posted by Martin Krauskopf on August 25, 2009 at 11:08 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Martin Krauskopf

Search

Categories
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