<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -18,7 +18,7 @@ The following would be a sceleton of an empty filter:
 
     module RoutingFilter
       class Awesomeness &lt; Base
-        def around_recognition(route, path, env)
+        def around_recognize(route, path, env)
           # Alter the path here before it gets recognized. 
           # Make sure to yield (calls the next around filter if present and 
           # eventually `recognize_path` on the routeset):
@@ -28,7 +28,7 @@ The following would be a sceleton of an empty filter:
           end
         end
     
-        def around_generation(controller, *args, &amp;block)
+        def around_generate(controller, *args, &amp;block)
           # Alter arguments here before they are passed to `url_for`. 
           # Make sure to yield (calls the next around filter if present and 
           # eventually `url_for` on the controller):</diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -3,35 +3,37 @@ module RoutingFilter
   @@active = true
   
   class &lt;&lt; self
-    def around_recognition(route, path, env)
-      return route.recognize_path_without_filtering(path, env) unless RoutingFilter.active
+    def around_recognize(path, env)
+      routes = ActionController::Routing::Routes
+      return routes.recognize_path_without_filtering(path, env) unless RoutingFilter.active
       path = path.dup
-      chain = [lambda{ route.recognize_path_without_filtering(path, env) }]
+      chain = [lambda{ routes.recognize_path_without_filtering(path, env) }]
       ActionController::Routing::Routes.filters.each do |filter|
         chain.unshift lambda{
-          filter.around_recognition(route, path, env, &amp;chain.shift)
+          filter.around_recognize(path, env, &amp;chain.shift)
         }
       end
       chain.shift.call
     end
   
-    def around_generation(controller, *args)
-      return controller.url_for_without_filtering(*args) unless RoutingFilter.active
-      chain = [lambda{ controller.url_for_without_filtering(*args) }]
+    def around_generate(*args)
+      routes = ActionController::Routing::Routes
+      return routes.generate_without_filtering(*args) unless RoutingFilter.active
+      chain = [lambda{ routes.generate_without_filtering(*args) }]
       ActionController::Routing::Routes.filters.each do |filter|
         chain.unshift lambda{
-          filter.around_generation(controller, *args, &amp;chain.shift)
+          filter.around_generate(args.first, &amp;chain.shift)
         }
       end
-      chain.shift.call *args
+      chain.shift.call
     end
   
-    def around_generation_optimized(controller, result, *args)
+    def around_generate_optimized(controller, result, *args)
       return result unless RoutingFilter.active
       chain = [lambda{ result }]
       ActionController::Routing::Routes.filters.each do |filter|
         chain.unshift lambda{
-          filter.around_generation(controller, *args, &amp;chain.shift)
+          filter.around_generate(*args, &amp;chain.shift)
         }
       end
       chain.shift.call
@@ -44,19 +46,10 @@ ActionController::Routing::RouteSet::Mapper.class_eval do
   def filter(name, options = {})
     require &quot;routing_filter/#{name}&quot;
     klass = RoutingFilter.const_get name.to_s.camelize
-    # klass = &quot;RoutingFilter::#{name.to_s.camelize}&quot;.constantize
     @set.filters.push klass.new(options)
   end
 end
 
-# hook into url_for and call before and after filters
-ActionController::Base.class_eval do
-  def url_for_with_filtering(*args)
-    RoutingFilter.around_generation(self, *args)
-  end
-  alias_method_chain :url_for, :filtering
-end
-
 # same here for the optimized url generation in named routes
 ActionController::Routing::RouteSet::NamedRouteCollection.class_eval do
   # gosh. monkey engineering optimization code
@@ -66,7 +59,7 @@ ActionController::Routing::RouteSet::NamedRouteCollection.class_eval do
       &lt;&lt;-code
         if #{match[2]}
           result = #{match[1]}
-          RoutingFilter.around_generation_optimized self, result, *args
+          RoutingFilter.around_generate_optimized self, result, *args
           return result
         end
       code
@@ -82,10 +75,15 @@ ActionController::Routing::RouteSet.class_eval do
   end
 
   # wrap recognition filters around recognize_path
