merb-core 0.9.13 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -3
- data/lib/merb-core.rb +84 -41
- data/lib/merb-core/bootloader.rb +71 -60
- data/lib/merb-core/config.rb +31 -17
- data/lib/merb-core/controller/abstract_controller.rb +35 -35
- data/lib/merb-core/controller/exceptions.rb +14 -9
- data/lib/merb-core/controller/merb_controller.rb +22 -20
- data/lib/merb-core/controller/mime.rb +5 -5
- data/lib/merb-core/controller/mixins/authentication.rb +11 -8
- data/lib/merb-core/controller/mixins/conditional_get.rb +7 -7
- data/lib/merb-core/controller/mixins/controller.rb +15 -15
- data/lib/merb-core/controller/mixins/render.rb +16 -16
- data/lib/merb-core/controller/mixins/responder.rb +23 -23
- data/lib/merb-core/controller/template.rb +17 -17
- data/lib/merb-core/core_ext/hash.rb +2 -2
- data/lib/merb-core/core_ext/kernel.rb +19 -18
- data/lib/merb-core/dispatch/cookies.rb +13 -0
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +12 -1
- data/lib/merb-core/dispatch/dispatcher.rb +6 -5
- data/lib/merb-core/dispatch/request.rb +56 -52
- data/lib/merb-core/dispatch/request_parsers.rb +7 -7
- data/lib/merb-core/dispatch/router.rb +14 -14
- data/lib/merb-core/dispatch/router/behavior.rb +31 -31
- data/lib/merb-core/dispatch/router/cached_proc.rb +13 -1
- data/lib/merb-core/dispatch/router/resources.rb +9 -9
- data/lib/merb-core/dispatch/router/route.rb +60 -7
- data/lib/merb-core/dispatch/session.rb +21 -15
- data/lib/merb-core/dispatch/session/container.rb +10 -8
- data/lib/merb-core/dispatch/session/cookie.rb +12 -11
- data/lib/merb-core/dispatch/session/memcached.rb +4 -2
- data/lib/merb-core/dispatch/session/memory.rb +8 -6
- data/lib/merb-core/dispatch/session/store_container.rb +6 -5
- data/lib/merb-core/dispatch/worker.rb +28 -10
- data/lib/merb-core/gem_ext/erubis.rb +4 -2
- data/lib/merb-core/logger.rb +3 -22
- data/lib/merb-core/plugins.rb +5 -5
- data/lib/merb-core/rack.rb +1 -1
- data/lib/merb-core/rack/adapter.rb +5 -1
- data/lib/merb-core/rack/adapter/abstract.rb +15 -10
- data/lib/merb-core/rack/adapter/ebb.rb +4 -2
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -1
- data/lib/merb-core/rack/adapter/fcgi.rb +3 -1
- data/lib/merb-core/rack/adapter/irb.rb +10 -1
- data/lib/merb-core/rack/adapter/mongrel.rb +5 -2
- data/lib/merb-core/rack/adapter/runner.rb +3 -1
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +2 -1
- data/lib/merb-core/rack/adapter/thin.rb +4 -1
- data/lib/merb-core/rack/adapter/thin_turbo.rb +1 -0
- data/lib/merb-core/rack/adapter/webrick.rb +8 -34
- data/lib/merb-core/rack/application.rb +2 -2
- data/lib/merb-core/rack/handler/mongrel.rb +7 -0
- data/lib/merb-core/rack/helpers.rb +1 -1
- data/lib/merb-core/rack/middleware.rb +7 -1
- data/lib/merb-core/rack/middleware/conditional_get.rb +3 -0
- data/lib/merb-core/rack/middleware/content_length.rb +2 -0
- data/lib/merb-core/rack/middleware/path_prefix.rb +4 -0
- data/lib/merb-core/rack/middleware/profiler.rb +3 -1
- data/lib/merb-core/rack/middleware/static.rb +7 -1
- data/lib/merb-core/rack/middleware/tracer.rb +1 -0
- data/lib/merb-core/rack/stream_wrapper.rb +35 -30
- data/lib/merb-core/server.rb +17 -16
- data/lib/merb-core/tasks/gem_management.rb +1 -1
- data/lib/merb-core/tasks/merb.rb +3 -1
- data/lib/merb-core/tasks/merb_rake_helper.rb +1 -1
- data/lib/merb-core/test.rb +8 -8
- data/lib/merb-core/test/helpers.rb +1 -1
- data/lib/merb-core/test/helpers/cookie_jar.rb +16 -2
- data/lib/merb-core/test/helpers/mock_request_helper.rb +13 -13
- data/lib/merb-core/test/helpers/request_helper.rb +1 -1
- data/lib/merb-core/test/helpers/route_helper.rb +2 -2
- data/lib/merb-core/test/matchers.rb +3 -3
- data/lib/merb-core/test/matchers/request_matchers.rb +1 -1
- data/lib/merb-core/test/run_spec.rb +1 -1
- data/lib/merb-core/test/tasks/spectasks.rb +1 -1
- data/lib/merb-core/test/test_ext/hpricot.rb +1 -1
- data/lib/merb-core/test/test_ext/rspec.rb +2 -2
- data/lib/merb-core/test/test_ext/string.rb +1 -1
- data/lib/merb-core/version.rb +1 -1
- metadata +8 -22
- data/lib/merb-core/test/matchers/view_matchers.rb +0 -231
- data/lib/merb-core/test/webrat.rb +0 -37
- data/lib/merb-core/vendor/nokogiri/css.rb +0 -6
- data/lib/merb-core/vendor/nokogiri/css/generated_parser.rb +0 -653
- data/lib/merb-core/vendor/nokogiri/css/generated_tokenizer.rb +0 -159
- data/lib/merb-core/vendor/nokogiri/css/node.rb +0 -95
- data/lib/merb-core/vendor/nokogiri/css/parser.rb +0 -24
- data/lib/merb-core/vendor/nokogiri/css/parser.y +0 -198
- data/lib/merb-core/vendor/nokogiri/css/tokenizer.rb +0 -9
- data/lib/merb-core/vendor/nokogiri/css/tokenizer.rex +0 -63
- data/lib/merb-core/vendor/nokogiri/css/xpath_visitor.rb +0 -159
@@ -13,7 +13,7 @@ module Merb
|
|
13
13
|
# Merb::Parse.query("bar=nik&post[body]=heya")
|
14
14
|
# # => { :bar => "nik", :post => { :body => "heya" } }
|
15
15
|
#
|
16
|
-
#
|
16
|
+
# :api: plugin
|
17
17
|
def self.query(query_string, delimiter = '&;', preserve_order = false)
|
18
18
|
query = preserve_order ? Dictionary.new : {}
|
19
19
|
for pair in (query_string || '').split(/[#{delimiter}] */n)
|
@@ -45,7 +45,7 @@ module Merb
|
|
45
45
|
# ==== Returns
|
46
46
|
# Hash:: The parsed request.
|
47
47
|
#
|
48
|
-
#
|
48
|
+
# :api: plugin
|
49
49
|
def self.multipart(request, boundary, content_length)
|
50
50
|
boundary = "--#{boundary}"
|
51
51
|
paramhsh = {}
|
@@ -152,7 +152,7 @@ module Merb
|
|
152
152
|
# params_to_query_string([ "ice-cream", "cake" ], "shopping_list")
|
153
153
|
# # => "shopping_list[]=ice-cream&shopping_list[]=cake"
|
154
154
|
#
|
155
|
-
#
|
155
|
+
# :api: plugin
|
156
156
|
def self.params_to_query_string(value, prefix = nil)
|
157
157
|
case value
|
158
158
|
when Array
|
@@ -174,7 +174,7 @@ module Merb
|
|
174
174
|
# ==== returns
|
175
175
|
# String:: The escaped string.
|
176
176
|
#
|
177
|
-
#
|
177
|
+
# :api: public
|
178
178
|
def self.escape(s)
|
179
179
|
s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
|
180
180
|
'%'+$1.unpack('H2'*$1.size).join('%').upcase
|
@@ -187,7 +187,7 @@ module Merb
|
|
187
187
|
# ==== returns
|
188
188
|
# String:: The unescaped string.
|
189
189
|
#
|
190
|
-
#
|
190
|
+
# :api: public
|
191
191
|
def self.unescape(s)
|
192
192
|
s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){
|
193
193
|
[$1.delete('%')].pack('H*')
|
@@ -207,7 +207,7 @@ module Merb
|
|
207
207
|
# ==== Returns
|
208
208
|
# Hash:: Normalized parameters
|
209
209
|
#
|
210
|
-
#
|
210
|
+
# :api: private
|
211
211
|
def self.normalize_params(parms, name, val=nil)
|
212
212
|
name =~ %r([\[\]]*([^\[\]]+)\]*)
|
213
213
|
key = $1 || ''
|
@@ -233,4 +233,4 @@ module Merb
|
|
233
233
|
end
|
234
234
|
|
235
235
|
end
|
236
|
-
end
|
236
|
+
end
|
@@ -38,14 +38,14 @@ module Merb
|
|
38
38
|
# An array containing all the application routes in order of
|
39
39
|
# priority.
|
40
40
|
# ---
|
41
|
-
#
|
41
|
+
# :api: private
|
42
42
|
attr_accessor :routes
|
43
43
|
|
44
44
|
# A hash containing all the named application routes. The names
|
45
45
|
# are absolute (as in, all routes named in a namespace will
|
46
46
|
# contain the name of the namespace).
|
47
47
|
# ---
|
48
|
-
#
|
48
|
+
# :api: private
|
49
49
|
attr_accessor :named_routes
|
50
50
|
|
51
51
|
# A hash of all the application resource routes. The key of the hash
|
@@ -58,7 +58,7 @@ module Merb
|
|
58
58
|
#
|
59
59
|
# The show comment route will have a key of ["User", "Comment"]
|
60
60
|
# ---
|
61
|
-
#
|
61
|
+
# :api: private
|
62
62
|
attr_accessor :resource_routes
|
63
63
|
|
64
64
|
# The starting point for route definition. Any route defined in a
|
@@ -74,13 +74,13 @@ module Merb
|
|
74
74
|
# routes are defined in order for the behavior to be applied to the
|
75
75
|
# routes.
|
76
76
|
# ---
|
77
|
-
#
|
77
|
+
# :api: plugin
|
78
78
|
attr_accessor :root_behavior
|
79
79
|
|
80
80
|
# A block that will be run around route matching. This block must yield
|
81
81
|
# in order for the actual matching to happen.
|
82
82
|
# ---
|
83
|
-
#
|
83
|
+
# :api: plugin
|
84
84
|
attr_accessor :around_match
|
85
85
|
|
86
86
|
# Creates a route building context and evaluates the block in it. A
|
@@ -99,7 +99,7 @@ module Merb
|
|
99
99
|
# Merb::Router::
|
100
100
|
# Returns self to allow chaining of methods.
|
101
101
|
# ---
|
102
|
-
#
|
102
|
+
# :api: public
|
103
103
|
def prepare(first = [], last = [], &block)
|
104
104
|
@routes = []
|
105
105
|
root_behavior._with_proxy(&block)
|
@@ -111,7 +111,7 @@ module Merb
|
|
111
111
|
# Clears the routing table. Route generation and request matching
|
112
112
|
# won't work anymore until a new routing table is built.
|
113
113
|
#
|
114
|
-
#
|
114
|
+
# :api: private
|
115
115
|
def reset!
|
116
116
|
class << self
|
117
117
|
alias_method :match, :match_before_compilation
|
@@ -131,7 +131,7 @@ module Merb
|
|
131
131
|
# Two-tuple: route index and route parameters. Route parameters
|
132
132
|
# are :controller, :action and all the named segments of the route.
|
133
133
|
#
|
134
|
-
#
|
134
|
+
# :api: private
|
135
135
|
def route_for(request)
|
136
136
|
index, params = if @around_match
|
137
137
|
send(@around_match, request) { match(request) }
|
@@ -157,7 +157,7 @@ module Merb
|
|
157
157
|
# ==== Raises
|
158
158
|
# NotCompiledError:: routes have not been compiled yet.
|
159
159
|
#
|
160
|
-
#
|
160
|
+
# :api: private
|
161
161
|
def match_before_compilation(request) #:nodoc:
|
162
162
|
raise NotCompiledError, "The routes have not been compiled yet"
|
163
163
|
end
|
@@ -217,7 +217,7 @@ module Merb
|
|
217
217
|
#
|
218
218
|
# url(:articles, 2008, 10, "test_article")
|
219
219
|
# ---
|
220
|
-
#
|
220
|
+
# :api: plugin
|
221
221
|
def url(name, *args)
|
222
222
|
if name.is_a?(Route)
|
223
223
|
route = name
|
@@ -251,7 +251,7 @@ module Merb
|
|
251
251
|
# ==== Returns
|
252
252
|
# String:: The generated URL
|
253
253
|
# ---
|
254
|
-
#
|
254
|
+
# :api: plugin
|
255
255
|
def resource(*args)
|
256
256
|
defaults = args.pop
|
257
257
|
options = extract_options_from_args!(args) || {}
|
@@ -306,7 +306,7 @@ module Merb
|
|
306
306
|
# end
|
307
307
|
# end
|
308
308
|
# ---
|
309
|
-
#
|
309
|
+
# :api: public
|
310
310
|
def extensions(&block)
|
311
311
|
Router::Behavior.class_eval(&block)
|
312
312
|
end
|
@@ -315,7 +315,7 @@ module Merb
|
|
315
315
|
|
316
316
|
# Compiles the routes and creates the +match+ method.
|
317
317
|
# ---
|
318
|
-
#
|
318
|
+
# :api: private
|
319
319
|
def compile
|
320
320
|
if routes.any?
|
321
321
|
eval(compiled_statement, binding, "Generated Code for Router", 1)
|
@@ -327,7 +327,7 @@ module Merb
|
|
327
327
|
# Generates the method for evaluation defining a +match+ method to match
|
328
328
|
# a request with the defined routes.
|
329
329
|
# ---
|
330
|
-
#
|
330
|
+
# :api: private
|
331
331
|
def compiled_statement
|
332
332
|
@compiler_mutex.synchronize do
|
333
333
|
condition_keys, if_statements = Set.new, ""
|
@@ -10,14 +10,14 @@ module Merb
|
|
10
10
|
# This allows building routes without constantly having to catching the
|
11
11
|
# yielded behavior object
|
12
12
|
#
|
13
|
-
#
|
13
|
+
# :api: private
|
14
14
|
class Proxy
|
15
15
|
|
16
16
|
# Undefine as many methods as possible so that everything can be proxied
|
17
17
|
# along to the behavior
|
18
18
|
instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get instance_eval].include?(m) }
|
19
19
|
|
20
|
-
#
|
20
|
+
# :api: private
|
21
21
|
def initialize
|
22
22
|
@behaviors = []
|
23
23
|
end
|
@@ -27,7 +27,7 @@ module Merb
|
|
27
27
|
# ==== Notes
|
28
28
|
# The behaviors keep track of nested scopes.
|
29
29
|
#
|
30
|
-
#
|
30
|
+
# :api: private
|
31
31
|
def push(behavior)
|
32
32
|
@behaviors.push(behavior)
|
33
33
|
end
|
@@ -37,7 +37,7 @@ module Merb
|
|
37
37
|
# ==== Notes
|
38
38
|
# This occurs at the end of a nested scope (namespace, etc).
|
39
39
|
#
|
40
|
-
#
|
40
|
+
# :api: private
|
41
41
|
def pop
|
42
42
|
@behaviors.pop
|
43
43
|
end
|
@@ -47,7 +47,7 @@ module Merb
|
|
47
47
|
# ==== Notes
|
48
48
|
# Behaviors contain the actual functionality of the proxy.
|
49
49
|
#
|
50
|
-
#
|
50
|
+
# :api: private
|
51
51
|
def respond_to?(*args)
|
52
52
|
super || @behaviors.last.respond_to?(*args)
|
53
53
|
end
|
@@ -124,7 +124,7 @@ module Merb
|
|
124
124
|
#
|
125
125
|
# url(:articles, 2008, 10, "test_article")
|
126
126
|
#
|
127
|
-
#
|
127
|
+
# :api: public
|
128
128
|
def url(name, *args)
|
129
129
|
args << {}
|
130
130
|
Merb::Router.url(name, *args)
|
@@ -135,7 +135,7 @@ module Merb
|
|
135
135
|
# ==== Notes
|
136
136
|
# Refer to Merb::Rack::Helpers.redirect for documentation.
|
137
137
|
#
|
138
|
-
#
|
138
|
+
# :api: public
|
139
139
|
def redirect(url, opts = {})
|
140
140
|
Merb::Rack::Helpers.redirect(url, opts)
|
141
141
|
end
|
@@ -148,7 +148,7 @@ module Merb
|
|
148
148
|
# Please refer to:
|
149
149
|
# http://ruby-doc.org/core/classes/Kernel.html#M005951
|
150
150
|
#
|
151
|
-
#
|
151
|
+
# :api: private
|
152
152
|
def method_missing(method, *args, &block)
|
153
153
|
behavior = @behaviors.last
|
154
154
|
|
@@ -185,7 +185,7 @@ module Merb
|
|
185
185
|
# ==== Returns
|
186
186
|
# Behavior:: The initialized Behavior object
|
187
187
|
#
|
188
|
-
#
|
188
|
+
# :api: private
|
189
189
|
def initialize(proxy = nil, conditions = {}, params = {}, defaults = {}, identifiers = {}, options = {}, blocks = []) #:nodoc:
|
190
190
|
@proxy = proxy
|
191
191
|
@conditions = conditions
|
@@ -276,7 +276,7 @@ module Merb
|
|
276
276
|
# match("/guides/:action/:id").to(:controller => "tour_guides")
|
277
277
|
# end
|
278
278
|
#
|
279
|
-
#
|
279
|
+
# :api: public
|
280
280
|
def match(path = {}, conditions = {}, &block)
|
281
281
|
path, conditions = path[:path], path if path.is_a?(Hash)
|
282
282
|
|
@@ -313,7 +313,7 @@ module Merb
|
|
313
313
|
# match('/other').to(:action => 'other')
|
314
314
|
# end
|
315
315
|
#
|
316
|
-
#
|
316
|
+
# :api: public
|
317
317
|
def to(params = {}, &block)
|
318
318
|
raise Error, "The route has already been committed. Further params cannot be specified" if @route
|
319
319
|
|
@@ -361,7 +361,7 @@ module Merb
|
|
361
361
|
# ==== Block parameters
|
362
362
|
# r<Behavior>:: +optional+ - The defaults behavior object.
|
363
363
|
#
|
364
|
-
#
|
364
|
+
# :api: public
|
365
365
|
def default(defaults = {}, &block)
|
366
366
|
behavior = Behavior.new(@proxy, @conditions, @params, @defaults.merge(defaults), @identifiers, @options, @blocks)
|
367
367
|
with_behavior_context(behavior, &block)
|
@@ -390,7 +390,7 @@ module Merb
|
|
390
390
|
# # of nil.
|
391
391
|
# match("/users(/:group)").default(:group => "registered")
|
392
392
|
#
|
393
|
-
#
|
393
|
+
# :api: public
|
394
394
|
def options(opts = {}, &block)
|
395
395
|
options = @options.dup
|
396
396
|
|
@@ -435,7 +435,7 @@ module Merb
|
|
435
435
|
# resources :accounts
|
436
436
|
# end
|
437
437
|
#
|
438
|
-
#
|
438
|
+
# :api: public
|
439
439
|
def namespace(name_or_path, opts = {}, &block)
|
440
440
|
name = name_or_path.to_s # We don't want this modified ever
|
441
441
|
path = opts.has_key?(:path) ? opts[:path] : name
|
@@ -471,7 +471,7 @@ module Merb
|
|
471
471
|
# ==== Block parameters
|
472
472
|
# r<Behavior>:: The identify behavior object. This is optional
|
473
473
|
#
|
474
|
-
#
|
474
|
+
# :api: public
|
475
475
|
def identify(identifiers = {}, &block)
|
476
476
|
identifiers = if Hash === identifiers
|
477
477
|
@identifiers.merge(identifiers)
|
@@ -511,7 +511,7 @@ module Merb
|
|
511
511
|
# end
|
512
512
|
# end
|
513
513
|
#
|
514
|
-
#
|
514
|
+
# :api: public
|
515
515
|
def default_routes(params = {}, &block)
|
516
516
|
match("/:controller(/:action(/:id))(.:format)").to(params, &block).name(:default)
|
517
517
|
end
|
@@ -534,7 +534,7 @@ module Merb
|
|
534
534
|
# :action => 'there' if request.xhr?
|
535
535
|
# end
|
536
536
|
#
|
537
|
-
#
|
537
|
+
# :api: public
|
538
538
|
def defer_to(params = {}, &block)
|
539
539
|
defer(block).to(params)
|
540
540
|
end
|
@@ -551,7 +551,7 @@ module Merb
|
|
551
551
|
# resources :comments
|
552
552
|
# end
|
553
553
|
#
|
554
|
-
#
|
554
|
+
# :api: public
|
555
555
|
def defer(deferred_block, &block)
|
556
556
|
blocks = @blocks + [CachedProc.new(deferred_block)]
|
557
557
|
behavior = Behavior.new(@proxy, @conditions, @params, @defaults, @identifiers, @options, blocks)
|
@@ -566,7 +566,7 @@ module Merb
|
|
566
566
|
# ==== Raises
|
567
567
|
# ArgumentError:: symbol is not a Symbol.
|
568
568
|
#
|
569
|
-
#
|
569
|
+
# :api: public
|
570
570
|
def name(prefix, name = nil)
|
571
571
|
unless name
|
572
572
|
name, prefix = prefix, nil
|
@@ -584,7 +584,7 @@ module Merb
|
|
584
584
|
# ==== Raises
|
585
585
|
# ArgumentError:: symbol is not a Symbol.
|
586
586
|
#
|
587
|
-
#
|
587
|
+
# :api: private
|
588
588
|
def full_name(name)
|
589
589
|
raise Error, ":this is reserved. Please pick another name." if name == :this
|
590
590
|
|
@@ -601,7 +601,7 @@ module Merb
|
|
601
601
|
# ==== Parameters
|
602
602
|
# enabled<Boolean>:: True enables fixation on the route.
|
603
603
|
#
|
604
|
-
#
|
604
|
+
# :api: public
|
605
605
|
def fixatable(enable = true)
|
606
606
|
@route.fixation = enable
|
607
607
|
self
|
@@ -620,7 +620,7 @@ module Merb
|
|
620
620
|
# Whether or not the redirect should be permanent.
|
621
621
|
# The default value is false.
|
622
622
|
#
|
623
|
-
#
|
623
|
+
# :api: public
|
624
624
|
def redirect(url, opts = {})
|
625
625
|
raise Error, "The route has already been committed." if @route
|
626
626
|
|
@@ -637,7 +637,7 @@ module Merb
|
|
637
637
|
#
|
638
638
|
# &block:: A context in which routes are generated.
|
639
639
|
#
|
640
|
-
#
|
640
|
+
# :api: public
|
641
641
|
def capture(&block)
|
642
642
|
captured_routes = {}
|
643
643
|
name_prefix = [@options[:name_prefix]].flatten.compact.map { |p| "#{p}_"}
|
@@ -659,7 +659,7 @@ module Merb
|
|
659
659
|
# ==== Parameters
|
660
660
|
# &block:: defines routes within the provided context.
|
661
661
|
#
|
662
|
-
#
|
662
|
+
# :api: private
|
663
663
|
def _with_proxy(&block)
|
664
664
|
proxy = Proxy.new
|
665
665
|
proxy.push Behavior.new(proxy, @conditions, @params, @defaults, @identifiers, @options, @blocks)
|
@@ -674,7 +674,7 @@ module Merb
|
|
674
674
|
# ==== Returns
|
675
675
|
# Route:: the route.
|
676
676
|
#
|
677
|
-
#
|
677
|
+
# :api: private
|
678
678
|
def _route
|
679
679
|
@route
|
680
680
|
end
|
@@ -684,7 +684,7 @@ module Merb
|
|
684
684
|
# ==== Returns
|
685
685
|
# Route:: the route generated.
|
686
686
|
#
|
687
|
-
#
|
687
|
+
# :api: private
|
688
688
|
def to_route
|
689
689
|
raise Error, "The route has already been committed." if @route
|
690
690
|
|
@@ -723,7 +723,7 @@ module Merb
|
|
723
723
|
# route<Route>:: the route to insert before.
|
724
724
|
# &block:: the route definition to insert.
|
725
725
|
#
|
726
|
-
#
|
726
|
+
# :api: plugin
|
727
727
|
def before(route, &block)
|
728
728
|
options(:before => route, &block)
|
729
729
|
end
|
@@ -733,7 +733,7 @@ module Merb
|
|
733
733
|
# Takes @conditions and turns values into strings (except for Regexp and
|
734
734
|
# Array values).
|
735
735
|
#
|
736
|
-
#
|
736
|
+
# :api: private
|
737
737
|
def stringify_condition_values # :nodoc:
|
738
738
|
@conditions.each do |key, value|
|
739
739
|
unless value.nil? || Regexp === value || Array === value
|
@@ -752,7 +752,7 @@ module Merb
|
|
752
752
|
# ==== Returns
|
753
753
|
# Behavior:: the behavior wrapping.
|
754
754
|
#
|
755
|
-
#
|
755
|
+
# :api: private
|
756
756
|
def with_behavior_context(behavior, &block) # :nodoc:
|
757
757
|
if block_given?
|
758
758
|
@proxy.push(behavior)
|
@@ -775,11 +775,11 @@ module Merb
|
|
775
775
|
# An array of ['a', 'b'] (the 'a' namespace with the 'b' action) will
|
776
776
|
# produce a name of :a_b.
|
777
777
|
#
|
778
|
-
#
|
778
|
+
# :api: private
|
779
779
|
def merge_paths(path) # :nodoc:
|
780
780
|
[@conditions[:path], path.freeze].flatten.compact
|
781
781
|
end
|
782
782
|
|
783
783
|
end
|
784
784
|
end
|
785
|
-
end
|
785
|
+
end
|
@@ -2,20 +2,26 @@ module Merb
|
|
2
2
|
|
3
3
|
class Router
|
4
4
|
# Cache procs for future reference in eval statement
|
5
|
+
# :api: private
|
5
6
|
class CachedProc
|
6
7
|
@@index = 0
|
7
8
|
@@list = []
|
8
9
|
|
10
|
+
# :api: private
|
9
11
|
attr_accessor :cache, :index
|
10
12
|
|
11
13
|
# ==== Parameters
|
12
14
|
# cache<Proc>:: The block of code to cache.
|
15
|
+
#
|
16
|
+
# :api: private
|
13
17
|
def initialize(cache)
|
14
18
|
@cache, @index = cache, CachedProc.register(self)
|
15
19
|
end
|
16
20
|
|
17
21
|
# ==== Returns
|
18
22
|
# String:: The CachedProc object in a format embeddable within a string.
|
23
|
+
#
|
24
|
+
# :api: private
|
19
25
|
def to_s
|
20
26
|
"CachedProc[#{@index}].cache"
|
21
27
|
end
|
@@ -27,6 +33,8 @@ module Merb
|
|
27
33
|
#
|
28
34
|
# ==== Returns
|
29
35
|
# Fixnum:: The index of the newly registered CachedProc.
|
36
|
+
#
|
37
|
+
# :api: private
|
30
38
|
def register(cached_code)
|
31
39
|
CachedProc[@@index] = cached_code
|
32
40
|
@@index += 1
|
@@ -38,6 +46,8 @@ module Merb
|
|
38
46
|
# ==== Parameters
|
39
47
|
# index<Fixnum>:: The index of the cached code to set.
|
40
48
|
# code<CachedProc>:: The cached code to set.
|
49
|
+
#
|
50
|
+
# :api: private
|
41
51
|
def []=(index, code) @@list[index] = code end
|
42
52
|
|
43
53
|
# ==== Parameters
|
@@ -45,8 +55,10 @@ module Merb
|
|
45
55
|
#
|
46
56
|
# ==== Returns
|
47
57
|
# CachedProc:: The cached code at index.
|
58
|
+
#
|
59
|
+
# :api: private
|
48
60
|
def [](index) @@list[index] end
|
49
61
|
end
|
50
62
|
end # CachedProc
|
51
63
|
end
|
52
|
-
end
|
64
|
+
end
|