rails 2.1.2 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +27 -3
- data/Rakefile +70 -10
- data/bin/about +0 -0
- data/bin/console +0 -0
- data/bin/destroy +0 -0
- data/bin/generate +0 -0
- data/bin/performance/benchmarker +0 -0
- data/bin/performance/profiler +0 -0
- data/bin/performance/request +0 -0
- data/bin/plugin +0 -0
- data/bin/process/inspector +0 -0
- data/bin/process/reaper +0 -0
- data/bin/process/spawner +0 -0
- data/bin/runner +0 -0
- data/bin/server +0 -0
- data/config.ru +17 -0
- data/configs/apache.conf +0 -0
- data/configs/databases/ibm_db.yml +62 -0
- data/configs/databases/mysql.yml +3 -0
- data/configs/databases/postgresql.yml +3 -0
- data/configs/databases/sqlite2.yml +3 -0
- data/configs/databases/sqlite3.yml +3 -0
- data/configs/locales/en.yml +5 -0
- data/dispatches/dispatch.fcgi +1 -1
- data/dispatches/dispatch.rb +2 -2
- data/dispatches/gateway.cgi +2 -2
- data/doc/README_FOR_APP +5 -2
- data/doc/guides/html/2_2_release_notes.html +1185 -0
- data/doc/guides/html/actioncontroller_basics.html +1270 -0
- data/doc/guides/html/activerecord_validations_callbacks.html +749 -0
- data/doc/guides/html/association_basics.html +2585 -0
- data/doc/guides/html/authors.html +240 -0
- data/doc/guides/html/benchmarking_and_profiling.html +1018 -0
- data/doc/guides/html/caching_with_rails.html +583 -0
- data/doc/guides/html/command_line.html +434 -0
- data/doc/guides/html/configuring.html +438 -0
- data/doc/guides/html/creating_plugins.html +1594 -0
- data/doc/guides/html/debugging_rails_applications.html +1175 -0
- data/doc/guides/html/finders.html +1090 -0
- data/doc/guides/html/form_helpers.html +638 -0
- data/doc/guides/html/getting_started_with_rails.html +2066 -0
- data/doc/guides/html/index.html +349 -0
- data/doc/guides/html/layouts_and_rendering.html +1406 -0
- data/doc/guides/html/migrations.html +921 -0
- data/doc/guides/html/routing_outside_in.html +2213 -0
- data/doc/guides/html/security.html +1346 -0
- data/doc/guides/html/testing_rails_applications.html +1859 -0
- data/doc/guides/source/2_2_release_notes.txt +435 -0
- data/doc/guides/source/actioncontroller_basics/changelog.txt +5 -0
- data/doc/guides/source/actioncontroller_basics/cookies.txt +34 -0
- data/doc/guides/source/actioncontroller_basics/csrf.txt +32 -0
- data/doc/guides/source/actioncontroller_basics/filters.txt +119 -0
- data/doc/guides/source/actioncontroller_basics/http_auth.txt +24 -0
- data/doc/guides/source/actioncontroller_basics/index.txt +40 -0
- data/doc/guides/source/actioncontroller_basics/introduction.txt +9 -0
- data/doc/guides/source/actioncontroller_basics/methods.txt +39 -0
- data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +14 -0
- data/doc/guides/source/actioncontroller_basics/params.txt +93 -0
- data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +43 -0
- data/doc/guides/source/actioncontroller_basics/rescue.txt +67 -0
- data/doc/guides/source/actioncontroller_basics/session.txt +187 -0
- data/doc/guides/source/actioncontroller_basics/streaming.txt +91 -0
- data/doc/guides/source/actioncontroller_basics/verification.txt +40 -0
- data/doc/guides/source/active_record_basics.txt +181 -0
- data/doc/guides/source/activerecord_validations_callbacks.txt +404 -0
- data/doc/guides/source/association_basics.txt +1840 -0
- data/doc/guides/source/authors.txt +39 -0
- data/doc/guides/source/benchmarking_and_profiling/appendix.txt +95 -0
- data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +105 -0
- data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +185 -0
- data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +27 -0
- data/doc/guides/source/benchmarking_and_profiling/index.txt +242 -0
- data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +179 -0
- data/doc/guides/source/benchmarking_and_profiling/statistics.txt +57 -0
- data/doc/guides/source/caching_with_rails.txt +367 -0
- data/doc/guides/source/command_line.txt +147 -0
- data/doc/guides/source/configuring.txt +225 -0
- data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +191 -0
- data/doc/guides/source/creating_plugins/appendix.txt +46 -0
- data/doc/guides/source/creating_plugins/controllers.txt +59 -0
- data/doc/guides/source/creating_plugins/core_ext.txt +123 -0
- data/doc/guides/source/creating_plugins/custom_route.txt +69 -0
- data/doc/guides/source/creating_plugins/gem.txt +1 -0
- data/doc/guides/source/creating_plugins/generator_method.txt +89 -0
- data/doc/guides/source/creating_plugins/helpers.txt +51 -0
- data/doc/guides/source/creating_plugins/index.txt +52 -0
- data/doc/guides/source/creating_plugins/migration_generator.txt +156 -0
- data/doc/guides/source/creating_plugins/models.txt +76 -0
- data/doc/guides/source/creating_plugins/odds_and_ends.txt +69 -0
- data/doc/guides/source/creating_plugins/test_setup.txt +230 -0
- data/doc/guides/source/debugging_rails_applications.txt +733 -0
- data/doc/guides/source/finders.txt +668 -0
- data/doc/guides/source/form_helpers.txt +345 -0
- data/doc/guides/source/getting_started_with_rails.txt +1256 -0
- data/doc/guides/source/images/belongs_to.png +0 -0
- data/doc/guides/source/images/bullet.gif +0 -0
- data/doc/guides/source/images/csrf.png +0 -0
- data/doc/guides/source/images/habtm.png +0 -0
- data/doc/guides/source/images/has_many.png +0 -0
- data/doc/guides/source/images/has_many_through.png +0 -0
- data/doc/guides/source/images/has_one.png +0 -0
- data/doc/guides/source/images/has_one_through.png +0 -0
- data/doc/guides/source/images/header_backdrop.png +0 -0
- data/doc/guides/source/images/icons/README +5 -0
- data/doc/guides/source/images/icons/callouts/1.png +0 -0
- data/doc/guides/source/images/icons/callouts/10.png +0 -0
- data/doc/guides/source/images/icons/callouts/11.png +0 -0
- data/doc/guides/source/images/icons/callouts/12.png +0 -0
- data/doc/guides/source/images/icons/callouts/13.png +0 -0
- data/doc/guides/source/images/icons/callouts/14.png +0 -0
- data/doc/guides/source/images/icons/callouts/15.png +0 -0
- data/doc/guides/source/images/icons/callouts/2.png +0 -0
- data/doc/guides/source/images/icons/callouts/3.png +0 -0
- data/doc/guides/source/images/icons/callouts/4.png +0 -0
- data/doc/guides/source/images/icons/callouts/5.png +0 -0
- data/doc/guides/source/images/icons/callouts/6.png +0 -0
- data/doc/guides/source/images/icons/callouts/7.png +0 -0
- data/doc/guides/source/images/icons/callouts/8.png +0 -0
- data/doc/guides/source/images/icons/callouts/9.png +0 -0
- data/doc/guides/source/images/icons/caution.png +0 -0
- data/doc/guides/source/images/icons/example.png +0 -0
- data/doc/guides/source/images/icons/home.png +0 -0
- data/doc/guides/source/images/icons/important.png +0 -0
- data/doc/guides/source/images/icons/next.png +0 -0
- data/doc/guides/source/images/icons/note.png +0 -0
- data/doc/guides/source/images/icons/prev.png +0 -0
- data/doc/guides/source/images/icons/tip.png +0 -0
- data/doc/guides/source/images/icons/up.png +0 -0
- data/doc/guides/source/images/icons/warning.png +0 -0
- data/doc/guides/source/images/polymorphic.png +0 -0
- data/doc/guides/source/images/rails_logo_remix.gif +0 -0
- data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
- data/doc/guides/source/images/session_fixation.png +0 -0
- data/doc/guides/source/index.txt +118 -0
- data/doc/guides/source/layouts_and_rendering.txt +982 -0
- data/doc/guides/source/migrations/anatomy_of_a_migration.txt +85 -0
- data/doc/guides/source/migrations/changelog.txt +5 -0
- data/doc/guides/source/migrations/creating_a_migration.txt +109 -0
- data/doc/guides/source/migrations/foreign_keys.txt +8 -0
- data/doc/guides/source/migrations/index.txt +22 -0
- data/doc/guides/source/migrations/rakeing_around.txt +111 -0
- data/doc/guides/source/migrations/scheming.txt +47 -0
- data/doc/guides/source/migrations/using_models_in_migrations.txt +46 -0
- data/doc/guides/source/migrations/writing_a_migration.txt +159 -0
- data/doc/guides/source/routing_outside_in.txt +986 -0
- data/doc/guides/source/security.txt +984 -0
- data/doc/guides/source/stylesheets/base.css +358 -0
- data/doc/guides/source/stylesheets/forms.css +35 -0
- data/doc/guides/source/stylesheets/more.css +82 -0
- data/doc/guides/source/templates/guides.html.erb +97 -0
- data/doc/guides/source/templates/inline.css +165 -0
- data/doc/guides/source/testing_rails_applications.txt +995 -0
- data/environments/boot.rb +2 -2
- data/environments/environment.rb +9 -1
- data/environments/production.rb +3 -1
- data/helpers/performance_test.rb +9 -0
- data/html/500.html +4 -1
- data/html/javascripts/controls.js +72 -72
- data/html/javascripts/dragdrop.js +165 -164
- data/html/javascripts/effects.js +173 -165
- data/html/javascripts/prototype.js +362 -267
- data/lib/commands/console.rb +13 -0
- data/lib/commands/dbconsole.rb +2 -2
- data/lib/commands/ncgi/listener +2 -2
- data/lib/commands/ncgi/tracker +2 -2
- data/lib/commands/plugin.rb +41 -24
- data/lib/commands/process/spawner.rb +4 -4
- data/lib/commands/runner.rb +1 -1
- data/lib/commands/server.rb +11 -1
- data/lib/commands/servers/thin.rb +25 -0
- data/lib/fcgi_handler.rb +1 -3
- data/lib/initializer.rb +162 -39
- data/lib/performance_test_help.rb +5 -0
- data/lib/rails/gem_builder.rb +3 -3
- data/lib/rails/gem_dependency.rb +155 -33
- data/lib/rails/mongrel_server/commands.rb +1 -1
- data/lib/rails/plugin.rb +10 -2
- data/lib/rails/rack.rb +6 -0
- data/lib/rails/rack/logger.rb +28 -0
- data/lib/rails/rack/static.rb +35 -0
- data/lib/rails/vendor_gem_source_index.rb +140 -0
- data/lib/rails/version.rb +1 -1
- data/lib/rails_generator/commands.rb +10 -16
- data/lib/rails_generator/generated_attribute.rb +4 -0
- data/lib/rails_generator/generators/applications/app/app_generator.rb +9 -3
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +1 -1
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +1 -1
- data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +1 -1
- data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +2 -2
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +1 -1
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +2 -3
- data/lib/rails_generator/generators/components/model/model_generator.rb +1 -1
- data/lib/rails_generator/generators/components/model/templates/model.rb +3 -0
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +1 -1
- data/lib/rails_generator/generators/components/observer/observer_generator.rb +1 -1
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +1 -1
- data/lib/rails_generator/generators/components/performance_test/USAGE +8 -0
- data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +16 -0
- data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +9 -0
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +11 -11
- data/lib/rails_generator/generators/components/plugin/templates/Rakefile +1 -0
- data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +3 -0
- data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +4 -4
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +2 -2
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +1 -1
- data/lib/rails_generator/generators/components/scaffold/USAGE +9 -5
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +10 -3
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +7 -7
- data/lib/rails_generator/scripts.rb +1 -1
- data/lib/rails_generator/scripts/destroy.rb +6 -7
- data/lib/rails_generator/secret_key_generator.rb +5 -147
- data/lib/tasks/annotations.rake +8 -11
- data/lib/tasks/databases.rake +42 -15
- data/lib/tasks/documentation.rake +15 -0
- data/lib/tasks/framework.rake +5 -1
- data/lib/tasks/gems.rake +24 -8
- data/lib/tasks/misc.rake +3 -4
- data/lib/tasks/testing.rake +25 -4
- data/lib/test_help.rb +1 -2
- data/lib/webrick_server.rb +2 -11
- metadata +165 -9
data/lib/commands/console.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
+
|
4
5
|
options = { :sandbox => false, :irb => irb }
|
5
6
|
OptionParser.new do |opt|
|
6
7
|
opt.banner = "Usage: console [environment] [options]"
|
7
8
|
opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
|
8
9
|
opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
|
10
|
+
opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
|
9
11
|
opt.parse!(ARGV)
|
10
12
|
end
|
11
13
|
|
@@ -15,6 +17,17 @@ libs << " -r console_app"
|
|
15
17
|
libs << " -r console_sandbox" if options[:sandbox]
|
16
18
|
libs << " -r console_with_helpers"
|
17
19
|
|
20
|
+
if options[:debugger]
|
21
|
+
begin
|
22
|
+
require 'ruby-debug'
|
23
|
+
libs << " -r ruby-debug"
|
24
|
+
puts "=> Debugger enabled"
|
25
|
+
rescue Exception
|
26
|
+
puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
18
31
|
ENV['RAILS_ENV'] = case ARGV.first
|
19
32
|
when "p"; "production"
|
20
33
|
when "d"; "development"
|
data/lib/commands/dbconsole.rb
CHANGED
@@ -6,7 +6,7 @@ include_password = false
|
|
6
6
|
|
7
7
|
OptionParser.new do |opt|
|
8
8
|
opt.banner = "Usage: dbconsole [options] [environment]"
|
9
|
-
opt.on("-p", "--include-password", "Automatically provide the
|
9
|
+
opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v|
|
10
10
|
include_password = true
|
11
11
|
end
|
12
12
|
opt.parse!(ARGV)
|
@@ -47,7 +47,7 @@ when "mysql"
|
|
47
47
|
|
48
48
|
args << config['database']
|
49
49
|
|
50
|
-
exec(find_cmd('
|
50
|
+
exec(find_cmd('mysql', 'mysql5'), *args)
|
51
51
|
|
52
52
|
when "postgresql"
|
53
53
|
ENV['PGUSER'] = config["username"] if config["username"]
|
data/lib/commands/ncgi/listener
CHANGED
data/lib/commands/ncgi/tracker
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'drb'
|
4
4
|
require 'thread'
|
@@ -66,4 +66,4 @@ end
|
|
66
66
|
socket_path = ARGV.shift
|
67
67
|
instances = ARGV.shift.to_i
|
68
68
|
t = Tracker.new(instances, socket_path)
|
69
|
-
t.background(ARGV.first ? ARGV.shift.to_i : 90)
|
69
|
+
t.background(ARGV.first ? ARGV.shift.to_i : 90)
|
data/lib/commands/plugin.rb
CHANGED
@@ -43,6 +43,16 @@
|
|
43
43
|
# plugin is pulled via `svn checkout` or `svn export` but looks
|
44
44
|
# exactly the same.
|
45
45
|
#
|
46
|
+
# Specifying revisions:
|
47
|
+
#
|
48
|
+
# * Subversion revision is a single integer.
|
49
|
+
#
|
50
|
+
# * Git revision format:
|
51
|
+
# - full - 'refs/tags/1.8.0' or 'refs/heads/experimental'
|
52
|
+
# - short: 'experimental' (equivalent to 'refs/heads/experimental')
|
53
|
+
# 'tag 1.8.0' (equivalent to 'refs/tags/1.8.0')
|
54
|
+
#
|
55
|
+
#
|
46
56
|
# This is Free Software, copyright 2005 by Ryan Tomayko (rtomayko@gmail.com)
|
47
57
|
# and is licensed MIT: (http://www.opensource.org/licenses/mit-license.php)
|
48
58
|
|
@@ -175,7 +185,7 @@ class Plugin
|
|
175
185
|
method ||= rails_env.best_install_method?
|
176
186
|
if :http == method
|
177
187
|
method = :export if svn_url?
|
178
|
-
method = :
|
188
|
+
method = :git if git_url?
|
179
189
|
end
|
180
190
|
|
181
191
|
uninstall if installed? and options[:force]
|
@@ -255,8 +265,25 @@ class Plugin
|
|
255
265
|
end
|
256
266
|
end
|
257
267
|
|
258
|
-
def
|
259
|
-
|
268
|
+
def install_using_git(options = {})
|
269
|
+
root = rails_env.root
|
270
|
+
install_path = mkdir_p "#{root}/vendor/plugins/#{name}"
|
271
|
+
Dir.chdir install_path do
|
272
|
+
init_cmd = "git init"
|
273
|
+
init_cmd += " -q" if options[:quiet] and not $verbose
|
274
|
+
puts init_cmd if $verbose
|
275
|
+
system(init_cmd)
|
276
|
+
base_cmd = "git pull --depth 1 #{uri}"
|
277
|
+
base_cmd += " -q" if options[:quiet] and not $verbose
|
278
|
+
base_cmd += " #{options[:revision]}" if options[:revision]
|
279
|
+
puts base_cmd if $verbose
|
280
|
+
if system(base_cmd)
|
281
|
+
puts "removing: .git" if $verbose
|
282
|
+
rm_rf ".git"
|
283
|
+
else
|
284
|
+
rm_rf install_path
|
285
|
+
end
|
286
|
+
end
|
260
287
|
end
|
261
288
|
|
262
289
|
def svn_command(cmd, options = {})
|
@@ -268,16 +295,6 @@ class Plugin
|
|
268
295
|
puts base_cmd if $verbose
|
269
296
|
system(base_cmd)
|
270
297
|
end
|
271
|
-
|
272
|
-
def git_command(cmd, options = {})
|
273
|
-
root = rails_env.root
|
274
|
-
mkdir_p "#{root}/vendor/plugins"
|
275
|
-
base_cmd = "git #{cmd} --depth 1 #{uri} \"#{root}/vendor/plugins/#{name}\""
|
276
|
-
puts base_cmd if $verbose
|
277
|
-
puts "removing: #{root}/vendor/plugins/#{name}/.git"
|
278
|
-
system(base_cmd)
|
279
|
-
rm_rf "#{root}/vendor/plugins/#{name}/.git"
|
280
|
-
end
|
281
298
|
|
282
299
|
def guess_name(url)
|
283
300
|
@name = File.basename(url)
|
@@ -444,11 +461,11 @@ module Commands
|
|
444
461
|
|
445
462
|
o.on("-r", "--root=DIR", String,
|
446
463
|
"Set an explicit rails app directory.",
|
447
|
-
"Default: #{@rails_root}") {
|
464
|
+
"Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) }
|
448
465
|
o.on("-s", "--source=URL1,URL2", Array,
|
449
|
-
"Use the specified plugin repositories instead of the defaults.") {
|
466
|
+
"Use the specified plugin repositories instead of the defaults.") { |sources| @sources = sources}
|
450
467
|
|
451
|
-
o.on("-v", "--verbose", "Turn on verbose output.") {
|
468
|
+
o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose }
|
452
469
|
o.on("-h", "--help", "Show this help message.") { puts o; exit }
|
453
470
|
|
454
471
|
o.separator ""
|
@@ -535,12 +552,12 @@ module Commands
|
|
535
552
|
o.separator "Options:"
|
536
553
|
o.separator ""
|
537
554
|
o.on( "-s", "--source=URL1,URL2", Array,
|
538
|
-
"Use the specified plugin repositories.") {
|
555
|
+
"Use the specified plugin repositories.") {|sources| @sources = sources}
|
539
556
|
o.on( "--local",
|
540
|
-
"List locally installed plugins.") {
|
557
|
+
"List locally installed plugins.") {|local| @local, @remote = local, false}
|
541
558
|
o.on( "--remote",
|
542
559
|
"List remotely available plugins. This is the default behavior",
|
543
|
-
"unless --local is provided.") {
|
560
|
+
"unless --local is provided.") {|remote| @remote = remote}
|
544
561
|
end
|
545
562
|
end
|
546
563
|
|
@@ -581,7 +598,7 @@ module Commands
|
|
581
598
|
o.separator "Options:"
|
582
599
|
o.separator ""
|
583
600
|
o.on( "-c", "--check",
|
584
|
-
"Report status of repository.") {
|
601
|
+
"Report status of repository.") { |sources| @sources = sources}
|
585
602
|
end
|
586
603
|
end
|
587
604
|
|
@@ -672,7 +689,7 @@ module Commands
|
|
672
689
|
o.separator "Options:"
|
673
690
|
o.separator ""
|
674
691
|
o.on( "-l", "--list",
|
675
|
-
"List but don't prompt or add discovered repositories.") {
|
692
|
+
"List but don't prompt or add discovered repositories.") { |list| @list, @prompt = list, !@list }
|
676
693
|
o.on( "-n", "--no-prompt",
|
677
694
|
"Add all new repositories without prompting.") { |v| @prompt = !v }
|
678
695
|
end
|
@@ -756,8 +773,8 @@ module Commands
|
|
756
773
|
"Suppresses the output from installation.",
|
757
774
|
"Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true }
|
758
775
|
o.on( "-r REVISION", "--revision REVISION",
|
759
|
-
"Checks out the given revision from subversion.",
|
760
|
-
"Ignored if subversion is not used.") { |v| @options[:revision] = v }
|
776
|
+
"Checks out the given revision from subversion or git.",
|
777
|
+
"Ignored if subversion/git is not used.") { |v| @options[:revision] = v }
|
761
778
|
o.on( "-f", "--force",
|
762
779
|
"Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true }
|
763
780
|
o.separator ""
|
@@ -884,7 +901,7 @@ class RecursiveHTTPFetcher
|
|
884
901
|
def initialize(urls_to_fetch, level = 1, cwd = ".")
|
885
902
|
@level = level
|
886
903
|
@cwd = cwd
|
887
|
-
@urls_to_fetch = urls_to_fetch.to_a
|
904
|
+
@urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a
|
888
905
|
@quiet = false
|
889
906
|
end
|
890
907
|
|
@@ -66,9 +66,9 @@ class MongrelSpawner < Spawner
|
|
66
66
|
"-l #{OPTIONS[:rails_root]}/log/mongrel.log"
|
67
67
|
|
68
68
|
# Add prefix functionality to spawner's call to mongrel_rails
|
69
|
-
# Digging through
|
69
|
+
# Digging through mongrel's project subversion server, the earliest
|
70
70
|
# Tag that has prefix implemented in the bin/mongrel_rails file
|
71
|
-
# is 0.3.15 which also happens to be the
|
71
|
+
# is 0.3.15 which also happens to be the earliest tag listed.
|
72
72
|
# References: http://mongrel.rubyforge.org/svn/tags
|
73
73
|
if Mongrel::Const::MONGREL_VERSION.to_f >=0.3 && !OPTIONS[:prefix].nil?
|
74
74
|
cmd = cmd + " --prefix #{OPTIONS[:prefix]}"
|
@@ -181,10 +181,10 @@ ARGV.options do |opts|
|
|
181
181
|
|
182
182
|
opts.on(" Options:")
|
183
183
|
|
184
|
-
opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |OPTIONS[:port]
|
184
|
+
opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |v| OPTIONS[:port] = v }
|
185
185
|
|
186
186
|
if spawner_class.can_bind_to_custom_address?
|
187
|
-
opts.on("-a", "--address=ip", String, "Bind to IP address (default: #{OPTIONS[:address]})") { |OPTIONS[:address]
|
187
|
+
opts.on("-a", "--address=ip", String, "Bind to IP address (default: #{OPTIONS[:address]})") { |v| OPTIONS[:address] = v }
|
188
188
|
end
|
189
189
|
|
190
190
|
opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |v| OPTIONS[:port] = v }
|
data/lib/commands/runner.rb
CHANGED
data/lib/commands/server.rb
CHANGED
@@ -13,12 +13,20 @@ rescue Exception
|
|
13
13
|
# Mongrel not available
|
14
14
|
end
|
15
15
|
|
16
|
+
begin
|
17
|
+
require_library_or_gem 'thin'
|
18
|
+
rescue Exception
|
19
|
+
# Thin not available
|
20
|
+
end
|
21
|
+
|
16
22
|
server = case ARGV.first
|
17
|
-
when "lighttpd", "mongrel", "new_mongrel", "webrick"
|
23
|
+
when "lighttpd", "mongrel", "new_mongrel", "webrick", "thin"
|
18
24
|
ARGV.shift
|
19
25
|
else
|
20
26
|
if defined?(Mongrel)
|
21
27
|
"mongrel"
|
28
|
+
elsif defined?(Thin)
|
29
|
+
"thin"
|
22
30
|
elsif RUBY_PLATFORM !~ /(:?mswin|mingw)/ && !silence_stderr { `lighttpd -version` }.blank? && defined?(FCGI)
|
23
31
|
"lighttpd"
|
24
32
|
else
|
@@ -33,6 +41,8 @@ case server
|
|
33
41
|
puts "=> Booting lighttpd (use 'script/server webrick' to force WEBrick)"
|
34
42
|
when "mongrel", "new_mongrel"
|
35
43
|
puts "=> Booting Mongrel (use 'script/server webrick' to force WEBrick)"
|
44
|
+
when "thin"
|
45
|
+
puts "=> Booting Thin (use 'script/server webrick' to force WEBrick)"
|
36
46
|
end
|
37
47
|
|
38
48
|
%w(cache pids sessions sockets).each { |dir_to_make| FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make)) }
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'commands/servers/base'
|
3
|
+
require 'thin'
|
4
|
+
|
5
|
+
|
6
|
+
options = ARGV.clone
|
7
|
+
options.insert(0,'start') unless Thin::Runner.commands.include?(options[0])
|
8
|
+
|
9
|
+
thin = Thin::Runner.new(options)
|
10
|
+
|
11
|
+
puts "=> Rails #{Rails.version} application starting on http://#{thin.options[:address]}:#{thin.options[:port]}"
|
12
|
+
puts "=> Ctrl-C to shutdown server"
|
13
|
+
|
14
|
+
log = Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath
|
15
|
+
open(log, (File::WRONLY | File::APPEND | File::CREAT)) unless File.exist? log
|
16
|
+
tail_thread = tail(log)
|
17
|
+
trap(:INT) { exit }
|
18
|
+
|
19
|
+
begin
|
20
|
+
thin.run!
|
21
|
+
ensure
|
22
|
+
tail_thread.kill if tail_thread
|
23
|
+
puts 'Exiting'
|
24
|
+
end
|
25
|
+
|
data/lib/fcgi_handler.rb
CHANGED
@@ -18,7 +18,6 @@ class RailsFCGIHandler
|
|
18
18
|
attr_accessor :log_file_path
|
19
19
|
attr_accessor :gc_request_period
|
20
20
|
|
21
|
-
|
22
21
|
# Initialize and run the FastCGI instance, passing arguments through to new.
|
23
22
|
def self.process!(*args, &block)
|
24
23
|
new(*args, &block).process!
|
@@ -68,7 +67,6 @@ class RailsFCGIHandler
|
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
71
|
-
|
72
70
|
protected
|
73
71
|
def process_each_request(provider)
|
74
72
|
cgi = nil
|
@@ -197,7 +195,7 @@ class RailsFCGIHandler
|
|
197
195
|
# close resources as they won't be closed by
|
198
196
|
# the OS when using exec
|
199
197
|
logger.close rescue nil
|
200
|
-
|
198
|
+
Rails.logger.close rescue nil
|
201
199
|
|
202
200
|
exec(command_line)
|
203
201
|
end
|
data/lib/initializer.rb
CHANGED
@@ -8,6 +8,7 @@ require 'rails/version'
|
|
8
8
|
require 'rails/plugin/locator'
|
9
9
|
require 'rails/plugin/loader'
|
10
10
|
require 'rails/gem_dependency'
|
11
|
+
require 'rails/rack'
|
11
12
|
|
12
13
|
|
13
14
|
RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV)
|
@@ -18,15 +19,27 @@ module Rails
|
|
18
19
|
def configuration
|
19
20
|
@@configuration
|
20
21
|
end
|
21
|
-
|
22
|
+
|
22
23
|
def configuration=(configuration)
|
23
24
|
@@configuration = configuration
|
24
25
|
end
|
25
|
-
|
26
|
+
|
27
|
+
def initialized?
|
28
|
+
@initialized || false
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialized=(initialized)
|
32
|
+
@initialized ||= initialized
|
33
|
+
end
|
34
|
+
|
26
35
|
def logger
|
27
|
-
RAILS_DEFAULT_LOGGER
|
36
|
+
if defined?(RAILS_DEFAULT_LOGGER)
|
37
|
+
RAILS_DEFAULT_LOGGER
|
38
|
+
else
|
39
|
+
nil
|
40
|
+
end
|
28
41
|
end
|
29
|
-
|
42
|
+
|
30
43
|
def root
|
31
44
|
if defined?(RAILS_ROOT)
|
32
45
|
RAILS_ROOT
|
@@ -34,12 +47,14 @@ module Rails
|
|
34
47
|
nil
|
35
48
|
end
|
36
49
|
end
|
37
|
-
|
50
|
+
|
38
51
|
def env
|
39
|
-
|
40
|
-
|
52
|
+
@_env ||= begin
|
53
|
+
require 'active_support/string_inquirer'
|
54
|
+
ActiveSupport::StringInquirer.new(RAILS_ENV)
|
55
|
+
end
|
41
56
|
end
|
42
|
-
|
57
|
+
|
43
58
|
def cache
|
44
59
|
RAILS_CACHE
|
45
60
|
end
|
@@ -56,7 +71,7 @@ module Rails
|
|
56
71
|
@@public_path = path
|
57
72
|
end
|
58
73
|
end
|
59
|
-
|
74
|
+
|
60
75
|
# The Initializer is responsible for processing the Rails configuration, such
|
61
76
|
# as setting the $LOAD_PATH, requiring the right frameworks, initializing
|
62
77
|
# logging, and more. It can be run either as a single command that'll just
|
@@ -90,7 +105,7 @@ module Rails
|
|
90
105
|
# Rails::Initializer.run(:set_load_path)
|
91
106
|
#
|
92
107
|
# This is useful if you only want the load path initialized, without
|
93
|
-
#
|
108
|
+
# incurring the overhead of completely loading the entire environment.
|
94
109
|
def self.run(command = :process, configuration = Configuration.new)
|
95
110
|
yield configuration if block_given?
|
96
111
|
initializer = new configuration
|
@@ -129,12 +144,15 @@ module Rails
|
|
129
144
|
initialize_logger
|
130
145
|
initialize_framework_logging
|
131
146
|
|
132
|
-
initialize_framework_views
|
133
147
|
initialize_dependency_mechanism
|
134
148
|
initialize_whiny_nils
|
135
149
|
initialize_temporary_session_directory
|
150
|
+
|
136
151
|
initialize_time_zone
|
152
|
+
initialize_i18n
|
153
|
+
|
137
154
|
initialize_framework_settings
|
155
|
+
initialize_framework_views
|
138
156
|
|
139
157
|
add_support_load_paths
|
140
158
|
|
@@ -145,7 +163,7 @@ module Rails
|
|
145
163
|
add_gem_load_paths
|
146
164
|
load_gems
|
147
165
|
check_gem_dependencies
|
148
|
-
|
166
|
+
|
149
167
|
load_application_initializers
|
150
168
|
|
151
169
|
# the framework is now fully initialized
|
@@ -158,8 +176,19 @@ module Rails
|
|
158
176
|
initialize_routing
|
159
177
|
|
160
178
|
# Observers are loaded after plugins in case Observers or observed models are modified by plugins.
|
161
|
-
|
162
179
|
load_observers
|
180
|
+
|
181
|
+
# Load view path cache
|
182
|
+
load_view_paths
|
183
|
+
|
184
|
+
# Load application classes
|
185
|
+
load_application_classes
|
186
|
+
|
187
|
+
# Disable dependency loading during request cycle
|
188
|
+
disable_dependency_loading
|
189
|
+
|
190
|
+
# Flag initialized
|
191
|
+
Rails.initialized = true
|
163
192
|
end
|
164
193
|
|
165
194
|
# Check for valid Ruby version
|
@@ -188,6 +217,7 @@ module Rails
|
|
188
217
|
Gem.loaded_specs[stub] = Gem::Specification.new do |s|
|
189
218
|
s.name = stub
|
190
219
|
s.version = Rails::VERSION::STRING
|
220
|
+
s.loaded_from = ""
|
191
221
|
end
|
192
222
|
end
|
193
223
|
end
|
@@ -240,6 +270,7 @@ module Rails
|
|
240
270
|
end
|
241
271
|
|
242
272
|
def add_gem_load_paths
|
273
|
+
Rails::GemDependency.add_frozen_gem_path
|
243
274
|
unless @configuration.gems.empty?
|
244
275
|
require "rubygems"
|
245
276
|
@configuration.gems.each { |gem| gem.add_load_paths }
|
@@ -302,12 +333,12 @@ Run `rake gems:install` to install the missing gems.
|
|
302
333
|
silence_warnings do
|
303
334
|
return if @environment_loaded
|
304
335
|
@environment_loaded = true
|
305
|
-
|
336
|
+
|
306
337
|
config = configuration
|
307
338
|
constants = self.class.constants
|
308
|
-
|
339
|
+
|
309
340
|
eval(IO.read(configuration.environment_path), binding, configuration.environment_path)
|
310
|
-
|
341
|
+
|
311
342
|
(self.class.constants - constants).each do |const|
|
312
343
|
Object.const_set(const, self.class.const_get(const))
|
313
344
|
end
|
@@ -320,6 +351,26 @@ Run `rake gems:install` to install the missing gems.
|
|
320
351
|
end
|
321
352
|
end
|
322
353
|
|
354
|
+
def load_view_paths
|
355
|
+
if configuration.frameworks.include?(:action_view)
|
356
|
+
ActionView::PathSet::Path.eager_load_templates! if configuration.cache_classes
|
357
|
+
ActionController::Base.view_paths.load if configuration.frameworks.include?(:action_controller)
|
358
|
+
ActionMailer::Base.template_root.load if configuration.frameworks.include?(:action_mailer)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
# Eager load application classes
|
363
|
+
def load_application_classes
|
364
|
+
if configuration.cache_classes
|
365
|
+
configuration.eager_load_paths.each do |load_path|
|
366
|
+
matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/
|
367
|
+
Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
|
368
|
+
require_dependency file.sub(matcher, '\1')
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
323
374
|
# For Ruby 1.8, this initialization sets $KCODE to 'u' to enable the
|
324
375
|
# multibyte safe operations. Plugin authors supporting other encodings
|
325
376
|
# should override this behaviour and set the relevant +default_charset+
|
@@ -364,7 +415,7 @@ Run `rake gems:install` to install the missing gems.
|
|
364
415
|
# +STDERR+, with a log level of +WARN+.
|
365
416
|
def initialize_logger
|
366
417
|
# if the environment has explicitly defined a logger, use it
|
367
|
-
return if
|
418
|
+
return if Rails.logger
|
368
419
|
|
369
420
|
unless logger = configuration.logger
|
370
421
|
begin
|
@@ -372,7 +423,6 @@ Run `rake gems:install` to install the missing gems.
|
|
372
423
|
logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase)
|
373
424
|
if configuration.environment == "production"
|
374
425
|
logger.auto_flushing = false
|
375
|
-
logger.set_non_blocking_io
|
376
426
|
end
|
377
427
|
rescue StandardError => e
|
378
428
|
logger = ActiveSupport::BufferedLogger.new(STDERR)
|
@@ -393,10 +443,11 @@ Run `rake gems:install` to install the missing gems.
|
|
393
443
|
# RAILS_DEFAULT_LOGGER.
|
394
444
|
def initialize_framework_logging
|
395
445
|
for framework in ([ :active_record, :action_controller, :action_mailer ] & configuration.frameworks)
|
396
|
-
framework.to_s.camelize.constantize.const_get("Base").logger ||=
|
446
|
+
framework.to_s.camelize.constantize.const_get("Base").logger ||= Rails.logger
|
397
447
|
end
|
398
|
-
|
399
|
-
|
448
|
+
|
449
|
+
ActiveSupport::Dependencies.logger ||= Rails.logger
|
450
|
+
Rails.cache.logger ||= Rails.logger
|
400
451
|
end
|
401
452
|
|
402
453
|
# Sets +ActionController::Base#view_paths+ and +ActionMailer::Base#template_root+
|
@@ -404,8 +455,11 @@ Run `rake gems:install` to install the missing gems.
|
|
404
455
|
# paths have already been set, it is not changed, otherwise it is
|
405
456
|
# set to use Configuration#view_path.
|
406
457
|
def initialize_framework_views
|
407
|
-
|
408
|
-
|
458
|
+
if configuration.frameworks.include?(:action_view)
|
459
|
+
view_path = ActionView::PathSet::Path.new(configuration.view_path, false)
|
460
|
+
ActionMailer::Base.template_root ||= view_path if configuration.frameworks.include?(:action_mailer)
|
461
|
+
ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.empty?
|
462
|
+
end
|
409
463
|
end
|
410
464
|
|
411
465
|
# If Action Controller is not one of the loaded frameworks (Configuration#frameworks)
|
@@ -441,7 +495,7 @@ Run `rake gems:install` to install the missing gems.
|
|
441
495
|
# If assigned value cannot be matched to a TimeZone, an exception will be raised.
|
442
496
|
def initialize_time_zone
|
443
497
|
if configuration.time_zone
|
444
|
-
zone_default = Time.
|
498
|
+
zone_default = Time.__send__(:get_zone, configuration.time_zone)
|
445
499
|
unless zone_default
|
446
500
|
raise %{Value assigned to config.time_zone not recognized. Run "rake -D time" for a list of tasks for finding appropriate time zone names.}
|
447
501
|
end
|
@@ -453,6 +507,18 @@ Run `rake gems:install` to install the missing gems.
|
|
453
507
|
end
|
454
508
|
end
|
455
509
|
|
510
|
+
# Set the i18n configuration from config.i18n but special-case for the load_path which should be
|
511
|
+
# appended to what's already set instead of overwritten.
|
512
|
+
def initialize_i18n
|
513
|
+
configuration.i18n.each do |setting, value|
|
514
|
+
if setting == :load_path
|
515
|
+
I18n.load_path += value
|
516
|
+
else
|
517
|
+
I18n.send("#{setting}=", value)
|
518
|
+
end
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
456
522
|
# Initializes framework-specific settings for each of the loaded frameworks
|
457
523
|
# (Configuration#frameworks). The available settings map to the accessors
|
458
524
|
# on each of the corresponding Base classes.
|
@@ -490,9 +556,14 @@ Run `rake gems:install` to install the missing gems.
|
|
490
556
|
return unless configuration.frameworks.include?(:action_controller)
|
491
557
|
require 'dispatcher' unless defined?(::Dispatcher)
|
492
558
|
Dispatcher.define_dispatcher_callbacks(configuration.cache_classes)
|
493
|
-
Dispatcher.new(
|
559
|
+
Dispatcher.new(Rails.logger).send :run_callbacks, :prepare_dispatch
|
494
560
|
end
|
495
561
|
|
562
|
+
def disable_dependency_loading
|
563
|
+
if configuration.cache_classes && !configuration.dependency_loading
|
564
|
+
ActiveSupport::Dependencies.unhook!
|
565
|
+
end
|
566
|
+
end
|
496
567
|
end
|
497
568
|
|
498
569
|
# The Configuration class holds all the parameters for the Initializer and
|
@@ -520,7 +591,7 @@ Run `rake gems:install` to install the missing gems.
|
|
520
591
|
# A stub for setting options on ActiveRecord::Base.
|
521
592
|
attr_accessor :active_record
|
522
593
|
|
523
|
-
# A stub for setting options on
|
594
|
+
# A stub for setting options on ActiveResource::Base.
|
524
595
|
attr_accessor :active_resource
|
525
596
|
|
526
597
|
# A stub for setting options on ActiveSupport.
|
@@ -537,7 +608,7 @@ Run `rake gems:install` to install the missing gems.
|
|
537
608
|
# The path to the database configuration file to use. (Defaults to
|
538
609
|
# <tt>config/database.yml</tt>.)
|
539
610
|
attr_accessor :database_configuration_file
|
540
|
-
|
611
|
+
|
541
612
|
# The path to the routes configuration file to use. (Defaults to
|
542
613
|
# <tt>config/routes.rb</tt>.)
|
543
614
|
attr_accessor :routes_configuration_file
|
@@ -556,6 +627,11 @@ Run `rake gems:install` to install the missing gems.
|
|
556
627
|
# All elements of this array must also be in +load_paths+.
|
557
628
|
attr_accessor :load_once_paths
|
558
629
|
|
630
|
+
# An array of paths from which Rails will eager load on boot if cache
|
631
|
+
# classes is enabled. All elements of this array must also be in
|
632
|
+
# +load_paths+.
|
633
|
+
attr_accessor :eager_load_paths
|
634
|
+
|
559
635
|
# The log level to use for the default Rails logger. In production mode,
|
560
636
|
# this defaults to <tt>:info</tt>. In development mode, it defaults to
|
561
637
|
# <tt>:debug</tt>.
|
@@ -603,7 +679,7 @@ Run `rake gems:install` to install the missing gems.
|
|
603
679
|
# a sub class would have access to fine grained modification of the loading behavior. See
|
604
680
|
# the implementation of Rails::Plugin::Loader for more details.
|
605
681
|
attr_accessor :plugin_loader
|
606
|
-
|
682
|
+
|
607
683
|
# Enables or disables plugin reloading. You can get around this setting per plugin.
|
608
684
|
# If <tt>reload_plugins?</tt> is false, add this to your plugin's <tt>init.rb</tt>
|
609
685
|
# to make it reloadable:
|
@@ -622,6 +698,17 @@ Run `rake gems:install` to install the missing gems.
|
|
622
698
|
!!@reload_plugins
|
623
699
|
end
|
624
700
|
|
701
|
+
# Enables or disables dependency loading during the request cycle. Setting
|
702
|
+
# <tt>dependency_loading</tt> to true will allow new classes to be loaded
|
703
|
+
# during a request. Setting it to false will disable this behavior.
|
704
|
+
#
|
705
|
+
# Those who want to run in a threaded environment should disable this
|
706
|
+
# option and eager load or require all there classes on initialization.
|
707
|
+
#
|
708
|
+
# If <tt>cache_classes</tt> is disabled, dependency loaded will always be
|
709
|
+
# on.
|
710
|
+
attr_accessor :dependency_loading
|
711
|
+
|
625
712
|
# An array of gems that this rails application depends on. Rails will automatically load
|
626
713
|
# these gems during installation, and allow you to install any missing gems with:
|
627
714
|
#
|
@@ -644,7 +731,7 @@ Run `rake gems:install` to install the missing gems.
|
|
644
731
|
def gem(name, options = {})
|
645
732
|
@gems << Rails::GemDependency.new(name, options)
|
646
733
|
end
|
647
|
-
|
734
|
+
|
648
735
|
# Deprecated options:
|
649
736
|
def breakpoint_server(_ = nil)
|
650
737
|
$stderr.puts %(
|
@@ -660,6 +747,9 @@ Run `rake gems:install` to install the missing gems.
|
|
660
747
|
# timezone to <tt>:utc</tt>.
|
661
748
|
attr_accessor :time_zone
|
662
749
|
|
750
|
+
# Accessor for i18n settings.
|
751
|
+
attr_accessor :i18n
|
752
|
+
|
663
753
|
# Create a new Configuration instance, initialized with the default
|
664
754
|
# values.
|
665
755
|
def initialize
|
@@ -668,11 +758,13 @@ Run `rake gems:install` to install the missing gems.
|
|
668
758
|
self.frameworks = default_frameworks
|
669
759
|
self.load_paths = default_load_paths
|
670
760
|
self.load_once_paths = default_load_once_paths
|
761
|
+
self.eager_load_paths = default_eager_load_paths
|
671
762
|
self.log_path = default_log_path
|
672
763
|
self.log_level = default_log_level
|
673
764
|
self.view_path = default_view_path
|
674
765
|
self.controller_paths = default_controller_paths
|
675
766
|
self.cache_classes = default_cache_classes
|
767
|
+
self.dependency_loading = default_dependency_loading
|
676
768
|
self.whiny_nils = default_whiny_nils
|
677
769
|
self.plugins = default_plugins
|
678
770
|
self.plugin_paths = default_plugin_paths
|
@@ -681,6 +773,7 @@ Run `rake gems:install` to install the missing gems.
|
|
681
773
|
self.database_configuration_file = default_database_configuration_file
|
682
774
|
self.routes_configuration_file = default_routes_configuration_file
|
683
775
|
self.gems = default_gems
|
776
|
+
self.i18n = default_i18n
|
684
777
|
|
685
778
|
for framework in default_frameworks
|
686
779
|
self.send("#{framework}=", Rails::OrderedOptions.new)
|
@@ -703,11 +796,21 @@ Run `rake gems:install` to install the missing gems.
|
|
703
796
|
else
|
704
797
|
Pathname.new(::RAILS_ROOT).realpath.to_s
|
705
798
|
end
|
706
|
-
|
799
|
+
|
707
800
|
Object.const_set(:RELATIVE_RAILS_ROOT, ::RAILS_ROOT.dup) unless defined?(::RELATIVE_RAILS_ROOT)
|
708
801
|
::RAILS_ROOT.replace @root_path
|
709
802
|
end
|
710
803
|
|
804
|
+
# Enable threaded mode. Allows concurrent requests to controller actions and
|
805
|
+
# multiple database connections. Also disables automatic dependency loading
|
806
|
+
# after boot
|
807
|
+
def threadsafe!
|
808
|
+
self.cache_classes = true
|
809
|
+
self.dependency_loading = false
|
810
|
+
self.action_controller.allow_concurrency = true
|
811
|
+
self
|
812
|
+
end
|
813
|
+
|
711
814
|
# Loads and returns the contents of the #database_configuration_file. The
|
712
815
|
# contents of the file are processed via ERB before being sent through
|
713
816
|
# YAML::load.
|
@@ -745,7 +848,7 @@ Run `rake gems:install` to install the missing gems.
|
|
745
848
|
#
|
746
849
|
# See Dispatcher#to_prepare.
|
747
850
|
def to_prepare(&callback)
|
748
|
-
after_initialize do
|
851
|
+
after_initialize do
|
749
852
|
require 'dispatcher' unless defined?(::Dispatcher)
|
750
853
|
Dispatcher.to_prepare(&callback)
|
751
854
|
end
|
@@ -759,11 +862,11 @@ Run `rake gems:install` to install the missing gems.
|
|
759
862
|
def framework_paths
|
760
863
|
paths = %w(railties railties/lib activesupport/lib)
|
761
864
|
paths << 'actionpack/lib' if frameworks.include? :action_controller or frameworks.include? :action_view
|
762
|
-
|
865
|
+
|
763
866
|
[:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework|
|
764
867
|
paths << "#{framework.to_s.gsub('_', '')}/lib" if frameworks.include? framework
|
765
868
|
end
|
766
|
-
|
869
|
+
|
767
870
|
paths.map { |dir| "#{framework_root_path}/#{dir}" }.select { |dir| File.directory?(dir) }
|
768
871
|
end
|
769
872
|
|
@@ -778,7 +881,7 @@ Run `rake gems:install` to install the missing gems.
|
|
778
881
|
|
779
882
|
def default_load_paths
|
780
883
|
paths = []
|
781
|
-
|
884
|
+
|
782
885
|
# Add the old mock paths only if the directories exists
|
783
886
|
paths.concat(Dir["#{root_path}/test/mocks/#{environment}"]) if File.exists?("#{root_path}/test/mocks/#{environment}")
|
784
887
|
|
@@ -809,6 +912,14 @@ Run `rake gems:install` to install the missing gems.
|
|
809
912
|
[]
|
810
913
|
end
|
811
914
|
|
915
|
+
def default_eager_load_paths
|
916
|
+
%w(
|
917
|
+
app/models
|
918
|
+
app/controllers
|
919
|
+
app/helpers
|
920
|
+
).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) }
|
921
|
+
end
|
922
|
+
|
812
923
|
def default_log_path
|
813
924
|
File.join(root_path, 'log', "#{environment}.log")
|
814
925
|
end
|
@@ -835,12 +946,12 @@ Run `rake gems:install` to install the missing gems.
|
|
835
946
|
paths
|
836
947
|
end
|
837
948
|
|
838
|
-
def
|
839
|
-
|
949
|
+
def default_dependency_loading
|
950
|
+
true
|
840
951
|
end
|
841
952
|
|
842
953
|
def default_cache_classes
|
843
|
-
|
954
|
+
true
|
844
955
|
end
|
845
956
|
|
846
957
|
def default_whiny_nils
|
@@ -864,7 +975,7 @@ Run `rake gems:install` to install the missing gems.
|
|
864
975
|
def default_plugin_loader
|
865
976
|
Plugin::Loader
|
866
977
|
end
|
867
|
-
|
978
|
+
|
868
979
|
def default_cache_store
|
869
980
|
if File.exist?("#{root_path}/tmp/cache/")
|
870
981
|
[ :file_store, "#{root_path}/tmp/cache/" ]
|
@@ -872,10 +983,22 @@ Run `rake gems:install` to install the missing gems.
|
|
872
983
|
:memory_store
|
873
984
|
end
|
874
985
|
end
|
875
|
-
|
986
|
+
|
876
987
|
def default_gems
|
877
988
|
[]
|
878
989
|
end
|
990
|
+
|
991
|
+
def default_i18n
|
992
|
+
i18n = Rails::OrderedOptions.new
|
993
|
+
i18n.load_path = []
|
994
|
+
|
995
|
+
if File.exist?(File.join(RAILS_ROOT, 'config', 'locales'))
|
996
|
+
i18n.load_path << Dir[File.join(RAILS_ROOT, 'config', 'locales', '*.{rb,yml}')]
|
997
|
+
i18n.load_path.flatten!
|
998
|
+
end
|
999
|
+
|
1000
|
+
i18n
|
1001
|
+
end
|
879
1002
|
end
|
880
1003
|
end
|
881
1004
|
|