-  def recognize_path_with_filtering(path, env)
-    RoutingFilter.around_recognition(self, path, env)
+  def recognize_path_with_filtering(*args)
+    RoutingFilter.around_recognize *args
   end
   alias_method_chain :recognize_path, :filtering
+  
+  def generate_with_filtering(*args)
+    RoutingFilter.around_generate *args
+  end
+  alias_method_chain :generate, :filtering
 
   # add some useful information to the request environment
   # right, this is from jamis buck's excellent article about routes internals</diff>
      <filename>lib/routing_filter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,12 +6,12 @@ module RoutingFilter
       @options = options
     end
     
-    def around_recognition(route, path, env, &amp;block)
-      yield path, env
+    def around_recognize(*args, &amp;block)
+      yield
     end
     
-    def around_generation(controller, *args, &amp;block)
-      yield options
+    def around_generate(*args, &amp;block)
+      yield
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/routing_filter/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@ module RoutingFilter
     
     # remove the locale from the beginning of the path, pass the path
     # to the given block and set it to the resulting params hash
-    def around_recognition(route, path, env, &amp;block)
+    def around_recognize(path, env, &amp;block)
       locale = nil
       path.sub! %r(^/([a-zA-Z]{2})(?=/|$)) do locale = $1; '' end
       returning yield do |params|
@@ -22,8 +22,8 @@ module RoutingFilter
       end
     end
     
-    def around_generation(controller, *args, &amp;block)
-      options = args.last.is_a?(Hash) ? args.last : {}
+    def around_generate(*args, &amp;block)
+      options = args.extract_options!
       locale = options.delete(:locale) || I18n.locale
       returning yield do |result|
         prepend_locale! result, locale if locale.to_sym != @@default_locale
@@ -31,9 +31,8 @@ module RoutingFilter
     end
     
     def prepend_locale!(result, locale)
