Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 139 lines (124 sloc) 4.718 kB
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored
1 require 'active_support/core_ext/string/encoding'
3096629 @tenderlove we are *sure* we want to set the encoding, so silence warnings around it
tenderlove authored
2 require 'active_support/core_ext/kernel/reporting'
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
afc8288 @josevalim Remove the ability for engines to serve assets from the public direct…
josevalim authored
8 attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets,
9 :cache_classes, :cache_store, :consider_all_requests_local,
10 :dependency_loading, :encoding, :filter_parameters,
11 :force_ssl, :helpers_paths, :logger, :preload_frameworks,
12 :reload_plugins, :secret_token, :serve_static_assets,
1ca8123 @josevalim Add static_cache_control as configuration option and set a default fo…
josevalim authored
13 :static_cache_control, :session_options, :time_zone, :whiny_nils
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
14
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
15 attr_writer :log_level
16
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
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"
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
20 @allow_concurrency = false
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
21 @consider_all_requests_local = false
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
22 @filter_parameters = []
23 @helpers_paths = []
24 @dependency_loading = true
25 @serve_static_assets = true
1ca8123 @josevalim Add static_cache_control as configuration option and set a default fo…
josevalim authored
26 @static_cache_control = nil
2c0c4d7 @sikachu Add `config.force_ssl` configuration which will load `Rack::SSL` midd…
sikachu authored
27 @force_ssl = false
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
28 @session_store = :cookie_store
29 @session_options = {}
30 @time_zone = "UTC"
31 @log_level = nil
32 @middleware = app_middleware
33 @generators = app_generators
8f0e0b6 @josevalim assets.cache_store now defaults to filesystem. You will want to share…
josevalim authored
34 @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
28fee29 @josh Unify sprockets config options
josh authored
35
36 @assets = ActiveSupport::OrderedOptions.new
827cdae @guilleiguaran Add config.allow_debugging option to determine if the debug_assets qu…
guilleiguaran authored
37 @assets.enabled = false
38 @assets.paths = []
39 @assets.precompile = [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
40 @assets.prefix = "/assets"
41 @assets.version = ''
42 @assets.debug = false
43 @assets.allow_debugging = false
dab96a2 @josh Add shorthand for js and css compressors
josh authored
44
704ee0d @josevalim Use cache/assets instead.
josevalim authored
45 @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
dab96a2 @josh Add shorthand for js and css compressors
josh authored
46 @assets.js_compressor = nil
47 @assets.css_compressor = nil
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
48 end
49
8284fd3 @drogus Get rid of static_paths method and instead configure paths for Action…
drogus authored
50 def compiled_asset_path
51 "/"
52 end
53
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
54 def encoding=(value)
55 @encoding = value
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored
56 if "ruby".encoding_aware?
3096629 @tenderlove we are *sure* we want to set the encoding, so silence warnings around it
tenderlove authored
57 silence_warnings do
58 Encoding.default_external = value
59 Encoding.default_internal = value
60 end
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored
61 else
62 $KCODE = value
63 if $KCODE == "NONE"
64 raise "The value you specified for config.encoding is " \
65 "invalid. The possible values are UTF8, SJIS, or EUC"
66 end
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
67 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
68 end
69
70 def paths
71 @paths ||= begin
72 paths = super
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
73 paths.add "config/database", :with => "config/database.yml"
74 paths.add "config/environment", :with => "config/environment.rb"
75 paths.add "lib/templates"
76 paths.add "log", :with => "log/#{Rails.env}.log"
afc8288 @josevalim Remove the ability for engines to serve assets from the public direct…
josevalim authored
77 paths.add "public"
78 paths.add "public/javascripts"
79 paths.add "public/stylesheets"
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
80 paths.add "tmp"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
81 paths
82 end
83 end
84
85 # Enable threaded mode. Allows concurrent requests to controller actions and
86 # multiple database connections. Also disables automatic dependency loading
87 # after boot, and disables reloading code on every request, as these are
88 # fundamentally incompatible with thread safety.
89 def threadsafe!
90 self.preload_frameworks = true
91 self.cache_classes = true
92 self.dependency_loading = false
0dece79 @josevalim Deprecate AC configuration values which were moved to Rack.
josevalim authored
93 self.allow_concurrency = true
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
94 self
95 end
96
97 # Loads and returns the contents of the #database_configuration_file. The
98 # contents of the file are processed via ERB before being sent through
99 # YAML::load.
100 def database_configuration
101 require 'erb'
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
102 YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
103 end
104
105 def log_level
106 @log_level ||= Rails.env.production? ? :info : :debug
107 end
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
108
109 def colorize_logging
110 @colorize_logging
111 end
112
113 def colorize_logging=(val)
114 @colorize_logging = val
6788db8 @josevalim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing f…
josevalim authored
115 ActiveSupport::LogSubscriber.colorize_logging = val
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
116 self.generators.colorize_logging = val
117 end
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored
118
119 def session_store(*args)
120 if args.empty?
121 case @session_store
122 when :disabled
123 nil
124 when :active_record_store
125 ActiveRecord::SessionStore
126 when Symbol
127 ActionDispatch::Session.const_get(@session_store.to_s.camelize)
128 else
129 @session_store
130 end
131 else
132 @session_store = args.shift
133 @session_options = args.shift || {}
134 end
135 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
136 end
137 end
f38e89c @josh Move railties/builtin into lib
josh authored
138 end
Something went wrong with that request. Please try again.