<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,7 +3,7 @@ module IncludeGoogleJs
   
   @@javascript_expansions = { :defaults =&gt; ActionView::Helpers::AssetTagHelper::JAVASCRIPT_DEFAULT_SOURCES.dup }
   @@include_google_js = false
-  @@google_js_libs = ['prototype', 'scriptaculous', 'jquery', 'mootools', 'dojo','swfobject','yui']
+  @@google_js_libs = %w[prototype scriptaculous jquery jqueryui mootools dojo yui swfobject]
   @@scriptaculous_files = ['controls','dragdrop','effects']
   @@default_google_js_libs = ['prototype','scriptaculous']
   @@google_js_to_include = []
@@ -14,21 +14,22 @@ module IncludeGoogleJs
   end
   
   def javascript_include_tag_with_google_js(*sources)
-    options                 = sources.extract_options!.stringify_keys
-    cache                   = options.delete(&quot;cache&quot;)
-    @@include_google_js     = options.delete(&quot;include_google_js&quot;) &amp;&amp; IncludeGoogleJs.confirm_internet_connection
-    @@javascript_versions   = options.delete(&quot;versions&quot;) || {}
+    # split apart the sources, check for :cache, confirm that we're using :include_google_js, and grab :versions
+    libraries               = sources.extract_options!.stringify_keys
+    use_cache               = libraries.delete(&quot;cache&quot;)
+    @@include_google_js     = libraries.delete(&quot;include_google_js&quot;) &amp;&amp; IncludeGoogleJs.confirm_internet_connection
+    @@javascript_versions   = libraries.delete(&quot;versions&quot;) || {}
     
     @@google_js_to_include  = []
-
-    if ActionController::Base.perform_caching &amp;&amp; cache
-      joined_javascript_name = (cache == true ? &quot;all&quot; : cache) + &quot;.js&quot;
+    
+    if ActionController::Base.perform_caching &amp;&amp; use_cache # Using the locally cached libraries
+      joined_javascript_name = (cache == true ? &quot;all&quot; : use_cache) + &quot;.js&quot;
       joined_javascript_path = File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, joined_javascript_name)
 
       write_asset_file_contents(joined_javascript_path, compute_javascript_paths(sources))
-      javascript_src_tag(joined_javascript_name, options)
-    else
-      base_html = IncludeGoogleJs.expand_javascript_sources(sources).collect { |source| javascript_src_tag(source, options) }.join(&quot;\n&quot;)
+      javascript_src_tag(joined_javascript_name, libraries)
+    else # Using Google libraries
+      base_html = IncludeGoogleJs.expand_javascript_sources(sources).collect { |source| javascript_src_tag(source, libraries) }.join(&quot;\n&quot;)
       if @@include_google_js
         html = %Q{
           &lt;script src='http://www.google.com/jsapi'&gt;&lt;/script&gt;
@@ -50,7 +51,7 @@ module IncludeGoogleJs
   end
 
   def self.expand_javascript_sources(sources)
-    if sources.include?(:all)
+    if sources.include?(:all) # All libraries, get everything in the javascripts folder, see which are hosted by Google
       all_javascript_files = Dir[File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, '*.js')].collect { |file| File.basename(file).gsub(/\.\w+$/, '') }.sort
       all_javascript_files = IncludeGoogleJs.determine_if_google_hosts_files(all_javascript_files) if @@include_google_js
       @@all_javascript_sources ||= ((IncludeGoogleJs.determine_source(:defaults, @@javascript_expansions).dup &amp; all_javascript_files) + all_javascript_files).uniq
@@ -75,7 +76,6 @@ module IncludeGoogleJs
     javascript_files.each do |file|
       if @@google_js_libs.include?(file.split(&quot;-&quot;)[0])
         @@google_js_to_include &lt;&lt; file
-        # IncludeGoogleJs.get_file_version(file)
       end
       if @@scriptaculous_files.include?(file)
         @@google_js_to_include &lt;&lt; 'scriptaculous' unless @@google_js_to_include.include?('scriptaculous')
@@ -115,6 +115,8 @@ module IncludeGoogleJs
         version = IncludeGoogleJs.parse_scriptaculous(file_name)
       when &quot;jquery&quot;
         version = IncludeGoogleJs.parse_jquery(file_name)
+      when &quot;jqueryui&quot;
+        version = IncludeGoogleJs.parse_jquery_ui(file_name)
       when &quot;mootools&quot;
         version = IncludeGoogleJs.parse_mootools(file_name)
       when &quot;dojo&quot;
@@ -143,8 +145,20 @@ module IncludeGoogleJs
       case file.split(&quot;-&quot;)[0] # Split on '-' because of jQuery's file names with version numbers
         when &quot;prototype&quot;
           return IncludeGoogleJs.parse_prototype(file)
