about summary refs log tree commit homepage
path: root/lib/yahns/config.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/yahns/config.rb')
-rw-r--r--lib/yahns/config.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/yahns/config.rb b/lib/yahns/config.rb
index 1862eee..4ea51af 100644
--- a/lib/yahns/config.rb
+++ b/lib/yahns/config.rb
@@ -334,9 +334,7 @@ class Yahns::Config # :nodoc:
   end
 
   # boolean config directives for app
-  %w(check_client_connection
-     output_buffering
-     persistent_connections).each do |_v|
+  %w(check_client_connection persistent_connections).each do |_v|
     eval(
     %Q(def #{_v}(bool);) <<
     %Q(  _check_in_block(:app, :#{_v});) <<
@@ -345,6 +343,21 @@ class Yahns::Config # :nodoc:
     )
   end
 
+  def output_buffering(bool, opts = {})
+    var = _check_in_block(:app, :output_buffering)
+    @block.ctx.__send__("#{var}=", _check_bool(var, bool))
+    tmpdir = opts[:tmpdir] and
+      @block.ctx.output_buffer_tmpdir = _check_tmpdir(var, tmpdir)
+  end
+
+  def _check_tmpdir(var, path)
+    File.directory?(path) or
+      raise ArgumentError, "#{var} tmpdir: #{path} is not a directory"
+    File.writable?(path) or
+      raise ArgumentError, "#{var} tmpdir: #{path} is not writable"
+    path
+  end
+
   # integer config directives for app
   {
     # config name, minimum value
@@ -371,12 +384,14 @@ class Yahns::Config # :nodoc:
     @block.ctx.__send__("#{var}=", val)
   end
 
-  def input_buffering(val)
+  def input_buffering(val, opts = {})
     var = _check_in_block(:app, :input_buffering)
     ok = [ :lazy, true, false ]
     ok.include?(val) or
       raise ArgumentError, "`#{var}' must be one of: #{ok.inspect}"
     @block.ctx.__send__("#{var}=", val)
+    tmpdir = opts[:tmpdir] and
+      @block.ctx.input_buffer_tmpdir = _check_tmpdir(var, tmpdir)
   end
 
   # used to configure rack.errors destination