deas 0.17.0 → 0.17.1

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.
@@ -2,10 +2,18 @@ module Deas
2
2
 
3
3
  Error = Class.new(RuntimeError)
4
4
  ServerError = Class.new(Error)
5
+
5
6
  ServerRootError = Class.new(ServerError) do
6
7
  def message
7
8
  "server `root` not set but required"
8
9
  end
9
10
  end
10
11
 
12
+ NoHandlerClassError = Class.new(Error) do
13
+ def initialize(handler_class_name)
14
+ super "Deas couldn't find the view handler '#{handler_class_name}'" \
15
+ " - it doesn't exist or hasn't been required in yet."
16
+ end
17
+ end
18
+
11
19
  end
@@ -0,0 +1,29 @@
1
+ require 'deas/view_handler'
2
+
3
+ module Deas
4
+ class RedirectProxy
5
+
6
+ attr_reader :handler_class_name, :handler_class
7
+
8
+ def initialize(path = nil, &block)
9
+ @handler_class = Class.new do
10
+ include Deas::ViewHandler
11
+
12
+ def self.redirect_path; @redirect_path; end
13
+ def self.redirect_path=(value)
14
+ @redirect_path = value
15
+ end
16
+
17
+ def self.name; 'Deas::RedirectHandler'; end
18
+
19
+ def run!
20
+ redirect self.instance_eval(&self.class.redirect_path)
21
+ end
22
+
23
+ end
24
+ @handler_class.redirect_path = path ? proc{ path } : block
25
+ @handler_class_name = @handler_class.name
26
+ end
27
+
28
+ end
29
+ end
data/lib/deas/route.rb CHANGED
@@ -1,51 +1,28 @@
1
1
  require 'deas/sinatra_runner'
2
2
 
3
3
  module Deas
4
-
5
4
  class Route
6
- attr_reader :method, :path, :handler_class_name, :handler_class
7
5
 
8
- def initialize(method, path, handler_class_name, handler_class = nil)
9
- @method = method
10
- @path = path
11
- @handler_class_name = handler_class_name
12
- @handler_class = handler_class
6
+ attr_reader :method, :path, :handler_proxy, :handler_class
7
+
8
+ def initialize(method, path, handler_proxy)
9
+ @method, @path, @handler_proxy = method, path, handler_proxy
13
10
  end
14
11
 
15
- def constantize!
16
- @handler_class ||= constantize_name(handler_class_name)
17
- raise(NoHandlerClassError.new(handler_class_name)) if !@handler_class
12
+ def validate!
13
+ @handler_class = @handler_proxy.handler_class
18
14
  end
19
15
 
16
+ # TODO: unit test this??
20
17
  def run(sinatra_call)
21
18
  sinatra_call.request.env.tap do |env|
22
19
  env['sinatra.params'] = sinatra_call.params
23
- env['deas.handler_class_name'] = @handler_class_name
20
+ env['deas.handler_class_name'] = self.handler_class.name
24
21
  env['deas.logging'].call " Handler: #{env['deas.handler_class_name']}"
25
22
  env['deas.logging'].call " Params: #{env['sinatra.params'].inspect}"
26
23
  end
27
- Deas::SinatraRunner.run(@handler_class, sinatra_call)
28
- end
29
-
30
- private
31
-
32
- def constantize_name(class_name)
33
- names = class_name.to_s.split('::').reject{|name| name.empty? }
34
- klass = names.inject(Object) do |constant, name|
35
- constant.const_get(name)
36
- end
37
- klass == Object ? false : klass
38
- rescue NameError
39
- false
24
+ Deas::SinatraRunner.run(self.handler_class, sinatra_call)
40
25
  end
41
26
 
42
27
  end
43
-
44
- class NoHandlerClassError < RuntimeError
45
- def initialize(handler_class_name)
46
- super "Deas couldn't find the view handler '#{handler_class_name}'. " \
47
- "It doesn't exist or hasn't been required in yet."
48
- end
49
- end
50
-
51
28
  end
