Skip to content
Newer
Older
100644 151 lines (137 sloc) 5.49 KB
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored May 17, 2010
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 Aug 24, 2011
2 require 'active_support/core_ext/kernel/reporting'
cd3033e @josevalim Add config.file_watcher so developers can provide their own watchers …
josevalim authored Dec 13, 2011
3 require 'active_support/file_update_checker'
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
4 require 'rails/engine/configuration'
5
6 module Rails
7 class Application
8 class Configuration < ::Rails::Engine::Configuration
afc8288 @josevalim Remove the ability for engines to serve assets from the public direct…
josevalim authored Apr 15, 2011
9 attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets,
10 :cache_classes, :cache_store, :consider_all_requests_local,
02127e6 @josevalim Allow a custom exceptions app to set.
josevalim authored Dec 16, 2011
11 :dependency_loading, :exceptions_app, :file_watcher, :filter_parameters,
cd3033e @josevalim Add config.file_watcher so developers can provide their own watchers …
josevalim authored Dec 13, 2011
12 :force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks,
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored Dec 12, 2011
13 :railties_order, :relative_url_root, :reload_plugins, :secret_token,
14 :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
15 :time_zone, :reload_classes_only_on_change, :whiny_nils
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
16
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored Jan 5, 2011
17 attr_writer :log_level
4af4312 @tenderlove only define the encoding reader since we define the writer later on
tenderlove authored Aug 24, 2011
18 attr_reader :encoding
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored Jan 5, 2011
19
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
20 def initialize(*)
21 super
aaec007 @wycats Make sure apps upgrading from 2.3 get defaulted to UTF-8 (ht: parndt)
wycats authored Aug 15, 2010
22 self.encoding = "utf-8"
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored Dec 12, 2011
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 Dec 13, 2011
42 @file_watcher = ActiveSupport::FileUpdateChecker
02127e6 @josevalim Allow a custom exceptions app to set.
josevalim authored Dec 16, 2011
43 @exceptions_app = nil
28fee29 @josh Unify sprockets config options
josh authored Mar 30, 2011
44
45 @assets = ActiveSupport::OrderedOptions.new
7534240 @josevalim Provide initialize_on_precompile which, when set to false, does not i…
josevalim authored Oct 2, 2011
46 @assets.enabled = false
47 @assets.paths = []
48 @assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) },
49 /(?:\/|\\|\A)application\.(css|js)$/ ]
50 @assets.prefix = "/assets"
51 @assets.version = ''
52 @assets.debug = false
53 @assets.compile = true
54 @assets.digest = false
55 @assets.manifest = nil
56 @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
57 @assets.js_compressor = nil
58 @assets.css_compressor = nil
59 @assets.initialize_on_precompile = true
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored Apr 7, 2010
60 end
61
8284fd3 @drogus Get rid of static_paths method and instead configure paths for Action…
drogus authored Aug 4, 2010
62 def compiled_asset_path
63 "/"
64 end
65
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored Apr 7, 2010
66 def encoding=(value)
67 @encoding = value
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored May 17, 2010
68 if "ruby".encoding_aware?
3096629 @tenderlove we are *sure* we want to set the encoding, so silence warnings around it
tenderlove authored Aug 24, 2011
69 silence_warnings do
70 Encoding.default_external = value
71 Encoding.default_internal = value
72 end
80b6067 @wycats Revert "Moved encoding work in progress to a feature branch."
wycats authored May 17, 2010
73 else
74 $KCODE = value
75 if $KCODE == "NONE"
76 raise "The value you specified for config.encoding is " \
77 "invalid. The possible values are UTF8, SJIS, or EUC"
78 end
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored Apr 7, 2010
79 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
80 end
81
82 def paths
83 @paths ||= begin
84 paths = super
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored Oct 6, 2010
85 paths.add "config/database", :with => "config/database.yml"
86 paths.add "config/environment", :with => "config/environment.rb"
87 paths.add "lib/templates"
88 paths.add "log", :with => "log/#{Rails.env}.log"
afc8288 @josevalim Remove the ability for engines to serve assets from the public direct…
josevalim authored Apr 15, 2011
89 paths.add "public"
90 paths.add "public/javascripts"
91 paths.add "public/stylesheets"
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored Oct 6, 2010
92 paths.add "tmp"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
93 paths
94 end
95 end
96
97 # Enable threaded mode. Allows concurrent requests to controller actions and
98 # multiple database connections. Also disables automatic dependency loading
99 # after boot, and disables reloading code on every request, as these are
100 # fundamentally incompatible with thread safety.
101 def threadsafe!
102 self.preload_frameworks = true
103 self.cache_classes = true
104 self.dependency_loading = false
0dece79 @josevalim Deprecate AC configuration values which were moved to Rack.
josevalim authored Feb 1, 2010
105 self.allow_concurrency = true
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
106 self
107 end
108
109 # Loads and returns the contents of the #database_configuration_file. The
110 # contents of the file are processed via ERB before being sent through
111 # YAML::load.
112 def database_configuration
113 require 'erb'
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored Oct 6, 2010
114 YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
115 end
116
117 def log_level
118 @log_level ||= Rails.env.production? ? :info : :debug
119 end
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored Mar 2, 2010
120
121 def colorize_logging
122 @colorize_logging
123 end
124
125 def colorize_logging=(val)
126 @colorize_logging = val
6788db8 @josevalim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing f…
josevalim authored Jun 24, 2010
127 ActiveSupport::LogSubscriber.colorize_logging = val
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored Mar 2, 2010
128 self.generators.colorize_logging = val
129 end
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored Mar 26, 2010
130
131 def session_store(*args)
132 if args.empty?
133 case @session_store
134 when :disabled
135 nil
136 when :active_record_store
137 ActiveRecord::SessionStore
138 when Symbol
139 ActionDispatch::Session.const_get(@session_store.to_s.camelize)
140 else
141 @session_store
142 end
143 else
144 @session_store = args.shift
145 @session_options = args.shift || {}
146 end
147 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored Jan 23, 2010
148 end
149 end
f38e89c @josh Move railties/builtin into lib
josh authored Mar 20, 2010
150 end
Something went wrong with that request. Please try again.