-      url, host, path = *result.match(%r(^(http.?://[^/]*)?(.*)))
-      path = &quot;/#{locale}#{path}&quot; unless path =~ %r(^/#{locale})
-      result.replace &quot;#{host}#{path}&quot;
+      result.match(%r(^(http.?://[^/]*)?(.*)))
+      result.replace &quot;#{$1}/#{locale}#{$2}&quot;
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/routing_filter/locale.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,15 @@
 $: &lt;&lt; File.dirname(__FILE__) + '/../'
 $: &lt;&lt; File.dirname(__FILE__) + '/../../lib/'
-$: &lt;&lt; File.dirname(__FILE__) + '/../../vendor/rails'
-$: &lt;&lt; File.dirname(__FILE__) + '/../../vendor/rails/activesupport/lib/active_support'
+$: &lt;&lt; File.dirname(__FILE__) + '/../../vendor/rails/actionpack/lib'
+$: &lt;&lt; File.dirname(__FILE__) + '/../../vendor/rails/activesupport/lib'
 
 require 'action_controller'
 require 'action_controller/test_process'
-require 'activesupport/lib/active_support/vendor'
+require 'active_support/vendor'
 
 require 'routing_filter'
 require 'routing_filter/base'
 require 'routing_filter/locale'
-#require File.dirname(__FILE__) + '/mock_filter.rb'
 
 class Section
   def to_param</diff>
      <filename>spec/helper/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,69 +6,92 @@ describe 'RoutingFilter', 'the Locale filter' do
   before :each do
     RoutingFilter::Locale.default_locale = :en
     I18n.default_locale = :en
+    I18n.locale = :de
 
-    @controller = instantiate_controller :locale =&gt; 'de', :section_id =&gt; 1
+    @controller = instantiate_controller :locale =&gt; 'de', :id =&gt; 1
     @set = draw_routes do |map|
-      map.section 'sections/:section_id', :controller =&gt; 'sections', :action =&gt; &quot;show&quot;
+      map.section 'sections/:id', :controller =&gt; 'sections', :action =&gt; &quot;show&quot;
       map.filter 'locale'
     end
-
+    
+    @params = {:controller =&gt; 'sections', :action =&gt; &quot;show&quot;, :id =&gt; &quot;1&quot;}
     @locale_filter = @set.filters.first
   end
+  
+  def should_recognize_path(path, params)
+    @set.recognize_path(path, {}).should == params
+  end
+  
+  def section_path(*args)
+    @controller.send :section_path, *args
+  end
+  
+  def url_for(*args)
+    @controller.send :url_for, *args
+  end
 
-  # it 'recognizes the path /de/sections/1 and sets the :locale param' do
-  #   @set.recognize_path('/de/sections/1', {})[:locale].should == 'de'
-  # end
-  # 
-  # it 'recognizes the path /sections/1 and does not set a :locale param' do
-  #   @set.recognize_path('/sections/1', {})[:locale].should be_nil
-  # end
-  # 
-  # it 'does not change a generated path when the current locale is the default locale' do
-  #   I18n.locale = :en
-  #   @controller.send(:section_path, :section_id =&gt; 1).should == '/sections/1'
-  # end
-  # 
-  # describe &quot;when used with named route url_helper&quot; do
-  #   it 'prepends the current locale to the generated path when it is not the default locale' do
-  #     I18n.locale = :de
-  #     @controller.send(:section_path, :section_id =&gt; 1).should == '/de/sections/1'
-  #   end
-  # 
-  #   it 'prepends a given locale param to the generated path when it is not the default locale' do
-  #     I18n.locale = :de
-  #     @controller.send(:section_path, :section_id =&gt; 1, :locale =&gt; :fi).should == '/fi/sections/1'
-  #   end
-  # end
+  it 'recognizes the path /de/sections/1 and sets the :locale param' do
+    should_recognize_path '/de/sections/1', @params.update(:locale =&gt; 'de')
+  end
+  
+  it 'recognizes the path /sections/1 and does not set a :locale param' do
+    should_recognize_path '/sections/1', @params
+  end
+  
+  describe &quot;named route url_helpers&quot; do
+    it 'does not change the result when the current locale is the default locale' do
+      I18n.locale = :en
+      section_path(:id =&gt; 1).should == '/sections/1'
+    end
+  
+    it 'prepends the current locale when it is not the default locale' do
+      section_path(:id =&gt; 1).should == '/de/sections/1'
+    end
+  
+    it 'prepends a given locale param when it is not the default locale' do
+      section_path(:id =&gt; 1, :locale =&gt; :fi).should == '/fi/sections/1'
+    end
+  end
   
-  # describe 'when used with named route url_helper with &quot;optimized&quot; generation blocks' do
-  #   it 'prepends the current locale to the generated path when it is not the default locale' do
-  #     I18n.locale = :de
-  #     @controller.send(:section_path, 1).should == '/de/sections/1'
-  #   end
-  # 
-  #   it 'prepends a given locale param to the generated path when it is not the default locale' do
-  #     I18n.locale = :de
-  #     @controller.send(:section_path, 1, :locale =&gt; :fi).should == '/fi/sections/1'
-  #   end
-  # end
+  describe 'when used with named route url_helper with &quot;optimized&quot; generation blocks' do
+    # uses optimization
+    it 'does not change the result when the current locale is the default locale' do
+      I18n.locale = :en
+      section_path(1).should == '/sections/1'
+    end
+      
+    # uses optimization
+    it 'prepends the current locale when it is not the default locale' do
+      section_path(1).should == '/de/sections/1'
+    end
+      
+    # does not use optimization
+    it 'prepends a given locale param when it is not the default locale' do
+      section_path(1, :locale =&gt; :fi).should == '/fi/sections/1'
+    end
+  end
 
-  # describe 'when used with a polymorphic_path' do
-  #   it 'prepends the current locale to the generated path when it is not the default locale' do
-  #     I18n.locale = :de
-  #     @controller.send(:section_path, Section.new).should == '/de/sections/1'
-  #   end
-  # 
-  #   it 'prepends a given locale param to the generated path when it is not the default locale' do
-  #     I18n.locale = :de
-  #     @controller.send(:section_path, Section.new, :locale =&gt; :fi).should == '/fi/sections/1'
-  #   end
-  # end
+  describe 'when used with a polymorphic_path' do
+    # uses optimization
+    it 'does not change the result when the current locale is the default locale' do
+      I18n.locale = :en
+      section_path(Section.new).should == '/sections/1'
+    end
+  
+    # uses optimization
+    it 'prepends the current locale when it is not the default locale' do
+      section_path(Section.new).should == '/de/sections/1'
+    end
+      
+    # does not use optimization
+    it 'prepends a given locale param when it is not the default locale' do
+      section_path(Section.new, :locale =&gt; :fi).should == '/fi/sections/1'
+    end
+  end
   
   describe 'when used with url_for and an ActivRecord instance' do
-    it 'prepends the current locale to the generated path when it is not the default locale' do
-      I18n.locale = :de
-      @controller.send(:url_for, Section.new).should == 'http://test.host/de/sections/1'
+    it 'prepends the current locale when it is not the default locale' do
+      url_for(Section.new).should == 'http://test.host/de/sections/1'
     end
   end
 end
\ No newline at end of file</diff>
      <filename>spec/locale_filter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -18,47 +18,51 @@ describe 'RoutingFilter' do
     @set.recognize_path path, options
   end
   
-  def generate_url_for(options = {:controller =&gt; 'sections', :action =&gt; 'show', :section_id =&gt; 1})
+  def url_for(options)
     @controller.send :url_for, options
   end
+  
+  def section_path(*args)
+    @controller.send :section_path, *args
+  end
 
   it 'installs filters to the route set' do
     @locale_filter.should be_instance_of(RoutingFilter::Locale)
     @mock_filter.should be_instance_of(RoutingFilter::Mock)
   end
-
+  
   it 'calls the first filter for route recognition' do
-    @locale_filter.should_receive :around_recognition
+    @locale_filter.should_receive :around_recognize
     recognize_path
   end
-
+  
   it 'calls the second filter for route recognition' do
-    @mock_filter.should_receive :around_recognition
+    @mock_filter.should_receive :around_recognize
     recognize_path
   end
 
   it 'calls the first filter for url generation' do
-    @locale_filter.should_receive :around_generation
-    generate_url_for
+    @locale_filter.should_receive(:around_generate).and_return '/sections/1'
+    url_for :controller =&gt; 'sections', :action =&gt; 'show', :section_id =&gt; 1
   end
 
   it 'calls the second filter for url generation' do
-    @mock_filter.should_receive :around_generation
-    generate_url_for
+    @mock_filter.should_receive(:around_generate).and_return '/sections/1'
+    url_for :controller =&gt; 'sections', :action =&gt; 'show', :section_id =&gt; 1
   end
-
+  
   it 'calls the first filter for named route url_helper' do
-    @locale_filter.should_receive :around_generation
-    @controller.send :section_path, :section_id =&gt; 1
+    @locale_filter.should_receive(:around_generate).and_return '/sections/1'
+    section_path :section_id =&gt; 1
   end
   
   it 'calls the filter for named route url_helper with &quot;optimized&quot; generation blocks' do
-    @locale_filter.should_receive :around_generation
-    @controller.send :section_path, 1
+    @locale_filter.should_receive(:around_generate).and_return '/sections/1'
+    section_path 1
   end
   
   it 'calls the filter for named route polymorphic_path' do
-    @locale_filter.should_receive :around_generation
-    @controller.send :section_path, Section.new
+    @locale_filter.should_receive(:around_generate).and_return '/sections/1'
+    section_path Section.new
   end
 end
\ No newline at end of file</diff>
      <filename>spec/routing_filter_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>935edde0a80b5c6257184aca39f094024972755c</id>
    </parent>
  </parents>
  <author>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </author>
  <url>http://github.com/svenfuchs/routing-filter/commit/a5a8d053578f6716f76ecda1c0c26a23e0437098</url>
  <id>a5a8d053578f6716f76ecda1c0c26a23e0437098</id>
  <committed-date>2008-09-20T13:44:58-07:00</committed-date>
  <authored-date>2008-09-20T13:44:58-07:00</authored-date>
  <message>refactoring</message>
  <tree>e98f57a1a2d130de29f31a7b9b023683c5229e0b</tree>
  <committer>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </committer>
</commit>
