diff --git a/railties/Rakefile b/railties/Rakefile index 49d0891f5d7dfd8cd8e15ea597bfb225804c5fd3..dba31803655d3b565cab358f258f3b1fb2df58e0 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -25,7 +25,7 @@ task :default => :test ## This is required until the regular test task ## below passes. It's not ideal, but at least ## we can see the failures -task :test do +task :test do Dir['test/**/*_test.rb'].all? do |file| ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) system(ruby, '-Itest', file) @@ -38,7 +38,7 @@ Rake::TestTask.new("regular_test") do |t| end -BASE_DIRS = %w( +BASE_DIRS = %w( app config/environments config/initializers @@ -158,17 +158,11 @@ end # Copy Ties Content ----------------------------------------------------------------------- desc "Make copies of all the default content of ties" -task :copy_ties_content => [ +task :copy_ties_content => [ :copy_rootfiles, :copy_dispatches, :copy_html_files, :copy_application, :copy_configs, :copy_binfiles, :copy_test_helpers, :copy_app_doc_readme ] task :copy_dispatches do - copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb") - chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb" - - copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi") - chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi" - copy_with_rewritten_ruby_path("dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi") chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi" end @@ -187,7 +181,7 @@ task :copy_configs do socket = nil require 'erb' File.open("#{PKG_DESTINATION}/config/database.yml", 'w') {|f| f.write ERB.new(IO.read("configs/databases/sqlite3.yml"), nil, '-').result(binding)} - + cp "configs/routes.rb", "#{PKG_DESTINATION}/config/routes.rb" cp "configs/initializers/backtrace_silencers.rb", "#{PKG_DESTINATION}/config/initializers/backtrace_silencers.rb" @@ -288,15 +282,15 @@ end PKG_FILES = FileList[ '[a-zA-Z]*', - 'bin/**/*', + 'bin/**/*', 'builtin/**/*', - 'configs/**/*', - 'doc/**/*', - 'dispatches/**/*', - 'environments/**/*', - 'helpers/**/*', - 'generators/**/*', - 'html/**/*', + 'configs/**/*', + 'doc/**/*', + 'dispatches/**/*', + 'environments/**/*', + 'helpers/**/*', + 'generators/**/*', + 'html/**/*', 'lib/**/*' ] - [ 'test' ] @@ -336,7 +330,7 @@ end # Publishing ------------------------------------------------------- desc "Publish the rails gem" -task :pgem => [:gem] do +task :pgem => [:gem] do Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` end diff --git a/railties/dispatches/dispatch.rb b/railties/dispatches/dispatch.rb deleted file mode 100755 index 32fa3b2665af0d582ec89fbeddd91d231760f963..0000000000000000000000000000000000000000 --- a/railties/dispatches/dispatch.rb +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch diff --git a/railties/dispatches/gateway.cgi b/railties/dispatches/gateway.cgi deleted file mode 100755 index 0305b7f810fe966dd0ae557effbbf14ebb98687c..0000000000000000000000000000000000000000 --- a/railties/dispatches/gateway.cgi +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env ruby - -require 'drb' - -# This file includes an experimental gateway CGI implementation. It will work -# only on platforms which support both fork and sockets. -# -# To enable it edit public/.htaccess and replace dispatch.cgi with gateway.cgi. -# -# Next, create the directory log/drb_gateway and grant the apache user rw access -# to said directory. -# -# On the next request to your server, the gateway tracker should start up, along -# with a few listener processes. This setup should provide you with much better -# speeds than dispatch.cgi. -# -# Keep in mind that the first request made to the server will be slow, as the -# tracker and listeners will have to load. Also, the tracker and listeners will -# shutdown after a period if inactivity. You can set this value below -- the -# default is 90 seconds. - -TrackerSocket = File.expand_path(File.join(File.dirname(__FILE__), '../log/drb_gateway/tracker.sock')) -DieAfter = 90 # Seconds -Listeners = 3 - -def message(s) - $stderr.puts "gateway.cgi: #{s}" if ENV && ENV["DEBUG_GATEWAY"] -end - -def listener_socket(number) - File.expand_path(File.join(File.dirname(__FILE__), "../log/drb_gateway/listener_#{number}.sock")) -end - -unless File.exist? TrackerSocket - message "Starting tracker and #{Listeners} listeners" - fork do - Process.setsid - STDIN.reopen "/dev/null" - STDOUT.reopen "/dev/null", "a" - - root = File.expand_path(File.dirname(__FILE__) + '/..') - - message "starting tracker" - fork do - ARGV.clear - ARGV << TrackerSocket << Listeners.to_s << DieAfter.to_s - load File.join(root, 'script', 'tracker') - end - - message "starting listeners" - require File.join(root, 'config/environment.rb') - Listeners.times do |number| - fork do - ARGV.clear - ARGV << listener_socket(number) << DieAfter.to_s - load File.join(root, 'script', 'listener') - end - end - end - - message "waiting for tracker and listener to arise..." - ready = false - 10.times do - sleep 0.5 - break if (ready = File.exist?(TrackerSocket) && File.exist?(listener_socket(0))) - end - - if ready - message "tracker and listener are ready" - else - message "Waited 5 seconds, listener and tracker not ready... dropping request" - Kernel.exit 1 - end -end - -DRb.start_service - -message "connecting to tracker" -tracker = DRbObject.new_with_uri("drbunix:#{TrackerSocket}") - -input = $stdin.read -$stdin.close - -env = ENV.inspect - -output = nil -tracker.with_listener do |number| - message "connecting to listener #{number}" - socket = listener_socket(number) - listener = DRbObject.new_with_uri("drbunix:#{socket}") - output = listener.process(env, input) - message "listener #{number} has finished, writing output" -end - -$stdout.write output -$stdout.flush -$stdout.close diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index 0b67eef5a9227e69d63bd861235d8476f4a871b2..012fe5868a165ce843687f51b0b8107912ade7b3 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -1,6 +1,6 @@ require 'rbconfig' require File.dirname(__FILE__) + '/template_runner' -require 'digest/md5' +require 'digest/md5' require 'active_support/secure_random' class AppGenerator < Rails::Generator::Base @@ -110,12 +110,12 @@ def create_directories(m) tmp/pids ).each { |path| m.directory(path) } end - + def create_root_files(m) m.file "fresh_rakefile", "Rakefile" m.file "README", "README" end - + def create_app_files(m) m.file "helpers/application_controller.rb", "app/controllers/application_controller.rb" m.file "helpers/application_helper.rb", "app/helpers/application_helper.rb" @@ -138,7 +138,7 @@ def create_log_files(m) %w( server production development test ).each do |file| m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666 end - end + end def create_public_files(m) create_dispatch_files(m) @@ -148,14 +148,14 @@ def create_public_files(m) create_rails_image(m) create_javascript_files(m) end - + def create_script_files(m) - %w( + %w( about console dbconsole destroy generate runner server plugin performance/benchmarker performance/profiler ).each do |file| - m.file "bin/#{file}", "script/#{file}", { - :chmod => 0755, + m.file "bin/#{file}", "script/#{file}", { + :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] } end @@ -172,7 +172,7 @@ def create_database_configuration_file(m) :app_name => @app_name, :socket => options[:db] == "mysql" ? mysql_socket_location : nil } end - + def create_routes_file(m) m.file "configs/routes.rb", "config/routes.rb" end @@ -182,19 +182,19 @@ def create_seeds_file(m) end def create_initializer_files(m) - %w( - backtrace_silencers - inflections - mime_types + %w( + backtrace_silencers + inflections + mime_types new_rails_defaults ).each do |initializer| m.file "configs/initializers/#{initializer}.rb", "config/initializers/#{initializer}.rb" end - m.template "configs/initializers/session_store.rb", "config/initializers/session_store.rb", + m.template "configs/initializers/session_store.rb", "config/initializers/session_store.rb", :assigns => { :app_name => @app_name, :app_secret => ActiveSupport::SecureRandom.hex(64) } - m.template "configs/initializers/cookie_verification_secret.rb", "config/initializers/cookie_verification_secret.rb", + m.template "configs/initializers/cookie_verification_secret.rb", "config/initializers/cookie_verification_secret.rb", :assigns => { :app_secret => ActiveSupport::SecureRandom.hex(64) } end @@ -203,7 +203,7 @@ def create_locale_file(m) end def create_environment_files(m) - m.template "environments/environment.rb", "config/environment.rb", + m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] } m.file "environments/boot.rb", "config/boot.rb" @@ -218,8 +218,6 @@ def create_dispatch_files(m) dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] } m.file "dispatches/config.ru", "config.ru" - m.file "dispatches/dispatch.rb", "public/dispatch.rb", dispatcher_options - m.file "dispatches/dispatch.rb", "public/dispatch.cgi", dispatcher_options m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", dispatcher_options end end @@ -263,4 +261,4 @@ def mysql_socket_location "/opt/lampp/var/mysql/mysql.sock" # xampp for linux ].find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ end -end \ No newline at end of file +end diff --git a/railties/lib/tasks/framework.rake b/railties/lib/tasks/framework.rake index 1175036649b3334dc99ce2479e83770b83dee904..2829224dfc8bb61892e839ef518ef8ae64048869 100644 --- a/railties/lib/tasks/framework.rake +++ b/railties/lib/tasks/framework.rake @@ -97,7 +97,7 @@ namespace :rails do local = Dir["#{local_base}/**/*"].reject { |path| File.directory?(path) } edge = Dir["#{edge_base}/**/*"].reject { |path| File.directory?(path) } - + edge.each do |script| base_name = script[(edge_base.length+1)..-1] next if base_name == "rails" @@ -111,7 +111,7 @@ namespace :rails do desc "Update your javascripts from your current rails install" task :javascripts do - require 'railties_path' + require 'railties_path' project_dir = RAILS_ROOT + '/public/javascripts/' scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js'] scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js') @@ -120,10 +120,10 @@ namespace :rails do desc "Update config/boot.rb from your current rails install" task :configs do - require 'railties_path' + require 'railties_path' FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb') end - + desc "Rename application.rb to application_controller.rb" task :application_controller do old_style = RAILS_ROOT + '/app/controllers/application.rb' @@ -133,14 +133,12 @@ namespace :rails do puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary" end end - + desc "Generate dispatcher files in RAILS_ROOT/public" task :generate_dispatchers do require 'railties_path' FileUtils.cp(RAILTIES_PATH + '/dispatches/config.ru', RAILS_ROOT + '/config.ru') FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.fcgi', RAILS_ROOT + '/public/dispatch.fcgi') - FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.rb') - FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.cgi') end end end