Rails 2.1 RC1

Updated Instiki to Rails 2.1 RC1 (aka 2.0.991).
This commit is contained in:
Jacques Distler 2008-05-17 23:22:34 -05:00
parent 14afed5893
commit 5292899c9a
971 changed files with 46318 additions and 17450 deletions

View file

@ -16,9 +16,9 @@ libs << " -r console_sandbox" if options[:sandbox]
libs << " -r console_with_helpers"
ENV['RAILS_ENV'] = case ARGV.first
when "p": "production"
when "d": "development"
when "t": "test"
when "p"; "production"
when "d"; "development"
when "t"; "test"
else
ARGV.first || ENV['RAILS_ENV'] || 'development'
end

View file

@ -0,0 +1,56 @@
require 'erb'
require 'yaml'
require 'optparse'
OptionParser.new do |opt|
opt.banner = "Usage: dbconsole [environment]"
opt.parse!(ARGV)
abort opt.to_s unless (0..1).include?(ARGV.size)
end
env = ARGV.first || ENV['RAILS_ENV'] || 'development'
unless config = YAML::load(ERB.new(IO.read(RAILS_ROOT + "/config/database.yml")).result)[env]
abort "No database is configured for the environment '#{env}'"
end
def find_cmd(*commands)
dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR)
commands += commands.map{|cmd| "#{cmd}.exe"} if RUBY_PLATFORM =~ /win32/
commands.detect do |cmd|
dirs_on_path.detect do |path|
File.executable? File.join(path, cmd)
end
end || abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.")
end
case config["adapter"]
when "mysql"
args = {
'host' => '--host',
'port' => '--port',
'socket' => '--socket',
'username' => '--user',
'password' => '--password',
'encoding' => '--default-character-set'
}.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
args << config['database']
exec(find_cmd('mysql5', 'mysql'), *args)
when "postgresql"
ENV['PGHOST'] = config["host"] if config["host"]
ENV['PGPORT'] = config["port"].to_s if config["port"]
ENV['PGPASSWORD'] = config["password"].to_s if config["password"]
exec(find_cmd('psql'), '-U', config["username"], config["database"])
when "sqlite"
exec(find_cmd('sqlite'), config["database"])
when "sqlite3"
exec(find_cmd('sqlite3'), config["database"])
else
abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!"
end

View file

@ -19,7 +19,7 @@ begin
begin
require "ruby-prof"
$stderr.puts 'Using the ruby-prof extension.'
RubyProf.clock_mode = RubyProf::WALL_TIME
RubyProf.measure_mode = RubyProf::WALL_TIME
RubyProf.start
profile_me
results = RubyProf.stop

View file

@ -162,6 +162,10 @@ class Plugin
@uri =~ /svn(?:\+ssh)?:\/\/*/
end
def git_url?
@uri =~ /^git:\/\// || @url =~ /\.git$/
end
def installed?
File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \
or rails_env.externals.detect{ |name, repo| self.uri == repo }
@ -169,7 +173,10 @@ class Plugin
def install(method=nil, options = {})
method ||= rails_env.best_install_method?
method = :export if method == :http and svn_url?
if :http == method
method = :export if svn_url?
method = :clone if git_url?
end
uninstall if installed? and options[:force]
@ -247,6 +254,10 @@ class Plugin
fetcher.fetch
end
end
def install_using_clone(options = {})
git_command :clone, options
end
def svn_command(cmd, options = {})
root = rails_env.root
@ -257,12 +268,23 @@ 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)
if @name == 'trunk' || @name.empty?
@name = File.basename(File.dirname(url))
end
@name.gsub!(/\.git$/, '') if @name =~ /\.git$/
end
def rails_env
@ -447,6 +469,8 @@ module Commands
o.separator " #{@script_name} install continuous_builder\n"
o.separator " Install a plugin from a subversion URL:"
o.separator " #{@script_name} install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n"
o.separator " Install a plugin from a git URL:"
o.separator " #{@script_name} install git://github.com/SomeGuy/my_awesome_plugin.git\n"
o.separator " Install a plugin and add a svn:externals entry to vendor/plugins"
o.separator " #{@script_name} install -x continuous_builder\n"
o.separator " List all available plugins:"
@ -725,6 +749,9 @@ module Commands
o.on( "-o", "--checkout",
"Use svn checkout to grab the plugin.",
"Enables updating but does not add a svn:externals entry.") { |v| @method = :checkout }
o.on( "-e", "--export",
"Use svn export to grab the plugin.",
"Exports the plugin, allowing you to check it into your local repository. Does not enable updates, or add an svn:externals entry.") { |v| @method = :export }
o.on( "-q", "--quiet",
"Suppresses the output from installation.",
"Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true }

View file

@ -14,7 +14,7 @@ rescue Exception
end
server = case ARGV.first
when "lighttpd", "mongrel", "webrick"
when "lighttpd", "mongrel", "new_mongrel", "webrick"
ARGV.shift
else
if defined?(Mongrel)
@ -31,7 +31,7 @@ case server
puts "=> Booting WEBrick..."
when "lighttpd"
puts "=> Booting lighttpd (use 'script/server webrick' to force WEBrick)"
when "mongrel"
when "mongrel", "new_mongrel"
puts "=> Booting Mongrel (use 'script/server webrick' to force WEBrick)"
end

View file

@ -34,10 +34,10 @@ end
puts "=> Rails application starting on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
parameters = [
"start",
"-p", OPTIONS[:port].to_s,
"-a", OPTIONS[:ip].to_s,
parameters = [
"start",
"-p", OPTIONS[:port].to_s,
"-a", OPTIONS[:ip].to_s,
"-e", OPTIONS[:environment],
"-P", "#{RAILS_ROOT}/tmp/pids/mongrel.pid"
]
@ -50,12 +50,12 @@ else
start_debugger if OPTIONS[:debugger]
require 'initializer'
Rails::Initializer.run(:initialize_logger)
puts "=> Call with -d to detach"
puts "=> Ctrl-C to shutdown server"
tail_thread = tail(Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath)
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 }

View file

@ -0,0 +1,16 @@
unless defined?(Mongrel)
abort "PROBLEM: Mongrel is not available on your system (or not in your path)"
end
require 'rails/mongrel_server/commands'
GemPlugin::Manager.instance.load "rails::mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE
case ARGV[0] ||= 'start'
when 'start', 'stop', 'restart'
ARGV[0] = "rails::mongrelserver::#{ARGV[0]}"
end
if not Mongrel::Command::Registry.instance.run ARGV
exit 1
end