Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 153 lines (138 sloc) 5.871 kb
3096629 @tenderlove we are *sure* we want to set the encoding, so silence warnings around it
tenderlove authored
1 require 'active_support/core_ext/kernel/reporting'
cd3033e @josevalim Add config.file_watcher so developers can provide their own watchers …
josevalim authored
2 require 'active_support/file_update_checker'
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
0f3d426 @felixbuenemann Make log autoflushing configurable
felixbuenemann authored
8 attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets, :autoflush_log,
951b582 @drogus Allow to set custom console type with Rails.application.config.console=
drogus authored
9 :cache_classes, :cache_store, :consider_all_requests_local, :console,
02127e6 @josevalim Allow a custom exceptions app to set.
josevalim authored
10 :dependency_loading, :exceptions_app, :file_watcher, :filter_parameters,
1385388 @carlosantoniodasilva Allow configuring a different queue consumer
carlosantoniodasilva authored
11 :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,
12 :preload_frameworks, :railties_order, :relative_url_root, :secret_token,
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored
13 :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
1385388 @carlosantoniodasilva Allow configuring a different queue consumer
carlosantoniodasilva authored
14 :time_zone, :reload_classes_only_on_change, :use_schema_cache_dump,
15 :queue, :queue_consumer
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
16
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
17 attr_writer :log_level
4af4312 @tenderlove only define the encoding reader since we define the writer later on
tenderlove authored
18 attr_reader :encoding
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
19
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
20 def initialize(*)
21 super
aaec007 @wycats Make sure apps upgrading from 2.3 get defaulted to UTF-8 (ht: parndt)
wycats authored
22 self.encoding = "utf-8"
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored
23 @allow_concurrency = false
24 @consider_all_requests_local = false
25 @filter_parameters = []
26 @helpers_paths = []
27 @dependency_loading = true
28 @serve_static_assets = true
29 @static_cache_control = nil
30 @force_ssl = false
31 @ssl_options = {}
32 @session_store = :cookie_store
33 @session_options = {}
34 @time_zone = "UTC"
35 @log_level = nil
36 @middleware = app_middleware
37 @generators = app_generators
38 @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
39 @railties_order = [:all]
40 @relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
41 @reload_classes_only_on_change = true
cd3033e @josevalim Add config.file_watcher so developers can provide their own watchers …
josevalim authored
42 @file_watcher = ActiveSupport::FileUpdateChecker
02127e6 @josevalim Allow a custom exceptions app to set.
josevalim authored
43 @exceptions_app = nil
4a98a30 @felixbuenemann Always default to flushing enabled
felixbuenemann authored
44 @autoflush_log = true
51aeae9 @tenderlove allow people to specify custom formatters, use the default formatter …
tenderlove authored
45 @log_formatter = ActiveSupport::Logger::SimpleFormatter.new
0da12df @kennyj Load db/schema_cache.dump duaring boot time.
kennyj authored
46 @use_schema_cache_dump = true
9fc9e89 @josevalim Use Rails::Queueing::Queue instead of Queue so people can build their…
josevalim authored
47 @queue = Rails::Queueing::Queue
1385388 @carlosantoniodasilva Allow configuring a different queue consumer
carlosantoniodasilva authored
48 @queue_consumer = Rails::Queueing::ThreadedConsumer
28fee29 @josh Unify sprockets config options
josh authored
49
50 @assets = ActiveSupport::OrderedOptions.new
7534240 @josevalim Provide initialize_on_precompile which, when set to false, does not i…
josevalim authored
51 @assets.enabled = false
52 @assets.paths = []
53 @assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) },
54 /(?:\/|\\|\A)application\.(css|js)$/ ]
55 @assets.prefix = "/assets"
56 @assets.version = ''
57 @assets.debug = false
58 @assets.compile = true
59 @assets.digest = false
60 @assets.manifest = nil
61 @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
62 @assets.js_compressor = nil
63 @assets.css_compressor = nil
64 @assets.initialize_on_precompile = true
226783d @guilleiguaran Silent Sprockets logger when config.assets.logger is set to false
guilleiguaran authored
65 @assets.logger = nil
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
66 end
67
8284fd3 @drogus Get rid of static_paths method and instead configure paths for Action…
drogus authored
68 def compiled_asset_path
69 "/"
70 end
71
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
72 def encoding=(value)
73 @encoding = value
5ca86ac @lest deprecate String#encoding_aware? and remove its usage
lest authored
74 silence_warnings do
75 Encoding.default_external = value
76 Encoding.default_internal = value
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
77 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
78 end
79
80 def paths
81 @paths ||= begin
82 paths = super
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
83 paths.add "config/database", :with => "config/database.yml"
84 paths.add "config/environment", :with => "config/environment.rb"
85 paths.add "lib/templates"
86 paths.add "log", :with => "log/#{Rails.env}.log"
afc8288 @josevalim Remove the ability for engines to serve assets from the public direct…
josevalim authored
87 paths.add "public"
88 paths.add "public/javascripts"
89 paths.add "public/stylesheets"
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
90 paths.add "tmp"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
91 paths
92 end
93 end
94
95 # Enable threaded mode. Allows concurrent requests to controller actions and
96 # multiple database connections. Also disables automatic dependency loading
97 # after boot, and disables reloading code on every request, as these are
98 # fundamentally incompatible with thread safety.
99 def threadsafe!
76df63e changing self.attribute to @atrribute to follow one kind of value ass…
prasath authored
100 @preload_frameworks = true
101 @cache_classes = true
102 @dependency_loading = false
103 @allow_concurrency = true
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
104 self
105 end
106
107 # Loads and returns the contents of the #database_configuration_file. The
108 # contents of the file are processed via ERB before being sent through
109 # YAML::load.
110 def database_configuration
111 require 'erb'
3b378a7 @tenderlove use File.binread to pull in the schema cache
tenderlove authored
112 YAML.load ERB.new(IO.read(paths["config/database"].first)).result
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
113 end
114
115 def log_level
116 @log_level ||= Rails.env.production? ? :info : :debug
117 end
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
118
119 def colorize_logging
2e7d6ff @kennyj Remove redundant instance_variables (@colorize_logging)
kennyj authored
120 ActiveSupport::LogSubscriber.colorize_logging
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
121 end
122
123 def colorize_logging=(val)
6788db8 @josevalim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing f…
josevalim authored
124 ActiveSupport::LogSubscriber.colorize_logging = val
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
125 self.generators.colorize_logging = val
126 end
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored
127
128 def session_store(*args)
129 if args.empty?
130 case @session_store
131 when :disabled
132 nil
133 when :active_record_store
134 ActiveRecord::SessionStore
135 when Symbol
136 ActionDispatch::Session.const_get(@session_store.to_s.camelize)
137 else
138 @session_store
139 end
140 else
141 @session_store = args.shift
142 @session_options = args.shift || {}
143 end
144 end
4f6af26 @lest remove AS whiny nil extension and deprecate config.whiny_nils
lest authored
145
146 def whiny_nils=(*)
147 ActiveSupport::Deprecation.warn "config.whiny_nils option " \
148 "is deprecated and no longer works", caller
149 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
150 end
151 end
f38e89c @josh Move railties/builtin into lib
josh authored
152 end
Something went wrong with that request. Please try again.