merb-core 1.0.6.1 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -255,7 +255,7 @@ class Merb::BootLoader::DropPidFile < Merb::BootLoader
255
255
  #
256
256
  # :api: plugin
257
257
  def run
258
- Merb::Server.store_pid("main") #if Merb::Config[:daemonize] || Merb::Config[:cluster]
258
+ Merb::Server.store_pid("main") if Merb::Config[:daemonize] || Merb::Config[:cluster]
259
259
  nil
260
260
  end
261
261
  end
@@ -15,6 +15,10 @@ module Merb::RenderMixin
15
15
 
16
16
  module ClassMethods
17
17
 
18
+ def _templates_for
19
+ @_templates_for ||= {}
20
+ end
21
+
18
22
  # Return the default render options.
19
23
  #
20
24
  # ==== Returns
@@ -293,8 +297,8 @@ module Merb::RenderMixin
293
297
  template_path = File.dirname(template) / "_#{File.basename(template)}"
294
298
  else
295
299
  kontroller = (m = template.match(/.*(?=\/)/)) ? m[0] : controller_name
296
- template = "_#{File.basename(template)}"
297
300
  end
301
+ template = "_#{File.basename(template)}"
298
302
 
299
303
  # This handles no :with as well
300
304
  with = [opts.delete(:with)].flatten
@@ -408,28 +412,31 @@ module Merb::RenderMixin
408
412
  #
409
413
  # :api: private
410
414
  def _template_for(context, content_type, controller=nil, template=nil, locals=[])
411
- template_method, template_location = nil, nil
412
-
413
- # absolute path to a template (:template => "/foo/bar")
414
- if template.is_a?(String) && template =~ %r{^/}
415
- template_location = self._absolute_template_location(template, content_type)
416
- return [_template_method_for(template_location, locals), template_location]
417
- end
415
+ self.class._templates_for[[context, content_type, controller, template, locals]] ||= begin
416
+
417
+ template_method, template_location = nil, nil
418
418
 
419
- self.class._template_roots.reverse_each do |root, template_meth|
420
- # :template => "foo/bar.html" where root / "foo/bar.html.*" exists
421
- if template
422
- template_location = root / self.send(template_meth, template, content_type, nil)
423
- # :layout => "foo" where root / "layouts" / "#{controller}.html.*" exists
424
- else
425
- template_location = root / self.send(template_meth, context, content_type, controller)
419
+ # absolute path to a template (:template => "/foo/bar")
420
+ if template.is_a?(String) && template =~ %r{^/}
421
+ template_location = self._absolute_template_location(template, content_type)
422
+ return [_template_method_for(template_location, locals), template_location]
426
423
  end
424
+
425
+ self.class._template_roots.reverse_each do |root, template_meth|
426
+ # :template => "foo/bar.html" where root / "foo/bar.html.*" exists
427
+ if template
428
+ template_location = root / self.send(template_meth, template, content_type, nil)
429
+ # :layout => "foo" where root / "layouts" / "#{controller}.html.*" exists
430
+ else
431
+ template_location = root / self.send(template_meth, context, content_type, controller)
432
+ end
427
433
 
428
- break if template_method = _template_method_for(template_location.to_s, locals)
429
- end
434
+ break if template_method = _template_method_for(template_location.to_s, locals)
435
+ end
430
436
 
431
- # template_location is a Pathname
432
- [template_method, template_location.to_s]
437
+ # template_location is a Pathname
438
+ [template_method, template_location.to_s]
439
+ end
433
440
  end
434
441
 
435
442
  # Return the template method for a location, and check to make sure the current controller
@@ -528,6 +528,15 @@ module Merb
528
528
  # ==== Returns
529
529
  # Route :: The default route.
530
530
  #
531
+ # ==== Note
532
+ # The block takes two parameters, request and params. The params that
533
+ # are passed into the block are *just* the placeholder params from the
534
+ # route. If you want the full parsed params, use request.params.
535
+ #
536
+ # The rationale for this is that request.params is a fairly slow
537
+ # operation, and if the full params parsing is not required, we would
538
+ # rather not do the full parsing.
539
+ #
531
540
  # ==== Examples
532
541
  # defer_to do |request, params|
533
542
  # params.merge :controller => 'here',
@@ -37,7 +37,7 @@ module Merb
37
37
  env["HTTP_COOKIE"] = @__cookie_jar__.for(jar, uri)
38
38
  end
39
39
 
40
- app = Merb::Rack::Application.new
40
+ app = Merb::Config[:app]
41
41
  rack = app.call(::Rack::MockRequest.env_for(uri.to_s, env))
42
42
 
43
43
  rack = Struct.new(:status, :headers, :body, :url, :original_env).
@@ -1,4 +1,4 @@
1
1
  module Merb
2
- VERSION = '1.0.6.1' unless defined?(Merb::VERSION)
2
+ VERSION = '1.0.7' unless defined?(Merb::VERSION)
3
3
  DM_VERSION = '0.9.8' unless defined?(Merb::DM_VERSION)
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6.1
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezra Zygmuntowicz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-16 00:00:00 -08:00
12
+ date: 2008-12-28 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency