<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -20,10 +20,11 @@ module ScrewUnit
       end
     end
 
-    attr_reader :path_containing_screwrc, :asset_manager
+    attr_reader :path_containing_screwrc, :asset_manager, :resource_locators
 
     def initialize
       @asset_manager = AssetManager.new
+      @resource_locators = []
       asset_manager.add_js_location(&quot;/screw_unit_core&quot;, &quot;#{SCREW_UNIT_ROOT}/client/lib&quot;)
       asset_manager.add_js_location(&quot;/screw_unit_vendor&quot;, &quot;#{SCREW_UNIT_ROOT}/client/vendor&quot;)
       asset_manager.add_js_location(&quot;/screw_unit_stylesheets&quot;, &quot;#{SCREW_UNIT_ROOT}/client/stylesheets&quot;)
@@ -47,6 +48,10 @@ module ScrewUnit
       asset_manager.add_location(virtual_path, absolutize_path(relative_path))
     end
 
+    def add_resource_locator(locator)
+      resource_locators.unshift(locator)
+    end
+
     def absolutize_path(relative_path)
       File.expand_path(File.join(path_containing_screwrc, relative_path))
     end</diff>
      <filename>lib/screw_unit/configuration.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,9 @@
 module ScrewUnit
   class Dispatcher
-    attr_reader :root
+    attr_reader :root, :resource_locators
 
     def initialize(configuration)
+      @resource_locators = configuration.resource_locators
       @root = Resources::Root.new(configuration)
     end
 
@@ -23,6 +24,11 @@ module ScrewUnit
     end
 
     def locate_resource(path)
+      resource_locators.each do |locator|
+        resource = locator.locate_resource(path)
+        return resource if resource
+      end
+
       path_parts(path).inject(root) do |resource, child_resource_name|
         resource.locate(child_resource_name)
       end</diff>
      <filename>lib/screw_unit/dispatcher.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,7 @@ module ScrewUnit
     def require_declarations
       declarations = []
       File.open(physical_path, 'r') do |f|
-        f.lines.each do |line|
+        f.readlines.each do |line|
           if match = RELATIVE_REQUIRE_REGEX.match(line)
             require_path = match[0]
             declarations.push(RelativeRequireDeclaration.new(containing_dir, match[1], asset_manager))</diff>
      <filename>lib/screw_unit/js_file.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,9 +11,29 @@ module ScrewUnit
       end
 
       def get
-        file = Rack::File.new(nil)
-        file.path = asset_manager.physicalize_path(virtual_path)
-        file.serving
+        [200, headers, ::File.read(physical_path)]
+      end
+
+      MIME_TYPES = {
+        &quot;.css&quot; =&gt; &quot;text/css&quot;,
+        &quot;.gif&quot; =&gt; &quot;image/gif&quot;,
+        &quot;.js&quot; =&gt; &quot;application/javascript&quot;,
+        &quot;.jpg&quot; =&gt; &quot;image/jpeg&quot;,
+        &quot;.jpeg&quot; =&gt; &quot;image/jpeg&quot;,
+        &quot;.png&quot; =&gt; &quot;image/png&quot;,
+        }
+
+      def headers
+        {
+          &quot;Content-Type&quot; =&gt; mime_type(physical_path),
+          &quot;Last-Modified&quot; =&gt; ::File.mtime(physical_path).httpdate
+        }
+      end
+
+      protected
+
+      def mime_type(physical_path)
+        MIME_TYPES[::File.extname(physical_path)]
       end
     end
   end</diff>
      <filename>lib/screw_unit/resources/file.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ module ScrewUnit
     attr_reader :manager, :dir
 
     before do
-      @dir = File.dirname(__FILE__)
+      @dir = File.expand_path(File.dirname(__FILE__))
       @manager = AssetManager.new
       manager.add_js_location(&quot;/specs/1&quot;, &quot;#{dir}/file_system_fixtures_for_asset_manager_specs/dir_1&quot;)
       manager.add_js_location(&quot;/specs/2&quot;, &quot;#{dir}/file_system_fixtures_for_asset_manager_specs/dir_2&quot;)</diff>
      <filename>spec/screw_unit/asset_manager_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,5 +2,59 @@ require &quot;#{File.dirname(__FILE__)}/../screw_unit_spec_helper&quot;
 
 module ScrewUnit
   describe Dispatcher do
+    attr_reader :dispatcher, :locator_1, :locator_2
+    before do
+      @locator_1 = Object.new
+      @locator_2 = Object.new
+      @dispatcher = Dispatcher.new(configuration)
+    end
+
+    describe &quot;#locate_resource(path)&quot; do
+      context &quot;when there are #resource_locators&quot; do
+        def configuration
+          return @configuration if @configuration
+          @configuration = Configuration.new
+          @configuration.add_resource_locator(locator_1)
+          @configuration.add_resource_locator(locator_2)
+          @configuration
+        end
+
+        context &quot;when one of the custom locators returns a resource&quot; do
+          attr_reader :resource
+          before do
+            @resource = Object.new
+            mock(locator_2).locate_resource(&quot;/foo&quot;).ordered { nil }
+            mock(locator_1).locate_resource(&quot;/foo&quot;).ordered { resource }
+          end
+
+          it &quot;returns that resource&quot; do
+            dispatcher.locate_resource(&quot;/foo&quot;).should == resource
+          end
+        end
+
+        context &quot;when no custom locators return a resource&quot; do
+          before do
+            mock(locator_2).locate_resource(&quot;/foo&quot;).ordered { nil }
+            mock(locator_1).locate_resource(&quot;/foo&quot;).ordered { nil }
+          end
+
+          it &quot;performs the normal dispatch starting at Resources::Root&quot; do
+            mock.instance_of(Resources::Root).locate(&quot;foo&quot;)
+            dispatcher.locate_resource(&quot;/foo&quot;)
+          end
+        end
+      end
+
+      context &quot;when there are no #resource_locators&quot; do
+        def configuration
+          @configuration ||= Configuration.new
+        end
+
+        it &quot;performs the normal dispatch starting at Resources::Root&quot; do
+          mock.instance_of(Resources::Root).locate(&quot;foo&quot;)
+          dispatcher.locate_resource(&quot;/foo&quot;)
+        end
+      end
+    end
   end
 end</diff>
      <filename>spec/screw_unit/dispatcher_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ module ScrewUnit
     attr_reader :js_file, :dir
 
     before do
-      @dir = File.dirname(__FILE__)
+      @dir = File.expand_path(File.dirname(__FILE__))
       asset_manager = Configuration.new.asset_manager
       asset_manager.add_js_location(&quot;/implementations&quot;, &quot;#{dir}/file_system_fixtures_for_asset_manager_specs/dir_3&quot;)
       @js_file = JsFile.new(&quot;#{dir}/file_system_fixtures_for_asset_manager_specs/dir_1/1.js&quot;, asset_manager)</diff>
      <filename>spec/screw_unit/js_file_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,13 +6,13 @@ module ScrewUnit
       attr_reader :dir, :asset_manager
 
       before do
-        spec_file_dir = ::File.dirname(__FILE__)
+        spec_file_dir = ::File.expand_path(::File.dirname(__FILE__))
         @asset_manager = Configuration.new.asset_manager
       end
 
       describe &quot;#locate&quot; do
         before do
-          asset_manager.add_location(&quot;/x&quot;, &quot;#{::File.dirname(__FILE__)}/file_system_fixtures&quot;)
+          asset_manager.add_location(&quot;/x&quot;, &quot;#{::File.expand_path(::File.dirname(__FILE__))}/file_system_fixtures&quot;)
           @dir = Dir.new(&quot;/x&quot;, asset_manager)
         end
 
@@ -50,8 +50,9 @@ module ScrewUnit
       describe &quot;#glob&quot; do
         before do
           @dir = Dir.new(&quot;/foo&quot;, asset_manager)
-          asset_manager.add_location(&quot;/foo/bar&quot;, &quot;#{::File.dirname(__FILE__)}/file_system_fixtures/code_under_test&quot;)
-          asset_manager.add_location(&quot;/foo/baz&quot;, &quot;#{::File.dirname(__FILE__)}/file_system_fixtures/specs&quot;)
+          absolute_dir = ::File.expand_path(::File.dirname(__FILE__))
+          asset_manager.add_location(&quot;/foo/bar&quot;, &quot;#{absolute_dir}/file_system_fixtures/code_under_test&quot;)
+          asset_manager.add_location(&quot;/foo/baz&quot;, &quot;#{absolute_dir}/file_system_fixtures/specs&quot;)
         end
 
         it &quot;returns File resources with the correct relative paths for all files matching the pattern&quot; do</diff>
      <filename>spec/screw_unit/resources/dir_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ module ScrewUnit
       attr_reader :dir, :file, :asset_manager
 
       before do
-        @dir = ::File.dirname(__FILE__)
+        @dir = ::File.expand_path(::File.dirname(__FILE__))
         @asset_manager = Configuration.new.asset_manager
         asset_manager.add_js_location(&quot;/&quot;, &quot;#{dir}/file_system_fixtures&quot;)
         @file = File.new(virtual_path, asset_manager)</diff>
      <filename>spec/screw_unit/resources/file_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ module ScrewUnit
       attr_reader :spec_dir, :asset_manager
 
       before do
-        dir = ::File.dirname(__FILE__)
+        dir = ::File.expand_path(::File.dirname(__FILE__))
         @asset_manager = Configuration.new.asset_manager
         asset_manager.add_js_location(&quot;/specs&quot;, &quot;#{dir}/file_system_fixtures/specs&quot;)
         @spec_dir = SpecDir.new(&quot;/specs&quot;, asset_manager)</diff>
      <filename>spec/screw_unit/resources/spec_dir_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ module ScrewUnit
       attr_reader :dir, :spec_file_resources, :spec_suite, :asset_manager
 
       before do
-        @dir = ::File.dirname(__FILE__)
+        @dir = ::File.expand_path(::File.dirname(__FILE__))
         @asset_manager = Configuration.new.asset_manager
         asset_manager.add_location(&quot;/specs&quot;, &quot;#{dir}/file_system_fixtures/specs&quot;)
         @spec_file_resources = Dir.new(&quot;/specs&quot;, asset_manager).glob(&quot;**/*.js&quot;)</diff>
      <filename>spec/screw_unit/resources/spec_suite_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0a996bfb70fbd3bb9dd6ab2a729fc62da6d5b080</id>
    </parent>
    <parent>
      <id>cfcef85e2f7a84299b3b40e692e239385bb3ba8b</id>
    </parent>
  </parents>
  <author>
    <name>Grockit</name>
    <email>grockit@grok-a.local</email>
  </author>
  <url>http://github.com/nathansobo/screw-unit/commit/9fc63d0dda5a4e4793ed23e076392bcdc604e6ca</url>
  <id>9fc63d0dda5a4e4793ed23e076392bcdc604e6ca</id>
  <committed-date>2009-10-09T13:04:39-07:00</committed-date>
  <authored-date>2009-10-09T13:04:39-07:00</authored-date>
  <message>Merge branch 'mmol'</message>
  <tree>4314ba80a3bfa1ab5215fdccd8236ade5cb96fe1</tree>
  <committer>
    <name>Grockit</name>
    <email>grockit@grok-a.local</email>
  </committer>
</commit>
