Permalink
Browse files

add Rack::Printout and myself as author

  • Loading branch information...
1 parent 759ab41 commit d5184f79962ccf71be66c33196aee1eaaa2ea89a @JordiPolo JordiPolo committed Mar 5, 2011
Showing with 28 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +1 −0 README.rdoc
  3. +1 −0 lib/rack/contrib.rb
  4. +25 −0 lib/rack/contrib/printout.rb
View
@@ -24,3 +24,4 @@ TJ Holowaychuk <tj@vision-media.ca>
anupom syam <anupom.syam@gmail.com>
ichverstehe <ichverstehe@gmail.com>
kubicek <jiri@kubicek.cz>
+Jordi Polo <mumismo@gmail.com>
View
@@ -48,6 +48,7 @@ interface:
* Rack::ResponseHeaders - Manipulates response headers object at runtime
* Rack::SimpleEndpoint - Creates simple endpoints with routing rules, similar to Sinatra actions
* Rack::TryStatic - Tries to match request to a static file
+* Rack::Printout - Prints the environment and the response per request
=== Use
View
@@ -37,4 +37,5 @@ def self.release
autoload :RelativeRedirect, "rack/contrib/relative_redirect"
autoload :StaticCache, "rack/contrib/static_cache"
autoload :TryStatic, "rack/contrib/try_static"
+ autoload :Printout, "rack/contrib/printout"
end
@@ -0,0 +1,25 @@
+module Rack
+ #prints the environment and request for simple debugging
+ class Printout
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ # See http://rack.rubyforge.org/doc/SPEC.html for details
+ puts "**********\n Environment\n **************"
+ puts env.inspect
+
+ puts "**********\n Response\n **************"
+ response = @app.call(env)
+ puts response.inspect
+
+ puts "**********\n Response contents\n **************"
+ response[2].each do |chunk|
+ puts chunk
+ end
+ puts "\n \n"
+ return response
+ end
+ end
+end

0 comments on commit d5184f7

Please sign in to comment.