Skip to content

Commit f6bcbe9

Browse files
committed
drop rails 3.x specific feature detection in railtie
1 parent 784755f commit f6bcbe9

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/main/ruby/jruby/rack/rails/railtie.rb

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,30 @@ module JRuby::Rack
1414
class Railtie < ::Rails::Railtie
1515

1616
config.before_configuration do |app|
17-
paths = app.config.paths; public = JRuby::Rack.public_path
18-
if paths.respond_to?(:'[]') && paths.respond_to?(:keys)
19-
# Rails 3.1/3.2/4.x: paths["app/controllers"] style
17+
public = JRuby::Rack.public_path
18+
if public # nil if /public does not exist
19+
paths = app.config.paths
2020
old_public = Pathname.new(paths['public'].to_a.first)
2121
javascripts = Pathname.new(paths['public/javascripts'].to_a.first)
2222
stylesheets = Pathname.new(paths['public/stylesheets'].to_a.first)
2323
paths['public'] = public.to_s; public = Pathname.new(public)
2424
paths['public/javascripts'] = public.join(javascripts.relative_path_from(old_public)).to_s
2525
paths['public/stylesheets'] = public.join(stylesheets.relative_path_from(old_public)).to_s
26-
else
27-
# Rails 3.0: old paths.app.controllers style
28-
old_public = Pathname.new(paths.public.to_a.first)
29-
javascripts = Pathname.new(paths.public.javascripts.to_a.first)
30-
stylesheets = Pathname.new(paths.public.stylesheets.to_a.first)
31-
paths.public = public.to_s; public = Pathname.new(public)
32-
paths.public.javascripts = public.join(javascripts.relative_path_from(old_public)).to_s
33-
paths.public.stylesheets = public.join(stylesheets.relative_path_from(old_public)).to_s
34-
end if public # nil if /public does not exist
26+
end
3527
end
3628

3729
# TODO prefix initializers with 'jruby_rack.' !?
3830

3931
initializer 'set_servlet_logger', :before => :initialize_logger do |app|
4032
app.config.logger ||= begin
41-
config = app.config; logger = JRuby::Rack.logger
33+
logger = JRuby::Rack.logger
34+
config = app.config
4235
log_level = config.log_level || :info
4336
logger.level = logger.class.const_get(log_level.to_s.upcase)
44-
log_formatter = config.log_formatter if config.respond_to?(:log_formatter) # >= 4.0
37+
log_formatter = config.log_formatter if config.respond_to?(:log_formatter)
4538
logger.formatter = log_formatter if log_formatter && logger.respond_to?(:formatter=)
46-
if defined?(ActiveSupport::TaggedLogging)
47-
if ActiveSupport::TaggedLogging.is_a?(Class) # Rails 3.2
48-
logger = ActiveSupport::TaggedLogging.new(logger)
49-
else # Rails 4.0
50-
# extends the logger as well as it's logger.formatter instance :
51-
# NOTE: good idea to keep or should we use a clone as Rails.logger ?
52-
#dup_logger = logger.dup
53-
#dup_logger.formatter = logger.formatter.dup
54-
logger = ActiveSupport::TaggedLogging.new(logger)
55-
end
56-
end
57-
logger
39+
require 'active_support/tagged_logging' unless defined?(ActiveSupport::TaggedLogging)
40+
ActiveSupport::TaggedLogging.new(logger) # returns a logger.clone
5841
end
5942
end
6043

0 commit comments

Comments
 (0)