Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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