Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 145 lines (131 sloc) 5.145 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 directory...
josevalim authored
8 attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets,
9 :cache_classes, :cache_store, :consider_all_requests_local,
4af4312 @tenderlove only define the encoding reader since we define the writer later on
tenderlove authored
10 :dependency_loading, :filter_parameters,
afc8288 @josevalim Remove the ability for engines to serve assets from the public directory...
josevalim authored
11 :force_ssl, :helpers_paths, :logger, :preload_frameworks,
12 :reload_plugins, :secret_token, :serve_static_assets,
cb5c39f @jsl Make the Rack::SSL middleware configurable
jsl authored
13 :ssl_options, :static_cache_control, :session_options,
14 :time_zone, :whiny_nils
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"
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
22 @allow_concurrency = false
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
23 @consider_all_requests_local = false
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
24 @filter_parameters = []
25 @helpers_paths = []
26 @dependency_loading = true
27 @serve_static_assets = true
1ca8123 @josevalim Add static_cache_control as configuration option and set a default for t...
josevalim authored
28 @static_cache_control = nil
2c0c4d7 @sikachu Add `config.force_ssl` configuration which will load `Rack::SSL` middlew...
sikachu authored
29 @force_ssl = false
cb5c39f @jsl Make the Rack::SSL middleware configurable
jsl authored
30 @ssl_options = {}
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
31 @session_store = :cookie_store
32 @session_options = {}
33 @time_zone = "UTC"
34 @log_level = nil
35 @middleware = app_middleware
36 @generators = app_generators
8f0e0b6 @josevalim assets.cache_store now defaults to filesystem. You will want to share tm...
josevalim authored
37 @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
28fee29 @josh Unify sprockets config options
josh authored
38
39 @assets = ActiveSupport::OrderedOptions.new
7534240 @josevalim Provide initialize_on_precompile which, when set to false, does not init...
josevalim authored
40 @assets.enabled = false
41 @assets.paths = []
42 @assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) },
43 /(?:\/|\\|\A)application\.(css|js)$/ ]
44 @assets.prefix = "/assets"
45 @assets.version = ''
46 @assets.debug = false
47 @assets.compile = true
48 @assets.digest = false
49 @assets.manifest = nil
50 @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
51 @assets.js_compressor = nil
52 @assets.css_compressor = nil
53 @assets.initialize_on_precompile = true
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
54 end
55
8284fd3 @drogus Get rid of static_paths method and instead configure paths for ActionDis...
drogus authored
56 def compiled_asset_path
57 "/"
58 end
59
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
60 def encoding=(value)
61 @encoding = value
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored
62 if "ruby".encoding_aware?
3096629 @tenderlove we are *sure* we want to set the encoding, so silence warnings around it
tenderlove authored
63 silence_warnings do
64 Encoding.default_external = value
65 Encoding.default_internal = value
66 end
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored
67 else
68 $KCODE = value
69 if $KCODE == "NONE"
70 raise "The value you specified for config.encoding is " \
71 "invalid. The possible values are UTF8, SJIS, or EUC"
72 end
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
73 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
74 end
75
76 def paths
77 @paths ||= begin
78 paths = super
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely on m...
josevalim authored
79 paths.add "config/database", :with => "config/database.yml"
80 paths.add "config/environment", :with => "config/environment.rb"
81 paths.add "lib/templates"
82 paths.add "log", :with => "log/#{Rails.env}.log"
afc8288 @josevalim Remove the ability for engines to serve assets from the public directory...
josevalim authored
83 paths.add "public"
84 paths.add "public/javascripts"
85 paths.add "public/stylesheets"
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely on m...
josevalim authored
86 paths.add "tmp"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
87 paths
88 end
89 end
90
91 # Enable threaded mode. Allows concurrent requests to controller actions and
92 # multiple database connections. Also disables automatic dependency loading
93 # after boot, and disables reloading code on every request, as these are
94 # fundamentally incompatible with thread safety.
95 def threadsafe!
96 self.preload_frameworks = true
97 self.cache_classes = true
98 self.dependency_loading = false
0dece79 @josevalim Deprecate AC configuration values which were moved to Rack.
josevalim authored
99 self.allow_concurrency = true
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
100 self
101 end
102
103 # Loads and returns the contents of the #database_configuration_file. The
104 # contents of the file are processed via ERB before being sent through
105 # YAML::load.
106 def database_configuration
107 require 'erb'
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely on m...
josevalim authored
108 YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
109 end
110
111 def log_level
112 @log_level ||= Rails.env.production? ? :info : :debug
113 end
c2dbc39 Have log subscribers subscribe to the actual events, so the subscriber d...
Carlhuda authored
114
115 def colorize_logging
116 @colorize_logging
117 end
118
119 def colorize_logging=(val)
120 @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
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
142 end
143 end
f38e89c @josh Move railties/builtin into lib
josh authored
144 end
Something went wrong with that request. Please try again.