Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require "rack"
  4. Rack::Server.start
  5.  
  6. require "#{File.dirname(__FILE__)}/../testrequest"
  7.  
  8. $stderr = File.open("#{File.dirname(__FILE__)}/log_output", "w")
  9.  
  10. class EnvMiddleware
  11. def initialize(app)
  12. @app = app
  13. end
  14.  
  15. def call(env)
  16. # provides a way to test that lint is present
  17. if env["PATH_INFO"] == "/broken_lint"
  18. return [200, {}, ["Broken Lint"]]
  19. # provides a way to kill the process without knowing the pid
  20. elsif env["PATH_INFO"] == "/die"
  21. exit!
  22. end
  23.  
  24. env["test.$DEBUG"] = $DEBUG
  25. env["test.$EVAL"] = BUKKIT if defined?(BUKKIT)
  26. env["test.$VERBOSE"] = $VERBOSE
  27. env["test.$LOAD_PATH"] = $LOAD_PATH
  28. env["test.stderr"] = File.expand_path($stderr.path)
  29. env["test.Ping"] = defined?(Ping)
  30. env["test.pid"] = Process.pid
  31. @app.call(env)
  32. end
  33. end
  34.  
  35. use EnvMiddleware
  36. run Rack::Server.new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement