<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -58,6 +58,7 @@ module IncludeGoogleJs
         google_javascript_files += []
       end
     else
+      sources = IncludeGoogleJs.check_for_dependencies(sources)
       sources.collect do |source|
         if IncludeGoogleJs.does_google_host?(source) &amp;&amp; use_google_libraries
           google_javascript_files &lt;&lt; source
@@ -69,6 +70,15 @@ module IncludeGoogleJs
     return { &quot;google&quot; =&gt; google_javascript_files, &quot;local&quot; =&gt; local_javascript_files }
   end
   
+  def self.check_for_dependencies(source)
+    if source.include?(&quot;scriptaculous&quot;) &amp;&amp; !source.include?(&quot;prototype&quot;)
+      source.unshift(&quot;prototype&quot;)
+    elsif source.include?(&quot;jquery-ui&quot;) &amp;&amp; !source.include?(&quot;jquery&quot;)
+      source.unshift(&quot;jquery&quot;)
+    end
+    return source
+  end
+  
   def self.determine_source(source, collection)
     case source
     when Symbol
@@ -84,8 +94,8 @@ module IncludeGoogleJs
       &lt;script&gt;
       }
       libraries.each do |js_lib|
-      version = versions.has_key?(js_lib.split(&quot;-&quot;)[0].to_sym) ? versions.fetch(js_lib.split(&quot;-&quot;)[0].to_sym) : IncludeGoogleJs.get_file_version(js_lib)
-      html += %Q{google.load(&quot;#{js_lib.split(&quot;-&quot;)[0]}&quot;, &quot;#{version}&quot;);
+      version = versions.has_key?(js_lib.to_sym) ? versions.fetch(js_lib.to_sym) : IncludeGoogleJs.get_file_version(js_lib)
+      html += %Q{google.load(&quot;#{js_lib}&quot;, &quot;#{version}&quot;);
       }
     end
     html += %Q{&lt;/script&gt;
@@ -95,7 +105,7 @@ module IncludeGoogleJs
   def self.determine_if_google_hosts_files(javascript_files)
     @@google_js_to_include = []
     javascript_files.each do |file|
-      if @@google_js_libs.include?(file.split(&quot;-&quot;)[0])
+      if @@google_js_libs.include?(file)
         @@google_js_to_include &lt;&lt; file
       end
       if @@scriptaculous_files.include?(file)
@@ -160,8 +170,8 @@ module IncludeGoogleJs
   def self.get_file_version(file)
     version = &quot;1&quot;
     # split file_name for instances where the file has a version number at the end
-    library = file.split(&quot;-&quot;)[0]
-    return IncludeGoogleJs.send(&quot;parse_#{library}&quot;)
+    # library = file.replace(&quot;-&quot;,&quot;_&quot;)
+    return IncludeGoogleJs.send(&quot;parse_#{file.gsub(&quot;-&quot;,&quot;_&quot;)}&quot;)
   end
   
   def self.parse_prototype(file=&quot;prototype&quot;)</diff>
      <filename>lib/include_google_js.rb</filename>
    </modified>
    <modified>
      <diff>@@ -60,23 +60,23 @@ class IncludeGoogleJsTest &lt; Test::Unit::TestCase
     should_not_match(string, unmatched_values)
   end
   
-  # def test_javascript_tag_for_scriptaculous_with_google
-  #   string           = javascript_include_tag(&quot;scriptaculous&quot;, :include_google_js =&gt; true)
-  #   matched_values   = [&quot;google.load(\&quot;prototype\&quot;, \&quot;1.6.0.3\&quot;)&quot;, &quot;google.load(\&quot;scriptaculous\&quot;, \&quot;1.8.2\&quot;)&quot;]
-  #   unmatched_values = [&quot;src=\&quot;/javascripts/prototype.js&quot;]
-  #   
-  #   should_match(string, matched_values)
-  #   should_not_match(string, unmatched_values)
-  # end
-  # 
-  # def test_javascript_tag_for_scriptaculous_without_google
-  #   string           = javascript_include_tag(&quot;scriptaculous&quot;, :include_google_js =&gt; false)
-  #   matched_values   = [&quot;src=\&quot;/javascripts/prototype.js&quot;, &quot;src=\&quot;/javascripts/scriptaculous.js&quot;]
-  #   unmatched_values = [&quot;google.load(\&quot;prototype\&quot;, \&quot;1.6.0.3\&quot;)&quot;, &quot;google.load(\&quot;scriptaculous\&quot;, \&quot;1.8.2\&quot;)&quot;]
-  #   
-  #   should_match(string, matched_values)
-  #   should_not_match(string, unmatched_values)
-  # end
+  def test_javascript_tag_for_scriptaculous_with_google
+    string           = javascript_include_tag(&quot;scriptaculous&quot;, :include_google_js =&gt; true)
+    matched_values   = [&quot;google.load(\&quot;prototype\&quot;, \&quot;1.6.0.3\&quot;)&quot;, &quot;google.load(\&quot;scriptaculous\&quot;, \&quot;1.8.2\&quot;)&quot;]
+    unmatched_values = [&quot;src=\&quot;/javascripts/prototype.js&quot;]
+    
+    should_match(string, matched_values)
+    should_not_match(string, unmatched_values)
+  end
+  
+  def test_javascript_tag_for_scriptaculous_without_google
+    string           = javascript_include_tag(&quot;scriptaculous&quot;, :include_google_js =&gt; false)
+    matched_values   = [&quot;src=\&quot;/javascripts/prototype.js&quot;, &quot;src=\&quot;/javascripts/scriptaculous.js&quot;]
+    unmatched_values = [&quot;google.load(\&quot;prototype\&quot;, \&quot;1.6.0.3\&quot;)&quot;, &quot;google.load(\&quot;scriptaculous\&quot;, \&quot;1.8.2\&quot;)&quot;]
+    
+    should_match(string, matched_values)
+    should_not_match(string, unmatched_values)
+  end
   
   def test_javascript_tag_for_jquery_with_google
     string           = javascript_include_tag(&quot;jquery&quot;, :include_google_js =&gt; true)
@@ -96,23 +96,23 @@ class IncludeGoogleJsTest &lt; Test::Unit::TestCase
     should_not_match(string, unmatched_values)
   end
   
-  # def test_javascript_tag_for_jquery_ui_with_google
-  #   string           = javascript_include_tag(&quot;jquery-ui&quot;, :include_google_js =&gt; true)
-  #   matched_values   = [&quot;google.load(\&quot;jquery\&quot;, \&quot;1.3.2\&quot;)&quot;, ]
-  #   unmatched_values = [&quot;src=\&quot;/javascripts/jquery.js&quot;]
-  #   
-  #   should_match(string, matched_values)
-  #   should_not_match(string, unmatched_values)
-  # end
-  # 
-  # def test_javascript_tag_for_jquery_ui_without_google
-  #   string           = javascript_include_tag(&quot;jquery-ui&quot;, :include_google_js =&gt; false)
-  #   matched_values   = [&quot;src=\&quot;/javascripts/jquery.js&quot;]
-  #   unmatched_values = [&quot;google.load(\&quot;jquery\&quot;, \&quot;1.3.2\&quot;)&quot;]
-  #   
-  #   should_match(string, matched_values)
-  #   should_not_match(string, unmatched_values)
-  # end
+  def test_javascript_tag_for_jquery_ui_with_google
+    string           = javascript_include_tag(&quot;jquery-ui&quot;, :include_google_js =&gt; true)
+    matched_values   = [&quot;google.load(\&quot;jquery\&quot;, \&quot;1.3.2\&quot;)&quot;, &quot;google.load(\&quot;jquery-ui\&quot;, \&quot;1.7.2\&quot;)&quot;]
+    unmatched_values = [&quot;src=\&quot;/javascripts/jquery.js&quot;]
+    
+    should_match(string, matched_values)
+    should_not_match(string, unmatched_values)
+  end
+  
+  def test_javascript_tag_for_jquery_ui_without_google
+    string           = javascript_include_tag(&quot;jquery-ui&quot;, :include_google_js =&gt; false)
+    matched_values   = [&quot;src=\&quot;/javascripts/jquery.js&quot;, &quot;src=\&quot;/javascripts/jquery-ui.js&quot;]
+    unmatched_values = [&quot;google.load(\&quot;jquery\&quot;, \&quot;1.3.2\&quot;)&quot;]
+    
+    should_match(string, matched_values)
+    should_not_match(string, unmatched_values)
+  end
   
   def test_javascript_tag_for_all_with_google
     string           = javascript_include_tag(:all, :include_google_js =&gt; true)
@@ -147,7 +147,7 @@ class IncludeGoogleJsTest &lt; Test::Unit::TestCase
   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;)
+   assert_equal &quot;1.7.2&quot;, IncludeGoogleJs.parse_jquery_ui if js_exists(&quot;jquery-ui&quot;)
   end
   
   def test_parsing_mootools_for_version
@@ -255,6 +255,19 @@ class IncludeGoogleJsTest &lt; Test::Unit::TestCase
     assert libraries[&quot;local&quot;].include?(&quot;jquery-ui&quot;)
   end
   
+  # Library dependency checks
+  def test_if_prototype_added_to_scriptaculous_request
+    source = [&quot;scriptaculous&quot;]
+    updated_source = IncludeGoogleJs.check_for_dependencies(source)
+    assert_equal updated_source.first, &quot;prototype&quot;
+  end
+  
+  def test_if_jquery_added_to_jqueryui_request
+    source = [&quot;jquery-ui&quot;]
+    updated_source = IncludeGoogleJs.check_for_dependencies(source)
+    assert_equal updated_source.first, &quot;jquery&quot;
+  end
+  
   # helper methods
   def should_match(string=&quot;&quot;, values=[])
     check_values(string,values,true)</diff>
      <filename>test/include_google_js_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0fb1fae693454ff45a573a2aa9f85d9830c14aad</id>
    </parent>
  </parents>
  <author>
    <name>Christopher D Warren</name>
    <email>chris@expectless.com</email>
  </author>
  <url>http://github.com/chriswarren/include_google_js/commit/df84ade4590bb6f20fb65e85831fb2ab17970f1d</url>
  <id>df84ade4590bb6f20fb65e85831fb2ab17970f1d</id>
  <committed-date>2009-06-16T22:34:07-07:00</committed-date>
  <authored-date>2009-06-16T22:34:07-07:00</authored-date>
  <message>* Added a dependency check, so if you load scriptaculous without prototype or jquery-ui without jquery, it'll automatically add them in.</message>
  <tree>76417c8597c24c4d036ec00f551b96185704c374</tree>
  <committer>
    <name>Christopher D Warren</name>
    <email>chris@expectless.com</email>
  </committer>
</commit>
