2004-11-23 20:04:44 -05:00
|
|
|
require 'rake'
|
|
|
|
require 'rake/testtask'
|
|
|
|
require 'rake/rdoctask'
|
|
|
|
require 'rake/gempackagetask'
|
|
|
|
require 'rake/contrib/rubyforgepublisher'
|
|
|
|
|
|
|
|
require 'date'
|
|
|
|
|
|
|
|
|
|
|
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
|
|
|
PKG_NAME = 'rails'
|
|
|
|
PKG_VERSION = '0.8.5' + PKG_BUILD
|
|
|
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
|
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
|
|
|
|
BASE_DIRS = %w( app config/environments db doc log lib public script test vendor )
|
|
|
|
APP_DIRS = %w( models controllers helpers views views/layouts )
|
|
|
|
PUBLIC_DIRS = %w( images javascripts stylesheets _doc )
|
|
|
|
TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/testing )
|
|
|
|
|
|
|
|
LOG_FILES = %w( apache.log development.log test.log production.log )
|
|
|
|
HTML_FILES = %w( 404.html 500.html index.html )
|
2004-12-09 18:04:37 -05:00
|
|
|
SCRIPT_FILES = %w( generate )
|
2004-12-09 12:20:00 -05:00
|
|
|
BIN_FILES = %w( breakpointing envcon )
|
2004-12-07 06:49:38 -05:00
|
|
|
GENERATORS = %w( controller mailer model scaffold )
|
2004-11-25 11:27:59 -05:00
|
|
|
|
|
|
|
VENDOR_LIBS = %w( actionpack activerecord actionmailer railties )
|
|
|
|
|
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
desc "Default Task"
|
|
|
|
task :default => [ :fresh_rails ]
|
|
|
|
|
|
|
|
desc "Generates a fresh Rails package with documentation"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :fresh_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content, :generate_documentation ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
desc "Generates a fresh Rails package using GEMs with documentation"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :fresh_gem_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_ties_content, :copy_gem_environment ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
desc "Generates a fresh Rails package without documentation (faster)"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :fresh_rails_without_docs => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
desc "Packages the fresh Rails package with documentation"
|
|
|
|
task :package => [ :clean, :fresh_rails ] do
|
|
|
|
system %{cd ..; tar -czvf #{PKG_NAME}-#{PKG_VERSION}.tgz #{PKG_NAME}}
|
|
|
|
system %{cd ..; zip -r #{PKG_NAME}-#{PKG_VERSION}.zip #{PKG_NAME}}
|
|
|
|
end
|
|
|
|
|
|
|
|
task :clean do
|
2004-11-25 11:27:59 -05:00
|
|
|
rm_rf PKG_DESTINATION
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Make directory structure ----------------------------------------------------------------
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
def make_dest_dirs(dirs, path = nil)
|
|
|
|
mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path, dir) }
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
desc "Make the directory structure for the new Rails application"
|
|
|
|
task :make_dir_structure => [ :make_base_dirs, :make_app_dirs, :make_public_dirs, :make_test_dirs ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
task(:make_base_dirs) { make_dest_dirs BASE_DIRS }
|
|
|
|
task(:make_app_dirs) { make_dest_dirs APP_DIRS, 'app' }
|
|
|
|
task(:make_public_dirs) { make_dest_dirs PUBLIC_DIRS, 'public' }
|
|
|
|
task(:make_test_dirs) { make_dest_dirs TEST_DIRS, 'test' }
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Initialize file stubs -------------------------------------------------------------------
|
|
|
|
|
|
|
|
desc "Initialize empty file stubs (such as for logging)"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :initialize_file_stubs => [ :initialize_log_files ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
task :initialize_log_files do
|
2004-11-25 11:27:59 -05:00
|
|
|
log_dir = File.join(PKG_DESTINATION, 'log')
|
|
|
|
chmod 0777, log_dir
|
|
|
|
LOG_FILES.each do |log_file|
|
|
|
|
log_path = File.join(log_dir, log_file)
|
|
|
|
touch log_path
|
|
|
|
chmod 0777, log_path
|
|
|
|
end
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Copy Vendors ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
desc "Copy in all the Rails packages to vendor"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :copy_vendor_libraries do
|
|
|
|
cp_r VENDOR_LIBS.map { |dir| File.join('..', dir) },
|
|
|
|
File.join(PKG_DESTINATION, 'vendor')
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Copy Ties Content -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
# :link_apache_config
|
|
|
|
desc "Make copies of all the default content of ties"
|
|
|
|
task :copy_ties_content => [
|
|
|
|
:copy_rootfiles, :copy_dispatches, :copy_html_files, :copy_abstract_application,
|
2004-12-09 12:20:00 -05:00
|
|
|
:copy_configs, :copy_generators, :copy_binfiles, :copy_test_helpers, :copy_docs_in_public,
|
2004-11-25 11:27:59 -05:00
|
|
|
:copy_app_doc_readme ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
task :copy_dispatches do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb"
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi"
|
2004-11-23 20:04:44 -05:00
|
|
|
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi"
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi"
|
2004-11-23 20:04:44 -05:00
|
|
|
chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi"
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "dispatches/dispatch.servlet", "#{PKG_DESTINATION}/public/dispatch.servlet"
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2004-12-06 13:18:29 -05:00
|
|
|
cp "bin/envcon", "#{PKG_DESTINATION}/script/envcon"
|
|
|
|
chmod 0755, "#{PKG_DESTINATION}/script/envcon"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_html_files do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp HTML_FILES.map { |dir| File.join('html', dir) },
|
|
|
|
File.join(PKG_DESTINATION, 'public')
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_abstract_application do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "helpers/abstract_application.rb", "#{PKG_DESTINATION}/app/controllers/abstract_application.rb"
|
|
|
|
cp "helpers/application_helper.rb", "#{PKG_DESTINATION}/app/helpers/application_helper.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_configs do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "configs/database.yml", "#{PKG_DESTINATION}/config/database.yml"
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "configs/apache.conf", "#{PKG_DESTINATION}/public/.htaccess"
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "environments/shared.rb", "#{PKG_DESTINATION}/config/environment.rb"
|
|
|
|
cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb"
|
|
|
|
cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb"
|
|
|
|
cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_generators do
|
2004-12-09 10:54:22 -05:00
|
|
|
mkdir_p File.join(PKG_DESTINATION, 'script/generators')
|
|
|
|
|
2004-11-25 11:27:59 -05:00
|
|
|
SCRIPT_FILES.each do |file|
|
|
|
|
dest_file = File.join(PKG_DESTINATION, 'script', file)
|
|
|
|
cp File.join('generators', "#{file}.rb"), dest_file
|
|
|
|
chmod 0755, dest_file
|
|
|
|
end
|
2004-12-07 06:49:38 -05:00
|
|
|
|
|
|
|
GENERATORS.each do |dir|
|
2004-12-07 16:02:34 -05:00
|
|
|
cp_r File.join('generators', dir), File.join(PKG_DESTINATION, 'script', 'generators', dir)
|
2004-12-07 06:49:38 -05:00
|
|
|
end
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2004-12-09 12:20:00 -05:00
|
|
|
task :copy_binfiles do
|
|
|
|
BIN_FILES.each do |file|
|
|
|
|
dest_file = File.join(PKG_DESTINATION, 'script', file)
|
|
|
|
cp File.join('bin', file), dest_file
|
|
|
|
chmod 0755, dest_file
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
task :copy_rootfiles do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "fresh_rakefile", "#{PKG_DESTINATION}/Rakefile"
|
|
|
|
cp "README", "#{PKG_DESTINATION}/README"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_test_helpers do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "helpers/test_helper.rb", "#{PKG_DESTINATION}/test/test_helper.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_docs_in_public do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "doc/index.html", "#{PKG_DESTINATION}/public/_doc/index.html"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :copy_app_doc_readme do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
task :link_apache_config do
|
2004-11-25 11:27:59 -05:00
|
|
|
chdir(File.join(PKG_DESTINATION, 'config')) {
|
|
|
|
ln_s "../public/.htaccess", "apache.conf"
|
|
|
|
}
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Generate documentation ------------------------------------------------------------------
|
|
|
|
|
|
|
|
desc "Generate documentation for the framework and for the empty application"
|
2004-11-25 11:27:59 -05:00
|
|
|
task :generate_documentation => [ :generate_app_doc, :generate_rails_framework_doc ]
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
task :generate_rails_framework_doc do
|
|
|
|
system %{cd #{PKG_DESTINATION}; rake apidoc}
|
|
|
|
end
|
|
|
|
|
|
|
|
task :generate_app_doc do
|
|
|
|
File.cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
|
|
|
|
system %{cd #{PKG_DESTINATION}; rake appdoc}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# Generate GEM ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
task :copy_gem_environment do
|
2004-11-25 11:27:59 -05:00
|
|
|
cp "environments/shared_for_gem.rb", "#{PKG_DESTINATION}/config/environment.rb"
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PKG_FILES = FileList[
|
|
|
|
'[a-zA-Z]*',
|
|
|
|
'bin/**/*',
|
|
|
|
'configs/**/*',
|
|
|
|
'doc/**/*',
|
|
|
|
'dispatches/**/*',
|
|
|
|
'environments/**/*',
|
|
|
|
'generators/**/*',
|
|
|
|
'helpers/**/*',
|
|
|
|
'html/**/*',
|
|
|
|
'lib/**/*'
|
|
|
|
]
|
|
|
|
|
|
|
|
spec = Gem::Specification.new do |s|
|
|
|
|
s.name = 'rails'
|
|
|
|
s.version = PKG_VERSION
|
|
|
|
s.summary = "Web-application framework with template engine, control-flow layer, and ORM."
|
|
|
|
s.description = <<-EOF
|
|
|
|
Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick
|
|
|
|
on top of either MySQL, PostgreSQL, or SQLite with eRuby-based templates.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
s.add_dependency('rake', '>= 0.4.11')
|
|
|
|
s.add_dependency('activerecord', '>= 1.1.0')
|
|
|
|
s.add_dependency('actionpack', '>= 0.9.5')
|
|
|
|
s.add_dependency('actionmailer', '>= 0.4.0')
|
|
|
|
s.add_dependency('dev-utils', '>= 1.0.1')
|
|
|
|
|
|
|
|
s.files = PKG_FILES.to_a
|
|
|
|
s.require_path = 'lib'
|
|
|
|
|
|
|
|
s.bindir = "bin" # Use these for applications.
|
|
|
|
s.executables = ["rails"]
|
|
|
|
s.default_executable = "rails"
|
|
|
|
|
|
|
|
s.author = "David Heinemeier Hansson"
|
|
|
|
s.email = "david@loudthinking.com"
|
|
|
|
s.homepage = "http://www.rubyonrails.org"
|
|
|
|
s.rubyforge_project = "rails"
|
|
|
|
end
|
|
|
|
|
|
|
|
Rake::GemPackageTask.new(spec) do |pkg|
|
|
|
|
end
|
|
|
|
|
|
|
|
# Publish beta gem
|
|
|
|
desc "Publish the API documentation"
|
|
|
|
task :pgem => [:gem] do
|
|
|
|
Rake::SshFilePublisher.new("davidhh@one.textdrive.com", "domains/rubyonrails.org/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
|
|
|
`ssh davidhh@one.textdrive.com './gemupdate.sh'`
|
2004-11-25 11:27:59 -05:00
|
|
|
end
|