+        when &quot;scriptaculous&quot;
+          return IncludeGoogleJs.parse_scriptaculous(file)
         when &quot;jquery&quot;
           return IncludeGoogleJs.parse_jquery(file)
+        when &quot;jqueryui&quot;
+          return IncludeGoogleJs.parse_jquery_ui(file)
+        when &quot;mootools&quot;
+          return IncludeGoogleJs.parse_mootools(file)
+        when &quot;dojo&quot;
+          return IncludeGoogleJs.parse_dojo(file)
+        when &quot;yui&quot;
+          return IncludeGoogleJs.parse_yui(file)
+        when &quot;swfobject&quot;
+          return IncludeGoogleJs.parse_swfobject(file)
         else
           return 1
       end
@@ -170,6 +184,13 @@ module IncludeGoogleJs
     end
   end
   
+  def self.parse_jquery_ui(file=&quot;jquery-ui&quot;)
+    File.open(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, &quot;#{file}.js&quot;)).each do |line|
+      version_array = line.scan(/version:\W?&quot;([\d.]+)&quot;/x).to_s
+      return version_array.to_s unless version_array.blank?
+    end
+  end
+  
   def self.parse_mootools(file=&quot;mootools&quot;)
     File.open(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, &quot;#{file}.js&quot;)).each do |line|
       return line.match(/version:[&quot;|']([\d\.]+)[&quot;|']/i)[1] if line.include?(&quot;version&quot;)</diff>
      <filename>lib/include_google_js.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 namespace :javascript do
-  libraries = %w[prototype scriptaculous jquery mootools dojo yui swfobject]
+  libraries = %w[prototype scriptaculous jquery jqueryui mootools dojo yui swfobject]
   namespace :get do
     require 'net/http'
     
@@ -32,17 +32,10 @@ namespace :javascript do
           end
         when &quot;scriptaculous&quot;
           # Scriptaculous - http://script.aculo.us/dist/scriptaculous-js-1.8.2.zip
+          unzip_js_library(&quot;http://script.aculo.us/dist/scriptaculous-js-1.8.2.zip&quot;)
           Dir.chdir(&quot;#{RAILS_ROOT}/public/javascripts&quot;) do
-            Net::HTTP.start(&quot;script.aculo.us&quot;) do |http|
-              zip = http.get(&quot;/dist/scriptaculous-js-1.8.2.zip&quot;)
-              open(&quot;scriptaculous.zip&quot;, 'w') {
-                |f| f.write(zip.body)
-              }
-              `unzip scriptaculous.zip`
-              `rm scriptaculous.zip`
-              `mv scriptaculous-js-1.8.2/src/* ../javascripts/`
-              `rm -rf scriptaculous-js-1.8.2`
-            end
+            `mv scriptaculous-js-1.8.2/src/* ./`
+            `rm -rf scriptaculous-js-1.8.2`
           end
         when &quot;jquery&quot;
           # jQuery - http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js
@@ -51,6 +44,14 @@ namespace :javascript do
                 |f| f.write(http.get('/files/jquery-1.3.2.min.js').body)
               }
           end
+        when &quot;jqueryui&quot;
+          # jQueryUI - http://www.jqueryui.com/download/jquery-ui-1.7.2.custom.zip
+          unzip_js_library(&quot;http://www.jqueryui.com/download/jquery-ui-1.7.2.custom.zip&quot;)
+          Dir.chdir(&quot;#{RAILS_ROOT}/public/javascripts&quot;) do
+            `mv js/jquery-1.3.2.min.js jquery.js`
+            `mv js/jquery-ui-1.7.2.custom.min.js jquery-ui.js `
+            `rm -rf js`
+          end
         when &quot;mootools&quot;
           # mootools - http://mootools.net/download/get/mootools-1.2.2-core-yc.js
           Net::HTTP.start('mootools.net',80) do |http|
@@ -67,32 +68,28 @@ namespace :javascript do
           end
         when &quot;yui&quot;
           # YUI - http://yuilibrary.com/downloads/yui2/yui_2.7.0b.zip
-          Dir.chdir(&quot;#{RAILS_ROOT}/public/javascripts&quot;) do
-            Net::HTTP.start(&quot;yuilibrary.com&quot;) do |http|
-              zip = http.get(&quot;/downloads/yui2/yui_2.7.0b.zip&quot;)
-              open(&quot;yui.zip&quot;, 'w') {
-                |f| f.write(zip.body)
-              }
-              `unzip yui.zip`
-              `rm yui.zip`
-            end
-          end
+          unzip_js_library(&quot;http://yuilibrary.com/downloads/yui2/yui_2.7.0b.zip&quot;)
         when &quot;swfobject&quot;
           # swfobject - http://swfobject.googlecode.com/files/swfobject_2_1.zip
-          Dir.chdir(&quot;#{RAILS_ROOT}/public/javascripts&quot;) do
-            Net::HTTP.start(&quot;swfobject.googlecode.com&quot;) do |http|
-              zip = http.get(&quot;/files/swfobject_2_1.zip&quot;)
-              open(&quot;swfobject.zip&quot;, 'w') {
-                |f| f.write(zip.body)
-              }
-              `unzip swfobject.zip`
-              `rm swfobject.zip`
-            end
-          end
+          unzip_js_library(&quot;http://swfobject.googlecode.com/files/swfobject_2_1.zip&quot;)
         else
           puts &quot;I don't know about #{name}, sorry! Please check for a newer version of include_google_js.&quot;
         end
     end
+    
+    def unzip_js_library(path=&quot;&quot;)
+      path_parts = path.match(/http:\/\/([\w.]+)(\/[\w.\/-]+)/i)
+      Dir.chdir(&quot;#{RAILS_ROOT}/public/javascripts&quot;) do
+        Net::HTTP.start(path_parts[1]) do |http|
+          zip = http.get(path_parts[2])
+          open(&quot;lib.zip&quot;, 'w') {
+            |f| f.write(zip.body)
+          }
+          `unzip lib.zip`
+          `rm lib.zip`
+        end
+      end
+    end
   end
   
   namespace :remove do
@@ -116,14 +113,14 @@ namespace :javascript do
     case name
       when &quot;yui&quot;
         puts &quot;Removing YUI from /public/javascripts/&quot;
-        `rm -rf yui`
+        Dir.chdir(&quot;#{RAILS_ROOT}/public/javascripts&quot;) { `rm -rf yui` }
       when &quot;scriptaculous&quot;
         puts &quot;Removing Scriptaculous files from /public/javascripts/&quot;
         %w[scriptaculous builder controls dragdrop effects slider sound unittest].each do |file|
-          File.delete(&quot;#{RAILS_ROOT}/public/javascripts/#{file}.js&quot;)
+          Dir.chdir(&quot;#{RAILS_ROOT}/public/javascripts&quot;) { `rm #{file}.js` }
         end
       when &quot;swfobject&quot;
-        `rm -rf swfobject`
+        Dir.chdir(&quot;#{RAILS_ROOT}/public/javascripts&quot;) { `rm -rf swfobject` }
       else
         if File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, &quot;#{name}.js&quot;))
           puts &quot;Removing #{name} from /public/javascripts/&quot;</diff>
      <filename>tasks/include_google_js_tasks.rake</filename>
    </modified>
    <modified>
      <diff>@@ -81,6 +81,10 @@ class IncludeGoogleJsTest &lt; Test::Unit::TestCase
    assert_equal &quot;1.3.2&quot;, IncludeGoogleJs.parse_jquery if js_exists(&quot;jquery&quot;)
   end
   
+  def test_parsing_jquery_ui_for_version
+   assert_equal &quot;1.7.2&quot;, IncludeGoogleJs.parse_jquery_ui if js_exists(&quot;jqueryui&quot;)
+  end
+  
   def test_parsing_mootools_for_version
    assert_equal &quot;1.2.2&quot;, IncludeGoogleJs.parse_mootools if js_exists(&quot;mootools&quot;)
   end
@@ -118,6 +122,8 @@ class IncludeGoogleJsTest &lt; Test::Unit::TestCase
         File.exist?(&quot;#{RAILS_ROOT}/public/javascripts/yui/&quot;)
       when &quot;swfobject&quot;
         File.exist?(&quot;#{RAILS_ROOT}/public/javascripts/swfobject/&quot;)
+      when &quot;jqueryui&quot;
+        File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, &quot;jquery-ui.js&quot;))    
       else
         File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, &quot;#{library}.js&quot;))    
     end</diff>
      <filename>test/include_google_js_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a18baaae70c9fa29581c41f7d83c4c881af6aaba</id>
    </parent>
  </parents>
  <author>
    <name>Christopher D Warren</name>
    <email>chris@expectless.com</email>
  </author>
  <url>http://github.com/chriswarren/include_google_js/commit/42839b73f730c0139fd691f115ec86617cc068e9</url>
  <id>42839b73f730c0139fd691f115ec86617cc068e9</id>
  <committed-date>2009-06-09T23:56:39-07:00</committed-date>
  <authored-date>2009-06-09T23:56:39-07:00</authored-date>
  <message>* Added jQuery UI
* Little more refactoring, dryed up some of the rake tasks.</message>
  <tree>183696f92d05c60cebc71db733a9051a89d31c6a</tree>
  <committer>
    <name>Christopher D Warren</name>
    <email>chris@expectless.com</email>
  </committer>
</commit>
