Upgrade to Rails 2.2.0

As a side benefit, fix an (non-user-visible) bug in display_s5().
Also fixed a bug where removing orphaned pages did not expire cached summary pages.
This commit is contained in:
Jacques Distler 2008-10-27 01:47:01 -05:00
parent 39348c65c2
commit 7600aef48b
827 changed files with 123652 additions and 11027 deletions

View file

@ -1,11 +1,13 @@
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
require 'optparse'
options = { :sandbox => false, :irb => irb }
OptionParser.new do |opt|
opt.banner = "Usage: console [environment] [options]"
opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
opt.parse!(ARGV)
end
@ -15,6 +17,17 @@ libs << " -r console_app"
libs << " -r console_sandbox" if options[:sandbox]
libs << " -r console_with_helpers"
if options[:debugger]
begin
require 'ruby-debug'
libs << " -r ruby-debug"
puts "=> Debugger enabled"
rescue Exception
puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
exit
end
end
ENV['RAILS_ENV'] = case ARGV.first
when "p"; "production"
when "d"; "development"

View file

@ -6,7 +6,7 @@ include_password = false
OptionParser.new do |opt|
opt.banner = "Usage: dbconsole [options] [environment]"
opt.on("-p", "--include-password", "Automatically provide the database from database.yml") do |v|
opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v|
include_password = true
end
opt.parse!(ARGV)
@ -47,7 +47,7 @@ when "mysql"
args << config['database']
exec(find_cmd('mysql5', 'mysql'), *args)
exec(find_cmd('mysql', 'mysql5'), *args)
when "postgresql"
ENV['PGUSER'] = config["username"] if config["username"]

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby
#!/usr/bin/env ruby
require 'stringio'
require 'fileutils'
@ -83,4 +83,4 @@ end
socket_path = ARGV.shift
timeout = (ARGV.shift || 90).to_i
Listener.new(timeout, socket_path)
Listener.new(timeout, socket_path)

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby
#!/usr/bin/env ruby
require 'drb'
require 'thread'
@ -66,4 +66,4 @@ end
socket_path = ARGV.shift
instances = ARGV.shift.to_i
t = Tracker.new(instances, socket_path)
t.background(ARGV.first ? ARGV.shift.to_i : 90)
t.background(ARGV.first ? ARGV.shift.to_i : 90)

View file

