Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 137 lines (121 sloc) 4.518 kb
fef31be @jeremy Add missing deprecation requires
jeremy authored
1 require 'active_support/deprecation'
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored
2 require 'active_support/core_ext/string/encoding'
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
3 require 'rails/engine/configuration'
4
5 module Rails
6 class Application
7 class Configuration < ::Rails::Engine::Configuration
8 include ::Rails::Configuration::Deprecated
9
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
10 attr_accessor :allow_concurrency, :cache_classes, :cache_store,
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
11 :encoding, :consider_all_requests_local, :dependency_loading,
ad6be08 @drogus Made Engine valid rack app with its own middleware stack
drogus authored
12 :filter_parameters, :log_level, :logger,
9b19a6f @josevalim A few changes were done in this commit:
josevalim authored
13 :plugins, :preload_frameworks, :reload_plugins,
25f7c03 @josevalim Simplify cookie_store by simply relying on cookies.signed.
josevalim authored
14 :secret_token, :serve_static_assets, :session_options,
15 :time_zone, :whiny_nils
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
16
17 def initialize(*)
18 super
aaec007 @wycats Make sure apps upgrading from 2.3 get defaulted to UTF-8 (ht: parndt)
wycats authored
19 self.encoding = "utf-8"
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
20 @allow_concurrency = false
21 @consider_all_requests_local = false
22 @filter_parameters = []
23 @dependency_loading = true
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
24 @serve_static_assets = true
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored
25 @session_store = :cookie_store
26 @session_options = {}
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
27 @time_zone = "UTC"
19d8c8c @josevalim Remove the laziness from the middleware stack.
josevalim authored
28 @middleware = app_middleware
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
29 end
30
31 def encoding=(value)
32 @encoding = value
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored
33 if "ruby".encoding_aware?
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
34 Encoding.default_external = value
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored
35 Encoding.default_internal = value
36 else
37 $KCODE = value
38 if $KCODE == "NONE"
39 raise "The value you specified for config.encoding is " \
40 "invalid. The possible values are UTF8, SJIS, or EUC"
41 end
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
42 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
43 end
44
45 def paths
46 @paths ||= begin
47 paths = super
48 paths.app.controllers << builtin_controller if builtin_controller
1b816d5 @josevalim The rake task :environment now loads config/environment.rb instead of…
josevalim authored
49 paths.config.database "config/database.yml"
50 paths.config.environment "config/environment.rb"
51 paths.config.environments "config/environments", :glob => "#{Rails.env}.rb"
52 paths.lib.templates "lib/templates"
53 paths.log "log/#{Rails.env}.log"
54 paths.tmp "tmp"
55 paths.tmp.cache "tmp/cache"
56 paths.vendor "vendor", :load_path => true
57 paths.vendor.plugins "vendor/plugins"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
58
59 if File.exists?("#{root}/test/mocks/#{Rails.env}")
84e4643 @anildigital Replace 'RAILS_ROOT' to 'Rails.root' and 'RAILS_ENV' to 'Rails.env' i…
anildigital authored
60 ActiveSupport::Deprecation.warn "\"Rails.root/test/mocks/#{Rails.env}\" won't be added " <<
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
61 "automatically to load paths anymore in future releases"
9b19a6f @josevalim A few changes were done in this commit:
josevalim authored
62 paths.mocks_path "test/mocks", :autoload => true, :glob => Rails.env
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
63 end
64
65 paths
66 end
67 end
68
69 # Enable threaded mode. Allows concurrent requests to controller actions and
70 # multiple database connections. Also disables automatic dependency loading
71 # after boot, and disables reloading code on every request, as these are
72 # fundamentally incompatible with thread safety.
73 def threadsafe!
74 self.preload_frameworks = true
75 self.cache_classes = true
76 self.dependency_loading = false
0dece79 @josevalim Deprecate AC configuration values which were moved to Rack.
josevalim authored
77 self.allow_concurrency = true
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
78 self
79 end
80
81 # Loads and returns the contents of the #database_configuration_file. The
82 # contents of the file are processed via ERB before being sent through
83 # YAML::load.
84 def database_configuration
85 require 'erb'
86 YAML::load(ERB.new(IO.read(paths.config.database.to_a.first)).result)
87 end
88
89 def cache_store
90 @cache_store ||= begin
91 if File.exist?("#{root}/tmp/cache/")
92 [ :file_store, "#{root}/tmp/cache/" ]
93 else
94 :memory_store
95 end
96 end
97 end
98
99 def builtin_controller
f38e89c @josh Move railties/builtin into lib
josh authored
100 File.expand_path('../info_routes', __FILE__) if Rails.env.development?
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
101 end
102
103 def log_level
104 @log_level ||= Rails.env.production? ? :info : :debug
105 end
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
106
107 def colorize_logging
108 @colorize_logging
109 end
110
111 def colorize_logging=(val)
112 @colorize_logging = val
6788db8 @josevalim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing f…
josevalim authored
113 ActiveSupport::LogSubscriber.colorize_logging = val
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
114 self.generators.colorize_logging = val
115 end
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored
116
117 def session_store(*args)
118 if args.empty?
119 case @session_store
120 when :disabled
121 nil
122 when :active_record_store
123 ActiveRecord::SessionStore
124 when Symbol
125 ActionDispatch::Session.const_get(@session_store.to_s.camelize)
126 else
127 @session_store
128 end
129 else
130 @session_store = args.shift
131 @session_options = args.shift || {}
132 end
133 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
134 end
135 end
f38e89c @josh Move railties/builtin into lib
josh authored
136 end
Something went wrong with that request. Please try again.