<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/screw_unit/js_file.rb</filename>
    </added>
    <added>
      <filename>spec/screw_unit/asset_manager_spec/dir_4/1.css</filename>
    </added>
    <added>
      <filename>spec/screw_unit/js_file_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,4 +2,5 @@
 *.ipr
 *.iws
 .DS_Store
-pkg
\ No newline at end of file
+pkg
+.rakeTasks</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,7 @@ require &quot;#{dir}/screw_unit/resources&quot;
 require &quot;#{dir}/screw_unit/configuration&quot;
 require &quot;#{dir}/screw_unit/asset_manager&quot;
 require &quot;#{dir}/screw_unit/asset_location&quot;
+require &quot;#{dir}/screw_unit/js_file&quot;
 
 module ScrewUnit
   VERSION = &quot;1.9.0&quot;</diff>
      <filename>lib/screw_unit.rb</filename>
    </modified>
    <modified>
      <diff>@@ -49,5 +49,10 @@ module ScrewUnit
         raise &quot;Does not match glob pattern&quot;
       end
     end
+
+    def relative_find(relative_path)
+      physical_path = File.join(physical_prefix, relative_path)
+      return physical_path if File.exist?(physical_path)
+    end
   end
 end</diff>
      <filename>lib/screw_unit/asset_location.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,13 +17,22 @@ module ScrewUnit
       end
     end
 
-    attr_reader :locations
+    attr_reader :locations, :js_locations
     def initialize
       @locations = []
+      @js_locations = []
     end
 
     def add_location(virtual_path, physical_path)
-      locations.push(AssetLocation.new(virtual_path, physical_path))
+      location = AssetLocation.new(virtual_path, physical_path)
+      locations.unshift(location)
+      location
+    end
+
+    def add_js_location(virtual_path, physical_path)
+      location = add_location(virtual_path, physical_path)
+      js_locations.unshift(location)
+      location
     end
 
     def virtualize_path(physical_path)
@@ -47,5 +56,23 @@ module ScrewUnit
       matching_locations = locations.select {|l| l.matches_virtual_glob_pattern?(virtual_glob_pattern)}
       matching_locations.map {|l| l.virtual_glob(virtual_glob_pattern)}.flatten
     end
+
+    def virtual_dependency_paths(*relative_paths)
+      virtual_dependency_paths = []
+      relative_paths.each do |relative_path|
+        js_file = find_on_js_load_path(relative_path)
+        js_file.add_dependencies_to_required_virtual_paths(virtual_dependency_paths)
+      end
+      virtual_dependency_paths
+    end
+
+    def find_on_js_load_path(relative_path)
+      js_locations.each do |js_location|
+        if physical_path = js_location.relative_find(relative_path)
+          return JsFile.new(physical_path, self)
+        end
+      end
+      nil
+    end
   end
 end</diff>
      <filename>lib/screw_unit/asset_manager.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,9 +7,10 @@ module ScrewUnit
     before do
       @dir = File.dirname(__FILE__)
       @manager = AssetManager.new
-      manager.add_location(&quot;/specs/1&quot;, &quot;#{dir}/asset_manager_spec/dir_1&quot;)
-      manager.add_location(&quot;/specs/2&quot;, &quot;#{dir}/asset_manager_spec/dir_2&quot;)
-      manager.add_location(&quot;/implementations&quot;, &quot;#{dir}/asset_manager_spec/dir_3&quot;)
+      manager.add_js_location(&quot;/specs/1&quot;, &quot;#{dir}/asset_manager_spec/dir_1&quot;)
+      manager.add_js_location(&quot;/specs/2&quot;, &quot;#{dir}/asset_manager_spec/dir_2&quot;)
+      manager.add_js_location(&quot;/implementations&quot;, &quot;#{dir}/asset_manager_spec/dir_3&quot;)
+      manager.add_location(&quot;/css&quot;, &quot;#{dir}/asset_manager_spec/dir_4&quot;)
     end
 
     describe &quot;#virtualize_path&quot; do
@@ -31,12 +32,24 @@ module ScrewUnit
 
     describe &quot;#glob_virtual_paths&quot; do
       it &quot;maps the glob pattern to the declared locations, potentially spanning multiple physical locations, and returns the matching relative paths&quot; do
-        manager.glob_virtual_paths(&quot;/specs/**/*.js&quot;).should == [&quot;/specs/1/1.js&quot;, &quot;/specs/1/subdir_1/4.js&quot;, &quot;/specs/2/2.js&quot;]
+        manager.glob_virtual_paths(&quot;/specs/**/*.js&quot;).should == [&quot;/specs/2/2.js&quot;, &quot;/specs/1/1.js&quot;, &quot;/specs/1/subdir_1/4.js&quot;]
         manager.glob_virtual_paths(&quot;/specs/1/*.js&quot;).should == [&quot;/specs/1/1.js&quot;]
         manager.glob_virtual_paths(&quot;/specs/x/*.js&quot;).should == []
         manager.glob_virtual_paths(&quot;/implementations/**/*.js&quot;).should == [&quot;/implementations/3.js&quot;, &quot;/implementations/subdir_3/5.js&quot;]
         manager.glob_virtual_paths(&quot;/implementations/*.js&quot;).should == [&quot;/implementations/3.js&quot;]
       end
     end
+
+    describe &quot;#virtual_dependency_paths&quot; do
+      it &quot;computes the virtual paths of the require graph extending out from the files on the load path corresponding to the given paths&quot; do
+        expected_dependency_paths = [
+          &quot;/specs/1/subdir_1/4.js&quot;,
+          &quot;/implementations/subdir_3/5.js&quot;,
+          &quot;/implementations/3.js&quot;,
+          &quot;/specs/1/1.js&quot;
+        ]
+        manager.virtual_dependency_paths(&quot;1.js&quot;, &quot;subdir_3/5.js&quot;).should == expected_dependency_paths
+      end
+    end
   end
 end</diff>
      <filename>spec/screw_unit/asset_manager_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -0,0 +1,3 @@
+//= require &quot;subdir_1/4&quot;
+//= require &lt;3&gt;
+var x = 1;</diff>
      <filename>spec/screw_unit/asset_manager_spec/dir_1/1.js</filename>
    </modified>
    <modified>
      <diff>@@ -0,0 +1 @@
+//= require &quot;subdir_3/5&quot;</diff>
      <filename>spec/screw_unit/asset_manager_spec/dir_3/3.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6148c2d0891ff05d76982e3d394560c9c0da92dd</id>
    </parent>
  </parents>
  <author>
    <name>Grockit</name>
    <email>grockit@grok-a.local</email>
  </author>
  <url>http://github.com/grockit/screw-unit/commit/c5b2ae27608b0981c21571ac07ffdfd6983397be</url>
  <id>c5b2ae27608b0981c21571ac07ffdfd6983397be</id>
  <committed-date>2009-09-02T17:36:58-07:00</committed-date>
  <authored-date>2009-09-02T17:36:58-07:00</authored-date>
  <message>AssetManager can compute the require graph of scripts on the load path.</message>
  <tree>27944d7af7e1ca0214a06ccb917691f4c2d03965</tree>
  <committer>
    <name>Grockit</name>
    <email>grockit@grok-a.local</email>
  </committer>
</commit>
