Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 132 lines (118 sloc) 4.22 kb
80b6067 Yehuda Katz Revert "Moved encoding work in progress to a feature branch."
wycats authored
1 require 'active_support/core_ext/string/encoding'
b17e358 José Valim Move configuration to subfolders.
josevalim authored
2 require 'rails/engine/configuration'
3
4 module Rails
5 class Application
6 class Configuration < ::Rails::Engine::Configuration
8e6d276 José Valim Clean up asset_host and asset_path.
josevalim authored
7 attr_accessor :allow_concurrency, :asset_host, :cache_classes, :cache_store,
ec73710 José Valim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
8 :encoding, :consider_all_requests_local, :dependency_loading,
64c82f9 Aaron Patterson only define log_level reader once, make sure to initialize @log_level
tenderlove authored
9 :filter_parameters, :helpers_paths, :logger,
c787bfd Piotr Sarnacki Engine can now load its own plugins
drogus authored
10 :preload_frameworks, :reload_plugins,
3939d6b Piotr Sarnacki Removed ActionDispatch::Static, but left empty MiddlewareStack to unify ...
drogus authored
11 :secret_token, :serve_static_assets, :session_options,
56a5da8 Joshua Peek Merge branch 'master' into sprockets
josh authored
12 :time_zone, :whiny_nils, :force_ssl,
25c0b56 Joshua Peek Precompile configured assets
josh authored
13 :asset_pipeline, :precompile_assets
b17e358 José Valim Move configuration to subfolders.
josevalim authored
14
64c82f9 Aaron Patterson only define log_level reader once, make sure to initialize @log_level
tenderlove authored
15 attr_writer :log_level
16
b17e358 José Valim Move configuration to subfolders.
josevalim authored
17 def initialize(*)
18 super
aaec007 Yehuda Katz Make sure apps upgrading from 2.3 get defaulted to UTF-8 (ht: parndt)
wycats authored
19 self.encoding = "utf-8"
64c82f9 Aaron Patterson only define log_level reader once, make sure to initialize @log_level
tenderlove authored
20 @allow_concurrency = false
ec73710 José Valim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
21 @consider_all_requests_local = false
64c82f9 Aaron Patterson 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
2c0c4d7 Prem Sichanugrist Add `config.force_ssl` configuration which will load `Rack::SSL` middlew...
sikachu authored
26 @force_ssl = false
64c82f9 Aaron Patterson 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
651d371 Joshua Peek Rename option to config.asset_pipeline
josh authored
33 @asset_pipeline = false
25c0b56 Joshua Peek Precompile configured assets
josh authored
34 @precompile_assets = []
ec73710 José Valim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
35 end
36
8284fd3 Piotr Sarnacki Get rid of static_paths method and instead configure paths for ActionDis...
drogus authored
37 def compiled_asset_path
38 "/"
39 end
40
ec73710 José Valim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
41 def encoding=(value)
42 @encoding = value
80b6067 Yehuda Katz Revert "Moved encoding work in progress to a feature branch."
wycats authored
43 if "ruby".encoding_aware?
ec73710 José Valim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
44 Encoding.default_external = value
80b6067 Yehuda Katz Revert "Moved encoding work in progress to a feature branch."
wycats authored
45 Encoding.default_internal = value
46 else
47 $KCODE = value
48 if $KCODE == "NONE"
49 raise "The value you specified for config.encoding is " \
50 "invalid. The possible values are UTF8, SJIS, or EUC"
51 end
ec73710 José Valim Alleviate the pain in working with utf8 templates by setting a default e...
josevalim authored
52 end
b17e358 José Valim Move configuration to subfolders.
josevalim authored
53 end
54
55 def paths
56 @paths ||= begin
57 paths = super
d649bf1 José Valim Provide a cleaner syntax for paths configuration that does not rely on m...
josevalim authored
58 paths.add "config/database", :with => "config/database.yml"
59 paths.add "config/environment", :with => "config/environment.rb"
60 paths.add "lib/templates"
61 paths.add "log", :with => "log/#{Rails.env}.log"
62 paths.add "tmp"
63 paths.add "tmp/cache"
b17e358 José Valim Move configuration to subfolders.
josevalim authored
64 paths
65 end
66 end
67
68 # Enable threaded mode. Allows concurrent requests to controller actions and
69 # multiple database connections. Also disables automatic dependency loading
70 # after boot, and disables reloading code on every request, as these are
71 # fundamentally incompatible with thread safety.
72 def threadsafe!
73 self.preload_frameworks = true
74 self.cache_classes = true
75 self.dependency_loading = false
0dece79 José Valim Deprecate AC configuration values which were moved to Rack.
josevalim authored
76 self.allow_concurrency = true
b17e358 José Valim Move configuration to subfolders.
josevalim authored
77 self
78 end
79
80 # Loads and returns the contents of the #database_configuration_file. The
81 # contents of the file are processed via ERB before being sent through
82 # YAML::load.
83 def database_configuration
84 require 'erb'
d649bf1 José Valim Provide a cleaner syntax for paths configuration that does not rely on m...
josevalim authored
85 YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
b17e358 José Valim Move configuration to subfolders.
josevalim authored
86 end
87
88 def cache_store
89 @cache_store ||= begin
90 if File.exist?("#{root}/tmp/cache/")
91 [ :file_store, "#{root}/tmp/cache/" ]
92 else
93 :memory_store
94 end
95 end
96 end
97
98 def log_level
99 @log_level ||= Rails.env.production? ? :info : :debug
100 end
c2dbc39 Have log subscribers subscribe to the actual events, so the subscriber d...
Carlhuda authored
101
102 def colorize_logging
103 @colorize_logging
104 end
105
106 def colorize_logging=(val)
107 @colorize_logging = val
6788db8 José Valim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing fram...
josevalim authored
108 ActiveSupport::LogSubscriber.colorize_logging = val
c2dbc39 Have log subscribers subscribe to the actual events, so the subscriber d...
Carlhuda authored
109 self.generators.colorize_logging = val
110 end
395d664 José Valim Move application configuration to the application configuration object, ...
josevalim authored
111
112 def session_store(*args)
113 if args.empty?
114 case @session_store
115 when :disabled
116 nil
117 when :active_record_store
118 ActiveRecord::SessionStore
119 when Symbol
120 ActionDispatch::Session.const_get(@session_store.to_s.camelize)
121 else
122 @session_store
123 end
124 else
125 @session_store = args.shift
126 @session_options = args.shift || {}
127 end
128 end
b17e358 José Valim Move configuration to subfolders.
josevalim authored
129 end
130 end
f38e89c Joshua Peek Move railties/builtin into lib
josh authored
131 end
Something went wrong with that request. Please try again.