Skip to content

HTTPS clone URL

Subversion checkout URL

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