Getting the latest netbeans ruby-ide automatically
Update 10/04/2008: THE SCRIPT DOES NOT WORK ANYMORE. The Netbeans changed their nightly build system, you can download the latest version and install netbeans manually from http://bits.netbeans.org/download/trunk/nightly/latest/
I am using netbeans since april 2007 as my primary Rails editor on Linux ubuntu. I used to work with Radrails (now Aptana) because I used to be a java developper and work with Eclipse.
When RadRails "dissapeared", I started looking for alternative IDEs and so far I am very happy with netbeans.
Tor Norbye and his team are very active (and responsive!) and keep delivering new features all every week! The only way to use these features - as far as I am concerned - is to download the latest build from the Continuous Integration server at http://deadlock.netbeans.org/hudson/job/ruby/
To save a bit of time, I have written a script to install the latest netbeans ruby-ide automatically. You need to install the mechanize gem first.
This script will:
- connect to the Continuous Integration server of sun (http://deadlock.netbeans.org/hudson/job/ruby/)
- Guess what's the latest stable build file name and download it to a temp location (depending on your OS)
- rename the old install
- unzip the build to the netbeans installation folder
- delete the downloaded zip from the tmp location
You need to install mechanize:
gem install mechanize
Hten, copy the following code to a ruby file and adapt the last two lines to your configuration. The 1st paramater is the "netbeans installation folder" and the
second one your tmp folder.
Example:
script = NetbeansUpdaterScript.new("/home/jeanmichel/ruby/programs", "/tmp")
script.run
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'mechanize'
require 'fileutils'
class GenericScript
def download_from(url, save_as)
mechanize = WWW::Mechanize.new
mechanize.get(url).save_as(save_as)
puts "downloaded " + url + " and saved to " + save_as
end
def remove(file_or_directory)
FileUtils.remove_dir(file_or_directory, true) if File.directory?(file_or_directory)
FileUtils.rm file_or_directory if File.file?(file_or_directory)
puts "remove " + file_or_directory
end
def unzip_file(file, target_dir)
system(
"unzip", "-q", file, "-d", target_dir
) or raise "Error extracting (#{$?}): unzip #{file.inspect} -d #{target_dir.inspect}"
puts "unzip " + file + " to " + target_dir
end
def is_using_mac?
RUBY_PLATFORM == /darwin/
end
end
class NetbeansUpdaterScript < tmp_folder = "/tmp" netbeans_installation_folder =" netbeans_installation_folder" netbeans_folder_path =" @netbeans_installation_folder" tmp_folder =" tmp_folder" netbeans_installer_file =" @tmp_folder" doc =" Hpricot(open(" last_stable_build_number =" doc.inner_html" last_stable_build_number=" + @last_stable_build_number.to_s @last_stable_build_number end def url_latest_build get_last_stable_build_number if is_using_mac? " script =" NetbeansUpdaterScript.new(">
I have used this script for a week and it seems to work alright but I'd be happy to hear some feedback about the code or any problem you might have.