summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2016-05-25 14:56:20 +0200
committerAzul <azul@riseup.net>2016-05-25 14:56:20 +0200
commit9598e42722c13030b757b7b4ab47de0d50228d5c (patch)
tree57e92123d84c8edfd9ab09fad2359bbbacb1e572 /lib
parentc90b23b4b4a4f550d6e2f0ce6dc0cc2b6fc1a2d5 (diff)
silence some warnings from evma_httpserver
Diffstat (limited to 'lib')
-rw-r--r--lib/kernel_ext.rb28
-rw-r--r--lib/nickserver/server.rb5
2 files changed, 32 insertions, 1 deletions
diff --git a/lib/kernel_ext.rb b/lib/kernel_ext.rb
new file mode 100644
index 0000000..b5b58e0
--- /dev/null
+++ b/lib/kernel_ext.rb
@@ -0,0 +1,28 @@
+module Kernel
+ # Sets $VERBOSE to nil for the duration of the block and back to its original
+ # value afterwards.
+ #
+ # silence_warnings do
+ # value = noisy_call # no warning voiced
+ # end
+ #
+ # noisy_call # warning voiced
+ def silence_warnings
+ with_warnings(nil) { yield }
+ end
+
+ # Sets $VERBOSE to +true+ for the duration of the block and back to its
+ # original value afterwards.
+ def enable_warnings
+ with_warnings(true) { yield }
+ end
+
+ # Sets $VERBOSE for the duration of the block and back to its original
+ # value afterwards.
+ def with_warnings(flag)
+ old_verbose, $VERBOSE = $VERBOSE, flag
+ yield
+ ensure
+ $VERBOSE = old_verbose
+ end
+end
diff --git a/lib/nickserver/server.rb b/lib/nickserver/server.rb
index 8329406..2db2942 100644
--- a/lib/nickserver/server.rb
+++ b/lib/nickserver/server.rb
@@ -1,3 +1,4 @@
+require 'kernel_ext'
require 'eventmachine'
require 'evma_httpserver'
require 'json'
@@ -64,7 +65,9 @@ module Nickserver
response.status = options[:status]
response.content_type options[:content_type]
response.content = options[:content]
- response.send_response
+ silence_warnings do
+ response.send_response
+ end
end
def send_key(uid)