@@ -0,0 +1,30 @@
1
+ require 'deas/view_handler'
2
+ require 'deas/exceptions'
3
+
4
+ module Deas
5
+ class RouteProxy
6
+
7
+ attr_reader :handler_class_name
8
+
9
+ def initialize(handler_class_name)
10
+ @handler_class_name = handler_class_name
11
+ end
12
+
13
+ def handler_class
14
+ constantize(@handler_class_name).tap do |handler_class|
15
+ raise(NoHandlerClassError.new(@handler_class_name)) if !handler_class
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def constantize(class_name)
22
+ names = class_name.to_s.split('::').reject{ |name| name.empty? }
23
+ klass = names.inject(Object){ |constant, name| constant.const_get(name) }
24
+ klass == Object ? false : klass
25
+ rescue NameError
26
+ false
27
+ end
28
+
29
+ end
30
+ end
data/lib/deas/server.rb CHANGED
@@ -5,7 +5,8 @@ require 'set'
5
5
  require 'deas/exceptions'
6
6
  require 'deas/template'
7
7
  require 'deas/logging'
8
- require 'deas/redirect_handler'
8
+ require 'deas/redirect_proxy'
9
+ require 'deas/route_proxy'
9
10
  require 'deas/route'
10
11
  require 'deas/show_exceptions'
11
12
  require 'deas/sinatra_app'
@@ -70,8 +71,8 @@ module Deas::Server
70
71
  self.init_procs.each{ |p| p.call }
71
72
  raise Deas::ServerRootError if self.root.nil?
72
73
 
73
- # constantize the routes to ensure they are available
74
- self.routes.each(&:constantize!)
74
+ # validate the routes
75
+ self.routes.each(&:validate!)
75
76
 
76
77
  # set the :erb :outvar setting if it hasn't been set. this is used
77
78
  # by template helpers and plugins and needs to be queryable. the actual
@@ -96,6 +97,10 @@ module Deas::Server
96
97
  end
97
98
  end
98
99
 
100
+ def add_route(http_method, path, proxy)
101
+ Deas::Route.new(http_method, path, proxy).tap{ |r| self.routes.push(r) }
102
+ end
103
+
99
104
  end
100
105
 
101
106
  def self.included(receiver)
@@ -218,20 +223,16 @@ module Deas::Server
218
223
  end
219
224
 
220
225
  def redirect(http_method, path, to_path = nil, &block)
221
- name = 'Deas::RedirectHandler'
222
- handler_class = Deas::RedirectHandler.new(to_path, &block)
223
- Deas::Route.new(http_method, path, name, handler_class).tap do |route|
224
- self.configuration.routes.push(route)
225
- end
226
+ proxy = Deas::RedirectProxy.new(to_path, &block)
227
+ self.configuration.add_route(http_method, path, proxy)
226
228
  end
227
229
 
228
230
  def route(http_method, path, handler_class_name)
229
231
  if self.view_handler_ns && !(handler_class_name =~ /^::/)
230
232
  handler_class_name = "#{self.view_handler_ns}::#{handler_class_name}"
231
233
  end
232
- Deas::Route.new(http_method, path, handler_class_name).tap do |route|
233
- self.configuration.routes.push(route)
234
- end
234
+ proxy = Deas::RouteProxy.new(handler_class_name)
235
+ self.configuration.add_route(http_method, path, proxy)
235
236
  end
236
237
 
237
238
  end
data/lib/deas/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Deas
2
- VERSION = "0.17.0"
2
+ VERSION = "0.17.1"
3
3
  end
@@ -4,13 +4,13 @@ require 'deas'
4
4
 
5
5
  module Deas
6
6
 
7
- class RackTestContext < Assert::Context
7
+ class RackTestsContext < Assert::Context
8
8
  include Assert::Rack::Test
