lib/juicer/install/rhino_installer.rb in psyho_juicer-1.0.9 vs lib/juicer/install/rhino_installer.rb in psyho_juicer-1.0.11

- old
+ new

@@ -6,15 +6,13 @@ module Install # # Install and uninstall routines for the Mozilla Rhino jar. # class RhinoInstaller < Base - attr_reader :latest - def initialize(install_dir = Juicer.home) super(install_dir) - @latest = "1_7R2-RC1" + @latest = nil @website = "http://ftp.mozilla.org/pub/mozilla.org/js/" end # # Install Rhino. Downloads the jar file and stores it in the installation @@ -45,9 +43,16 @@ def uninstall(version = nil) super((version || latest).gsub(/\./, "_")) do |dir, version| base = "rhino#{version}" File.delete(File.join(dir, "bin/", "#{base}.jar")) end + end + + def latest + return @latest if @latest + webpage = Nokogiri::HTML(open(@website)) + versions = (webpage / "td a").to_a.find_all { |a| a.attr("href") =~ /rhino\d_/ } + @latest = versions.collect { |n| n.attr("href") }.sort.last.match(/rhino(\d_.*)\.zip/)[1] end end end end