Skip to content

Commit

Permalink
Add capture for RackConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksieger committed Feb 10, 2011
1 parent 75ce7b9 commit cb7aed1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/sinatra/lib/demo.rb
Expand Up @@ -4,6 +4,7 @@
include JRuby::Rack::Capture::Base
include JRuby::Rack::Capture::RubyGems
include JRuby::Rack::Capture::Bundler
include JRuby::Rack::Capture::JRubyRackConfig
include JRuby::Rack::Capture::Environment
include JRuby::Rack::Capture::JavaEnvironment
include JRuby::Rack::Capture::LoadPath
Expand Down
15 changes: 15 additions & 0 deletions src/main/ruby/jruby/rack/capture.rb
Expand Up @@ -64,6 +64,21 @@ def capture
end
end

module JRubyRackConfig
def capture
super
methods = $servlet_context.config.class.instance_methods(false) +
org.jruby.rack.DefaultRackConfig.instance_methods(false)
methods = methods.uniq.reject do |m|
m =~ /^(get|is|set)/ || m =~ /[A-Z]|create|quiet|([!?=]$)/
end
output.puts("\n--- JRuby-Rack Config",
*(methods.sort.map do |m|
"#{m} = #{$servlet_context.config.send(m)}" rescue "#{m} = <error: #{$?}>"
end))
end
end

module Environment
def capture
super
Expand Down
1 change: 1 addition & 0 deletions src/main/ruby/jruby/rack/core_ext.rb
Expand Up @@ -12,6 +12,7 @@ class StandardError
include JRuby::Rack::Capture::Exception
include JRuby::Rack::Capture::RubyGems
include JRuby::Rack::Capture::Bundler
include JRuby::Rack::Capture::JRubyRackConfig
end

class LoadError
Expand Down

0 comments on commit cb7aed1

Please sign in to comment.