9
9
 
10
10
  def app; @app; end
11
11
  end
12
12
 
13
- class RackTests < RackTestContext
13
+ class RackTests < RackTestsContext
14
14
  desc "a Deas server rack app"
15
15
  setup do
16
16
  @app = DeasTestServer.new
@@ -160,7 +160,7 @@ module Deas
160
160
 
161
161
  end
162
162
 
163
- class ShowExceptionsTests < RackTestContext
163
+ class ShowExceptionsTests < RackTestsContext
164
164
  desc "a Deas server rack app with show exceptions enabled"
165
165
  setup do
166
166
  @app = DeasDevServer.new
@@ -1,4 +1,5 @@
1
1
  require 'assert'
2
+ require 'test/support/fake_sinatra_call'
2
3
  require 'deas/error_handler'
3
4
 
4
5
  class Deas::ErrorHandler
@@ -11,6 +11,18 @@ module Deas
11
11
  assert_kind_of RuntimeError, Deas::Error.new
12
12
  end
13
13
 
14
+ should "provide a no handler class exception that subclasses `Error`" do
15
+ assert Deas::NoHandlerClassError
16
+
17
+ handler_class_name = 'AHandlerClass'
18
+ e = Deas::NoHandlerClassError.new(handler_class_name)
19
+ exp_msg = "Deas couldn't find the view handler '#{handler_class_name}'" \
20
+ " - it doesn't exist or hasn't been required in yet."
21
+
22
+ assert_kind_of Deas::Error, e
23
+ assert_equal exp_msg, e.message
24
+ end
25
+
14
26
  should "provide a server exception that subclasses `Error`" do
15
27
  assert Deas::ServerError
16
28
  assert_kind_of Deas::Error, Deas::ServerError.new
@@ -1,51 +1,73 @@
1
1
  require 'assert'
2
- require 'deas/redirect_handler'
3
2
  require 'deas/test_helpers'
3
+ require 'deas/redirect_proxy'
4
4
 
5
- module Deas::RedirectHandler
5
+ class Deas::RedirectProxy
6
6
 
7
7
  class BaseTests < Assert::Context
8
- desc "Deas::RedirectHandler"
8
+ desc "Deas::RedirectProxy"
9
9
  setup do
10
- @handler_class = Deas::RedirectHandler.new('/somewhere')
10
+ @proxy = Deas::RedirectProxy.new('/somewhere')
11
+ end
12
+ subject{ @proxy }
13
+
14
+ should have_readers :handler_class_name, :handler_class
15
+
16
+ should "know its handler class name" do
17
+ assert_equal subject.handler_class.name, subject.handler_class_name
18
+ end
19
+
20
+ end
21
+
22
+ class HandlerClassTests < BaseTests
23
+ desc "handler class"
24
+ setup do
25
+ @handler_class = @proxy.handler_class
11
26
  end
12
27
  subject{ @handler_class }
13
28
 
14
29
  should have_accessors :redirect_path
30
+ should have_imeth :name
15
31
 
16
- should "build a redirect handler class" do
32
+ should "be a view handler" do
17
33
  subject.included_modules.tap do |modules|
18
34
  assert_includes Deas::ViewHandler, modules
19
- assert_includes Deas::RedirectHandler::InstanceMethods, modules
20
35
  end
36
+ end
21
37
 
38
+ should "know its name" do
39
+ assert_equal 'Deas::RedirectHandler', subject.name
40
+ end
41
+
42
+ should "know its redirect path" do
22
43
  assert_instance_of Proc, subject.redirect_path
23
44
  assert_equal '/somewhere', subject.redirect_path.call
24
45
  end
25
46
 
26
- should "allow passing a block instead of a static path" do
47
+ should "allow specifying the redir path as a block" do
27
48
  path_proc = proc{ '/somewhere' }
28
49
 
