railties 4.2.11.3 → 5.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +262 -206
- data/MIT-LICENSE +20 -0
- data/README.rdoc +1 -1
- data/{bin → exe}/rails +0 -0
- data/lib/rails.rb +19 -1
- data/lib/rails/all.rb +10 -9
- data/lib/rails/api/task.rb +7 -14
- data/lib/rails/{app_rails_loader.rb → app_loader.rb} +4 -3
- data/lib/rails/application.rb +31 -41
- data/lib/rails/application/bootstrap.rb +1 -14
- data/lib/rails/application/configuration.rb +94 -95
- data/lib/rails/application/default_middleware_stack.rb +30 -16
- data/lib/rails/application/finisher.rb +11 -2
- data/lib/rails/application/routes_reloader.rb +1 -3
- data/lib/rails/application_controller.rb +1 -1
- data/lib/rails/cli.rb +2 -2
- data/lib/rails/code_statistics.rb +6 -8
- data/lib/rails/code_statistics_calculator.rb +8 -1
- data/lib/rails/command.rb +70 -0
- data/lib/rails/commands.rb +5 -3
- data/lib/rails/commands/commands_tasks.rb +25 -14
- data/lib/rails/commands/console.rb +7 -52
- data/lib/rails/commands/console_helper.rb +34 -0
- data/lib/rails/commands/dbconsole.rb +59 -78
- data/lib/rails/commands/dev_cache.rb +21 -0
- data/lib/rails/commands/plugin.rb +1 -1
- data/lib/rails/commands/rake_proxy.rb +34 -0
- data/lib/rails/commands/runner.rb +0 -1
- data/lib/rails/commands/server.rb +29 -36
- data/lib/rails/commands/test.rb +9 -0
- data/lib/rails/configuration.rb +21 -5
- data/lib/rails/console/app.rb +5 -0
- data/lib/rails/console/helpers.rb +1 -1
- data/lib/rails/engine.rb +68 -58
- data/lib/rails/engine/commands.rb +4 -2
- data/lib/rails/engine/configuration.rb +4 -10
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators.rb +30 -7
- data/lib/rails/generators/.named_base.rb.swp +0 -0
- data/lib/rails/generators/actions.rb +19 -5
- data/lib/rails/generators/app_base.rb +65 -45
- data/lib/rails/generators/base.rb +6 -6
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +5 -8
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +9 -7
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +2 -2
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb +1 -1
- data/lib/rails/generators/generated_attribute.rb +5 -1
- data/lib/rails/generators/migration.rb +7 -7
- data/lib/rails/generators/named_base.rb +21 -5
- data/lib/rails/generators/rails/app/USAGE +0 -1
- data/lib/rails/generators/rails/app/app_generator.rb +75 -11
- data/lib/rails/generators/rails/app/templates/Gemfile +17 -13
- data/lib/rails/generators/rails/app/templates/{README.rdoc → README.md} +1 -5
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +7 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.coffee +11 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +3 -3
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb +5 -0
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb +5 -0
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +3 -1
- data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb +2 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb +4 -0
- data/lib/rails/generators/rails/app/templates/app/models/application_record.rb +3 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +20 -17
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
- data/lib/rails/generators/{erb/mailer/templates/layout.text.erb → rails/app/templates/app/views/layouts/mailer.text.erb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/setup +17 -12
- data/lib/rails/generators/rails/app/templates/bin/update +28 -0
- data/lib/rails/generators/rails/app/templates/config.ru.tt +11 -0
- data/lib/rails/generators/rails/app/templates/config/application.rb +9 -14
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +20 -3
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +18 -11
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +7 -3
- data/lib/rails/generators/rails/app/templates/config/initializers/active_record_belongs_to_required_by_default.rb +5 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb +6 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb +5 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +1 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb +16 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/request_forgery_protection.rb +4 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/redis/cable.yml +9 -0
- data/lib/rails/generators/rails/app/templates/config/routes.rb +3 -53
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +3 -3
- data/lib/rails/generators/rails/app/templates/gitignore +7 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +6 -4
- data/lib/rails/generators/rails/migration/migration_generator.rb +1 -1
- data/lib/rails/generators/rails/model/USAGE +6 -1
- data/lib/rails/generators/rails/model/model_generator.rb +1 -1
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +88 -35
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +6 -9
- data/lib/rails/generators/rails/plugin/templates/Gemfile +3 -7
- data/lib/rails/generators/rails/plugin/templates/README.md +3 -0
- data/lib/rails/generators/rails/plugin/templates/Rakefile +2 -2
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/models/application_record.rb.tt +6 -0
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +14 -0
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/bin/test.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/plugin/templates/gitignore +2 -3
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb +5 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb +1 -0
- data/lib/rails/generators/rails/plugin/templates/lib/tasks/{%name%_tasks.rake → %namespaced_name%_tasks.rake} +1 -1
- data/lib/rails/generators/rails/plugin/templates/rails/application.rb +3 -3
- data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js +11 -0
- data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js +6 -0
- data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +1 -1
- data/lib/rails/generators/rails/plugin/templates/rails/routes.rb +1 -2
- data/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +3 -3
- data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +4 -2
- data/lib/rails/generators/rails/resource/resource_generator.rb +0 -1
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +0 -1
- data/lib/rails/generators/rails/scaffold/USAGE +1 -1
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css +35 -7
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +4 -1
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb +61 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
- data/lib/rails/generators/resource_helpers.rb +3 -3
- data/lib/rails/generators/test_unit/controller/templates/.functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +3 -5
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +8 -3
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +2 -2
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb +4 -4
- data/lib/rails/generators/test_unit/model/model_generator.rb +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +2 -0
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
- data/lib/rails/generators/test_unit/scaffold/templates/.api_functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/scaffold/templates/.functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +44 -0
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +14 -14
- data/lib/rails/generators/testing/assertions.rb +0 -2
- data/lib/rails/generators/testing/behaviour.rb +4 -17
- data/lib/rails/info.rb +2 -2
- data/lib/rails/info_controller.rb +23 -2
- data/lib/rails/mailers_controller.rb +2 -2
- data/lib/rails/paths.rb +14 -6
- data/lib/rails/rack.rb +1 -3
- data/lib/rails/rack/debugger.rb +2 -23
- data/lib/rails/rack/logger.rb +4 -0
- data/lib/rails/ruby_version_check.rb +3 -3
- data/lib/rails/source_annotation_extractor.rb +1 -1
- data/lib/rails/tasks.rb +4 -1
- data/lib/rails/tasks/engine.rake +1 -1
- data/lib/rails/tasks/framework.rake +18 -16
- data/lib/rails/tasks/initializers.rake +6 -0
- data/lib/rails/tasks/restart.rake +5 -0
- data/lib/rails/tasks/statistics.rake +5 -6
- data/lib/rails/tasks/tmp.rake +4 -12
- data/lib/rails/templates/rails/mailers/email.html.erb +17 -3
- data/lib/rails/templates/rails/welcome/index.html.erb +10 -3
- data/lib/rails/test_help.rb +7 -8
- data/lib/rails/test_unit/minitest_plugin.rb +91 -0
- data/lib/rails/test_unit/reporter.rb +74 -0
- data/lib/rails/test_unit/test_requirer.rb +28 -0
- data/lib/rails/test_unit/testing.rake +18 -39
- metadata +80 -33
- data/lib/rails/deprecation.rb +0 -19
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb +0 -5
- data/lib/rails/generators/rails/app/templates/config.ru +0 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/lib/rails/generators/rails/plugin/templates/README.rdoc +0 -3
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt +0 -5
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt +0 -4
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt +0 -14
- data/lib/rails/generators/rails/plugin/templates/lib/%name%.rb +0 -6
- data/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb +0 -7
- data/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb +0 -3
- data/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb +0 -7
- data/lib/rails/rack/log_tailer.rb +0 -38
- data/lib/rails/tasks/documentation.rake +0 -70
- data/lib/rails/test_unit/sub_test_task.rb +0 -126
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2004-2015 David Heinemeier Hansson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -17,7 +17,7 @@ The latest version of Railties can be installed with RubyGems:
|
|
17
17
|
|
18
18
|
Source code can be downloaded as part of the Rails project on GitHub
|
19
19
|
|
20
|
-
* https://github.com/rails/rails/tree/
|
20
|
+
* https://github.com/rails/rails/tree/master/railties
|
21
21
|
|
22
22
|
== License
|
23
23
|
|
data/{bin → exe}/rails
RENAMED
File without changes
|
data/lib/rails.rb
CHANGED
@@ -14,7 +14,7 @@ require 'rails/version'
|
|
14
14
|
require 'active_support/railtie'
|
15
15
|
require 'action_dispatch/railtie'
|
16
16
|
|
17
|
-
#
|
17
|
+
# UTF-8 is the default internal and external encoding.
|
18
18
|
silence_warnings do
|
19
19
|
Encoding.default_external = Encoding::UTF_8
|
20
20
|
Encoding.default_internal = Encoding::UTF_8
|
@@ -52,14 +52,27 @@ module Rails
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
# Returns a Pathname object of the current rails project,
|
56
|
+
# otherwise it returns nil if there is no project:
|
57
|
+
#
|
58
|
+
# Rails.root
|
59
|
+
# # => #<Pathname:/Users/someuser/some/path/project>
|
55
60
|
def root
|
56
61
|
application && application.config.root
|
57
62
|
end
|
58
63
|
|
64
|
+
# Returns the current Rails environment.
|
65
|
+
#
|
66
|
+
# Rails.env # => "development"
|
67
|
+
# Rails.env.development? # => true
|
68
|
+
# Rails.env.production? # => false
|
59
69
|
def env
|
60
70
|
@_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
|
61
71
|
end
|
62
72
|
|
73
|
+
# Sets the Rails environment.
|
74
|
+
#
|
75
|
+
# Rails.env = "staging" # => "staging"
|
63
76
|
def env=(environment)
|
64
77
|
@_env = ActiveSupport::StringInquirer.new(environment)
|
65
78
|
end
|
@@ -86,6 +99,11 @@ module Rails
|
|
86
99
|
groups
|
87
100
|
end
|
88
101
|
|
102
|
+
# Returns a Pathname object of the public folder of the current
|
103
|
+
# rails project, otherwise it returns nil if there is no project:
|
104
|
+
#
|
105
|
+
# Rails.public_path
|
106
|
+
# # => #<Pathname:/Users/someuser/some/path/project/public>
|
89
107
|
def public_path
|
90
108
|
application && Pathname.new(application.paths["public"].first)
|
91
109
|
end
|
data/lib/rails/all.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require "rails"
|
2
2
|
|
3
3
|
%w(
|
4
|
-
active_record
|
5
|
-
action_controller
|
6
|
-
action_view
|
7
|
-
action_mailer
|
8
|
-
active_job
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
active_record/railtie
|
5
|
+
action_controller/railtie
|
6
|
+
action_view/railtie
|
7
|
+
action_mailer/railtie
|
8
|
+
active_job/railtie
|
9
|
+
action_cable/engine
|
10
|
+
rails/test_unit/railtie
|
11
|
+
sprockets/railtie
|
12
|
+
).each do |railtie|
|
12
13
|
begin
|
13
|
-
require "#{
|
14
|
+
require "#{railtie}"
|
14
15
|
rescue LoadError
|
15
16
|
end
|
16
17
|
end
|
data/lib/rails/api/task.rb
CHANGED
@@ -57,6 +57,13 @@ module Rails
|
|
57
57
|
)
|
58
58
|
},
|
59
59
|
|
60
|
+
'actioncable' => {
|
61
|
+
:include => %w(
|
62
|
+
README.md
|
63
|
+
lib/action_cable/**/*.rb
|
64
|
+
)
|
65
|
+
},
|
66
|
+
|
60
67
|
'railties' => {
|
61
68
|
:include => %w(
|
62
69
|
README.rdoc
|
@@ -152,19 +159,5 @@ module Rails
|
|
152
159
|
File.read('RAILS_VERSION').strip
|
153
160
|
end
|
154
161
|
end
|
155
|
-
|
156
|
-
class AppTask < Task
|
157
|
-
def component_root_dir(gem_name)
|
158
|
-
$:.grep(%r{#{gem_name}[\w.-]*/lib\z}).first[0..-5]
|
159
|
-
end
|
160
|
-
|
161
|
-
def api_dir
|
162
|
-
'doc/api'
|
163
|
-
end
|
164
|
-
|
165
|
-
def rails_version
|
166
|
-
Rails::VERSION::STRING
|
167
|
-
end
|
168
|
-
end
|
169
162
|
end
|
170
163
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'pathname'
|
2
|
+
require 'rails/version'
|
2
3
|
|
3
4
|
module Rails
|
4
|
-
module
|
5
|
+
module AppLoader # :nodoc:
|
5
6
|
extend self
|
6
7
|
|
7
8
|
RUBY = Gem.ruby
|
@@ -9,7 +10,7 @@ module Rails
|
|
9
10
|
BUNDLER_WARNING = <<EOS
|
10
11
|
Looks like your app's ./bin/rails is a stub that was generated by Bundler.
|
11
12
|
|
12
|
-
In Rails
|
13
|
+
In Rails #{Rails::VERSION::MAJOR}, your app's bin/ directory contains executables that are versioned
|
13
14
|
like any other source code, rather than stubs that are generated on demand.
|
14
15
|
|
15
16
|
Here's how to upgrade:
|
@@ -28,7 +29,7 @@ generate it and add it to source control:
|
|
28
29
|
|
29
30
|
EOS
|
30
31
|
|
31
|
-
def
|
32
|
+
def exec_app
|
32
33
|
original_cwd = Dir.pwd
|
33
34
|
|
34
35
|
loop do
|
data/lib/rails/application.rb
CHANGED
@@ -7,8 +7,7 @@ require 'active_support/message_verifier'
|
|
7
7
|
require 'rails/engine'
|
8
8
|
|
9
9
|
module Rails
|
10
|
-
#
|
11
|
-
# an Engine but with the responsibility of coordinating the whole boot process.
|
10
|
+
# An Engine with the responsibility of coordinating the whole boot process.
|
12
11
|
#
|
13
12
|
# == Initialization
|
14
13
|
#
|
@@ -90,7 +89,6 @@ module Rails
|
|
90
89
|
super
|
91
90
|
Rails.app_class = base
|
92
91
|
add_lib_to_load_path!(find_root(base.called_from))
|
93
|
-
ActiveSupport.run_load_hooks(:before_configuration, base)
|
94
92
|
end
|
95
93
|
|
96
94
|
def instance
|
@@ -146,6 +144,7 @@ module Rails
|
|
146
144
|
def run_load_hooks! # :nodoc:
|
147
145
|
return self if @ran_load_hooks
|
148
146
|
@ran_load_hooks = true
|
147
|
+
ActiveSupport.run_load_hooks(:before_configuration, self)
|
149
148
|
|
150
149
|
@initial_variable_values.each do |variable_name, value|
|
151
150
|
if INITIAL_VARIABLES.include?(variable_name)
|
@@ -157,25 +156,20 @@ module Rails
|
|
157
156
|
self
|
158
157
|
end
|
159
158
|
|
160
|
-
# Implements call according to the Rack API. It simply
|
161
|
-
# dispatches the request to the underlying middleware stack.
|
162
|
-
def call(env)
|
163
|
-
env["ORIGINAL_FULLPATH"] = build_original_fullpath(env)
|
164
|
-
env["ORIGINAL_SCRIPT_NAME"] = env["SCRIPT_NAME"]
|
165
|
-
super(env)
|
166
|
-
end
|
167
|
-
|
168
159
|
# Reload application routes regardless if they changed or not.
|
169
160
|
def reload_routes!
|
170
161
|
routes_reloader.reload!
|
171
162
|
end
|
172
163
|
|
173
|
-
#
|
164
|
+
# Returns the application's KeyGenerator
|
174
165
|
def key_generator
|
175
166
|
# number of iterations selected based on consultation with the google security
|
176
167
|
# team. Details at https://github.com/rails/rails/pull/6952#issuecomment-7661220
|
177
168
|
@caching_key_generator ||=
|
178
169
|
if secrets.secret_key_base
|
170
|
+
unless secrets.secret_key_base.kind_of?(String)
|
171
|
+
raise ArgumentError, "`secret_key_base` for #{Rails.env} environment must be a type of String, change this value in `config/secrets.yml`"
|
172
|
+
end
|
179
173
|
key_generator = ActiveSupport::KeyGenerator.new(secrets.secret_key_base, iterations: 1000)
|
180
174
|
ActiveSupport::CachingKeyGenerator.new(key_generator)
|
181
175
|
else
|
@@ -224,12 +218,16 @@ module Rails
|
|
224
218
|
# Rails.application.configure do
|
225
219
|
# config.middleware.use ExceptionNotifier, config_for(:exception_notification)
|
226
220
|
# end
|
227
|
-
def config_for(name)
|
228
|
-
|
221
|
+
def config_for(name, env: Rails.env)
|
222
|
+
if name.is_a?(Pathname)
|
223
|
+
yaml = name
|
224
|
+
else
|
225
|
+
yaml = Pathname.new("#{paths["config"].existent.first}/#{name}.yml")
|
226
|
+
end
|
229
227
|
|
230
228
|
if yaml.exist?
|
231
229
|
require "erb"
|
232
|
-
(YAML.load(ERB.new(yaml.read).result) || {})[
|
230
|
+
(YAML.load(ERB.new(yaml.read).result) || {})[env] || {}
|
233
231
|
else
|
234
232
|
raise "Could not load configuration. No such file - #{yaml}"
|
235
233
|
end
|
@@ -420,25 +418,16 @@ module Rails
|
|
420
418
|
|
421
419
|
console do
|
422
420
|
unless ::Kernel.private_method_defined?(:y)
|
423
|
-
|
424
|
-
require "psych/y"
|
425
|
-
else
|
426
|
-
module ::Kernel
|
427
|
-
def y(*objects)
|
428
|
-
puts ::Psych.dump_stream(*objects)
|
429
|
-
end
|
430
|
-
private :y
|
431
|
-
end
|
432
|
-
end
|
421
|
+
require "psych/y"
|
433
422
|
end
|
434
423
|
end
|
435
424
|
|
436
425
|
# Return an array of railties respecting the order they're loaded
|
437
426
|
# and the order specified by the +railties_order+ config.
|
438
427
|
#
|
439
|
-
# While
|
440
|
-
#
|
441
|
-
#
|
428
|
+
# While running initializers we need engines in reverse order here when
|
429
|
+
# copying migrations from railties ; we need them in the order given by
|
430
|
+
# +railties_order+.
|
442
431
|
def migration_railties # :nodoc:
|
443
432
|
ordered_railties.flatten - [self]
|
444
433
|
end
|
@@ -513,27 +502,28 @@ module Rails
|
|
513
502
|
default_stack.build_stack
|
514
503
|
end
|
515
504
|
|
516
|
-
def build_original_fullpath(env) #:nodoc:
|
517
|
-
path_info = env["PATH_INFO"]
|
518
|
-
query_string = env["QUERY_STRING"]
|
519
|
-
script_name = env["SCRIPT_NAME"]
|
520
|
-
|
521
|
-
if query_string.present?
|
522
|
-
"#{script_name}#{path_info}?#{query_string}"
|
523
|
-
else
|
524
|
-
"#{script_name}#{path_info}"
|
525
|
-
end
|
526
|
-
end
|
527
|
-
|
528
505
|
def validate_secret_key_config! #:nodoc:
|
529
506
|
if secrets.secret_key_base.blank?
|
530
507
|
ActiveSupport::Deprecation.warn "You didn't set `secret_key_base`. " +
|
531
508
|
"Read the upgrade documentation to learn more about this new config option."
|
532
509
|
|
533
510
|
if secrets.secret_token.blank?
|
534
|
-
raise "Missing `
|
511
|
+
raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
|
535
512
|
end
|
536
513
|
end
|
537
514
|
end
|
515
|
+
|
516
|
+
private
|
517
|
+
|
518
|
+
def build_request(env)
|
519
|
+
req = super
|
520
|
+
env["ORIGINAL_FULLPATH"] = req.fullpath
|
521
|
+
env["ORIGINAL_SCRIPT_NAME"] = req.script_name
|
522
|
+
req
|
523
|
+
end
|
524
|
+
|
525
|
+
def build_middleware
|
526
|
+
config.app_middleware + super
|
527
|
+
end
|
538
528
|
end
|
539
529
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require "active_support/notifications"
|
2
2
|
require "active_support/dependencies"
|
3
|
-
require "active_support/deprecation"
|
4
3
|
require "active_support/descendants_tracker"
|
5
4
|
|
6
5
|
module Rails
|
@@ -55,18 +54,6 @@ INFO
|
|
55
54
|
logger
|
56
55
|
end
|
57
56
|
|
58
|
-
if Rails.env.production? && !config.has_explicit_log_level?
|
59
|
-
ActiveSupport::Deprecation.warn \
|
60
|
-
"You did not specify a `log_level` in `production.rb`. Currently, " \
|
61
|
-
"the default value for `log_level` is `:info` for the production " \
|
62
|
-
"environment and `:debug` in all other environments. In Rails 5 " \
|
63
|
-
"the default value will be unified to `:debug` across all " \
|
64
|
-
"environments. To preserve the current setting, add the following " \
|
65
|
-
"line to your `production.rb`:\n" \
|
66
|
-
"\n" \
|
67
|
-
" config.log_level = :info\n\n"
|
68
|
-
end
|
69
|
-
|
70
57
|
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
|
71
58
|
end
|
72
59
|
|
@@ -76,7 +63,7 @@ INFO
|
|
76
63
|
Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
|
77
64
|
|
78
65
|
if Rails.cache.respond_to?(:middleware)
|
79
|
-
config.middleware.insert_before(
|
66
|
+
config.middleware.insert_before(::Rack::Runtime, Rails.cache.middleware)
|
80
67
|
end
|
81
68
|
end
|
82
69
|
end
|
@@ -1,71 +1,88 @@
|
|
1
1
|
require 'active_support/core_ext/kernel/reporting'
|
2
|
-
require 'active_support/core_ext/string/filters'
|
3
2
|
require 'active_support/file_update_checker'
|
4
|
-
require 'active_support/deprecation'
|
5
3
|
require 'rails/engine/configuration'
|
6
4
|
require 'rails/source_annotation_extractor'
|
7
5
|
|
6
|
+
require 'active_support/deprecation'
|
7
|
+
require 'active_support/core_ext/string/strip' # for strip_heredoc
|
8
|
+
|
8
9
|
module Rails
|
9
10
|
class Application
|
10
11
|
class Configuration < ::Rails::Engine::Configuration
|
11
|
-
attr_accessor :allow_concurrency, :asset_host, :
|
12
|
+
attr_accessor :allow_concurrency, :asset_host, :autoflush_log,
|
12
13
|
:cache_classes, :cache_store, :consider_all_requests_local, :console,
|
13
14
|
:eager_load, :exceptions_app, :file_watcher, :filter_parameters,
|
14
15
|
:force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,
|
15
16
|
:railties_order, :relative_url_root, :secret_key_base, :secret_token,
|
16
|
-
:
|
17
|
-
:time_zone, :reload_classes_only_on_change,
|
17
|
+
:ssl_options, :public_file_server,
|
18
|
+
:session_options, :time_zone, :reload_classes_only_on_change,
|
18
19
|
:beginning_of_week, :filter_redirect, :x
|
19
20
|
|
20
|
-
|
21
|
+
attr_writer :log_level
|
22
|
+
attr_reader :encoding, :api_only, :static_cache_control
|
21
23
|
|
22
24
|
def initialize(*)
|
23
25
|
super
|
24
26
|
self.encoding = "utf-8"
|
25
|
-
@allow_concurrency
|
26
|
-
@consider_all_requests_local
|
27
|
-
@filter_parameters
|
28
|
-
@filter_redirect
|
29
|
-
@helpers_paths
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@log_level
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
@
|
66
|
-
|
67
|
-
|
68
|
-
|
27
|
+
@allow_concurrency = nil
|
28
|
+
@consider_all_requests_local = false
|
29
|
+
@filter_parameters = []
|
30
|
+
@filter_redirect = []
|
31
|
+
@helpers_paths = []
|
32
|
+
@public_file_server = ActiveSupport::OrderedOptions.new
|
33
|
+
@public_file_server.enabled = true
|
34
|
+
@public_file_server.index_name = "index"
|
35
|
+
@force_ssl = false
|
36
|
+
@ssl_options = {}
|
37
|
+
@session_store = :cookie_store
|
38
|
+
@session_options = {}
|
39
|
+
@time_zone = "UTC"
|
40
|
+
@beginning_of_week = :monday
|
41
|
+
@log_level = nil
|
42
|
+
@generators = app_generators
|
43
|
+
@cache_store = [ :file_store, "#{root}/tmp/cache/" ]
|
44
|
+
@railties_order = [:all]
|
45
|
+
@relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
|
46
|
+
@reload_classes_only_on_change = true
|
47
|
+
@file_watcher = ActiveSupport::FileUpdateChecker
|
48
|
+
@exceptions_app = nil
|
49
|
+
@autoflush_log = true
|
50
|
+
@log_formatter = ActiveSupport::Logger::SimpleFormatter.new
|
51
|
+
@eager_load = nil
|
52
|
+
@secret_token = nil
|
53
|
+
@secret_key_base = nil
|
54
|
+
@api_only = false
|
55
|
+
@debug_exception_response_format = nil
|
56
|
+
@x = Custom.new
|
57
|
+
end
|
58
|
+
|
59
|
+
def static_cache_control=(value)
|
60
|
+
ActiveSupport::Deprecation.warn <<-eow.strip_heredoc
|
61
|
+
`static_cache_control` is deprecated and will be removed in Rails 5.1.
|
62
|
+
Please use
|
63
|
+
`config.public_file_server.headers = { 'Cache-Control' => '#{value}' }`
|
64
|
+
instead.
|
65
|
+
eow
|
66
|
+
|
67
|
+
@static_cache_control = value
|
68
|
+
end
|
69
|
+
|
70
|
+
def serve_static_files
|
71
|
+
ActiveSupport::Deprecation.warn <<-eow.strip_heredoc
|
72
|
+
`serve_static_files` is deprecated and will be removed in Rails 5.1.
|
73
|
+
Please use `public_file_server.enabled` instead.
|
74
|
+
eow
|
75
|
+
|
76
|
+
@public_file_server.enabled
|
77
|
+
end
|
78
|
+
|
79
|
+
def serve_static_files=(value)
|
80
|
+
ActiveSupport::Deprecation.warn <<-eow.strip_heredoc
|
81
|
+
`serve_static_files` is deprecated and will be removed in Rails 5.1.
|
82
|
+
Please use `public_file_server.enabled = #{value}` instead.
|
83
|
+
eow
|
84
|
+
|
85
|
+
@public_file_server.enabled = value
|
69
86
|
end
|
70
87
|
|
71
88
|
def encoding=(value)
|
@@ -76,6 +93,21 @@ module Rails
|
|
76
93
|
end
|
77
94
|
end
|
78
95
|
|
96
|
+
def api_only=(value)
|
97
|
+
@api_only = value
|
98
|
+
generators.api_only = value
|
99
|
+
|
100
|
+
@debug_exception_response_format ||= :api
|
101
|
+
end
|
102
|
+
|
103
|
+
def debug_exception_response_format
|
104
|
+
@debug_exception_response_format || :default
|
105
|
+
end
|
106
|
+
|
107
|
+
def debug_exception_response_format=(value)
|
108
|
+
@debug_exception_response_format = value
|
109
|
+
end
|
110
|
+
|
79
111
|
def paths
|
80
112
|
@paths ||= begin
|
81
113
|
paths = super
|
@@ -119,15 +151,6 @@ module Rails
|
|
119
151
|
raise e, "Cannot load `Rails.application.database_configuration`:\n#{e.message}", e.backtrace
|
120
152
|
end
|
121
153
|
|
122
|
-
def has_explicit_log_level? # :nodoc:
|
123
|
-
@has_explicit_log_level
|
124
|
-
end
|
125
|
-
|
126
|
-
def log_level=(level)
|
127
|
-
@has_explicit_log_level = !!(level)
|
128
|
-
@log_level = level
|
129
|
-
end
|
130
|
-
|
131
154
|
def log_level
|
132
155
|
@log_level ||= (Rails.env.production? ? :info : :debug)
|
133
156
|
end
|
@@ -141,25 +164,6 @@ module Rails
|
|
141
164
|
self.generators.colorize_logging = val
|
142
165
|
end
|
143
166
|
|
144
|
-
# :nodoc:
|
145
|
-
SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE = <<-MSG.squish
|
146
|
-
The configuration option `config.serve_static_assets` has been renamed
|
147
|
-
to `config.serve_static_files` to clarify its role (it merely enables
|
148
|
-
serving everything in the `public` folder and is unrelated to the asset
|
149
|
-
pipeline). The `serve_static_assets` alias will be removed in Rails 5.0.
|
150
|
-
Please migrate your configuration files accordingly.
|
151
|
-
MSG
|
152
|
-
|
153
|
-
def serve_static_assets
|
154
|
-
ActiveSupport::Deprecation.warn SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE
|
155
|
-
serve_static_files
|
156
|
-
end
|
157
|
-
|
158
|
-
def serve_static_assets=(value)
|
159
|
-
ActiveSupport::Deprecation.warn SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE
|
160
|
-
self.serve_static_files = value
|
161
|
-
end
|
162
|
-
|
163
167
|
def session_store(*args)
|
164
168
|
if args.empty?
|
165
169
|
case @session_store
|
@@ -187,26 +191,21 @@ module Rails
|
|
187
191
|
SourceAnnotationExtractor::Annotation
|
188
192
|
end
|
189
193
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
end
|
195
|
-
|
196
|
-
def method_missing(method, *args)
|
197
|
-
if method =~ /=$/
|
198
|
-
@configurations[$`.to_sym] = args.first
|
199
|
-
else
|
200
|
-
@configurations.fetch(method) {
|
201
|
-
@configurations[method] = ActiveSupport::OrderedOptions.new
|
202
|
-
}
|
203
|
-
end
|
204
|
-
end
|
194
|
+
class Custom #:nodoc:
|
195
|
+
def initialize
|
196
|
+
@configurations = Hash.new
|
197
|
+
end
|
205
198
|
|
206
|
-
|
207
|
-
|
199
|
+
def method_missing(method, *args)
|
200
|
+
if method =~ /=$/
|
201
|
+
@configurations[$`.to_sym] = args.first
|
202
|
+
else
|
203
|
+
@configurations.fetch(method) {
|
204
|
+
@configurations[method] = ActiveSupport::OrderedOptions.new
|
205
|
+
}
|
208
206
|
end
|
209
207
|
end
|
208
|
+
end
|
210
209
|
end
|
211
210
|
end
|
212
211
|
end
|