@ -43,6 +43,16 @@
# plugin is pulled via `svn checkout` or `svn export` but looks
# exactly the same.
#
# Specifying revisions:
#
# * Subversion revision is a single integer.
#
# * Git revision format:
# - full - 'refs/tags/1.8.0' or 'refs/heads/experimental'
# - short: 'experimental' (equivalent to 'refs/heads/experimental')
# 'tag 1.8.0' (equivalent to 'refs/tags/1.8.0')
#
#
# This is Free Software, copyright 2005 by Ryan Tomayko (rtomayko@gmail.com)
# and is licensed MIT: (http://www.opensource.org/licenses/mit-license.php)
@ -175,7 +185,7 @@ class Plugin
method ||= rails_env.best_install_method?
if :http == method
method = :export if svn_url?
method = :clone if git_url?
method = :git if git_url?
end
uninstall if installed? and options[:force]
@ -255,8 +265,25 @@ class Plugin
end
end
def install_using_clone(options = {})
git_command :clone, options
def install_using_git(options = {})
root = rails_env.root
install_path = mkdir_p "#{root}/vendor/plugins/#{name}"
Dir.chdir install_path do
init_cmd = "git init"
init_cmd += " -q" if options[:quiet] and not $verbose
puts init_cmd if $verbose
system(init_cmd)
base_cmd = "git pull --depth 1 #{uri}"
base_cmd += " -q" if options[:quiet] and not $verbose
base_cmd += " #{options[:revision]}" if options[:revision]
puts base_cmd if $verbose
if system(base_cmd)
puts "removing: .git" if $verbose
rm_rf ".git"
else
rm_rf install_path
end
end
end
def svn_command(cmd, options = {})
@ -268,16 +295,6 @@ class Plugin
puts base_cmd if $verbose
system(base_cmd)
end
def git_command(cmd, options = {})
root = rails_env.root
mkdir_p "#{root}/vendor/plugins"
base_cmd = "git #{cmd} --depth 1 #{uri} \"#{root}/vendor/plugins/#{name}\""
puts base_cmd if $verbose
puts "removing: #{root}/vendor/plugins/#{name}/.git"
system(base_cmd)
rm_rf "#{root}/vendor/plugins/#{name}/.git"
end
def guess_name(url)
@name = File.basename(url)
@ -444,11 +461,11 @@ module Commands
o.on("-r", "--root=DIR", String,
"Set an explicit rails app directory.",
"Default: #{@rails_root}") { |@rails_root| self.environment = RailsEnvironment.new(@rails_root) }
"Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) }
o.on("-s", "--source=URL1,URL2", Array,
"Use the specified plugin repositories instead of the defaults.") { |@sources|}
"Use the specified plugin repositories instead of the defaults.") { |sources| @sources = sources}
o.on("-v", "--verbose", "Turn on verbose output.") { |$verbose| }
o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose }
o.on("-h", "--help", "Show this help message.") { puts o; exit }
o.separator ""
@ -535,12 +552,12 @@ module Commands
o.separator "Options:"
o.separator ""
o.on( "-s", "--source=URL1,URL2", Array,
"Use the specified plugin repositories.") {|@sources|}
"Use the specified plugin repositories.") {|sources| @sources = sources}
o.on( "--local",
"List locally installed plugins.") {|@local| @remote = false}
"List locally installed plugins.") {|local| @local, @remote = local, false}
o.on( "--remote",
"List remotely available plugins. This is the default behavior",
"unless --local is provided.") {|@remote|}
"unless --local is provided.") {|remote| @remote = remote}
end
end
@ -581,7 +598,7 @@ module Commands
o.separator "Options:"
o.separator ""
o.on( "-c", "--check",
"Report status of repository.") { |@sources|}
"Report status of repository.") { |sources| @sources = sources}
end
end
@ -672,7 +689,7 @@ module Commands
o.separator "Options:"
o.separator ""
o.on( "-l", "--list",
"List but don't prompt or add discovered repositories.") { |@list| @prompt = !@list }
"List but don't prompt or add discovered repositories.") { |list| @list, @prompt = list, !@list }
o.on( "-n", "--no-prompt",
"Add all new repositories without prompting.") { |v| @prompt = !v }
end
@ -756,8 +773,8 @@ module Commands
"Suppresses the output from installation.",
"Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true }
o.on( "-r REVISION", "--revision REVISION",
"Checks out the given revision from subversion.",
"Ignored if subversion is not used.") { |v| @options[:revision] = v }
"Checks out the given revision from subversion or git.",
"Ignored if subversion/git is not used.") { |v| @options[:revision] = v }
o.on( "-f", "--force",
"Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true }
o.separator ""
@ -884,7 +901,7 @@ class RecursiveHTTPFetcher
def initialize(urls_to_fetch, level = 1, cwd = ".")
@level = level
@cwd = cwd
@urls_to_fetch = urls_to_fetch.to_a
@urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a
@quiet = false
end

View file

@ -66,9 +66,9 @@ class MongrelSpawner < Spawner
"-l #{OPTIONS[:rails_root]}/log/mongrel.log"
# Add prefix functionality to spawner's call to mongrel_rails
# Digging through monrel's project subversion server, the earliest
# Digging through mongrel's project subversion server, the earliest
# Tag that has prefix implemented in the bin/mongrel_rails file
# is 0.3.15 which also happens to be the earilest tag listed.
# is 0.3.15 which also happens to be the earliest tag listed.
# References: http://mongrel.rubyforge.org/svn/tags
if Mongrel::Const::MONGREL_VERSION.to_f >=0.3 && !OPTIONS[:prefix].nil?
cmd = cmd + " --prefix #{OPTIONS[:prefix]}"
@ -181,10 +181,10 @@ ARGV.options do |opts|
opts.on(" Options:")
opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |OPTIONS[:port]| }
opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |v| OPTIONS[:port] = v }
if spawner_class.can_bind_to_custom_address?
opts.on("-a", "--address=ip", String, "Bind to IP address (default: #{OPTIONS[:address]})") { |OPTIONS[:address]| }
opts.on("-a", "--address=ip", String, "Bind to IP address (default: #{OPTIONS[:address]})") { |v| OPTIONS[:address] = v }
end
opts.on("-p", "--port=number", Integer, "Starting port number (default: #{OPTIONS[:port]})") { |v| OPTIONS[:port] = v }

View file

@ -42,7 +42,7 @@ if code_or_file.nil?
$stderr.puts "Run '#{$0} -h' for help."
exit 1
elsif File.exist?(code_or_file)
eval(File.read(code_or_file))
eval(File.read(code_or_file), nil, code_or_file)
else
eval(code_or_file)
end

View file

@ -13,12 +13,20 @@ rescue Exception
# Mongrel not available
end
begin
require_library_or_gem 'thin'
rescue Exception
# Thin not available
end
server = case ARGV.first
when "lighttpd", "mongrel", "new_mongrel", "webrick"
when "lighttpd", "mongrel", "new_mongrel", "webrick", "thin"
ARGV.shift
else
if defined?(Mongrel)
"mongrel"
elsif defined?(Thin)
"thin"
elsif RUBY_PLATFORM !~ /(:?mswin|mingw)/ && !silence_stderr { `lighttpd -version` }.blank? && defined?(FCGI)
"lighttpd"
else
@ -33,6 +41,8 @@ case server
puts "=> Booting lighttpd (use 'script/server webrick' to force WEBrick)"
when "mongrel", "new_mongrel"
puts "=> Booting Mongrel (use 'script/server webrick' to force WEBrick)"
when "thin"
puts "=> Booting Thin (use 'script/server webrick' to force WEBrick)"
end
%w(cache pids sessions sockets).each { |dir_to_make| FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make)) }

View file

@ -0,0 +1,25 @@
require 'rbconfig'
require 'commands/servers/base'
require 'thin'
options = ARGV.clone
options.insert(0,'start') unless Thin::Runner.commands.include?(options[0])
thin = Thin::Runner.new(options)
puts "=> Rails #{Rails.version} application starting on http://#{thin.options[:address]}:#{thin.options[:port]}"
puts "=> Ctrl-C to shutdown server"
log = Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath
open(log, (File::WRONLY | File::APPEND | File::CREAT)) unless File.exist? log
tail_thread = tail(log)
trap(:INT) { exit }
begin
thin.run!
ensure
tail_thread.kill if tail_thread
puts 'Exiting'
end