29
- handler_class = Deas::RedirectHandler.new(&path_proc)
50
+ handler_class = Deas::RedirectProxy.new(&path_proc).handler_class
30
51
  assert_equal path_proc, handler_class.redirect_path
52
+ assert_equal '/somewhere', subject.redirect_path.call
31
53
  end
32
54
 
33
55
  end
34
56
 
35
- class RunTests < BaseTests
57
+ class RunTests < HandlerClassTests
36
58
  include Deas::TestHelpers
37
59
 
38
60
  desc "when run"
39
61
 
40
62
  should "redirect to the path that it was build with" do
41
- render_args = test_runner(@handler_class).run
63
+ render_args = test_runner(subject).run
42
64
  assert_equal true, render_args.redirect?
43
65
  assert_equal '/somewhere', render_args.path
44
66
  end
45
67
 
46
68
  should "redirect to the path returned from instance evaling the proc" do
47
69
  path_proc = proc{ params['redirect_to'] }
48
- handler_class = Deas::RedirectHandler.new(&path_proc)
70
+ handler_class = Deas::RedirectProxy.new(&path_proc).handler_class
49
71
 
50
72
  render_args = test_runner(handler_class, {
51
73
  :params => { 'redirect_to' => '/go_here' }
@@ -0,0 +1,34 @@
1
+ require 'assert'
2
+ require 'deas/test_helpers'
3
+ require 'test/support/view_handlers'
4
+ require 'deas/route_proxy'
5
+
6
+ class Deas::RouteProxy
7
+
8
+ class BaseTests < Assert::Context
9
+ desc "Deas::RouteProxy"
10
+ setup do
11
+ @proxy = Deas::RouteProxy.new('TestViewHandler')
12
+ end
13
+ subject{ @proxy }
14
+
15
+ should have_reader :handler_class_name
16
+ should have_imeths :handler_class
17
+
18
+ should "know its handler class name" do
19
+ assert_equal 'TestViewHandler', subject.handler_class_name
20
+ end
21
+
22
+ should "know its handler class" do
23
+ assert_equal TestViewHandler, subject.handler_class
24
+ end
25
+
26
+ should "complain if there is no handler class with the given name" do
27
+ assert_raises(Deas::NoHandlerClassError) do
28
+ Deas::RouteProxy.new('SomethingNotDefined').handler_class
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -1,42 +1,38 @@
1
1
  require 'assert'
2
- require 'deas/route'
3
- require 'deas/sinatra_runner'
4
- require 'test/support/fake_sinatra_call'
5
2
  require 'test/support/view_handlers'
3
+ require 'deas/route_proxy'
4
+ require 'deas/route'
6
5
 
7
6
  class Deas::Route
8
7
 
9
8
  class BaseTests < Assert::Context
10
9
  desc "Deas::Route"
11
10
  setup do
12
- @route = Deas::Route.new(:get, '/test', 'TestViewHandler')
11
+ @handler_proxy = Deas::RouteProxy.new('TestViewHandler')
12
+ @route = Deas::Route.new(:get, '/test', @handler_proxy)
13
13
  end
14
14
  subject{ @route }
15
15
 
16
- should have_instance_methods :method, :path, :handler_class_name,
17
- :handler_class, :run
18
-
19
- should "allow passing a constantized handler when initialized" do
20
- route = Deas::Route.new(:get, '/test', 'TestViewHandler', TestViewHandler)
16
+ should have_readers :method, :path, :handler_proxy, :handler_class
17
+ should have_imeths :validate!, :run
21
18
 
22
- # handler class is set without calling constantize
23
- assert_equal TestViewHandler, route.handler_class
19
+ should "know its method and path and handler_proxy" do
20
+ assert_equal :get, subject.method
21
+ assert_equal '/test', subject.path
22
+ assert_equal @handler_proxy, subject.handler_proxy
24
23
  end
25
24
 
26
- should "constantize the handler class with #constantize!" do
25
+ should "set its handler class on `validate!`" do
27
26
  assert_nil subject.handler_class
28
27
 
29
- assert_nothing_raised{ subject.constantize! }
30
-
28
+ assert_nothing_raised{ subject.validate! }
31
29
  assert_equal TestViewHandler, subject.handler_class
32
30
  end
33
31
 
34
- should "raise a custom exception if the handler class name " \
35
- "can't be constantized" do
36
- route = Deas::Route.new(:get, '/', 'SomethingNotDefined')
37
-
32
+ should "complain given an invalid handler class" do
33
+ proxy = Deas::RouteProxy.new('SomethingNotDefined')
38
34
  assert_raises(Deas::NoHandlerClassError) do
39
- route.constantize!
35
+ Deas::Route.new(:get, '/test', proxy).validate!
40
36
  end
41
37
  end
42
38
 
@@ -1,6 +1,6 @@
1
1
  require 'assert'
2
- require 'deas/runner'
3
2
  require 'test/support/view_handlers'
3
+ require 'deas/runner'
4
4
 
5
5
  class Deas::Runner
6
6
 
@@ -3,6 +3,7 @@ require 'set'
3
3
  require 'test/support/view_handlers'
4
4
  require 'deas/exceptions'
5
5
  require 'deas/template'
6
+ require 'deas/route_proxy'
6
7
  require 'deas/server'
7
8
 
8
9
  class Deas::Server::Configuration
@@ -89,7 +90,8 @@ class Deas::Server::Configuration
89
90
  setup do
90
91
  @initialized = false
91
92
  @other_initialized = false
92
- @route = Deas::Route.new(:get, '/something', 'TestViewHandler')
93
+ proxy = Deas::RouteProxy.new('TestViewHandler')
94
+ @route = Deas::Route.new(:get, '/something', proxy)
93
95
 
94
96
  @configuration = Deas::Server::Configuration.new.tap do |c|
95
97
  c.env = 'staging'
@@ -95,64 +95,62 @@ module Deas::Server
95
95
  assert_equal 'MyStuff', subject.configuration.view_handler_ns
96
96
 
97
97
  # should use the ns
98
- subject.route(:get, '/ns_test', 'NsTest')
99
- route = subject.configuration.routes.last
100
- assert_equal 'MyStuff::NsTest', route.handler_class_name
98
+ route = subject.route(:get, '/ns_test', 'NsTest')
99
+ assert_equal 'MyStuff::NsTest', route.handler_proxy.handler_class_name
101
100
 
102
101
  # should ignore the ns when the leading colons are present
103
- subject.route(:post, '/no_ns_test', '::NoNsTest')
104
- route = subject.configuration.routes.last
105
- assert_equal '::NoNsTest', route.handler_class_name
102
+ route = subject.route(:post, '/no_ns_test', '::NoNsTest')
103
+ assert_equal '::NoNsTest', route.handler_proxy.handler_class_name
106
104
  end
107
105
 
108
106
  should "add a GET route using #get" do
109
- subject.get('/assets', 'ListAssets')
107
+ subject.get('/things', 'ListThings')
110
108
 
111
109
  route = subject.configuration.routes[0]
112
110
  assert_instance_of Deas::Route, route
113
111
  assert_equal :get, route.method
114
- assert_equal '/assets', route.path
115
- assert_equal 'ListAssets', route.handler_class_name
112
+ assert_equal '/things', route.path
113
+ assert_equal 'ListThings', route.handler_proxy.handler_class_name
116
114
  end
117
115
 
118
116
  should "add a POST route using #post" do
119
- subject.post('/assets', 'CreateAsset')
117
+ subject.post('/things', 'CreateThing')
120
118
 
121
119
  route = subject.configuration.routes[0]
122
120
  assert_instance_of Deas::Route, route
123
121
  assert_equal :post, route.method
124
- assert_equal '/assets', route.path
125
- assert_equal 'CreateAsset', route.handler_class_name
122
+ assert_equal '/things', route.path
123
+ assert_equal 'CreateThing', route.handler_proxy.handler_class_name
126
124
  end
127
125
 
128
126
  should "add a PUT route using #put" do
129
- subject.put('/assets/:id', 'UpdateAsset')
127
+ subject.put('/things/:id', 'UpdateThing')
130
128
 
131
129
  route = subject.configuration.routes[0]
132
130
  assert_instance_of Deas::Route, route
133
131
  assert_equal :put, route.method
134
- assert_equal '/assets/:id', route.path
135
- assert_equal 'UpdateAsset', route.handler_class_name
132
+ assert_equal '/things/:id', route.path
133
+ assert_equal 'UpdateThing', route.handler_proxy.handler_class_name
136
134
  end
137
135
 
138
136
  should "add a PATCH route using #patch" do
139
- subject.patch('/assets/:id', 'UpdateAsset')
137
+ subject.patch('/things/:id', 'UpdateThing')
140
138
 
141
139
  route = subject.configuration.routes[0]
142
140
  assert_instance_of Deas::Route, route
143
141
  assert_equal :patch, route.method
144
- assert_equal '/assets/:id', route.path
145
- assert_equal 'UpdateAsset', route.handler_class_name
142
+ assert_equal '/things/:id', route.path
143
+ assert_equal 'UpdateThing', route.handler_proxy.handler_class_name
146
144
  end
147
145
 
148
146
  should "add a DELETE route using #delete" do
149
- subject.delete('/assets/:id', 'DeleteAsset')
147
+ subject.delete('/things/:id', 'DeleteThing')
150
148
 
151
149
  route = subject.configuration.routes[0]
152
150
  assert_instance_of Deas::Route, route
153
151
  assert_equal :delete, route.method
154
- assert_equal '/assets/:id', route.path
155
- assert_equal 'DeleteAsset', route.handler_class_name
152
+ assert_equal '/things/:id', route.path
153
+ assert_equal 'DeleteThing', route.handler_proxy.handler_class_name
156
154
  end
157
155
 
158
156
  should "add a redirect route using #redirect" do
@@ -162,7 +160,9 @@ module Deas::Server
162
160
  assert_instance_of Deas::Route, route
163
161
  assert_equal :get, route.method
164
162
  assert_equal '/invalid', route.path
165
- assert_equal 'Deas::RedirectHandler', route.handler_class_name
163
+ assert_equal 'Deas::RedirectHandler', route.handler_proxy.handler_class_name
164
+
165
+ route.validate!
166
166
  assert_not_nil route.handler_class
167
167
  end
168
168
 
@@ -173,7 +173,7 @@ module Deas::Server
173
173
  assert_instance_of Deas::Route, route
174
174
  assert_equal :options, route.method
175
175
  assert_equal '/get_info', route.path
176
- assert_equal 'GetInfo', route.handler_class_name
176
+ assert_equal 'GetInfo', route.handler_proxy.handler_class_name
177
177
  end
178
178
 
179
179
  end
@@ -1,16 +1,18 @@
1
1
  require 'assert'
2
+ require 'sinatra/base'
3
+ require 'test/support/view_handlers'
4
+ require 'deas/route_proxy'
2
5
  require 'deas/route'
3
6
  require 'deas/server'
4
7
  require 'deas/sinatra_app'
5
- require 'sinatra/base'
6
- require 'test/support/view_handlers'
7
8
 
8
9
  module Deas::SinatraApp
9
10
 
10
11
  class BaseTests < Assert::Context
11
12
  desc "Deas::SinatraApp"
12
13
  setup do
13
- @route = Deas::Route.new(:get, '/something', 'TestViewHandler')
14
+ proxy = Deas::RouteProxy.new('TestViewHandler')
15
+ @route = Deas::Route.new(:get, '/something', proxy)
14
16
  @configuration = Deas::Server::Configuration.new.tap do |c|
15
17
  c.env = 'staging'
16
18
  c.root = 'path/to/somewhere'
@@ -1,8 +1,8 @@
1
1
  require 'assert'
2
- require 'deas/sinatra_runner'
3
- require 'deas/template'
4
2
  require 'test/support/fake_sinatra_call'
5
3
  require 'test/support/view_handlers'
4
+ require 'deas/template'
5
+ require 'deas/sinatra_runner'
6
6
 
7
7
  class Deas::SinatraRunner
8
8
 
@@ -1,6 +1,6 @@
1
1
  require 'assert'
2
- require 'deas/template'
3
2
  require 'test/support/fake_sinatra_call'
3
+ require 'deas/template'
4
4
 
5
5
  class Deas::Template
6
6
 
@@ -1,7 +1,7 @@
1
1
  require 'assert'
2
+ require 'test/support/view_handlers'
2
3
  require 'deas/test_helpers'
3
4
  require 'deas/view_handler'
4
- require 'test/support/view_handlers'
5
5
 
6
6
  module Deas::ViewHandler
7
7
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deas
3
3
  version: !ruby/object:Gem::Version
4
- hash: 91
4
+ hash: 89
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 17
9
- - 0
10
- version: 0.17.0
9
+ - 1
10
+ version: 0.17.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-06-12 00:00:00 Z
19
+ date: 2013-06-19 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: ns-options
@@ -150,8 +150,9 @@ files:
150
150
  - lib/deas/logging.rb
151
151
  - lib/deas/plugin.rb
152
152
  - lib/deas/rack_request_fix.rb
153
- - lib/deas/redirect_handler.rb
153
+ - lib/deas/redirect_proxy.rb
154
154
  - lib/deas/route.rb
155
+ - lib/deas/route_proxy.rb
155
156
  - lib/deas/runner.rb
156
157
  - lib/deas/server.rb
157
158
  - lib/deas/show_exceptions.rb
@@ -186,7 +187,8 @@ files:
186
187
  - test/unit/exceptions_tests.rb
187
188
  - test/unit/logging_tests.rb
188
189
  - test/unit/plugin_tests.rb
189
- - test/unit/redirect_handler_tests.rb
190
+ - test/unit/redirect_proxy_tests.rb
191
+ - test/unit/route_proxy_tests.rb
190
192
  - test/unit/route_tests.rb
191
193
  - test/unit/runner_tests.rb
192
194
  - test/unit/server_configuration_tests.rb
@@ -254,7 +256,8 @@ test_files:
254
256
  - test/unit/exceptions_tests.rb
255
257
  - test/unit/logging_tests.rb
256
258
  - test/unit/plugin_tests.rb
257
- - test/unit/redirect_handler_tests.rb
259
+ - test/unit/redirect_proxy_tests.rb
260
+ - test/unit/route_proxy_tests.rb
258
261
  - test/unit/route_tests.rb
259
262
  - test/unit/runner_tests.rb
260
263
  - test/unit/server_configuration_tests.rb
@@ -1,34 +0,0 @@
1
- require 'deas/view_handler'
2
-
3
- module Deas
4
-
5
- module RedirectHandler
6
-
7
- def self.new(path = nil, &block)
8
- handler_class = Class.new do
9
- include Deas::ViewHandler
10
- include InstanceMethods
11
- extend ClassMethods
12
- end
13
- handler_class.redirect_path = path ? proc{ path } : block
14
- handler_class
15
- end
16
-
17
- module InstanceMethods
18
-
19
- def run!
20
- path = self.instance_eval(&self.class.redirect_path)
21
- redirect path
22
- end
23
-
24
- end
25
-
26
- module ClassMethods
27
-
28
- attr_accessor :redirect_path
29
-
30
- end
31
-
32
- end
33
-
34
- end