vigetlabs-routing-filter 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ class RoutesTest < Test::Unit::TestCase
4
+ class RoutingFilter::Test < Filter
5
+ def around_recognize(path, env, &block)
6
+ 'recognized'
7
+ end
8
+
9
+ def around_generate(*args, &block)
10
+ 'generated'
11
+ end
12
+ end
13
+
14
+ attr_reader :routes
15
+
16
+ def setup
17
+ @routes = draw_routes { |set| set.filter :test }
18
+ end
19
+
20
+ test "routes.filter instantiates and registers a filter" do
21
+ assert routes.filters.first.is_a?(RoutingFilter::Test)
22
+ end
23
+
24
+ # test "filter.around_recognize is being called" do
25
+ # assert_equal 'recognized', routes.recognize_path('/')
26
+ # end
27
+
28
+ test "filter.around_generate is being called" do
29
+ assert_equal 'generated', routes.generate({})
30
+ end
31
+ end
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ include RoutingFilter
4
+
5
+ class RoutingFilterTest < Test::Unit::TestCase
6
+ class FooFilter < Filter
7
+ attr_reader :name
8
+
9
+ def initialize(name)
10
+ @name = name
11
+ end
12
+
13
+ def foo(log, &block)
14
+ log << name
15
+ yield
16
+ end
17
+ end
18
+
19
+ attr_reader :chain
20
+
21
+ def setup
22
+ @chain = Chain.new
23
+ @chain.unshift FooFilter.new('custom filter')
24
+ @chain.unshift FooFilter.new('common filter')
25
+ end
26
+
27
+ test "filter.previous is nil for the first filter in the chain" do
28
+ assert_nil chain.first.previous
29
+ end
30
+
31
+ test "filter.previous returns the previous filter in the chain" do
32
+ assert_equal chain.first, chain.last.previous
33
+ end
34
+
35
+ test "filter.next is nil for the last filter in the chain" do
36
+ assert_nil chain.last.next
37
+ end
38
+
39
+ test "filter.next returns the next filter in the chain" do
40
+ assert_equal chain.last, chain.first.next
41
+ end
42
+
43
+ test "chain.run calls the given method on registered filters in reverse order" do
44
+ log = []
45
+ assert_equal 'common filter, custom filter, finalizer', chain.run(:foo, log, &lambda { log << 'finalizer' }).join(', ')
46
+ end
47
+ end
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ module TestRailsAdapter
4
+ routes = ActionController::Routing::Routes = ActionController::Routing::RouteSet.new
5
+ routes.draw do |map|
6
+ map.connect '/', :controller => 'rails_test/tests', :action => 'index'
7
+ map.foo '/foo/:id', :controller => 'rails_test/tests', :action => 'show'
8
+ map.filter :uuid, :pagination ,:locale, :extension
9
+ end
10
+
11
+ attr_reader :session
12
+ delegate :get, :response, :to => :session
13
+
14
+ def setup
15
+ @session = ActionController::Integration::Session.new(lambda { |env| ActionController::Routing::Routes.call(env) })
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ require "rails"
4
+ require 'rack/test'
5
+
6
+ module TestRailsAdapter
7
+ include ::Rack::Test::Methods
8
+
9
+ APP = Class.new(Rails::Application).tap do |app|
10
+ app.config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
11
+ app.config.session_store :cookie_store, :key => "_myapp_session"
12
+ app.config.active_support.deprecation = :log
13
+ app.routes.draw do
14
+ match "/" => "rails_test/tests#index"
15
+ match "/foo/:id" => "rails_test/tests#show", :as => 'foo'
16
+ filter :uuid, :pagination ,:locale, :extension
17
+ end
18
+ app.initialize!
19
+ end
20
+
21
+ def app
22
+ APP
23
+ end
24
+
25
+ def response
26
+ last_response
27
+ end
28
+ end
@@ -0,0 +1,41 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require 'rubygems'
4
+ require 'test/unit'
5
+ require 'bundler/setup'
6
+
7
+ require 'i18n'
8
+ require 'action_pack'
9
+ require 'active_support'
10
+ require 'action_controller'
11
+ require 'active_support/core_ext/enumerable.rb'
12
+ require 'test_declarative'
13
+ require 'routing_filter'
14
+
15
+ include RoutingFilter
16
+
17
+ class SomeController < ActionController::Base
18
+ end
19
+
20
+ class Test::Unit::TestCase
21
+ def draw_routes(&block)
22
+ normalized_block = rails_2? ? lambda { |set| set.instance_eval(&block) } : block
23
+ klass = rails_2? ? ActionController::Routing::RouteSet : ActionDispatch::Routing::RouteSet
24
+ klass.new.tap { |set| set.draw(&normalized_block) }
25
+ end
26
+
27
+ def rails_2?
28
+ ActionPack::VERSION::MAJOR == 2
29
+ end
30
+ end
31
+
32
+ if ActionPack::VERSION::MAJOR == 2
33
+ ActionController::Routing::RouteSet::Mapper.class_eval do
34
+ def match(pattern, options)
35
+ pattern.gsub!('(.:format)', '.:format')
36
+ controller, action = options.delete(:to).split('#')
37
+ options.merge!(:controller => controller, :action => action)
38
+ connect(pattern, options)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,90 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{vigetlabs-routing-filter}
8
+ s.version = "0.2.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Sven Fuchs", "Brian Landau", "David Eisinger"]
12
+ s.date = %q{2011-04-04}
13
+ s.description = %q{Routing filters wraps around the complex beast that the Rails routing system is, allowing for unseen flexibility and power in Rails URL recognition and generation.}
14
+ s.email = %q{svenfuchs@artweb-design.de}
15
+ s.extra_rdoc_files = [
16
+ "README.markdown"
17
+ ]
18
+ s.files = [
19
+ ".travis.yml",
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "MIT-LICENSE",
23
+ "README.markdown",
24
+ "Rakefile",
25
+ "ci/Gemfile.rails-2.3.x",
26
+ "ci/Gemfile.rails-2.3.x.lock",
27
+ "ci/Gemfile.rails-3.x",
28
+ "ci/Gemfile.rails-3.x.lock",
29
+ "lib/routing-filter.rb",
30
+ "lib/routing_filter.rb",
31
+ "lib/routing_filter/adapters/rails_2.rb",
32
+ "lib/routing_filter/adapters/rails_3.rb",
33
+ "lib/routing_filter/chain.rb",
34
+ "lib/routing_filter/filter.rb",
35
+ "lib/routing_filter/filters/extension.rb",
36
+ "lib/routing_filter/filters/locale.rb",
37
+ "lib/routing_filter/filters/pagination.rb",
38
+ "lib/routing_filter/filters/uuid.rb",
39
+ "lib/routing_filter/version.rb",
40
+ "test/all.rb",
41
+ "test/filters/all_filters/generation.rb",
42
+ "test/filters/all_filters/recognition.rb",
43
+ "test/filters/all_filters_test.rb",
44
+ "test/filters/extension_test.rb",
45
+ "test/filters/locale_test.rb",
46
+ "test/filters/pagination_test.rb",
47
+ "test/filters/uuid_test.rb",
48
+ "test/rails_test.rb",
49
+ "test/routes_test.rb",
50
+ "test/routing_filter_test.rb",
51
+ "test/test_adapters/rails_2.rb",
52
+ "test/test_adapters/rails_3.rb",
53
+ "test/test_helper.rb",
54
+ "vigetlabs-routing-filter.gemspec"
55
+ ]
56
+ s.homepage = %q{https://github.com/vigetlabs/routing-filter}
57
+ s.require_paths = ["lib"]
58
+ s.rubygems_version = %q{1.3.7}
59
+ s.summary = %q{Routing filters wraps around the complex beast that the Rails routing system is, allowing for unseen flexibility and power in Rails URL recognition and generation.}
60
+ s.test_files = [
61
+ "test/all.rb",
62
+ "test/filters/all_filters/generation.rb",
63
+ "test/filters/all_filters/recognition.rb",
64
+ "test/filters/all_filters_test.rb",
65
+ "test/filters/extension_test.rb",
66
+ "test/filters/locale_test.rb",
67
+ "test/filters/pagination_test.rb",
68
+ "test/filters/uuid_test.rb",
69
+ "test/rails_test.rb",
70
+ "test/routes_test.rb",
71
+ "test/routing_filter_test.rb",
72
+ "test/test_adapters/rails_2.rb",
73
+ "test/test_adapters/rails_3.rb",
74
+ "test/test_helper.rb"
75
+ ]
76
+
77
+ if s.respond_to? :specification_version then
78
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
79
+ s.specification_version = 3
80
+
81
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
82
+ s.add_runtime_dependency(%q<actionpack>, [">= 0"])
83
+ else
84
+ s.add_dependency(%q<actionpack>, [">= 0"])
85
+ end
86
+ else
87
+ s.add_dependency(%q<actionpack>, [">= 0"])
88
+ end
89
+ end
90
+
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vigetlabs-routing-filter
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 4
10
+ version: 0.2.4
11
+ platform: ruby
12
+ authors:
13
+ - Sven Fuchs
14
+ - Brian Landau
15
+ - David Eisinger
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2011-04-04 00:00:00 -04:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ prerelease: false
25
+ type: :runtime
26
+ name: actionpack
27
+ version_requirements: &id001 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ hash: 3
33
+ segments:
34
+ - 0
35
+ version: "0"
36
+ requirement: *id001
37
+ description: Routing filters wraps around the complex beast that the Rails routing system is, allowing for unseen flexibility and power in Rails URL recognition and generation.
38
+ email: svenfuchs@artweb-design.de
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README.markdown
45
+ files:
46
+ - .travis.yml
47
+ - Gemfile
48
+ - Gemfile.lock
49
+ - MIT-LICENSE
50
+ - README.markdown
51
+ - Rakefile
52
+ - ci/Gemfile.rails-2.3.x
53
+ - ci/Gemfile.rails-2.3.x.lock
54
+ - ci/Gemfile.rails-3.x
55
+ - ci/Gemfile.rails-3.x.lock
56
+ - lib/routing-filter.rb
57
+ - lib/routing_filter.rb
58
+ - lib/routing_filter/adapters/rails_2.rb
59
+ - lib/routing_filter/adapters/rails_3.rb
60
+ - lib/routing_filter/chain.rb
61
+ - lib/routing_filter/filter.rb
62
+ - lib/routing_filter/filters/extension.rb
63
+ - lib/routing_filter/filters/locale.rb
64
+ - lib/routing_filter/filters/pagination.rb
65
+ - lib/routing_filter/filters/uuid.rb
66
+ - lib/routing_filter/version.rb
67
+ - test/all.rb
68
+ - test/filters/all_filters/generation.rb
69
+ - test/filters/all_filters/recognition.rb
70
+ - test/filters/all_filters_test.rb
71
+ - test/filters/extension_test.rb
72
+ - test/filters/locale_test.rb
73
+ - test/filters/pagination_test.rb
74
+ - test/filters/uuid_test.rb
75
+ - test/rails_test.rb
76
+ - test/routes_test.rb
77
+ - test/routing_filter_test.rb
78
+ - test/test_adapters/rails_2.rb
79
+ - test/test_adapters/rails_3.rb
80
+ - test/test_helper.rb
81
+ - vigetlabs-routing-filter.gemspec
82
+ has_rdoc: true
83
+ homepage: https://github.com/vigetlabs/routing-filter
84
+ licenses: []
85
+
86
+ post_install_message:
87
+ rdoc_options: []
88
+
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ requirements: []
110
+
111
+ rubyforge_project:
112
+ rubygems_version: 1.3.7
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: Routing filters wraps around the complex beast that the Rails routing system is, allowing for unseen flexibility and power in Rails URL recognition and generation.
116
+ test_files:
117
+ - test/all.rb
118
+ - test/filters/all_filters/generation.rb
119
+ - test/filters/all_filters/recognition.rb
120
+ - test/filters/all_filters_test.rb
121
+ - test/filters/extension_test.rb
122
+ - test/filters/locale_test.rb
123
+ - test/filters/pagination_test.rb
124
+ - test/filters/uuid_test.rb
125
+ - test/rails_test.rb
126
+ - test/routes_test.rb
127
+ - test/routing_filter_test.rb
128
+ - test/test_adapters/rails_2.rb
129
+ - test/test_adapters/rails_3.rb
130
+ - test/test_helper.rb